about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-09-28 02:40:42 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-09-28 02:40:42 +0000
commit34546ecb9b586f34e04f6e133a247ffe1f50046e (patch)
tree55c0c6c76c55bfe99a9f3c7dec416604a1c6dbd9
parentd484f36f7c690d0a88476127afd9bdf90233699d (diff)
downloadnetpbm-mirror-34546ecb9b586f34e04f6e133a247ffe1f50046e.tar.gz
netpbm-mirror-34546ecb9b586f34e04f6e133a247ffe1f50046e.tar.xz
netpbm-mirror-34546ecb9b586f34e04f6e133a247ffe1f50046e.zip
Release 1.04.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4700 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--analyzer/pamfile.c28
-rw-r--r--analyzer/pamgetcolor.c6
-rw-r--r--analyzer/pamsharpmap.c26
-rw-r--r--analyzer/pamsharpness.c26
-rw-r--r--analyzer/pamslice.c22
-rw-r--r--analyzer/pbmminkowski.c62
-rw-r--r--analyzer/pgmhist.c6
-rw-r--r--analyzer/pgmminkowski.c100
-rw-r--r--analyzer/pgmtexture.c840
-rw-r--r--analyzer/pnmhistmap.c28
-rwxr-xr-xbuildtools/makeman1
-rwxr-xr-xbuildtools/stamp-date16
-rw-r--r--converter/other/fiasco/binerror.c44
-rw-r--r--converter/other/fiasco/binerror.h12
-rw-r--r--converter/other/fiasco/buttons.c412
-rw-r--r--converter/other/fiasco/buttons.h16
-rw-r--r--converter/other/fiasco/codec/approx.c140
-rw-r--r--converter/other/fiasco/codec/approx.h10
-rw-r--r--converter/other/fiasco/codec/bintree.c26
-rw-r--r--converter/other/fiasco/codec/bintree.h8
-rw-r--r--converter/other/fiasco/codec/coder.h4
-rw-r--r--converter/other/fiasco/codec/coeff.c194
-rw-r--r--converter/other/fiasco/codec/coeff.h20
-rw-r--r--converter/other/fiasco/codec/control.c204
-rw-r--r--converter/other/fiasco/codec/control.h14
-rw-r--r--converter/other/fiasco/codec/cwfa.h102
-rw-r--r--converter/other/fiasco/codec/decoder.h52
-rw-r--r--converter/other/fiasco/codec/dfiasco.c178
-rw-r--r--converter/other/fiasco/codec/dfiasco.h8
-rw-r--r--converter/other/fiasco/codec/domain-pool.c148
-rw-r--r--converter/other/fiasco/codec/domain-pool.h28
-rw-r--r--converter/other/fiasco/codec/ip.c266
-rw-r--r--converter/other/fiasco/codec/ip.h22
-rw-r--r--converter/other/fiasco/codec/motion.c428
-rw-r--r--converter/other/fiasco/codec/motion.h14
-rw-r--r--converter/other/fiasco/codec/mwfa.c888
-rw-r--r--converter/other/fiasco/codec/mwfa.h14
-rw-r--r--converter/other/fiasco/codec/options.c414
-rw-r--r--converter/other/fiasco/codec/options.h80
-rw-r--r--converter/other/fiasco/codec/prediction.c406
-rw-r--r--converter/other/fiasco/codec/prediction.h14
-rw-r--r--converter/other/fiasco/codec/subdivide.c426
-rw-r--r--converter/other/fiasco/codec/subdivide.h12
-rw-r--r--converter/other/fiasco/codec/tiling.c166
-rw-r--r--converter/other/fiasco/codec/tiling.h14
-rw-r--r--converter/other/fiasco/codec/wfa.h144
-rw-r--r--converter/other/fiasco/codec/wfalib.c462
-rw-r--r--converter/other/fiasco/codec/wfalib.h18
-rw-r--r--converter/other/fiasco/display.c208
-rw-r--r--converter/other/fiasco/display.h12
-rw-r--r--converter/other/fiasco/fiasco.h242
-rw-r--r--converter/other/fiasco/fiascotopnm.c80
-rw-r--r--converter/other/fiasco/getopt.c824
-rw-r--r--converter/other/fiasco/getopt.h28
-rw-r--r--converter/other/fiasco/getopt1.c116
-rw-r--r--converter/other/fiasco/input/basis.c88
-rw-r--r--converter/other/fiasco/input/basis.h4
-rw-r--r--converter/other/fiasco/input/matrices.c636
-rw-r--r--converter/other/fiasco/input/matrices.h4
-rw-r--r--converter/other/fiasco/input/mc.c226
-rw-r--r--converter/other/fiasco/input/mc.h4
-rw-r--r--converter/other/fiasco/input/nd.c194
-rw-r--r--converter/other/fiasco/input/nd.h4
-rw-r--r--converter/other/fiasco/input/read.c354
-rw-r--r--converter/other/fiasco/input/read.h4
-rw-r--r--converter/other/fiasco/input/tree.c224
-rw-r--r--converter/other/fiasco/input/tree.h4
-rw-r--r--converter/other/fiasco/input/weights.c16
-rw-r--r--converter/other/fiasco/input/weights.h4
-rw-r--r--converter/other/fiasco/lib/arith.c440
-rw-r--r--converter/other/fiasco/lib/arith.h40
-rw-r--r--converter/other/fiasco/lib/bit-io.h20
-rw-r--r--converter/other/fiasco/lib/dither.c2258
-rw-r--r--converter/other/fiasco/lib/dither.h8
-rw-r--r--converter/other/fiasco/lib/error.c20
-rw-r--r--converter/other/fiasco/lib/error.h6
-rw-r--r--converter/other/fiasco/lib/image.h16
-rw-r--r--converter/other/fiasco/lib/list.c108
-rw-r--r--converter/other/fiasco/lib/list.h32
-rw-r--r--converter/other/fiasco/lib/macros.h36
-rw-r--r--converter/other/fiasco/lib/misc.c198
-rw-r--r--converter/other/fiasco/lib/misc.h26
-rw-r--r--converter/other/fiasco/lib/mvcode.c2
-rw-r--r--converter/other/fiasco/lib/rpf.c34
-rw-r--r--converter/other/fiasco/lib/rpf.h14
-rw-r--r--converter/other/fiasco/lib/types.h2
-rw-r--r--converter/other/fiasco/output/matrices.c560
-rw-r--r--converter/other/fiasco/output/matrices.h6
-rw-r--r--converter/other/fiasco/output/mc.c200
-rw-r--r--converter/other/fiasco/output/mc.h6
-rw-r--r--converter/other/fiasco/output/nd.c180
-rw-r--r--converter/other/fiasco/output/nd.h4
-rw-r--r--converter/other/fiasco/output/tree.c98
-rw-r--r--converter/other/fiasco/output/tree.h4
-rw-r--r--converter/other/fiasco/output/weights.c76
-rw-r--r--converter/other/fiasco/output/weights.h4
-rw-r--r--converter/other/fiasco/output/write.c58
-rw-r--r--converter/other/fiasco/output/write.h4
-rw-r--r--converter/other/fiasco/params.c506
-rw-r--r--converter/other/fiasco/params.h12
-rw-r--r--converter/other/jbig/libjbig/include/jbig.h54
-rw-r--r--converter/other/jbig/libjbig/include/jbig_ar.h6
-rw-r--r--converter/other/jbig/libjbig/jbig.c1770
-rw-r--r--converter/other/jbig/libjbig/jbig_ar.c130
-rw-r--r--converter/other/jbig/pnmtojbig.c42
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_debug.c82
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_getopt.c164
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_image.c1284
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_init.c128
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_malloc.c48
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_seq.c544
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_stream.c1484
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_string.c42
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_tvp.c204
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_version.c28
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_debug.h32
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_fix.h206
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_getopt.h44
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_image.h326
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_init.h26
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_malloc.h34
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_math.h54
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_seq.h182
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_stream.h222
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_string.h30
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_tvp.h50
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_types.h4
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jas_version.h64
-rw-r--r--converter/other/jpeg2000/libjasper/include/jasper/jasper.h26
-rw-r--r--converter/other/jpeg2000/libjasper/jp2/jp2_cod.c28
-rw-r--r--converter/other/jpeg2000/libjasper/jp2/jp2_cod.h256
-rw-r--r--converter/other/jpeg2000/libjasper/jp2/jp2_dec.c30
-rw-r--r--converter/other/jpeg2000/libjasper/jp2/jp2_dec.h44
-rw-r--r--converter/other/jpeg2000/libjasper/jp2/jp2_enc.c558
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_bs.c528
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_bs.h100
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_cod.h28
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_cs.c26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_cs.h544
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_dec.c28
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_dec.h694
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_enc.c26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_enc.h684
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_fix.h94
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_flt.h26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_math.c72
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_math.h46
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_mct.c368
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_mct.h32
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c214
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h50
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c266
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h214
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h110
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c1578
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h76
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c636
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h204
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c28
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c1052
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h200
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c886
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c1070
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h26
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c466
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h60
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c852
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h100
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_util.c176
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_util.h26
-rw-r--r--converter/other/jpeg2000/pamtojpeg2k.c8
-rw-r--r--converter/other/jpegtopnm.c18
-rw-r--r--converter/other/pamtosvg/Makefile3
-rw-r--r--converter/other/pamtosvg/autotrace.c27
-rw-r--r--converter/other/pamtosvg/autotrace.h48
-rw-r--r--converter/other/pamtosvg/curve.c323
-rw-r--r--converter/other/pamtosvg/curve.h126
-rw-r--r--converter/other/pamtosvg/epsilon.c (renamed from converter/other/pamtosvg/epsilon-equal.c)4
-rw-r--r--converter/other/pamtosvg/epsilon.h (renamed from converter/other/pamtosvg/epsilon-equal.h)6
-rw-r--r--converter/other/pamtosvg/fit.c1298
-rw-r--r--converter/other/pamtosvg/fit.h4
-rw-r--r--converter/other/pamtosvg/output-svg.c2
-rw-r--r--converter/other/pamtosvg/pamtosvg.test8
-rw-r--r--converter/other/pamtosvg/point.c90
-rw-r--r--converter/other/pamtosvg/point.h25
-rw-r--r--converter/other/pamtosvg/spline.c21
-rw-r--r--converter/other/pamtosvg/spline.h7
-rw-r--r--converter/other/pamtosvg/vector.c297
-rw-r--r--converter/other/pamtosvg/vector.h112
-rw-r--r--converter/other/pbmtopgm.c147
-rw-r--r--converter/other/pnmtojpeg.c1022
-rw-r--r--converter/other/sirtopnm.c202
-rw-r--r--converter/other/tifftopnm.c3
-rw-r--r--converter/other/xwdtopnm.c321
-rw-r--r--converter/pbm/g3topbm.c181
-rw-r--r--converter/pbm/mdatopbm.c267
-rw-r--r--converter/pbm/pbmto4425.c219
-rw-r--r--converter/pbm/pbmtolj.c34
-rw-r--r--converter/pbm/pbmtomda.c217
-rw-r--r--converter/pbm/pbmtoppa/pbmtoppa.c209
-rw-r--r--converter/pbm/pbmtoxbm.c145
-rw-r--r--converter/pbm/pktopbm.c830
-rw-r--r--converter/pbm/thinkjettopbm.l8
-rw-r--r--converter/pbm/ybmtopbm.c5
-rw-r--r--converter/pgm/lispmtopgm.c256
-rw-r--r--converter/pgm/psidtopgm.c24
-rw-r--r--converter/ppm/ilbm.h12
-rw-r--r--converter/ppm/ilbmtoppm.c383
-rw-r--r--converter/ppm/imgtoppm.c172
-rw-r--r--converter/ppm/pcxtoppm.c522
-rw-r--r--converter/ppm/pjtoppm.c204
-rw-r--r--converter/ppm/ppmtoeyuv.c219
-rw-r--r--converter/ppm/ppmtogif.c75
-rw-r--r--converter/ppm/ppmtoilbm.c18
-rw-r--r--converter/ppm/ppmtolj.c415
-rw-r--r--converter/ppm/ppmtomitsu.test12
-rw-r--r--converter/ppm/ppmtompeg/bframe.c122
-rw-r--r--converter/ppm/ppmtompeg/bitio.c24
-rw-r--r--converter/ppm/ppmtompeg/block.c32
-rw-r--r--converter/ppm/ppmtompeg/combine.c28
-rw-r--r--converter/ppm/ppmtompeg/file.c6
-rw-r--r--converter/ppm/ppmtompeg/frametype.c66
-rw-r--r--converter/ppm/ppmtompeg/fsize.c50
-rw-r--r--converter/ppm/ppmtompeg/gethostname_win32.c18
-rw-r--r--converter/ppm/ppmtompeg/headers/all.h10
-rw-r--r--converter/ppm/ppmtompeg/headers/bitio.h32
-rw-r--r--converter/ppm/ppmtompeg/headers/byteorder.h20
-rw-r--r--converter/ppm/ppmtompeg/headers/combine.h4
-rw-r--r--converter/ppm/ppmtompeg/headers/dct.h10
-rw-r--r--converter/ppm/ppmtompeg/headers/frame.h28
-rw-r--r--converter/ppm/ppmtompeg/headers/frames.h20
-rw-r--r--converter/ppm/ppmtompeg/headers/frametype.h2
-rw-r--r--converter/ppm/ppmtompeg/headers/fsize.h8
-rw-r--r--converter/ppm/ppmtompeg/headers/general.h20
-rw-r--r--converter/ppm/ppmtompeg/headers/huff.h8
-rw-r--r--converter/ppm/ppmtompeg/headers/iframe.h6
-rw-r--r--converter/ppm/ppmtompeg/headers/mheaders.h52
-rw-r--r--converter/ppm/ppmtompeg/headers/motion_search.h12
-rw-r--r--converter/ppm/ppmtompeg/headers/mpeg.h48
-rw-r--r--converter/ppm/ppmtompeg/headers/mproto.h26
-rw-r--r--converter/ppm/ppmtompeg/headers/mtypes.h18
-rw-r--r--converter/ppm/ppmtompeg/headers/opts.h10
-rw-r--r--converter/ppm/ppmtompeg/headers/parallel.h40
-rw-r--r--converter/ppm/ppmtompeg/headers/param.h2
-rw-r--r--converter/ppm/ppmtompeg/headers/postdct.h14
-rw-r--r--converter/ppm/ppmtompeg/headers/psocket.h4
-rw-r--r--converter/ppm/ppmtompeg/headers/rate.h30
-rw-r--r--converter/ppm/ppmtompeg/headers/readframe.h34
-rw-r--r--converter/ppm/ppmtompeg/headers/rgbtoycc.h8
-rw-r--r--converter/ppm/ppmtompeg/headers/specifics.h8
-rw-r--r--converter/ppm/ppmtompeg/huff.c45
-rw-r--r--converter/ppm/ppmtompeg/iframe.c106
-rw-r--r--converter/ppm/ppmtompeg/input.c92
-rw-r--r--converter/ppm/ppmtompeg/jrevdct.c1772
-rw-r--r--converter/ppm/ppmtompeg/memory.c12
-rw-r--r--converter/ppm/ppmtompeg/mfwddct.c171
-rw-r--r--converter/ppm/ppmtompeg/mheaders.c286
-rw-r--r--converter/ppm/ppmtompeg/moutput.c400
-rw-r--r--converter/ppm/ppmtompeg/mquant.c24
-rw-r--r--converter/ppm/ppmtompeg/nojpeg.c16
-rw-r--r--converter/ppm/ppmtompeg/noparallel.c22
-rw-r--r--converter/ppm/ppmtompeg/parallel.c57
-rw-r--r--converter/ppm/ppmtompeg/pframe.c164
-rw-r--r--converter/ppm/ppmtompeg/postdct.c502
-rw-r--r--converter/ppm/ppmtompeg/ppmtompeg.c90
-rw-r--r--converter/ppm/ppmtompeg/psearch.c110
-rw-r--r--converter/ppm/ppmtompeg/qtest.c10
-rw-r--r--converter/ppm/ppmtompeg/rate.c104
-rw-r--r--converter/ppm/ppmtompeg/rgbtoycc.c22
-rw-r--r--converter/ppm/ppmtompeg/specifics.c136
-rw-r--r--converter/ppm/ppmtompeg/subsample.c8
-rw-r--r--converter/ppm/ppmtosixel.c440
-rw-r--r--doc/HISTORY69
-rw-r--r--doc/INSTALL17
-rw-r--r--doc/Netpbm.programming425
-rw-r--r--editor/pamaddnoise.c89
-rw-r--r--editor/pamedge.c8
-rw-r--r--editor/pammasksharpen.c24
-rw-r--r--editor/pammixmulti.c77
-rw-r--r--editor/pamperspective.c44
-rw-r--r--editor/pamrecolor.c1
-rw-r--r--editor/pamwipeout.c28
-rw-r--r--editor/pgmdeshadow.c22
-rw-r--r--editor/pgmenhance.c4
-rw-r--r--editor/pgmmedian.c2
-rw-r--r--editor/pnmalias.c58
-rw-r--r--editor/pnmgamma.c68
-rw-r--r--editor/pnminvert.c20
-rw-r--r--editor/pnmmontage.c44
-rw-r--r--editor/pnmnlfilt.c2
-rw-r--r--editor/pnmrotate.c202
-rw-r--r--editor/pnmscalefixed.c106
-rw-r--r--editor/pnmsmooth.c12
-rw-r--r--editor/pnmstitch.c152
-rw-r--r--editor/pnmtile.c2
-rw-r--r--editor/ppmchange.c40
-rw-r--r--editor/ppmdim.c159
-rwxr-xr-xeditor/ppmfade633
-rw-r--r--editor/ppmflash.c9
-rw-r--r--editor/ppmlabel.c6
-rw-r--r--editor/specialty/pamdeinterlace.c8
-rw-r--r--editor/specialty/pamoil.c8
-rw-r--r--editor/specialty/pampop9.c4
-rw-r--r--editor/specialty/pbmlife.c114
-rw-r--r--editor/specialty/pgmabel.c2
-rw-r--r--editor/specialty/pgmbentley.c6
-rw-r--r--editor/specialty/pgmmorphconv.c56
-rw-r--r--editor/specialty/pnmindex.c6
-rw-r--r--editor/specialty/pnmmercator.c54
-rw-r--r--editor/specialty/ppm3d.c30
-rw-r--r--editor/specialty/ppmglobe.c14
-rw-r--r--editor/specialty/ppmntsc.c124
-rw-r--r--editor/specialty/ppmrelief.c2
-rw-r--r--editor/specialty/ppmshift.c1
-rw-r--r--editor/specialty/ppmtv.c167
-rw-r--r--generator/pamgauss.c32
-rw-r--r--generator/pamshadedrelief.c12
-rw-r--r--generator/pamstereogram.test70
-rw-r--r--generator/pamtris/framebuffer.c2
-rw-r--r--generator/pamtris/pamtris.c2
-rw-r--r--generator/pamtris/triangle.c4
-rw-r--r--generator/pamtris/utils.c4
-rw-r--r--generator/pbmnoise.c2
-rw-r--r--generator/pbmupc.c204
-rw-r--r--generator/pgmkernel.c8
-rw-r--r--generator/pgmmake.c4
-rw-r--r--generator/ppmcie.c21
-rw-r--r--generator/ppmcolors.c10
-rw-r--r--generator/ppmrough.c35
-rw-r--r--lib/Makefile10
-rw-r--r--lib/dithers.h2
-rw-r--r--lib/fileio.c16
-rw-r--r--lib/libpam.c28
-rw-r--r--lib/libpamread.c38
-rw-r--r--lib/libpbm1.c11
-rw-r--r--lib/libpgm1.c109
-rw-r--r--lib/libpgm2.c32
-rw-r--r--lib/libpm.c12
-rw-r--r--lib/libpnm1.c30
-rw-r--r--lib/libppm.h6
-rw-r--r--lib/libppm1.c24
-rw-r--r--lib/libppm2.c46
-rw-r--r--lib/libppmfuzzy.c6
-rw-r--r--lib/lum.h192
-rw-r--r--lib/pam.h2
-rw-r--r--lib/pamdraw.h132
-rw-r--r--lib/path.c24
-rw-r--r--lib/ppm.h6
-rw-r--r--lib/ppmdfont.c4
-rw-r--r--lib/ppmdfont.h4
-rw-r--r--lib/ppmdraw.h218
-rw-r--r--lib/util/LICENSE.txt40
-rw-r--r--lib/util/bitio.c14
-rw-r--r--lib/util/bitio.h12
-rw-r--r--lib/util/bitreverse.h2
-rw-r--r--lib/util/floatcode.h12
-rw-r--r--lib/util/intcode.h18
-rw-r--r--lib/util/io.c4
-rw-r--r--lib/util/matrix.c4
-rw-r--r--lib/util/nstring.c64
-rw-r--r--lib/util/nstring.h22
-rw-r--r--lib/util/pm_c_util.h6
-rw-r--r--lib/util/runlength.h4
-rw-r--r--lib/util/shhopt.c46
-rw-r--r--lib/util/testnstring.c4
-rw-r--r--lib/util/token.c2
-rw-r--r--lib/util/vasprintf.c13
-rw-r--r--other/pamchannel.c36
-rw-r--r--other/pamdepth.c2
-rw-r--r--other/pamlookup.c60
-rw-r--r--other/pamsplit.c14
-rw-r--r--other/pamsummcol.c46
-rw-r--r--other/pamvalidate.c2
-rw-r--r--other/pamx/fill.c8
-rw-r--r--other/pamx/image.c10
-rw-r--r--other/pamx/pamx.c26
-rw-r--r--other/pamx/send.c118
-rw-r--r--other/ppmdcfont.c14
-rw-r--r--other/ppmddumpfont.c10
-rw-r--r--other/ppmdmkfont.c56
-rw-r--r--other/ppmsvgalib.c42
-rw-r--r--test/Test-Order12
-rw-r--r--test/cis-roundtrip.ok5
-rwxr-xr-xtest/cis-roundtrip.test13
-rw-r--r--test/pamaddnoise-parameters.ok62
-rwxr-xr-xtest/pamaddnoise-parameters.test337
-rw-r--r--test/pamarith.ok84
-rwxr-xr-xtest/pamarith.test168
-rw-r--r--test/pamcat1.ok28
-rwxr-xr-xtest/pamcat1.test56
-rw-r--r--test/pamcat3.ok18
-rwxr-xr-xtest/pamcat3.test36
-rw-r--r--test/pamchannel.ok6
-rwxr-xr-xtest/pamchannel.test13
-rw-r--r--test/pamcrater.ok8
-rwxr-xr-xtest/pamcrater.test16
-rw-r--r--test/pamcut.ok30
-rwxr-xr-xtest/pamcut.test60
-rw-r--r--test/pamdepth.ok4
-rwxr-xr-xtest/pamdepth.test8
-rw-r--r--[-rwxr-xr-x]test/pamditherbw-random.ok0
-rw-r--r--test/pamditherbw.ok24
-rwxr-xr-xtest/pamditherbw.test48
-rw-r--r--test/pamfile.ok6
-rwxr-xr-xtest/pamfile.test12
-rw-r--r--test/pamfind.ok8
-rwxr-xr-xtest/pamfind.test16
-rw-r--r--test/pamfix.ok8
-rwxr-xr-xtest/pamfix.test14
-rw-r--r--test/pamfunc.ok48
-rwxr-xr-xtest/pamfunc.test96
-rw-r--r--test/pamgauss.ok10
-rwxr-xr-xtest/pamgauss.test20
-rw-r--r--test/pamhue.ok2
-rwxr-xr-xtest/pamhue.test4
-rw-r--r--[-rwxr-xr-x]test/pamrecolor.ok12
-rwxr-xr-xtest/pamrecolor.test24
-rw-r--r--test/pamrestack.ok10
-rwxr-xr-xtest/pamrestack.test20
-rw-r--r--test/pamscale-reportonly.ok12
-rwxr-xr-xtest/pamscale-reportonly.test24
-rw-r--r--test/pamseq.ok8
-rwxr-xr-xtest/pamseq.test16
-rw-r--r--[-rwxr-xr-x]test/pamshuffle.ok6
-rwxr-xr-xtest/pamshuffle.test12
-rw-r--r--test/pamstack.ok38
-rwxr-xr-xtest/pamstack.test125
-rw-r--r--test/pamstereogram.ok32
-rwxr-xr-xtest/pamstereogram.test80
-rw-r--r--test/pamsumm.ok8
-rwxr-xr-xtest/pamsumm.test16
-rw-r--r--test/pamtable.ok4
-rwxr-xr-xtest/pamtable.test6
-rw-r--r--test/pamtosvg.ok4
-rwxr-xr-xtest/pamtosvg.test45
-rw-r--r--test/pamundice.ok24
-rwxr-xr-xtest/pamundice.test48
-rw-r--r--test/pbmclean.ok2
-rwxr-xr-xtest/pbmclean.test4
-rw-r--r--[-rwxr-xr-x]test/pbmlife.ok0
-rw-r--r--test/pbmmake.ok16
-rwxr-xr-xtest/pbmmake.test32
-rw-r--r--test/pbmnoise-parameters.ok50
-rwxr-xr-xtest/pbmnoise-parameters.test100
-rw-r--r--test/pbmpage.ok6
-rwxr-xr-xtest/pbmpage.test12
-rw-r--r--test/pbmpscale.ok6
-rwxr-xr-xtest/pbmpscale.test12
-rwxr-xr-xtest/pbmtext-iso88591.test24
-rw-r--r--test/pbmtext-utf8.ok16
-rwxr-xr-xtest/pbmtext-utf8.test53
-rw-r--r--test/pbmtext.ok22
-rwxr-xr-xtest/pbmtext.test44
-rw-r--r--test/pbmtextps-dump.ok70
-rwxr-xr-xtest/pbmtextps-dump.test16
-rw-r--r--test/pbmtopgm.ok8
-rwxr-xr-xtest/pbmtopgm.test16
-rw-r--r--test/pbmupc.ok18
-rwxr-xr-xtest/pbmupc.test36
-rw-r--r--test/pgmhist.ok8
-rwxr-xr-xtest/pgmhist.test16
-rw-r--r--test/pgmmake.ok16
-rwxr-xr-xtest/pgmmake.test32
-rw-r--r--test/pgmnoise-parameters.ok10
-rwxr-xr-xtest/pgmnoise-parameters.test20
-rw-r--r--test/pgmnoise.ok20
-rwxr-xr-xtest/pgmnoise.test40
-rw-r--r--test/pgmramp.ok10
-rwxr-xr-xtest/pgmramp.test12
-rw-r--r--test/pgmtoppm.ok22
-rwxr-xr-xtest/pgmtoppm.test48
-rw-r--r--test/pnmcat.ok28
-rwxr-xr-xtest/pnmcat.test56
-rw-r--r--test/pnmcolormap.ok14
-rwxr-xr-xtest/pnmcolormap.test28
-rw-r--r--test/pnmcrop1.ok22
-rwxr-xr-xtest/pnmcrop1.test6
-rw-r--r--test/pnmcrop3.ok4
-rwxr-xr-xtest/pnmcrop3.test12
-rw-r--r--test/pnmpsnr.ok8
-rwxr-xr-xtest/pnmpsnr.test16
-rw-r--r--test/pnmquant.ok16
-rwxr-xr-xtest/pnmquant.test32
-rw-r--r--test/pnmremap1.ok12
-rwxr-xr-xtest/pnmremap1.test24
-rw-r--r--test/pnmtile.ok8
-rwxr-xr-xtest/pnmtile.test16
-rw-r--r--test/pnmtojpeg-scans.ok20
-rwxr-xr-xtest/pnmtojpeg-scans.test32
-rw-r--r--test/ppmforge-parameters.ok14
-rwxr-xr-xtest/ppmforge-parameters.test28
-rw-r--r--test/ppmhist.ok6
-rwxr-xr-xtest/ppmhist.test12
-rw-r--r--test/ppmmake.ok20
-rwxr-xr-xtest/ppmmake.test40
-rw-r--r--[-rwxr-xr-x]test/ppmpat-random.ok0
-rw-r--r--test/ppmpat.ok52
-rwxr-xr-xtest/ppmpat.test104
-rw-r--r--test/ppmrough-parameters.ok25
-rwxr-xr-xtest/ppmrough-parameters.test145
-rw-r--r--[-rwxr-xr-x]test/ppmrough.ok23
-rwxr-xr-xtest/ppmrough.test46
-rw-r--r--[-rwxr-xr-x]test/ppmshift.ok0
-rw-r--r--[-rwxr-xr-x]test/ppmspread.ok0
-rw-r--r--test/ppmtoapplevol.ok6
-rwxr-xr-xtest/ppmtoapplevol.test12
-rw-r--r--test/ppmtomitsu.ok14
-rwxr-xr-xtest/ppmtomitsu.test31
-rw-r--r--test/ppmwheel.ok10
-rwxr-xr-xtest/ppmwheel.test20
-rw-r--r--test/qoi-roundtrip.ok28
-rwxr-xr-xtest/qoi-roundtrip.test54
-rwxr-xr-xtest/stdin-pam1.test2
-rwxr-xr-xtest/stdin-pam2.test2
-rwxr-xr-xtest/stdin-ppm3.test2
-rw-r--r--test/xpm-roundtrip.ok3
-rwxr-xr-xtest/xpm-roundtrip.test6
-rw-r--r--test/xwd-roundtrip.ok7
-rwxr-xr-xtest/xwd-roundtrip.test17
-rw-r--r--test/ybm-roundtrip.ok2
-rwxr-xr-xtest/ybm-roundtrip.test7
-rw-r--r--version.mk4
526 files changed, 29874 insertions, 27582 deletions
diff --git a/analyzer/pamfile.c b/analyzer/pamfile.c
index 7b61f6fd..6e12375f 100644
--- a/analyzer/pamfile.c
+++ b/analyzer/pamfile.c
@@ -92,30 +92,30 @@ dumpHeaderHuman(struct pam const pam) {
         printf("    Tuple type: %s\n", pam.tuple_type);
         break;
 
-	case PBM_FORMAT:
+        case PBM_FORMAT:
         printf("PBM plain, %d by %d\n", pam.width, pam.height );
         break;
 
-	case RPBM_FORMAT:
+        case RPBM_FORMAT:
         printf("PBM raw, %d by %d\n", pam.width, pam.height);
         break;
 
-	case PGM_FORMAT:
+        case PGM_FORMAT:
         printf("PGM plain, %d by %d  maxval %ld\n",
                pam.width, pam.height, pam.maxval);
         break;
 
-	case RPGM_FORMAT:
+        case RPGM_FORMAT:
         printf("PGM raw, %d by %d  maxval %ld\n",
                pam.width, pam.height, pam.maxval);
         break;
 
-	case PPM_FORMAT:
+        case PPM_FORMAT:
         printf("PPM plain, %d by %d  maxval %ld\n",
                pam.width, pam.height, pam.maxval);
         break;
 
-	case RPPM_FORMAT:
+        case RPPM_FORMAT:
         printf("PPM raw, %d by %d  maxval %ld\n",
                pam.width, pam.height, pam.maxval);
         break;
@@ -136,32 +136,32 @@ dumpHeaderMachine(struct pam const pam) {
         plain = false;
         break;
 
-	case PBM_FORMAT:
+        case PBM_FORMAT:
         formatString = "PBM";
         plain = TRUE;
         break;
 
-	case RPBM_FORMAT:
+        case RPBM_FORMAT:
         formatString = "PBM";
         plain = false;
         break;
 
-	case PGM_FORMAT:
+        case PGM_FORMAT:
         formatString = "PGM";
         plain = TRUE;
         break;
 
-	case RPGM_FORMAT:
+        case RPGM_FORMAT:
         formatString = "PGM";
         plain = false;
         break;
 
-	case PPM_FORMAT:
+        case PPM_FORMAT:
         formatString = "PPM";
         plain = TRUE;
         break;
 
-	case RPPM_FORMAT:
+        case RPPM_FORMAT:
         formatString = "PPM";
         plain = false;        break;
     }
@@ -340,8 +340,8 @@ main(int argc, const char *argv[]) {
                             cmdline.comments);
 
             pm_close(ifP);
-	    }
-	}
+            }
+        }
 
     return 0;
 }
diff --git a/analyzer/pamgetcolor.c b/analyzer/pamgetcolor.c
index d1ea3799..2bd3050c 100644
--- a/analyzer/pamgetcolor.c
+++ b/analyzer/pamgetcolor.c
@@ -1,4 +1,8 @@
+#define _C99_SOURCE  /* Make sure snprintf() is in stdio.h */
+
 #include <string.h>
+#include <stdio.h>
+
 #include <nstring.h>
 #include <pm_gamma.h>
 #include <pam.h>
@@ -526,7 +530,7 @@ printColors(struct pam *    const pamP,
 
     tup = pnm_allocpamtuple(pamP);
 
-    pm_snprintf(fmt, sizeof(fmt), "%%%is: %%s\n", cmdLine.maxLbLen);
+    snprintf(fmt, sizeof(fmt), "%%%is: %%s\n", cmdLine.maxLbLen);
 
     for (r = 0; r < cmdLine.regN; ++r) {
         RegSpec      spec;
diff --git a/analyzer/pamsharpmap.c b/analyzer/pamsharpmap.c
index 2f31835b..f63760fe 100644
--- a/analyzer/pamsharpmap.c
+++ b/analyzer/pamsharpmap.c
@@ -14,7 +14,7 @@
    No warranty. See file 'artistic.license' for more details.
 
    boris@13thmonkey.org
-   www.13thmonkey.org/~boris/photopnmtools/ 
+   www.13thmonkey.org/~boris/photopnmtools/
 -----------------------------------------------------------------------------*/
 
 #include <stdio.h>
@@ -40,7 +40,7 @@ parseCommandLine ( int argc, char ** argv,
                    struct cmdlineInfo *cmdlineP ) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -58,7 +58,7 @@ parseCommandLine ( int argc, char ** argv,
     unsigned int contextSpec;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "context",       OPT_UINT,   &cmdlineP->context,       
+    OPTENT3(0, "context",       OPT_UINT,   &cmdlineP->context,
             &contextSpec,         0 );
 
     opt.opt_table = option_def;
@@ -92,7 +92,7 @@ makeSharpnessPixel(struct pam * const pamP,
 
     unsigned int plane;
     for (plane = 0; plane < pamP->depth; ++plane)
-        sharpnessTuple[plane] = 
+        sharpnessTuple[plane] =
             (sample)(sharpness[plane] * pamP->maxval + 0.5);
 }
 
@@ -132,20 +132,20 @@ main(int argc, char **argv) {
     int row;
     float * sharpness;
 
-	pnm_init(&argc, argv);
+        pnm_init(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFilespec);
 
-	tuplenarray = pnm_readpamn(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
+        tuplenarray = pnm_readpamn(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
     mappam = inpam;
     mappam.file = stdout;
     mappam.maxval = 255;
 
     MALLOCARRAY_NOFAIL(sharpness, inpam.depth);
-            
+
     map = pnm_allocpamarray(&mappam);
     makeBlackRown(&inpam, tuplenarray[0]);
     for (row = 1; row < inpam.height-1; ++row) {
@@ -154,7 +154,7 @@ main(int argc, char **argv) {
         for (col = 1; col < inpam.width-1; ++col) {
             int dy;
             unsigned int plane;
-            
+
             for (plane = 0; plane < inpam.depth; ++plane)
                 sharpness[plane] = 0.0;
 
@@ -164,9 +164,9 @@ main(int argc, char **argv) {
                     if (dx != 0 || dy != 0) {
                         unsigned int plane;
                         for (plane = 0; plane < inpam.depth; ++plane) {
-                            samplen const sampleval = 
+                            samplen const sampleval =
                                 tuplenarray[row][col][plane];
-                            samplen const sampleval2 = 
+                            samplen const sampleval2 =
                                 tuplenarray[row+dy][col+dx][plane];
                             sharpness[plane] += fabs(sampleval - sampleval2);
                         }
@@ -179,11 +179,11 @@ main(int argc, char **argv) {
     }
     makeBlackRown(&inpam, tuplenarray[inpam.height-1]);
     free(sharpness);
-    
+
     pnm_writepam(&mappam, map);
 
     pnm_freepamarray(map, &mappam);
-	pnm_freepamarrayn(tuplenarray, &inpam);
+        pnm_freepamarrayn(tuplenarray, &inpam);
 
-	return 0;
+        return 0;
 }
diff --git a/analyzer/pamsharpness.c b/analyzer/pamsharpness.c
index 5943416f..f9140bcf 100644
--- a/analyzer/pamsharpness.c
+++ b/analyzer/pamsharpness.c
@@ -14,7 +14,7 @@
    No warranty. See file 'artistic.license' for more details.
 
    boris@13thmonkey.org
-   www.13thmonkey.org/~boris/photopnmtools/ 
+   www.13thmonkey.org/~boris/photopnmtools/
 -----------------------------------------------------------------------------*/
 
 #include <stdio.h>
@@ -40,7 +40,7 @@ parseCommandLine(int argc, char ** argv,
                  struct cmdlineInfo *cmdlineP) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -60,7 +60,7 @@ parseCommandLine(int argc, char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "context",       OPT_UINT,   &cmdlineP->context,       
+    OPTENT3(0, "context",       OPT_UINT,   &cmdlineP->context,
             &contextSpec,         0 );
 
     opt.opt_table = option_def;
@@ -96,7 +96,7 @@ computeSharpness(struct pam * const inpamP,
 
     unsigned int row;
     double totsharp;
-    
+
     totsharp = 0.0;
 
     for (row = 1; row < inpamP->height-1; ++row) {
@@ -109,18 +109,18 @@ computeSharpness(struct pam * const inpamP,
                     if (dx != 0 || dy != 0) {
                         unsigned int plane;
                         for (plane = 0; plane < inpamP->depth; ++plane) {
-                            samplen const sampleval = 
+                            samplen const sampleval =
                                 tuplenarray[row][col][plane];
-                            samplen const sampleval2 = 
+                            samplen const sampleval2 =
                                 tuplenarray[row+dy][col+dx][plane];
                             totsharp += fabs(sampleval - sampleval2);
                         }
                     }
                 }
             }
-		}
-	}
-    *sharpnessP = 
+                }
+        }
+    *sharpnessP =
         totsharp / (inpamP->width * inpamP->height * inpamP->depth * 8);
         /* The 8 above is for the 8 neighbors to which we compare each pixel */
 }
@@ -136,13 +136,13 @@ main(int argc, char **argv) {
     struct pam inpam;
     double sharpness;
 
-	pnm_init(&argc, argv);
+        pnm_init(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFilespec);
 
-	tuplenarray = pnm_readpamn(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
+        tuplenarray = pnm_readpamn(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
     if (inpam.height < 3 || inpam.width < 3)
         pm_error("sharpness is undefined for an image less than 3 pixels "
@@ -153,8 +153,8 @@ main(int argc, char **argv) {
 
     printf("Sharpness = %f\n", sharpness);
 
-	pnm_freepamarrayn(tuplenarray, &inpam);
+        pnm_freepamarrayn(tuplenarray, &inpam);
     pm_close(ifP);
 
-	return 0;
+        return 0;
 }
diff --git a/analyzer/pamslice.c b/analyzer/pamslice.c
index db0ab9c0..5bdbea10 100644
--- a/analyzer/pamslice.c
+++ b/analyzer/pamslice.c
@@ -1,4 +1,4 @@
-/* 
+/*
  *
  * This program (Pamslice) was derived by Bryan Henderson in July 2002
  * from Pgmslice by Jos Dingjan.  Pgmslice did the same thing, but
@@ -10,10 +10,10 @@
  * 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) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+ * but WITHOUT ANY WARRANTY; without 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
@@ -77,12 +77,12 @@ parseCommandLine(int argc, char ** const argv,
     if (argc-1 > 1)
         pm_error("Too many arguments (%d).  Only argument is filename.",
                  argc-1);
-    else if (argc-1 == 1) 
+    else if (argc-1 == 1)
         cmdlineP->inputFilespec = argv[1];
     else
         cmdlineP->inputFilespec = "-";
 
-    if (rowSpec) 
+    if (rowSpec)
         cmdlineP->orientation = ROW;
     else if (colSpec)
         cmdlineP->orientation = COLUMN;
@@ -121,7 +121,7 @@ printSlice(FILE *       const outfile,
         else
             fprintf(stdout,"@    type  nxy\n");
     }
-    
+
     count = 0;
     for (row = rowstart; row < rowend; ++row) {
         unsigned int col;
@@ -137,7 +137,7 @@ printSlice(FILE *       const outfile,
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
 
     struct cmdlineInfo cmdline;
@@ -177,7 +177,7 @@ main(int argc, char *argv[]) {
 
         break;
     }
-    
+
     if (cmdline.onePlane) {
         if (cmdline.plane >= inpam.depth)
             pm_error("You specified plane %u, but there are only %u planes "
@@ -189,12 +189,12 @@ main(int argc, char *argv[]) {
         planeend = inpam.depth;
     }
 
-    printSlice(stdout, tuples, 
+    printSlice(stdout, tuples,
                rowstart, rowend, colstart, colend, planestart, planeend,
                cmdline.xmgr);
 
     pm_close(ifP);
     pm_close(stdout);
-        
+
     exit(0);
 }
diff --git a/analyzer/pbmminkowski.c b/analyzer/pbmminkowski.c
index 0f7b47a9..368ff34e 100644
--- a/analyzer/pbmminkowski.c
+++ b/analyzer/pbmminkowski.c
@@ -25,15 +25,15 @@ int main(int argc, const char ** argv) {
     bit * prevrow;
     bit * thisrow;
     bit * tmprow;
-  
+
     int row;
-    int col; 
+    int col;
 
     int countTile;
     int countEdgeX;
     int countEdgeY;
     int countVertex;
-  
+
     int rows;
     int cols;
     int format;
@@ -42,15 +42,15 @@ int main(int argc, const char ** argv) {
 
 
     pm_proginit(&argc, argv);
-  
+
     if (argc > 2)
         pm_usage("[pbmfile]");
-  
+
     if (argc == 2)
         ifP = pm_openr(argv[1]);
     else
         ifP = stdin;
-  
+
     pbm_readpbminit(ifP, &cols, &rows, &format);
 
     prevrow = pbm_allocrow(cols);
@@ -68,10 +68,10 @@ int main(int argc, const char ** argv) {
 
     /* tiles */
 
-    for (col = 0; col < cols; ++col) 
+    for (col = 0; col < cols; ++col)
         if (ISWHITE(thisrow[col]))
             ++countTile;
-  
+
     /* shortcut: for the first row, edgeY == countTile */
     countEdgeY = countTile;
 
@@ -80,7 +80,7 @@ int main(int argc, const char ** argv) {
     if (ISWHITE(thisrow[0]))
         ++countEdgeX;
 
-    for (col = 0; col < cols-1; ++col) 
+    for (col = 0; col < cols-1; ++col)
         if (ISWHITE(thisrow[col]) || ISWHITE(thisrow[col+1]))
             ++countEdgeX;
 
@@ -88,56 +88,56 @@ int main(int argc, const char ** argv) {
         ++countEdgeX;
 
     /* shortcut: for the first row, countVertex == countEdgeX */
-  
+
     countVertex = countEdgeX;
-  
 
-    for (row = 1; row < rows; ++row) {  
-    
-        tmprow  = prevrow; 
+
+    for (row = 1; row < rows; ++row) {
+
+        tmprow  = prevrow;
         prevrow = thisrow;
         thisrow = tmprow;
- 
+
         pbm_readpbmrow(ifP, thisrow, cols, format);
-  
+
         /* tiles */
 
-        for (col = 0; col < cols; ++col) 
+        for (col = 0; col < cols; ++col)
             if (ISWHITE(thisrow[col]))
                 ++countTile;
-    
+
         /* y-edges */
 
-        for (col = 0; col < cols; ++col) 
+        for (col = 0; col < cols; ++col)
             if (ISWHITE(thisrow[col]) || ISWHITE(prevrow[col]))
                 ++countEdgeY;
-    
+
         /* x-edges */
 
         if (ISWHITE(thisrow[0]))
             ++countEdgeX;
 
-        for (col = 0; col < cols-1; ++col) 
+        for (col = 0; col < cols-1; ++col)
             if (ISWHITE(thisrow[col]) || ISWHITE(thisrow[col+1]))
                 ++countEdgeX;
-    
+
         if (ISWHITE(thisrow[cols-1]))
             ++countEdgeX;
-    
+
         /* vertices */
 
         if (ISWHITE(thisrow[0]) || ISWHITE(prevrow[0]))
             ++countVertex;
 
-        for (col = 0; col < cols-1; ++col) 
-            if (ISWHITE(thisrow[col]) || ISWHITE(thisrow[col+1]) 
+        for (col = 0; col < cols-1; ++col)
+            if (ISWHITE(thisrow[col]) || ISWHITE(thisrow[col+1])
                 || ISWHITE(prevrow[col]) || ISWHITE(prevrow[col+1]))
                 ++countVertex;
 
         if (ISWHITE(thisrow[cols-1]) || ISWHITE(prevrow[cols-1]))
             ++countVertex;
 
-	  
+
     } /* for row */
 
     /* now thisrow contains the top row*/
@@ -145,19 +145,19 @@ int main(int argc, const char ** argv) {
        vertices remain
     */
 
-  
+
     /* y-edges */
 
-    for (col = 0; col < cols; ++col) 
+    for (col = 0; col < cols; ++col)
         if (ISWHITE(thisrow[col]))
             ++countEdgeY;
 
     /* vertices */
-  
+
     if (ISWHITE(thisrow[0]))
         ++countVertex;
 
-    for (col = 0; col < cols-1; ++col) 
+    for (col = 0; col < cols-1; ++col)
         if (ISWHITE(thisrow[col]) || ISWHITE(thisrow[col+1]))
             ++countVertex;
 
@@ -179,7 +179,7 @@ int main(int argc, const char ** argv) {
 
     printf("    area:\t%d\nperimeter:\t%d\n eulerchi:\t%d\n",
            area, perimeter, eulerchi );
-  
+
     return 0;
 }
 
diff --git a/analyzer/pgmhist.c b/analyzer/pgmhist.c
index 1e779655..a85f0649 100644
--- a/analyzer/pgmhist.c
+++ b/analyzer/pgmhist.c
@@ -211,8 +211,8 @@ findQuantiles(unsigned int      const n,
     cumCt = hist[0];  /* initial value */
 
     for (quantSeq = 1; quantSeq <= n; ++quantSeq) {
-        unsigned long int const q = totalCt / n; 
-        unsigned long int const r = totalCt % n;  
+        unsigned long int const q = totalCt / n;
+        unsigned long int const r = totalCt % n;
         unsigned long int const quantCt = q*quantSeq + (r*quantSeq + n - 1)/n;
        /* This is how many pixels are (ignoring quantization) in the
           quantile.  E.g. for the 3rd quartile, it is 3/4 of the pixels
@@ -419,7 +419,7 @@ summarizeInvalidPixels(unsigned long int const hist[],
   Print total count of valid and invalid pixels, if there are any
   invalid ones.
 -----------------------------------------------------------------------------*/
-    unsigned long int const invalidPixelCt = 
+    unsigned long int const invalidPixelCt =
         mmaxval > maxval ? rcount[maxval+1] : 0;
 
     if (invalidPixelCt > 0) {
diff --git a/analyzer/pgmminkowski.c b/analyzer/pgmminkowski.c
index dfb08429..676dd567 100644
--- a/analyzer/pgmminkowski.c
+++ b/analyzer/pgmminkowski.c
@@ -1,9 +1,9 @@
-/* pgmminkowsky.c - read a portable graymap and calculate the Minkowski 
+/* pgmminkowsky.c - read a portable graymap and calculate the Minkowski
 ** Integrals as a function of the threshold.
 **
 ** Copyright (C) 2000 by Luuk van Dijk/Mind over Matter
 **
-** Based on pgmhist.c, 
+** Based on pgmhist.c,
 ** Copyright (C) 1989 by Jef Poskanzer.
 **
 ** Permission to use, copy, modify, and distribute this software and its
@@ -22,7 +22,7 @@
 #define MAX4(a,b,c,d) MAX2( MAX2((a),(b)), MAX2((c),(d)) )
 
 int main( int argc, char** argv ){
-  
+
   FILE *ifp;
 
   gray maxval;
@@ -31,11 +31,11 @@ int main( int argc, char** argv ){
   gray* prevrow;
   gray* thisrow;
   gray* tmprow;
-  
-  int* countTile;   
-  int* countEdgeX;  
-  int* countEdgeY; 
-  int* countVertex; 
+
+  int* countTile;
+  int* countEdgeX;
+  int* countEdgeY;
+  int* countVertex;
 
   int i, col, row;
 
@@ -46,12 +46,12 @@ int main( int argc, char** argv ){
 
   /*
    * parse arg and initialize
-   */ 
+   */
 
   pgm_init( &argc, argv );
 
   if ( argc > 2 ) pm_usage( "[pgmfile]" );
-  
+
   if ( argc == 2 )
     ifp = pm_openr( argv[1] );
   else
@@ -62,19 +62,19 @@ int main( int argc, char** argv ){
    */
 
   pgm_readpgminit( ifp, &cols, &rows, &maxval, &format );
-  
+
   prevrow = pgm_allocrow( cols );
   thisrow = pgm_allocrow( cols );
-  
+
   MALLOCARRAY(countTile   , maxval + 1 );
   MALLOCARRAY(countEdgeX  , maxval + 1 );
   MALLOCARRAY(countEdgeY  , maxval + 1 );
   MALLOCARRAY(countVertex , maxval + 1 );
- 
+
   if (countTile == NULL || countEdgeX == NULL || countEdgeY == NULL ||
       countVertex == NULL)
       pm_error( "out of memory" );
-  
+
   for ( i = 0; i <= maxval; i++ ) countTile[i]   = 0;
   for ( i = 0; i <= maxval; i++ ) countEdgeX[i]  = 0;
   for ( i = 0; i <= maxval; i++ ) countEdgeY[i]  = 0;
@@ -89,84 +89,84 @@ int main( int argc, char** argv ){
 
   /* tiles */
 
-  for ( col = 0; col < cols; ++col ) ++countTile[thisrow[col]]; 
-  
+  for ( col = 0; col < cols; ++col ) ++countTile[thisrow[col]];
+
   /* y-edges */
 
-  for ( col = 0; col < cols; ++col ) ++countEdgeY[thisrow[col]]; 
+  for ( col = 0; col < cols; ++col ) ++countEdgeY[thisrow[col]];
 
   /* x-edges */
 
   ++countEdgeX[thisrow[0]];
 
-  for ( col = 0; col < cols-1; ++col ) 
+  for ( col = 0; col < cols-1; ++col )
     ++countEdgeX[ MAX2(thisrow[col], thisrow[col+1]) ];
-  
+
   ++countEdgeX[thisrow[cols-1]];
-  
+
   /* shortcut: for the first row, countVertex == countEdgeX */
-  
+
   ++countVertex[thisrow[0]];
 
-  for ( col = 0; col < cols-1; ++col ) 
+  for ( col = 0; col < cols-1; ++col )
     ++countVertex[ MAX2(thisrow[col], thisrow[col+1]) ];
 
   ++countVertex[thisrow[cols-1]];
 
-  
 
-  for ( row = 1; row < rows; ++row ){  
-    
-    tmprow = prevrow; 
+
+  for ( row = 1; row < rows; ++row ){
+
+    tmprow = prevrow;
     prevrow = thisrow;
     thisrow = tmprow;
- 
+
     pgm_readpgmrow( ifp, thisrow, cols, maxval, format );
-  
+
     /* tiles */
 
-    for ( col = 0; col < cols; ++col ) ++countTile[thisrow[col]]; 
-    
+    for ( col = 0; col < cols; ++col ) ++countTile[thisrow[col]];
+
     /* y-edges */
-    
-    for ( col = 0; col < cols; ++col ) 
+
+    for ( col = 0; col < cols; ++col )
       ++countEdgeY[ MAX2(thisrow[col], prevrow[col]) ];
     /* x-edges */
-    
+
     ++countEdgeX[thisrow[0]];
-    
-    for ( col = 0; col < cols-1; ++col ) 
+
+    for ( col = 0; col < cols-1; ++col )
       ++countEdgeX[ MAX2(thisrow[col], thisrow[col+1]) ];
-    
+
     ++countEdgeX[thisrow[cols-1]];
-    
+
     /* vertices */
 
     ++countVertex[ MAX2(thisrow[0],prevrow[0]) ];
 
-    for ( col = 0; col < cols-1; ++col ) 
+    for ( col = 0; col < cols-1; ++col )
       ++countVertex[
         MAX4(thisrow[col], thisrow[col+1], prevrow[col], prevrow[col+1])
       ];
-    
+
     ++countVertex[ MAX2(thisrow[cols-1],prevrow[cols-1]) ];
-    
+
   } /* for row */
-  
+
   /* now thisrow contains the top row*/
 
   /* tiles and x-edges have been counted, now upper
      y-edges and top vertices remain */
-  
+
   /* y-edges */
 
   for ( col = 0; col < cols; ++col ) ++countEdgeY[ thisrow[col] ];
 
   /* vertices */
-  
+
   ++countVertex[thisrow[0]];
 
-  for ( col = 0; col < cols-1; ++col ) 
+  for ( col = 0; col < cols-1; ++col )
     ++countVertex[ MAX2(thisrow[col],thisrow[col+1]) ];
 
   ++countVertex[ thisrow[cols-1] ];
@@ -178,7 +178,7 @@ int main( int argc, char** argv ){
   maxedgex =  rows    * (cols+1);
   maxedgey = (rows+1) *  cols;
   maxvertex= (rows+1) * (cols+1);
-  
+
   l2inv = 1.0/maxtiles;
   linv  = 0.5/(rows+cols);
 
@@ -187,14 +187,14 @@ int main( int argc, char** argv ){
   printf( "#---------\t -----\t-------\t-------\t--------\n" );
   for ( i = 0; i <= maxval; i++ ){
 
-    if( !(countTile[i] || countEdgeX[i] || countEdgeY[i] || countVertex[i] ) ) 
+    if( !(countTile[i] || countEdgeX[i] || countEdgeY[i] || countVertex[i] ) )
       continue; /* skip empty slots */
 
     area      = maxtiles;
     perimeter = 2*maxedgex + 2*maxedgey - 4*maxtiles;
     eulerchi  = maxtiles - maxedgex - maxedgey + maxvertex;
 
-    printf( "%f\t%6d\t%7d\t%7d\t%8d\t%g\t%g\t%6d\n", (float) i/(1.0*maxval), 
+    printf( "%f\t%6d\t%7d\t%7d\t%8d\t%g\t%g\t%6d\n", (float) i/(1.0*maxval),
         maxtiles, maxedgex, maxedgey, maxvertex,
         area*l2inv, perimeter*linv, eulerchi
         );
@@ -210,13 +210,13 @@ int main( int argc, char** argv ){
   }
 
   /* these should be zero: */
-  printf( "#  check:\t%6d\t%7d\t%7d\t%8d\n", 
+  printf( "#  check:\t%6d\t%7d\t%7d\t%8d\n",
           maxtiles, maxedgex, maxedgey, maxvertex );
 
   pm_close( ifp );
-  
+
   exit( 0 );
-  
+
 } /*main*/
 
 
diff --git a/analyzer/pgmtexture.c b/analyzer/pgmtexture.c
index 06db12f2..8a1678e2 100644
--- a/analyzer/pgmtexture.c
+++ b/analyzer/pgmtexture.c
@@ -9,25 +9,64 @@
 
 #include "pm_c_util.h"
 #include "mallocvar.h"
+#include "shhopt.h"
 #include "pgm.h"
 
+
+struct CmdlineInfo {
+    /* All the information the user supplied in the command line,
+     * in a form easy for the program to use.
+     */
+    const char * inputFileName;  /* Filespec of input file */
+    unsigned int d;
+};
+
+
+
+static void
+parseCommandLine(int argc, const char ** const argv,
+                 struct CmdlineInfo * const cmdlineP) {
+/*----------------------------------------------------------------------------
+   Note that the file spec array we return is stored in the storage that
+   was passed to us as the argv array.
+-----------------------------------------------------------------------------*/
+    optEntry * option_def;
+        /* Instructions to OptParseOptions3 on how to parse our options.
+         */
+    optStruct3 opt;
+    unsigned int option_def_index;
+
+    unsigned int dSpec;
+
+    MALLOCARRAY_NOFAIL(option_def, 100);
+
+    option_def_index = 0;   /* incremented by OPTENT3 */
+    OPTENT3(0,   "d",          OPT_UINT,   &cmdlineP->d,  &dSpec,      0);
+
+    opt.opt_table = option_def;
+    opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
+    opt.allowNegNum = TRUE;  /* We may have parms that are negative numbers */
+
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
+        /* Uses and sets argc, argv, and some of *cmdlineP and others. */
+
+    if (!dSpec)
+        cmdlineP->d = 1;
+
+    if (argc-1 < 1)
+        cmdlineP->inputFileName = "-";
+    else if (argc-1 == 1)
+        cmdlineP->inputFileName = argv[1];
+    else
+        pm_error("Program takes at most 1 parameter: the file name.  "
+                 "You specified %u", argc-1);
+}
+
+
+
 #define RADIX 2.0
 #define EPSILON 0.000000001
 #define BL  "Angle                 "
-#define F1  "Angular Second Moment "
-#define F2  "Contrast              "
-#define F3  "Correlation           "
-#define F4  "Variance              "
-#define F5  "Inverse Diff Moment   "
-#define F6  "Sum Average           "
-#define F7  "Sum Variance          "
-#define F8  "Sum Entropy           "
-#define F9  "Entropy               "
-#define F10 "Difference Variance   "
-#define F11 "Difference Entropy    "
-#define F12 "Meas of Correlation-1 "
-#define F13 "Meas of Correlation-2 "
-#define F14 "Max Correlation Coeff "
 
 #define SWAP(a,b) do {float const y=(a);(a)=(b);(b)=y;} while (0)
 
@@ -42,10 +81,6 @@ sign(float const x,
 
 
 
-static bool const sortit = FALSE;
-
-
-
 static float *
 vector(unsigned int const nl,
        unsigned int const nh) {
@@ -62,14 +97,14 @@ vector(unsigned int const nl,
     float * v;
     unsigned int i;
 
-    assert(nh >= nl);
+    assert(nh >= nl); assert(nh <= UINT_MAX-1);
 
     MALLOCARRAY(v, (unsigned) (nh - nl + 1));
 
     if (v == NULL)
         pm_error("Unable to allocate memory for a vector.");
 
-    for(i = 0; i < nh - nl +1; ++i)
+    for (i = 0; i < nh - nl +1; ++i)
         v[i] = 0;
     return v - nl;
 }
@@ -84,48 +119,61 @@ matrix (unsigned int const nrl,
 /*----------------------------------------------------------------------------
   Allocate a float matrix with range [nrl..nrh][ncl..nch]
 
-  We do some seedy C here, subtracting an arbitrary integer from a pointer and
-  calling the result a pointer.  It normally works because the only way we'll
-  use that pointer is by adding that same integer or something greater to it.
-
-  The point of this is not to allocate memory for matrix elements that will
-  never be referenced (row < nrl or column < ncl).
+  Return value is a pointer to array of pointers to rows
 -----------------------------------------------------------------------------*/
+    /* We do some seedy C here, subtracting an arbitrary integer from a
+       pointer and calling the result a pointer.  It normally works because
+       the only way we'll use that pointer is by adding that same integer or
+       something greater to it.
+
+       The point of this is not to allocate memory for matrix elements that
+       will never be referenced (row < nrl or column < ncl).
+    */
+
     unsigned int i;
-    float ** m;
+    float ** matrix;  /* What we are creating */
 
-    assert(nrh >= nrl);
+    assert(nrh >= nrl); assert(nrh <= UINT_MAX-1);
 
     /* allocate pointers to rows */
-    MALLOCARRAY(m, (unsigned) (nrh - nrl + 1));
-    if (m == NULL)
+    MALLOCARRAY(matrix, (unsigned) (nrh - nrl + 1));
+    if (matrix == NULL)
         pm_error("Unable to allocate memory for a matrix.");
 
-    m -= ncl;
+    matrix -= ncl;
 
-    assert (nch >= ncl);
+    assert (nch >= ncl); assert(nch <= UINT_MAX-1);
 
     /* allocate rows and set pointers to them */
     for (i = nrl; i <= nrh; ++i) {
-        MALLOCARRAY(m[i], (unsigned) (nch - ncl + 1));
-        if (m[i] == NULL)
+        MALLOCARRAY(matrix[i], (unsigned) (nch - ncl + 1));
+        if (!matrix[i])
             pm_error("Unable to allocate memory for a matrix row.");
-        m[i] -= ncl;
+        matrix[i] -= ncl;
     }
 
-    /* return pointer to array of pointers to rows */
-    return m;
+    return matrix;
 }
 
 
 
 static void
-results (const char *  const name,
-         const float * const a) {
+printHeader() {
+
+    fprintf(stdout,
+            "%-22.22s %10.10s %10.10s %10.10s %10.10s %10.10s\n",
+            "Angle", "0", "45", "90", "135", "Avg");
+}
+
+
+
+static void
+printResults(const char *  const name,
+             const float * const a) {
 
     unsigned int i;
 
-    fprintf(stdout, "%s", name);
+    fprintf(stdout, "%-22.22s ", name);
 
     for (i = 0; i < 4; ++i)
         fprintf(stdout, "% 1.3e ", a[i]);
@@ -136,24 +184,105 @@ results (const char *  const name,
 
 
 static void
-simplesrt (unsigned int  const n,
-           float *       const arr) {
+makeGrayToneSpatialDependenceMatrix(gray **        const grays,
+                                    unsigned int   const rows,
+                                    unsigned int   const cols,
+                                    unsigned int   const d,
+                                    unsigned int * const tone,
+                                    unsigned int   const toneCt,
+                                    float *** const pmatrix0P,
+                                    float *** const pmatrix45P,
+                                    float *** const pmatrix90P,
+                                    float *** const pmatrix135P) {
+
+    float ** pmatrix0, ** pmatrix45, ** pmatrix90, ** pmatrix135;
+    unsigned int row;
 
-    unsigned int j;
-    float a;
+    pm_message("Computing spatial dependence matrix...");
 
-    for (j = 2; j <= n; ++j) {
-        unsigned int i;
+    /* Allocate memory */
+    pmatrix0   = matrix(0, toneCt, 0, toneCt);
+    pmatrix45  = matrix(0, toneCt, 0, toneCt);
+    pmatrix90  = matrix(0, toneCt, 0, toneCt);
+    pmatrix135 = matrix(0, toneCt, 0, toneCt);
 
-        a = arr[j];
-        i = j;
+    for (row = 0; row < toneCt; ++row) {
+        unsigned int col;
+        for (col = 0; col < toneCt; ++col) {
+            pmatrix0 [row][col] = pmatrix45 [row][col] = 0;
+            pmatrix90[row][col] = pmatrix135[row][col] = 0;
+        }
+    }
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
+        for (col = 0; col < cols; ++col) {
+            unsigned int angle;
+            unsigned int x;
+            for (angle = 0, x = 0; angle <= 135; angle += 45) {
+                while (tone[x] != grays[row][col])
+                    ++x;
+                if (angle == 0 && col + d < cols) {
+                    unsigned int y;
+                    y = 0;
+                    while (tone[y] != grays[row][col + d])
+                        ++y;
+                    ++pmatrix0[x][y];
+                    ++pmatrix0[y][x];
+                }
+                if (angle == 90 && row + d < rows) {
+                    unsigned int y;
+                    y = 0;
+                    while (tone[y] != grays[row + d][col])
+                        ++y;
+                    ++pmatrix90[x][y];
+                    ++pmatrix90[y][x];
+                }
+                if (angle == 45 && row + d < rows && col >= d) {
+                    unsigned int y;
+                    y = 0;
+                    while (tone[y] != grays[row + d][col - d])
+                        ++y;
+                    ++pmatrix45[x][y];
+                    ++pmatrix45[y][x];
+                }
+                if (angle == 135 && row + d < rows && col + d < cols) {
+                    unsigned int y;
+                    y = 0;
+                    while (tone[y] != grays[row + d][col + d])
+                        ++y;
+                    ++pmatrix135[x][y];
+                    ++pmatrix135[y][x];
+                }
+            }
+        }
+    }
+    /* Gray-tone spatial dependence matrices are complete */
 
-        while (i > 1 && arr[i-1] > a) {
-            arr[i] = arr[i-1];
-            --i;
+    {
+    /* Find normalizing constants */
+    unsigned int const r0  = 2 * rows * (cols - d);
+    unsigned int const r45 = 2 * (rows - d) * (cols - d);
+    unsigned int const r90 = 2 * (rows - d) * cols;
+
+    unsigned int i;
+
+    /* Normalize gray-tone spatial dependence matrix */
+    for (i = 0; i < toneCt; ++i) {
+        unsigned int j;
+        for (j = 0; j < toneCt; ++j) {
+            pmatrix0  [i][j] /= r0;
+            pmatrix45 [i][j] /= r45;
+            pmatrix90 [i][j] /= r90;
+            pmatrix135[i][j] /= r45;
         }
-        arr[i] = a;
     }
+    }
+    pm_message(" ...done.");
+
+    *pmatrix0P   = pmatrix0;
+    *pmatrix45P  = pmatrix45;
+    *pmatrix90P  = pmatrix90;
+    *pmatrix135P = pmatrix135;
 }
 
 
@@ -209,8 +338,8 @@ mkbalanced (float **     const a,
 
 
 static void
-reduction (float **     const a,
-           unsigned int const n) {
+reduction(float **     const a,
+          unsigned int const n) {
 
     unsigned int m;
 
@@ -327,7 +456,7 @@ hessenberg(float **     const a,
                     float p, q, r;
                     if (its == 30)
                         pm_error("Too many iterations to required "
-                                 "to find %s.  Giving up", F14);
+                                 "to find max correlation coefficient");
                     if (its == 10 || its == 20) {
                         int i;
                         float s;
@@ -570,6 +699,43 @@ f5_idm (float **     const p,
 }
 
 
+static double *
+newPxpy2(unsigned int const ng) {
+
+    double * pxpy;
+
+    if (ng > UINT_MAX-1)
+        pm_error("Too many gray levels (%u) to do computations", ng);
+
+    MALLOCARRAY(pxpy, ng+1);
+
+    if (!pxpy)
+        pm_error("Unable to allocate %u entries for the pxpy table",
+                 ng+1);
+
+    return pxpy;
+}
+
+
+
+static float *
+newPxpy(unsigned int const ng) {
+
+    float * pxpy;
+
+    if (ng > (UINT_MAX-1)/2 -1)
+        pm_error("Too many gray levels (%u) to do computations", ng);
+
+    MALLOCARRAY(pxpy, 2 * (ng+1) + 1);
+
+    if (!pxpy)
+        pm_error("Unable to allocate %u entries for the pxpy table",
+                 2* (ng+1) + 1);
+
+    return pxpy;
+}
+
+
 
 static float
 f6_savg (float **     const p,
@@ -577,12 +743,11 @@ f6_savg (float **     const p,
 /*----------------------------------------------------------------------------
    Sum Average
 -----------------------------------------------------------------------------*/
-    float pxpy[2 * (PGM_MAXMAXVAL+1) + 1];
+    float * const pxpy = newPxpy(ng);
+
     unsigned int i;
     float savg;
 
-    assert(2*ng < ARRAY_SIZE(pxpy));
-
     for (i = 0; i <= 2 * ng; ++i)
         pxpy[i] = 0.0;
 
@@ -594,6 +759,8 @@ f6_savg (float **     const p,
     for (i = 2, savg = 0.0; i <= 2 * ng; ++i)
         savg += i * pxpy[i];
 
+    free(pxpy);
+
     return savg;
 }
 
@@ -606,12 +773,11 @@ f7_svar (float **     const p,
 /*----------------------------------------------------------------------------
    Sum Variance
 -----------------------------------------------------------------------------*/
-    float pxpy[2 * (PGM_MAXMAXVAL+1) + 1];
+    float * const pxpy = newPxpy(ng);
+
     unsigned int i;
     float var;
 
-    assert(2*ng < ARRAY_SIZE(pxpy));
-
     for (i = 0; i <= 2 * ng; ++i)
         pxpy[i] = 0;
 
@@ -623,6 +789,8 @@ f7_svar (float **     const p,
     for (i = 2, var = 0.0; i <= 2 * ng; ++i)
         var += (i - s) * (i - s) * pxpy[i];
 
+    free(pxpy);
+
     return var;
 }
 
@@ -634,12 +802,11 @@ f8_sentropy (float **     const p,
 /*----------------------------------------------------------------------------
    Sum Entropy
 -----------------------------------------------------------------------------*/
-    float pxpy[2 * (PGM_MAXMAXVAL+1) + 1];
+    float * const pxpy = newPxpy(ng);
+
     unsigned int i;
     float sentropy;
 
-    assert(2*ng < ARRAY_SIZE(pxpy));
-
     for (i = 0; i <= 2 * ng; ++i)
         pxpy[i] = 0;
 
@@ -651,6 +818,8 @@ f8_sentropy (float **     const p,
     for (i = 2, sentropy = 0.0; i <= 2 * ng; ++i)
         sentropy -= pxpy[i] * log10(pxpy[i] + EPSILON);
 
+    free(pxpy);
+
     return sentropy;
 }
 
@@ -681,15 +850,14 @@ f10_dvar(float **     const p,
 /*----------------------------------------------------------------------------
    Difference Variance
 -----------------------------------------------------------------------------*/
-    double pxpy[PGM_MAXMAXVAL + 1];
+    double * const pxpy = newPxpy2(ng);
+
     unsigned int i;
     double sqrNg;  /* Square of 'ng' */
     double sum;
     double sumSqr;
     double var;
 
-    assert(ng <= ARRAY_SIZE(pxpy));
-
     for (i = 0; i < ng; ++i)
         pxpy[i] = 0;
 
@@ -706,6 +874,8 @@ f10_dvar(float **     const p,
     sqrNg = SQR(ng);
     var = (sqrNg * sumSqr - SQR(sum)) / SQR(sqrNg);
 
+    free(pxpy);
+
     return var;
 }
 
@@ -717,12 +887,11 @@ f11_dentropy (float **     const p,
 /*----------------------------------------------------------------------------
    Difference Entropy
 -----------------------------------------------------------------------------*/
-    float pxpy[2 * (PGM_MAXMAXVAL+1) + 1];
+    float * const pxpy = newPxpy(ng);
+
     unsigned int i;
     float sum;
 
-    assert(2*ng < ARRAY_SIZE(pxpy));
-
     for (i = 0; i <= 2 * ng; ++i)
         pxpy[i] = 0;
 
@@ -734,6 +903,8 @@ f11_dentropy (float **     const p,
     for (i = 0, sum = 0.0; i < ng; ++i)
         sum += pxpy[i] * log10(pxpy[i] + EPSILON);
 
+    free(pxpy);
+
     return -sum;
 }
 
@@ -879,8 +1050,6 @@ f14_maxcorr (float **     const p,
     reduction(q, ng);
     /* Finding eigenvalue for nonsymetric matrix using QR algorithm */
     hessenberg(q, ng, x, iy);
-    if (sortit)
-        simplesrt(ng, x);
 
     /* Return the sqrt of the second largest eigenvalue of q */
     for (i = 2, tmp = x[1]; i <= ng; ++i)
@@ -891,257 +1060,370 @@ f14_maxcorr (float **     const p,
 
 
 
+static void
+printAngularSecondMom(float **     const pmatrix0,
+                      float **     const pmatrix45,
+                      float **     const pmatrix90,
+                      float **     const pmatrix135,
+                      unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f1_a2m(pmatrix0,   toneCt);
+    res[1] = f1_a2m(pmatrix45,  toneCt);
+    res[2] = f1_a2m(pmatrix90,  toneCt);
+    res[3] = f1_a2m(pmatrix135, toneCt);
+
+    printResults("Angular Second Moment", res);
+}
+
+
+
+static void
+printContrast(float **     const pmatrix0,
+              float **     const pmatrix45,
+              float **     const pmatrix90,
+              float **     const pmatrix135,
+              unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f2_contrast(pmatrix0,   toneCt);
+    res[1] = f2_contrast(pmatrix45,  toneCt);
+    res[2] = f2_contrast(pmatrix90,  toneCt);
+    res[3] = f2_contrast(pmatrix135, toneCt);
+
+    printResults("Contrast", res);
+}
+
+
+
+static void
+printCorrelation(float **     const pmatrix0,
+                 float **     const pmatrix45,
+                 float **     const pmatrix90,
+                 float **     const pmatrix135,
+                 unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f3_corr(pmatrix0,   toneCt);
+    res[1] = f3_corr(pmatrix45,  toneCt);
+    res[2] = f3_corr(pmatrix90,  toneCt);
+    res[3] = f3_corr(pmatrix135, toneCt);
+
+    printResults("Correlation", res);
+}
+
+
+
+static void
+printVariance(float **     const pmatrix0,
+              float **     const pmatrix45,
+              float **     const pmatrix90,
+              float **     const pmatrix135,
+              unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f4_var(pmatrix0,   toneCt);
+    res[1] = f4_var(pmatrix45,  toneCt);
+    res[2] = f4_var(pmatrix90,  toneCt);
+    res[3] = f4_var(pmatrix135, toneCt);
+
+    printResults("Variance", res);
+}
+
+
+
+static void
+printInverseDiffMoment(float **     const pmatrix0,
+                       float **     const pmatrix45,
+                       float **     const pmatrix90,
+                       float **     const pmatrix135,
+                       unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f5_idm(pmatrix0,   toneCt);
+    res[1] = f5_idm(pmatrix45,  toneCt);
+    res[2] = f5_idm(pmatrix90,  toneCt);
+    res[3] = f5_idm(pmatrix135, toneCt);
+
+    printResults("Inverse Diff Moment", res);
+}
+
+
+
+static void
+printSumAverage(float **     const pmatrix0,
+                float **     const pmatrix45,
+                float **     const pmatrix90,
+                float **     const pmatrix135,
+                unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f6_savg(pmatrix0,  toneCt);
+    res[1] = f6_savg(pmatrix45,  toneCt);
+    res[2] = f6_savg(pmatrix90,  toneCt);
+    res[3] = f6_savg(pmatrix135, toneCt);
+
+    printResults("Sum Average", res);
+}
+
+
+
+static void
+printSumVariance(float **     const pmatrix0,
+                 float **     const pmatrix45,
+                 float **     const pmatrix90,
+                 float **     const pmatrix135,
+                 unsigned int const toneCt) {
+
+    float res[4];
+    float savg[4];
+
+    savg[0] = f6_savg(pmatrix0,   toneCt);
+    savg[1] = f6_savg(pmatrix45,  toneCt);
+    savg[2] = f6_savg(pmatrix90,  toneCt);
+    savg[3] = f6_savg(pmatrix135, toneCt);
+
+    res[0] = f7_svar(pmatrix0,   toneCt, savg[0]);
+    res[1] = f7_svar(pmatrix45,  toneCt, savg[1]);
+    res[2] = f7_svar(pmatrix90,  toneCt, savg[2]);
+    res[3] = f7_svar(pmatrix135, toneCt, savg[3]);
+
+    printResults("Sum Variance", res);
+}
+
+
+
+static void
+printSumVarianceEnt(float **     const pmatrix0,
+                    float **     const pmatrix45,
+                    float **     const pmatrix90,
+                    float **     const pmatrix135,
+                    unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f8_sentropy(pmatrix0,   toneCt);
+    res[1] = f8_sentropy(pmatrix45,  toneCt);
+    res[2] = f8_sentropy(pmatrix90,  toneCt);
+    res[3] = f8_sentropy(pmatrix135, toneCt);
+
+    printResults("Sum Entropy", res);
+}
+
+
+
+static void
+printEntropy(float **     const pmatrix0,
+             float **     const pmatrix45,
+             float **     const pmatrix90,
+             float **     const pmatrix135,
+             unsigned int const toneCt) {
+
+    float res[4];
+
+
+    res[0] = f9_entropy(pmatrix0,   toneCt);
+    res[1] = f9_entropy(pmatrix45,  toneCt);
+    res[2] = f9_entropy(pmatrix90,  toneCt);
+    res[3] = f9_entropy(pmatrix135, toneCt);
+
+    printResults("Entropy", res);
+}
+
+
+
+static void
+printDiffVariance(float **     const pmatrix0,
+                  float **     const pmatrix45,
+                  float **     const pmatrix90,
+                  float **     const pmatrix135,
+                  unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f10_dvar(pmatrix0,   toneCt);
+    res[1] = f10_dvar(pmatrix45,  toneCt);
+    res[2] = f10_dvar(pmatrix90,  toneCt);
+    res[3] = f10_dvar(pmatrix135, toneCt);
+
+    printResults("Difference Variance", res);
+}
+
+
+
+static void
+printDiffEntropy(float **     const pmatrix0,
+                 float **     const pmatrix45,
+                 float **     const pmatrix90,
+                 float **     const pmatrix135,
+                 unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f11_dentropy(pmatrix0,   toneCt);
+    res[1] = f11_dentropy(pmatrix45,  toneCt);
+    res[2] = f11_dentropy(pmatrix90,  toneCt);
+    res[3] = f11_dentropy(pmatrix135, toneCt);
+
+    printResults ("Difference Entropy", res);
+}
+
+
+
+static void
+printCorrelation1(float **     const pmatrix0,
+                  float **     const pmatrix45,
+                  float **     const pmatrix90,
+                  float **     const pmatrix135,
+                  unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f12_icorr(pmatrix0,   toneCt);
+    res[1] = f12_icorr(pmatrix45,  toneCt);
+    res[2] = f12_icorr(pmatrix90,  toneCt);
+    res[3] = f12_icorr(pmatrix135, toneCt);
+
+    printResults("Meas of Correlation-1", res);
+}
+
+
+
+static void
+printCorrelation2(float **     const pmatrix0,
+                  float **     const pmatrix45,
+                  float **     const pmatrix90,
+                  float **     const pmatrix135,
+                  unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f13_icorr(pmatrix0,   toneCt);
+    res[1] = f13_icorr(pmatrix45,  toneCt);
+    res[2] = f13_icorr(pmatrix90,  toneCt);
+    res[3] = f13_icorr(pmatrix135, toneCt);
+
+    printResults("Meas of Correlation2", res);
+}
+
+
+
+static void
+printCorrelationMax(float **     const pmatrix0,
+                    float **     const pmatrix45,
+                    float **     const pmatrix90,
+                    float **     const pmatrix135,
+                    unsigned int const toneCt) {
+
+    float res[4];
+
+    res[0] = f14_maxcorr(pmatrix0,   toneCt);
+    res[1] = f14_maxcorr(pmatrix45,  toneCt);
+    res[2] = f14_maxcorr(pmatrix90,  toneCt);
+    res[3] = f14_maxcorr(pmatrix135, toneCt);
+
+    printResults("Max Correlation Coeff", res);
+}
+
+
+
 int
 main (int argc, const char ** argv) {
 
+    struct CmdlineInfo cmdline;
     FILE * ifP;
     gray ** grays;
-    unsigned int tone[PGM_MAXMAXVAL+1];
-    unsigned int r0, r45, r90;
-    unsigned int d;
-    unsigned int x, y;
+    unsigned int * tone;  /* malloced array */
+    unsigned int toneCt;
     unsigned int row;
     int rows, cols;
-    int argn;
     unsigned int itone;
-    unsigned int toneCt;
-    float ** p_matrix0, ** p_matrix45, ** p_matrix90, ** p_matrix135;
-    float a2m[4], contrast[4], corr[4], var[4], idm[4], savg[4];
-    float sentropy[4], svar[4], entropy[4], dvar[4], dentropy[4];
-    float icorr[4], maxcorr[4];
+    float ** pmatrix0, ** pmatrix45, ** pmatrix90, ** pmatrix135;
     gray maxval;
     unsigned int i;
-    const char * const usage = "[-d <d>] [pgmfile]";
 
     pm_proginit(&argc, argv);
 
-    d = 1;
+    parseCommandLine(argc, argv, &cmdline);
 
-    argn = 1;
-
-    /* Check for flags. */
-    if ( argn < argc && argv[argn][0] == '-' )
-    {
-        if ( argv[argn][1] == 'd' )
-        {
-            ++argn;
-            if ( argn == argc || sscanf( argv[argn], "%u", &d ) != 1 )
-                pm_usage( usage );
-        }
-        else
-            pm_usage( usage );
-        ++argn;
-    }
-
-    if ( argn < argc )
-    {
-        ifP = pm_openr( argv[argn] );
-        ++argn;
-    }
-    else
-        ifP = stdin;
-
-    if ( argn != argc )
-        pm_usage( usage );
+    ifP = pm_openr(cmdline.inputFileName);
 
     grays = pgm_readpgm(ifP, &cols, &rows, &maxval);
-    pm_close (ifP);
 
-    if (maxval > PGM_MAXMAXVAL)
-        pm_error("Maxval %u is too high.  We can handle only up to %u",
-                 maxval, PGM_MAXMAXVAL);
+    MALLOCARRAY(tone, maxval+1);
 
     /* Determine the number of different gray scales (not maxval) */
-    for (i = 0; i <= PGM_MAXMAXVAL; ++i)
+    for (i = 0; i <= maxval; ++i)
         tone[i] = -1;
     for (row = 0; row < rows; ++row) {
         unsigned int col;
         for (col = 0; col < cols; ++col)
             tone[grays[row][col]] = grays[row][col];
     }
-    for (i = 0, toneCt = 0; i <= PGM_MAXMAXVAL; ++i) {
+    for (i = 0, toneCt = 0; i <= maxval; ++i) {
         if (tone[i] != -1)
             ++toneCt;
     }
     pm_message("(Image has %u gray levels.)", toneCt);
 
     /* Collapse array, taking out all zero values */
-    for (row = 0, itone = 0; row <= PGM_MAXMAXVAL; ++row)
+    for (row = 0, itone = 0; row <= maxval; ++row)
         if (tone[row] != -1)
             tone[itone++] = tone[row];
     /* Now array contains only the gray levels present (in ascending order) */
 
-    /* Allocate memory for gray-tone spatial dependence matrix */
-    p_matrix0   = matrix (0, toneCt, 0, toneCt);
-    p_matrix45  = matrix (0, toneCt, 0, toneCt);
-    p_matrix90  = matrix (0, toneCt, 0, toneCt);
-    p_matrix135 = matrix (0, toneCt, 0, toneCt);
-
-    for (row = 0; row < toneCt; ++row) {
-        unsigned int col;
-        for (col = 0; col < toneCt; ++col) {
-            p_matrix0 [row][col] = p_matrix45 [row][col] = 0;
-            p_matrix90[row][col] = p_matrix135[row][col] = 0;
-        }
-    }
-    if (d > cols)
+    if (cmdline.d > cols)
         pm_error("Image is narrower (%u columns) "
-                 "than specified distance (%u)", cols, d);
-
-    /* Find gray-tone spatial dependence matrix */
-    pm_message("Computing spatial dependence matrix...");
-    for (row = 0; row < rows; ++row) {
-        unsigned int col;
-        for (col = 0; col < cols; ++col) {
-            unsigned int angle;
-            for (angle = 0, x = 0; angle <= 135; angle += 45) {
-                while (tone[x] != grays[row][col])
-                    ++x;
-                if (angle == 0 && col + d < cols) {
-                    y = 0;
-                    while (tone[y] != grays[row][col + d])
-                        ++y;
-                    ++p_matrix0[x][y];
-                    ++p_matrix0[y][x];
-                }
-                if (angle == 90 && row + d < rows) {
-                    y = 0;
-                    while (tone[y] != grays[row + d][col])
-                        ++y;
-                    ++p_matrix90[x][y];
-                    ++p_matrix90[y][x];
-                }
-                if (angle == 45 && row + d < rows && col >= d) {
-                    y = 0;
-                    while (tone[y] != grays[row + d][col - d])
-                        ++y;
-                    ++p_matrix45[x][y];
-                    ++p_matrix45[y][x];
-                }
-                if (angle == 135 && row + d < rows && col + d < cols) {
-                    y = 0;
-                    while (tone[y] != grays[row + d][col + d])
-                        ++y;
-                    ++p_matrix135[x][y];
-                    ++p_matrix135[y][x];
-                }
-            }
-        }
-    }
-    /* Gray-tone spatial dependence matrices are complete */
+                 "than specified distance (%u)", cols, cmdline.d);
 
-    /* Find normalizing constants */
-    r0  = 2 * rows * (cols - d);
-    r45 = 2 * (rows - d) * (cols - d);
-    r90 = 2 * (rows - d) * cols;
-
-    /* Normalize gray-tone spatial dependence matrix */
-    for (itone = 0; itone < toneCt; ++itone) {
-        unsigned int jtone;
-        for (jtone = 0; jtone < toneCt; ++jtone) {
-            p_matrix0[itone][jtone]   /= r0;
-            p_matrix45[itone][jtone]  /= r45;
-            p_matrix90[itone][jtone]  /= r90;
-            p_matrix135[itone][jtone] /= r45;
-        }
-    }
-    pm_message(" ...done.");
+    makeGrayToneSpatialDependenceMatrix(
+        grays, rows, cols, cmdline.d, tone, toneCt,
+        &pmatrix0, &pmatrix45, &pmatrix90, &pmatrix135);
 
     pm_message("Computing textural features ...");
 
     fprintf(stdout, "\n");
-    fprintf(stdout,
-            "%s         0         45         90        135        Avg\n",
-            BL);
-
-    a2m[0] = f1_a2m(p_matrix0,   toneCt);
-    a2m[1] = f1_a2m(p_matrix45,  toneCt);
-    a2m[2] = f1_a2m(p_matrix90,  toneCt);
-    a2m[3] = f1_a2m(p_matrix135, toneCt);
-    results(F1, a2m);
-
-    contrast[0] = f2_contrast(p_matrix0,   toneCt);
-    contrast[1] = f2_contrast(p_matrix45,  toneCt);
-    contrast[2] = f2_contrast(p_matrix90,  toneCt);
-    contrast[3] = f2_contrast(p_matrix135, toneCt);
-    results(F2, contrast);
-
-
-    corr[0] = f3_corr(p_matrix0,   toneCt);
-    corr[1] = f3_corr(p_matrix45,  toneCt);
-    corr[2] = f3_corr(p_matrix90,  toneCt);
-    corr[3] = f3_corr(p_matrix135, toneCt);
-    results(F3, corr);
-
-    var[0] = f4_var(p_matrix0,   toneCt);
-    var[1] = f4_var(p_matrix45,  toneCt);
-    var[2] = f4_var(p_matrix90,  toneCt);
-    var[3] = f4_var(p_matrix135, toneCt);
-    results(F4, var);
-
-
-    idm[0] = f5_idm(p_matrix0,   toneCt);
-    idm[1] = f5_idm(p_matrix45,  toneCt);
-    idm[2] = f5_idm(p_matrix90,  toneCt);
-    idm[3] = f5_idm(p_matrix135, toneCt);
-    results(F5, idm);
-
-    savg[0] = f6_savg(p_matrix0,  toneCt);
-    savg[1] = f6_savg(p_matrix45,  toneCt);
-    savg[2] = f6_savg(p_matrix90,  toneCt);
-    savg[3] = f6_savg(p_matrix135, toneCt);
-    results(F6, savg);
-
-    svar[0] = f7_svar(p_matrix0,   toneCt, savg[0]);
-    svar[1] = f7_svar(p_matrix45,  toneCt, savg[1]);
-    svar[2] = f7_svar(p_matrix90,  toneCt, savg[2]);
-    svar[3] = f7_svar(p_matrix135, toneCt, savg[3]);
-    results(F7, svar);
-
-    sentropy[0] = f8_sentropy(p_matrix0,   toneCt);
-    sentropy[1] = f8_sentropy(p_matrix45,  toneCt);
-    sentropy[2] = f8_sentropy(p_matrix90,  toneCt);
-    sentropy[3] = f8_sentropy(p_matrix135, toneCt);
-    results(F8, sentropy);
-
-    entropy[0] = f9_entropy(p_matrix0,   toneCt);
-    entropy[1] = f9_entropy(p_matrix45,  toneCt);
-    entropy[2] = f9_entropy(p_matrix90,  toneCt);
-    entropy[3] = f9_entropy(p_matrix135, toneCt);
-    results(F9, entropy);
-
-    dvar[0] = f10_dvar(p_matrix0,   toneCt);
-    dvar[1] = f10_dvar(p_matrix45,  toneCt);
-    dvar[2] = f10_dvar(p_matrix90,  toneCt);
-    dvar[3] = f10_dvar(p_matrix135, toneCt);
-    results(F10, dvar);
-
-    dentropy[0] = f11_dentropy(p_matrix0,   toneCt);
-    dentropy[1] = f11_dentropy(p_matrix45,  toneCt);
-    dentropy[2] = f11_dentropy(p_matrix90,  toneCt);
-    dentropy[3] = f11_dentropy(p_matrix135, toneCt);
-    results (F11, dentropy);
-
-    icorr[0] = f12_icorr(p_matrix0,   toneCt);
-    icorr[1] = f12_icorr(p_matrix45,  toneCt);
-    icorr[2] = f12_icorr(p_matrix90,  toneCt);
-    icorr[3] = f12_icorr(p_matrix135, toneCt);
-    results(F12, icorr);
-
-    icorr[0] = f13_icorr(p_matrix0,   toneCt);
-    icorr[1] = f13_icorr(p_matrix45,  toneCt);
-    icorr[2] = f13_icorr(p_matrix90,  toneCt);
-    icorr[3] = f13_icorr(p_matrix135, toneCt);
-    results(F13, icorr);
-
-    maxcorr[0] = f14_maxcorr(p_matrix0,   toneCt);
-    maxcorr[1] = f14_maxcorr(p_matrix45,  toneCt);
-    maxcorr[2] = f14_maxcorr(p_matrix90,  toneCt);
-    maxcorr[3] = f14_maxcorr(p_matrix135, toneCt);
-    results(F14, maxcorr);
+
+    printHeader();
+
+    printAngularSecondMom (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printContrast         (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printCorrelation      (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printVariance         (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printInverseDiffMoment(pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printSumAverage       (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printSumVariance      (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printSumVarianceEnt   (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printEntropy          (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printDiffVariance     (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printDiffEntropy      (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printCorrelation1     (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printCorrelation2     (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
+
+    printCorrelationMax   (pmatrix0, pmatrix45, pmatrix90, pmatrix135, toneCt);
 
     pm_message(" ...done.");
 
+    pm_close (ifP);
+
     return 0;
 }
 
diff --git a/analyzer/pnmhistmap.c b/analyzer/pnmhistmap.c
index fc1bbbde..e51bbb24 100644
--- a/analyzer/pnmhistmap.c
+++ b/analyzer/pnmhistmap.c
@@ -113,7 +113,7 @@ parseCommandLine(int argc, const char ** argv,
     if (!heightSpec)
         cmdlineP->height = 200;
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFilespec = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -202,7 +202,7 @@ pgmHist(FILE *       const ifP,
     unsigned int * ghist;
     double vscale;
     unsigned int hmax;
-    
+
     MALLOCARRAY(ghist, histWidth);
     if (ghist == NULL)
         pm_error("Not enough memory for histogram array (%u bytes)",
@@ -231,7 +231,7 @@ pgmHist(FILE *       const ifP,
         pm_message("finding max. slot height...");
     if (clipSpec)
         hmax = clipCount;
-    else 
+    else
         hmax = maxSlotCount(ghist, histWidth, no_white, no_black);
 
     assert(hmax > 0);
@@ -275,10 +275,10 @@ maxSlotCountAll(unsigned int *       const hist[3],
 
     for (color = 0; color < 3; ++color)
         if (hist[color])
-            hmax = MAX(hmax, 
-                       maxSlotCount(hist[color], 
+            hmax = MAX(hmax,
+                       maxSlotCount(hist[color],
                                     histWidth, no_white, no_black));
-    
+
     return hmax;
 }
 
@@ -418,7 +418,7 @@ ppmHist(FILE *       const ifP,
         pm_message("finding max. slot height...");
     if (clipSpec)
         hmax = clipCount;
-    else 
+    else
         hmax = maxSlotCountAll(hist, histWidth, no_white, no_black);
 
     assert(hmax > 0);
@@ -427,7 +427,7 @@ ppmHist(FILE *       const ifP,
 
     vscale = (double) histHeight / hmax;
     if (verbose && pm_have_float_format())
-        pm_message("Done: height = %u, vertical scale factor = %g", 
+        pm_message("Done: height = %u, vertical scale factor = %g",
                    hmax, vscale);
 
     for (i = 0; i < histWidth; ++i) {
@@ -435,8 +435,8 @@ ppmHist(FILE *       const ifP,
             unsigned int j;
             bool plotted;
             plotted = FALSE;
-            for (j = histHeight - (int)(vscale * hist[WANT_RED][i]); 
-                 j < histHeight && !plotted; 
+            for (j = histHeight - (int)(vscale * hist[WANT_RED][i]);
+                 j < histHeight && !plotted;
                  ++j) {
                 PPM_PUTR(pixels[j][i], maxval);
                 plotted = dots;
@@ -446,8 +446,8 @@ ppmHist(FILE *       const ifP,
             unsigned int j;
             bool plotted;
             plotted = FALSE;
-            for (j = histHeight - (int)(vscale * hist[WANT_GRN][i]); 
-                 j < histHeight && !plotted; 
+            for (j = histHeight - (int)(vscale * hist[WANT_GRN][i]);
+                 j < histHeight && !plotted;
                  ++j) {
                 PPM_PUTG(pixels[j][i], maxval);
                 plotted = dots;
@@ -457,8 +457,8 @@ ppmHist(FILE *       const ifP,
             unsigned int j;
             bool plotted;
             plotted = FALSE;
-            for (j = histHeight - (int)(vscale * hist[WANT_BLU][i]); 
-                 j < histHeight && !plotted; 
+            for (j = histHeight - (int)(vscale * hist[WANT_BLU][i]);
+                 j < histHeight && !plotted;
                  ++j) {
                 PPM_PUTB(pixels[j][i], maxval);
                 plotted = dots;
diff --git a/buildtools/makeman b/buildtools/makeman
index 6ff40aca..641ef856 100755
--- a/buildtools/makeman
+++ b/buildtools/makeman
@@ -247,6 +247,7 @@ def makeman(name, file, indoc):
     indoc = indoc.replace("&mdash;", "-")
     indoc = indoc.replace("&mu;", "mu")
     indoc = indoc.replace("&sigma;", "sigma")
+    indoc = indoc.replace("&apos;", "'")
     # Tables
     # This will not handle rowspan
     indoc = re.sub('(?i) *<table[^>]*>.*', ".TS", indoc)
diff --git a/buildtools/stamp-date b/buildtools/stamp-date
index f867416d..baeec3fd 100755
--- a/buildtools/stamp-date
+++ b/buildtools/stamp-date
@@ -12,6 +12,11 @@
 # SOURCE_DATE_EPOCH is an environment variable as described here:
 # https://reproducible-builds.org/specs/source-date-epoch/ on 2017.03.16.
 
+# COMPILED_BY is a similar environment variable whose value is some
+# description of who is doing the build.  If it is not set, we use the
+# value of LOGNAME; if that is not set, we use the value of User; if that
+# is not set, we use the output of program 'whoami'.
+
 SOURCE_DATE_OR_NONE=${SOURCE_DATE_EPOCH:-NONE}
 
 NOW_FROM_DATE_PGM=$(date +%s)
@@ -24,9 +29,12 @@ else
 fi
 
 LOGNAME_OR_UNKNOWN=${LOGNAME:-UNKNOWN}
-USER=${USER:-$LOGNAME_OR_UNKNOWN}
-if [ "$USER" = "UNKNOWN" ]; then
-    USER=$(whoami)
+USER_OR_UNKNOWN=${USER:-$LOGNAME_OR_UNKNOWN}
+COMPILED_BY_OR_UNKNOWN=${COMPILED_BY:-$USER_OR_UNKNOWN}
+if [ "$COMPILED_BY_OR_UNKNOWN" = "UNKNOWN" ]; then
+    COMPILED_BY=$(whoami)
+else
+    COMPILED_BY=$COMPILED_BY_OR_UNKNOWN
 fi
 
 echo "/* This file tells some facts about the building of the package */"
@@ -36,4 +44,4 @@ if [ "$SOURCE_DATE_OR_NONE" != "NONE" ]; then
   echo "#define SOURCE_DATETIME $SOURCE_DATE_OR_NONE"
 fi
 echo "#define BUILD_DATETIME $BUILD_DATETIME"
-echo "#define COMPILED_BY \"$USER\""
+echo "#define COMPILED_BY \"$COMPILED_BY\""
diff --git a/converter/other/fiasco/binerror.c b/converter/other/fiasco/binerror.c
index 9820d853..dd40dc9b 100644
--- a/converter/other/fiasco/binerror.c
+++ b/converter/other/fiasco/binerror.c
@@ -1,11 +1,11 @@
 /*
- *  error.c:		Error handling
+ *  error.c:            Error handling
  *
- *  Written by:		Stefan Frank
- *			Ullrich Hafner
- *  
- *  Credits:	Modelled after variable argument routines from Jef
- *		Poskanzer's pbmplus package. 
+ *  Written by:         Stefan Frank
+ *                      Ullrich Hafner
+ *
+ *  Credits:    Modelled after variable argument routines from Jef
+ *              Poskanzer's pbmplus package.
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -29,16 +29,16 @@
 #include <stdio.h>
 
 #if STDC_HEADERS
-#	include <stdarg.h>
-#	define VA_START(args, lastarg) va_start(args, lastarg)
+#       include <stdarg.h>
+#       define VA_START(args, lastarg) va_start(args, lastarg)
 #else  /* not STDC_HEADERS */
-#	include <varargs.h>
-#	define VA_START(args, lastarg) va_start(args)
+#       include <varargs.h>
+#       define VA_START(args, lastarg) va_start(args)
 #endif /* not STDC_HEADERS */
 #include <string.h>
 
 #if HAVE_SETJMP_H
-#	include <setjmp.h>
+#       include <setjmp.h>
 #endif /* HAVE_SETJMP_H */
 
 #include "fiasco.h"
@@ -46,8 +46,8 @@
 
 /*****************************************************************************
 
-			     global variables
-  
+                             global variables
+
 *****************************************************************************/
 
 int   error_line = 0;
@@ -55,16 +55,16 @@ const char *error_file = NULL;
 
 /*****************************************************************************
 
-			     local variables
-  
+                             local variables
+
 *****************************************************************************/
 
 static const char *executable = "(name not initialized)";
 
 /*****************************************************************************
 
-			       public code
-  
+                               public code
+
 *****************************************************************************/
 
 void
@@ -87,12 +87,12 @@ _error (const char *format, ...)
  *  No return value.
  */
 {
-   va_list	args;
+   va_list      args;
 
    VA_START (args, format);
 
    fprintf (stderr, "%s: %s: line %d:\nError: ",
-	    executable, error_file, error_line);
+            executable, error_file, error_line);
    vfprintf (stderr, format, args);
    fputc ('\n', stderr);
    va_end(args);
@@ -109,13 +109,13 @@ _file_error (const char *filename)
  */
 {
    fprintf (stderr, "%s: %s: line %d:\nError: ",
-	    executable, error_file, error_line);
+            executable, error_file, error_line);
    perror (filename);
 
    exit (2);
 }
 
-void 
+void
 _warning (const char *format, ...)
 /*
  *  Issue a warning and continue execution.
@@ -128,7 +128,7 @@ _warning (const char *format, ...)
    VA_START (args, format);
 
    fprintf (stderr, "%s: %s: line %d:\nWarning: ",
-	    executable, error_file, error_line);
+            executable, error_file, error_line);
    vfprintf (stderr, format, args);
    fputc ('\n', stderr);
 
diff --git a/converter/other/fiasco/binerror.h b/converter/other/fiasco/binerror.h
index 4f313aca..b30f53e0 100644
--- a/converter/other/fiasco/binerror.h
+++ b/converter/other/fiasco/binerror.h
@@ -1,8 +1,8 @@
 /*
  *  error.h
- *  
- *  Written by:		Stefan Frank
- *			Ullrich Hafner
+ *
+ *  Written by:         Stefan Frank
+ *                      Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -25,7 +25,7 @@
 #ifdef _ERROR_C
 #define _EXTERN_TYPE
 #else
-#define _EXTERN_TYPE	extern
+#define _EXTERN_TYPE    extern
 #endif
 
 _EXTERN_TYPE int   error_line;
@@ -41,9 +41,9 @@ void
 _file_error (const char *filename);
 
 #if HAVE_ASSERT_H
-#	include <assert.h>
+#       include <assert.h>
 #else /* not HAVE_ASSERT_H */
-#	define assert(exp)	{if (!(exp)) error ("Assertion `" #exp " != NULL' failed.");}
+#       define assert(exp)      {if (!(exp)) error ("Assertion `" #exp " != NULL' failed.");}
 #endif /* not HAVE_ASSERT_H */
 
 #endif /* not _ERROR_H */
diff --git a/converter/other/fiasco/buttons.c b/converter/other/fiasco/buttons.c
index fc54d84a..7a6c77a3 100644
--- a/converter/other/fiasco/buttons.c
+++ b/converter/other/fiasco/buttons.c
@@ -1,8 +1,8 @@
 /*
- *  buttons.c:		Draw MWFA player buttons in X11 window	
+ *  buttons.c:          Draw MWFA player buttons in X11 window
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -23,7 +23,7 @@
 #include <X11/StringDefs.h>
 
 #if STDC_HEADERS
-#	include <stdlib.h>
+#       include <stdlib.h>
 #endif /* not STDC_HEADERS */
 
 #include "types.h"
@@ -35,38 +35,38 @@
 
 /*****************************************************************************
 
-			     local variables
-  
+                             local variables
+
 *****************************************************************************/
 
 static const int EVENT_MASK = (KeyPressMask | ButtonPressMask |
-			       ButtonReleaseMask | ExposureMask);
+                               ButtonReleaseMask | ExposureMask);
 
 /*****************************************************************************
 
-				prototypes
-  
+                                prototypes
+
 *****************************************************************************/
 
 static void
 draw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n,
-		   unsigned n_frames);
+                   unsigned n_frames);
 static void
 draw_button (x11_info_t *xinfo, binfo_t *binfo,
-	     buttons_t button, bool_t pressed);
+             buttons_t button, bool_t pressed);
 static void
 draw_control_panel (x11_info_t *xinfo, binfo_t *binfo,
-		    unsigned n, unsigned n_frames);
+                    unsigned n, unsigned n_frames);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
-binfo_t * 
+binfo_t *
 init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
-	      unsigned buttons_height, unsigned progbar_height)
+              unsigned buttons_height, unsigned progbar_height)
 /*
  *  Initialize a toolbar with the typical collection of video player
  *  buttons (pause, play, record, next, etc.) in the window given by 'xinfo'.
@@ -76,7 +76,7 @@ init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
  *  the size of the progressbar is given by 'progbar_height'.
  *
  *  Return value:
- *	struct managing the toolbar and progressbar information
+ *      struct managing the toolbar and progressbar information
  */
 {
    XGCValues  values;
@@ -84,12 +84,12 @@ init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
    Colormap   cmap;
    XColor     gray, dgray, lgray, red;
    XColor     graye, dgraye, lgraye, rede;
-   buttons_t  button;			/* counter */
+   buttons_t  button;                   /* counter */
    binfo_t   *binfo = calloc (1, sizeof (binfo_t));
 
    if (!binfo)
       error ("Out of memory.");
-   
+
    binfo->width            = xinfo->ximage->width;
    binfo->height           = buttons_height;
    binfo->progbar_height   = progbar_height;
@@ -99,12 +99,12 @@ init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
     *  Generate sub-window for control panel
     */
    binfo->window = XCreateSimpleWindow (xinfo->display, xinfo->window,
-					0, xinfo->ximage->height,
-					binfo->width, binfo->height, 0,
-					BlackPixel (xinfo->display,
-						    xinfo->screen),
-					WhitePixel (xinfo->display,
-						    xinfo->screen));
+                                        0, xinfo->ximage->height,
+                                        binfo->width, binfo->height, 0,
+                                        BlackPixel (xinfo->display,
+                                                    xinfo->screen),
+                                        WhitePixel (xinfo->display,
+                                                    xinfo->screen));
    XSelectInput(xinfo->display, binfo->window, StructureNotifyMask);
    XMapWindow (xinfo->display, binfo->window);
    do
@@ -122,47 +122,47 @@ init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
    XAllocNamedColor (xinfo->display, cmap, "white", &lgray, &lgraye);
    XAllocNamedColor (xinfo->display, cmap, "#a8a8a8", &gray, &graye);
    XAllocNamedColor (xinfo->display, cmap, "red", &red, &rede);
-   
+
    values.foreground = BlackPixel (xinfo->display, xinfo->screen);
    values.background = WhitePixel (xinfo->display, xinfo->screen);
    binfo->gc [BLACK] = XCreateGC (xinfo->display,
-				  RootWindow (xinfo->display, xinfo->screen),
-				  (GCForeground | GCBackground), &values);
+                                  RootWindow (xinfo->display, xinfo->screen),
+                                  (GCForeground | GCBackground), &values);
    values.foreground = BlackPixel (xinfo->display, xinfo->screen);
    values.background = WhitePixel (xinfo->display, xinfo->screen);
    values.line_width = 3;
    values.join_style = JoinRound;
    binfo->gc [THICKBLACK] = XCreateGC (xinfo->display,
-				       RootWindow (xinfo->display,
-						   xinfo->screen),
-				       (GCForeground | GCBackground
-					| GCLineWidth | GCJoinStyle), &values);
+                                       RootWindow (xinfo->display,
+                                                   xinfo->screen),
+                                       (GCForeground | GCBackground
+                                        | GCLineWidth | GCJoinStyle), &values);
    values.foreground = gray.pixel;
    values.background = WhitePixel (xinfo->display, xinfo->screen);
    binfo->gc [NGRAY] = XCreateGC (xinfo->display,
-				  RootWindow (xinfo->display, xinfo->screen),
-				  (GCForeground | GCBackground), &values);
+                                  RootWindow (xinfo->display, xinfo->screen),
+                                  (GCForeground | GCBackground), &values);
    values.foreground = lgray.pixel;
    values.background = WhitePixel (xinfo->display, xinfo->screen);
    binfo->gc [LGRAY] = XCreateGC (xinfo->display,
-				  RootWindow (xinfo->display, xinfo->screen),
-				  (GCForeground | GCBackground), &values);
+                                  RootWindow (xinfo->display, xinfo->screen),
+                                  (GCForeground | GCBackground), &values);
    values.foreground = dgray.pixel;
    values.background = WhitePixel (xinfo->display, xinfo->screen);
    binfo->gc [DGRAY] = XCreateGC (xinfo->display,
-				  RootWindow (xinfo->display, xinfo->screen),
-				  (GCForeground | GCBackground), &values);
+                                  RootWindow (xinfo->display, xinfo->screen),
+                                  (GCForeground | GCBackground), &values);
    values.foreground = red.pixel;
    values.background = WhitePixel (xinfo->display, xinfo->screen);
    binfo->gc [RED]   = XCreateGC (xinfo->display,
-				  RootWindow (xinfo->display, xinfo->screen),
-				  (GCForeground | GCBackground), &values);
+                                  RootWindow (xinfo->display, xinfo->screen),
+                                  (GCForeground | GCBackground), &values);
 
    for (button = 0; button < NO_BUTTON; button++)
       binfo->pressed [button] = NO;
 
-   draw_control_panel (xinfo, binfo, n, n_frames); 
-   
+   draw_control_panel (xinfo, binfo, n, n_frames);
+
    return binfo;
 }
 
@@ -176,11 +176,11 @@ wait_for_input (x11_info_t *xinfo)
  *  No return value.
  *
  *  Side effect:
- *	program is terminated after key press or mouse click.
+ *      program is terminated after key press or mouse click.
  */
 {
    bool_t leave_loop = NO;
-   
+
    XSelectInput (xinfo->display, xinfo->window, EVENT_MASK);
 
    while (!leave_loop)
@@ -190,13 +190,13 @@ wait_for_input (x11_info_t *xinfo)
       XMaskEvent (xinfo->display, EVENT_MASK, &event);
       switch (event.type)
       {
-	 case ButtonPress:
-	 case KeyPress:
-	    leave_loop = YES;
-	    break;
-	 default:
-	    display_image (0, 0, xinfo);
-	    break;
+         case ButtonPress:
+         case KeyPress:
+            leave_loop = YES;
+            break;
+         default:
+            display_image (0, 0, xinfo);
+            break;
       }
    }
 }
@@ -214,17 +214,17 @@ check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames)
  *  No return values.
  *
  *  Side effects:
- *	status of buttons (binfo->pressed [button]) is changed accordingly.
+ *      status of buttons (binfo->pressed [button]) is changed accordingly.
  */
 {
    bool_t leave_eventloop;
 
    leave_eventloop = (!binfo->pressed [PAUSE_BUTTON]
-		      && binfo->pressed [PLAY_BUTTON])
-		     || (!binfo->pressed [PAUSE_BUTTON]
-			 && binfo->record_is_rewind
-			 && binfo->pressed [RECORD_BUTTON])
-		     || binfo->pressed [RECORD_BUTTON];
+                      && binfo->pressed [PLAY_BUTTON])
+                     || (!binfo->pressed [PAUSE_BUTTON]
+                         && binfo->record_is_rewind
+                         && binfo->pressed [RECORD_BUTTON])
+                     || binfo->pressed [RECORD_BUTTON];
    draw_progress_bar (xinfo, binfo, n, n_frames);
 
    if (binfo->pressed [PAUSE_BUTTON] && binfo->pressed [PLAY_BUTTON])
@@ -253,48 +253,48 @@ check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames)
       XEvent event;
       int    button;
       bool_t wait_release = NO;
-	 
-      
+
+
       if (XCheckMaskEvent (xinfo->display, EVENT_MASK, &event))
       {
-	 switch (event.type)
-	 {
-	    case ButtonPress:
-	       wait_release = NO;
-	       if (!(binfo->pressed [RECORD_BUTTON] &&
-		     !binfo->record_is_rewind))
-		  for (button = 0; button < NO_BUTTON; button++)
-		  {
-		     int x0, y0, x1, y1; /* button coordinates */
-		  
-		     x0 = button * (binfo->width / NO_BUTTON);
-		     y0 = binfo->progbar_height;
-		     x1 = x0 + binfo->width / NO_BUTTON;
-		     y1 = y0 + binfo->height - binfo->progbar_height - 1;
-		     if (event.xbutton.x > x0 && event.xbutton.x < x1
-			 && event.xbutton.y > y0 && event.xbutton.y < y1) 
-		     {
-			draw_button (xinfo, binfo, button,
-				     !binfo->pressed [button]);
-			wait_release = YES;
-			break;
-		     }
-		  }
-	       break;
-	    case ButtonRelease:
-	       wait_release = NO;
-	       break;
-	    default:
-	       wait_release = NO;
-	       draw_control_panel (xinfo, binfo, n, n_frames);
-	       display_image (0, 0, xinfo);
-	       break;
-	 }
-	 leave_eventloop = !wait_release
-			   && (binfo->pressed [PLAY_BUTTON]
-			       || binfo->pressed [STOP_BUTTON]
-			       || binfo->pressed [RECORD_BUTTON]
-			       || binfo->pressed [QUIT_BUTTON]);
+         switch (event.type)
+         {
+            case ButtonPress:
+               wait_release = NO;
+               if (!(binfo->pressed [RECORD_BUTTON] &&
+                     !binfo->record_is_rewind))
+                  for (button = 0; button < NO_BUTTON; button++)
+                  {
+                     int x0, y0, x1, y1; /* button coordinates */
+
+                     x0 = button * (binfo->width / NO_BUTTON);
+                     y0 = binfo->progbar_height;
+                     x1 = x0 + binfo->width / NO_BUTTON;
+                     y1 = y0 + binfo->height - binfo->progbar_height - 1;
+                     if (event.xbutton.x > x0 && event.xbutton.x < x1
+                         && event.xbutton.y > y0 && event.xbutton.y < y1)
+                     {
+                        draw_button (xinfo, binfo, button,
+                                     !binfo->pressed [button]);
+                        wait_release = YES;
+                        break;
+                     }
+                  }
+               break;
+            case ButtonRelease:
+               wait_release = NO;
+               break;
+            default:
+               wait_release = NO;
+               draw_control_panel (xinfo, binfo, n, n_frames);
+               display_image (0, 0, xinfo);
+               break;
+         }
+         leave_eventloop = !wait_release
+                           && (binfo->pressed [PLAY_BUTTON]
+                               || binfo->pressed [STOP_BUTTON]
+                               || binfo->pressed [RECORD_BUTTON]
+                               || binfo->pressed [QUIT_BUTTON]);
       }
    } while (!leave_eventloop);
 
@@ -308,13 +308,13 @@ check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames)
 
 /*****************************************************************************
 
-				private code
-  
+                                private code
+
 *****************************************************************************/
 
 static void
 draw_control_panel (x11_info_t *xinfo, binfo_t *binfo,
-		    unsigned n, unsigned n_frames)
+                    unsigned n, unsigned n_frames)
 /*
  *  Draw control panel 'binfo' with all buttons and progressbar in
  *  the given 'window'.
@@ -325,9 +325,9 @@ draw_control_panel (x11_info_t *xinfo, binfo_t *binfo,
  */
 {
    buttons_t button;
-   
+
    XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],
-		   0, 0, binfo->width, binfo->height);
+                   0, 0, binfo->width, binfo->height);
    draw_progress_bar (xinfo, binfo, n, n_frames);
    for (button = 0; button < NO_BUTTON; button++)
       draw_button (xinfo, binfo, button, binfo->pressed [button]);
@@ -335,7 +335,7 @@ draw_control_panel (x11_info_t *xinfo, binfo_t *binfo,
 
 static void
 draw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n,
-		   unsigned n_frames)
+                   unsigned n_frames)
 /*
  *  Draw progressbar of control panel 'binfo' in the given 'window'.
  *  'n' gives the current frame, whereas 'n_frames' is the total number of
@@ -346,32 +346,32 @@ draw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n,
 {
    unsigned x, y, width, height;
 
-   x 	  = 2;
-   y 	  = 1;
+   x      = 2;
+   y      = 1;
    width  = binfo->width - 5;
    height = binfo->progbar_height - 3;
-   
+
    XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY],
-	      x, y, x + width, y);
+              x, y, x + width, y);
    XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY],
-	      x, y, x, y + height - 1);
+              x, y, x, y + height - 1);
    XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY],
-	      x + width, y + 1, x + width, y + height);
+              x + width, y + 1, x + width, y + height);
    XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY],
-	      x, y + height, x + width, y + height);
+              x, y + height, x + width, y + height);
 
    x++; y++; width  -= 2; height -= 2;
    XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],
-		   x, y, width, height);
+                   x, y, width, height);
 
    XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-		   x + n * max (1, width / n_frames), y,
-		   max (1, width / n_frames), height);
+                   x + n * max (1, width / n_frames), y,
+                   max (1, width / n_frames), height);
 }
 
 static void
 draw_button (x11_info_t *xinfo, binfo_t *binfo,
-	     buttons_t button, bool_t pressed)
+             buttons_t button, bool_t pressed)
 /*
  *  Draw 'button' of control panel 'binfo' in the given 'window'.
  *  'pressed' indicates whether the button is pressed or not.
@@ -379,17 +379,17 @@ draw_button (x11_info_t *xinfo, binfo_t *binfo,
  *  No return value.
  */
 {
-   grayscale_t top, bottom;		/* index of GC */
-   unsigned    x, y, width, height;	/* coordinates of button */
-   
-   x 	  = button * (binfo->width / NO_BUTTON);
-   y 	  = binfo->progbar_height;
+   grayscale_t top, bottom;             /* index of GC */
+   unsigned    x, y, width, height;     /* coordinates of button */
+
+   x      = button * (binfo->width / NO_BUTTON);
+   y      = binfo->progbar_height;
    width  = binfo->width / NO_BUTTON;
    height = binfo->height - binfo->progbar_height - 1;
-   
+
    if (width < 4 || height < 4)
       return;
-   
+
    if (pressed)
    {
       top    = DGRAY;
@@ -401,108 +401,108 @@ draw_button (x11_info_t *xinfo, binfo_t *binfo,
       bottom = DGRAY;
    }
 
-   x 	 += 2;
+   x     += 2;
    width -= 4;
-   
+
    XDrawLine (xinfo->display, binfo->window, binfo->gc [top],
-	      x, y, x + width, y);
+              x, y, x + width, y);
    XDrawLine (xinfo->display, binfo->window, binfo->gc [top],
-	      x, y, x, y + height - 1);
+              x, y, x, y + height - 1);
    XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom],
-	      x + width, y + 1, x + width, y + height);
+              x + width, y + 1, x + width, y + height);
    XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom],
-	      x, y + height, x + width, y + height);
+              x, y + height, x + width, y + height);
 
    x++; y++; width  -= 2; height -= 2;
    XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],
-		   x, y, width, height);
+                   x, y, width, height);
 
    switch (button)
    {
       case STOP_BUTTON:
-	 XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-			 x + width / 2 - 6, y + height / 2 - 4, 11, 11);
-	 if (pressed && !binfo->pressed [STOP_BUTTON])
-	 {
-	    draw_button (xinfo, binfo, PLAY_BUTTON, NO);
-	    draw_button (xinfo, binfo, PAUSE_BUTTON, NO); 
-	    draw_button (xinfo, binfo, RECORD_BUTTON, NO); 
-	 }
-	 break;
+         XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
+                         x + width / 2 - 6, y + height / 2 - 4, 11, 11);
+         if (pressed && !binfo->pressed [STOP_BUTTON])
+         {
+            draw_button (xinfo, binfo, PLAY_BUTTON, NO);
+            draw_button (xinfo, binfo, PAUSE_BUTTON, NO);
+            draw_button (xinfo, binfo, RECORD_BUTTON, NO);
+         }
+         break;
       case PAUSE_BUTTON:
-	 XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-			 x + width / 2 - 6, y + height / 2 - 4, 5, 11);
-	 XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-			 x + width / 2 + 1, y + height / 2 - 4, 5, 11);
-	 break;
+         XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
+                         x + width / 2 - 6, y + height / 2 - 4, 5, 11);
+         XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
+                         x + width / 2 + 1, y + height / 2 - 4, 5, 11);
+         break;
       case PLAY_BUTTON:
-	 {
-	    XPoint triangle [3];
-
-	    triangle [0].x = x + width / 2 - 5;
-	    triangle [0].y = y + height / 2 - 5;
-	    triangle [1].x = 10;
-	    triangle [1].y = 6;
-	    triangle [2].x = -10;
-	    triangle [2].y = 6;
-
-	    XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
-			  triangle, 3, Convex, CoordModePrevious);
-	    if (pressed && !binfo->pressed [PLAY_BUTTON]
-		&& binfo->pressed [RECORD_BUTTON])
-	       draw_button (xinfo, binfo, RECORD_BUTTON, NO);
-	 }
-	 break;
+         {
+            XPoint triangle [3];
+
+            triangle [0].x = x + width / 2 - 5;
+            triangle [0].y = y + height / 2 - 5;
+            triangle [1].x = 10;
+            triangle [1].y = 6;
+            triangle [2].x = -10;
+            triangle [2].y = 6;
+
+            XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
+                          triangle, 3, Convex, CoordModePrevious);
+            if (pressed && !binfo->pressed [PLAY_BUTTON]
+                && binfo->pressed [RECORD_BUTTON])
+               draw_button (xinfo, binfo, RECORD_BUTTON, NO);
+         }
+         break;
       case RECORD_BUTTON:
-	 if (!binfo->record_is_rewind)
-	 {
-	    XFillArc (xinfo->display, binfo->window, binfo->gc [RED],
-		      x + width / 2 - 5, y + height / 2 - 5, 11, 11, 0,
-		      360 * 64);
-	    if (pressed && !binfo->pressed [RECORD_BUTTON])
-	    {
-	       draw_button (xinfo, binfo, STOP_BUTTON, YES);
-	       draw_button (xinfo, binfo, PLAY_BUTTON, NO);
-	       draw_button (xinfo, binfo, PAUSE_BUTTON, NO); 
-	    }
-	 }
-	 else
-	 {
-	    XPoint triangle [3];
-
-	    triangle [0].x = x + width / 2 + 5;
-	    triangle [0].y = y + height / 2 - 5;
-	    triangle [1].x = -10;
-	    triangle [1].y = 6;
-	    triangle [2].x = 10;
-	    triangle [2].y = 6;
-
-	    XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
-			  triangle, 3, Convex, CoordModePrevious);
-	    if (pressed && !binfo->pressed [RECORD_BUTTON]
-		&& binfo->pressed [PLAY_BUTTON])
-	       draw_button (xinfo, binfo, PLAY_BUTTON, NO);
-	 }
-	 break;
+         if (!binfo->record_is_rewind)
+         {
+            XFillArc (xinfo->display, binfo->window, binfo->gc [RED],
+                      x + width / 2 - 5, y + height / 2 - 5, 11, 11, 0,
+                      360 * 64);
+            if (pressed && !binfo->pressed [RECORD_BUTTON])
+            {
+               draw_button (xinfo, binfo, STOP_BUTTON, YES);
+               draw_button (xinfo, binfo, PLAY_BUTTON, NO);
+               draw_button (xinfo, binfo, PAUSE_BUTTON, NO);
+            }
+         }
+         else
+         {
+            XPoint triangle [3];
+
+            triangle [0].x = x + width / 2 + 5;
+            triangle [0].y = y + height / 2 - 5;
+            triangle [1].x = -10;
+            triangle [1].y = 6;
+            triangle [2].x = 10;
+            triangle [2].y = 6;
+
+            XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
+                          triangle, 3, Convex, CoordModePrevious);
+            if (pressed && !binfo->pressed [RECORD_BUTTON]
+                && binfo->pressed [PLAY_BUTTON])
+               draw_button (xinfo, binfo, PLAY_BUTTON, NO);
+         }
+         break;
       case QUIT_BUTTON:
-	 {
-	    XPoint triangle [3];
-
-	    triangle [0].x = x + width / 2 - 6;
-	    triangle [0].y = y + height / 2 + 2;
-	    triangle [1].x = 6;
-	    triangle [1].y = -7;
-	    triangle [2].x = 6;
-	    triangle [2].y = 7;
-
-	    XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
-			  triangle, 3, Convex, CoordModePrevious);
-	    XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-			    x + width / 2 - 5, y + height / 2 + 4, 11, 3);
-	 }
-	 break;
+         {
+            XPoint triangle [3];
+
+            triangle [0].x = x + width / 2 - 6;
+            triangle [0].y = y + height / 2 + 2;
+            triangle [1].x = 6;
+            triangle [1].y = -7;
+            triangle [2].x = 6;
+            triangle [2].y = 7;
+
+            XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
+                          triangle, 3, Convex, CoordModePrevious);
+            XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
+                            x + width / 2 - 5, y + height / 2 + 4, 11, 3);
+         }
+         break;
       default:
-	 break;
+         break;
    }
    binfo->pressed [button] = pressed;
 }
diff --git a/converter/other/fiasco/buttons.h b/converter/other/fiasco/buttons.h
index 079715f5..19c4935e 100644
--- a/converter/other/fiasco/buttons.h
+++ b/converter/other/fiasco/buttons.h
@@ -1,8 +1,8 @@
 /*
  *  buttons.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -20,15 +20,15 @@
 #ifndef X_DISPLAY_MISSING
 
 typedef enum grayscale_e {BLACK, NGRAY, LGRAY, DGRAY, RED,
-			  THICKBLACK, NO_GC} grayscale_t;
+                          THICKBLACK, NO_GC} grayscale_t;
 typedef enum buttons_e {STOP_BUTTON, PLAY_BUTTON, PAUSE_BUTTON, RECORD_BUTTON,
-			QUIT_BUTTON, NO_BUTTON} buttons_t;
+                        QUIT_BUTTON, NO_BUTTON} buttons_t;
 
 typedef struct buttoninfo
 {
    Window   window;
    bool_t   pressed [NO_BUTTON];
-   GC	    gc [NO_GC];
+   GC       gc [NO_GC];
    unsigned width;
    unsigned height;
    unsigned progbar_height;
@@ -37,12 +37,12 @@ typedef struct buttoninfo
 
 void
 check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n,
-	      unsigned n_frames);
+              unsigned n_frames);
 void
 wait_for_input (x11_info_t *xinfo);
-binfo_t * 
+binfo_t *
 init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
-	      unsigned buttons_height, unsigned progbar_height);
+              unsigned buttons_height, unsigned progbar_height);
 
 #endif /* not X_DISPLAY_MISSING */
 
diff --git a/converter/other/fiasco/codec/approx.c b/converter/other/fiasco/codec/approx.c
index d8fefcaa..a3f6523d 100644
--- a/converter/other/fiasco/codec/approx.c
+++ b/converter/other/fiasco/codec/approx.c
@@ -2,7 +2,7 @@
  *  approx.c:       Approximation of range images with matching pursuit
  *
  *  Written by:     Ullrich Hafner
- *      
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -35,7 +35,7 @@
 /*****************************************************************************
 
                  local variables
-  
+
 *****************************************************************************/
 
 typedef struct mp
@@ -53,13 +53,13 @@ typedef struct mp
 /*****************************************************************************
 
                  prototypes
-  
+
 *****************************************************************************/
 
 static void
 orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm,
            const word_t *domain_blocks, const coding_t *c);
-static void 
+static void
 matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
           unsigned max_edges, int y_state, const range_t *range,
           const domain_pool_t *domain_pool, const coeff_t *coeff,
@@ -68,14 +68,14 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
 /*****************************************************************************
 
                 public code
-  
+
 *****************************************************************************/
 
-real_t 
+real_t
 approximate_range (real_t max_costs, real_t price, int max_edges,
                    int y_state, range_t *range, domain_pool_t *domain_pool,
                    coeff_t *coeff, const wfa_t *wfa, const coding_t *c) {
-/*---------------------------------------------------------------------------- 
+/*----------------------------------------------------------------------------
   Approximate image block 'range' by matching pursuit. This functions
   calls the matching pursuit algorithm several times (with different
   parameters) in order to find the best approximation. Refer to function
@@ -99,15 +99,15 @@ approximate_range (real_t max_costs, real_t price, int max_edges,
      */
     if (c->options.second_domain_block) {
         mp_t tmp_mp;
-      
+
         tmp_mp = mp;  /* initial value */
 
         tmp_mp.exclude[0] = tmp_mp.indices [0];
         tmp_mp.exclude[1] = NO_EDGE;
-        
+
         matching_pursuit(&tmp_mp, c->options.full_search, price, max_edges,
                          y_state, range, domain_pool, coeff, wfa, c);
-        if (tmp_mp.costs < mp.costs)  /* success */ 
+        if (tmp_mp.costs < mp.costs)  /* success */
             mp = tmp_mp;
     }
 
@@ -123,23 +123,23 @@ approximate_range (real_t max_costs, real_t price, int max_edges,
 
         tmp_mp = mp;  /* initial value */
         iteration = -1;  /* initial value */
-      
+
         do {
             int i;
-            
+
             ++iteration;
             tmp_mp.exclude[iteration] = NO_EDGE;
-     
+
             for (i = 0; isdomain(tmp_mp.indices[i]); ++i) {
                 if (tmp_mp.weight [i] == 0) {
                     tmp_mp.exclude[iteration] = tmp_mp.indices [i];
                     break;
                 }
-            }      
+            }
             if (isdomain (tmp_mp.exclude [iteration])) {
                 /* try again */
                 tmp_mp.exclude [iteration + 1] = NO_EDGE;
-        
+
                 matching_pursuit(&tmp_mp, c->options.full_search, price,
                                  max_edges, y_state, range, domain_pool,
                                  coeff, wfa, c);
@@ -165,25 +165,25 @@ approximate_range (real_t max_costs, real_t price, int max_edges,
 
         do {
             int i;
- 
+
             ++iteration;
             tmp_mp.exclude[iteration] = NO_EDGE;
-     
+
             for (i = 0; isdomain (tmp_mp.indices [i]); ++i) {
                 rpf_t * const rpf =
                     tmp_mp.indices [i] ? coeff->rpf : coeff->dc_rpf;
-        
+
                 if (tmp_mp.weight [i] == btor (rtob (200, rpf), rpf)
                     || tmp_mp.weight [i] == btor (rtob (-200, rpf), rpf)) {
                     tmp_mp.exclude [iteration] = tmp_mp.indices [i];
                     break;
                 }
             }
-      
+
             if (isdomain(tmp_mp.exclude[iteration])) {
                 /* try again */
                 tmp_mp.exclude[iteration + 1] = NO_EDGE;
-        
+
                 matching_pursuit(&tmp_mp, c->options.full_search, price,
                                  max_edges, y_state, range, domain_pool,
                                  coeff, wfa, c);
@@ -226,10 +226,10 @@ approximate_range (real_t max_costs, real_t price, int max_edges,
                                 range->level, y_state, wfa,
                                 domain_pool->model);
             coeff->update (mp.weight, mp.into, range->level, coeff);
-     
+
             Free(domain_blocks);
         }
-      
+
         for (edge = 0; isedge (mp.indices [edge]); ++edge) {
             range->into   [edge] = mp.into   [edge];
             range->weight [edge] = mp.weight [edge];
@@ -242,7 +242,7 @@ approximate_range (real_t max_costs, real_t price, int max_edges,
         range->into [0] = NO_EDGE;
         mp.costs        = MAXCOSTS;
     }
-   
+
     return mp.costs;
 }
 
@@ -251,25 +251,25 @@ approximate_range (real_t max_costs, real_t price, int max_edges,
 /*****************************************************************************
 
                  local variables
-  
+
 *****************************************************************************/
 
-static real_t norm_ortho_vector [MAXSTATES];     
+static real_t norm_ortho_vector [MAXSTATES];
 /*
  *  Square-norm of the i-th vector of the orthogonal basis (OB)
  *  ||o_i||^2; i = 0, ... ,n
  */
 static real_t ip_image_ortho_vector [MAXEDGES];
-/* 
- *  Inner product between the i-th vector of the OB and the given range: 
- *  <b, o_i>; i = 0, ... ,n 
+/*
+ *  Inner product between the i-th vector of the OB and the given range:
+ *  <b, o_i>; i = 0, ... ,n
  */
 static real_t ip_domain_ortho_vector [MAXSTATES][MAXEDGES];
-/* 
- *  Inner product between the i-th vector of the OB and the image of domain j: 
- *  <s_j, o_i>; j = 0, ... , wfa->states; i = 0, ... ,n, 
+/*
+ *  Inner product between the i-th vector of the OB and the image of domain j:
+ *  <s_j, o_i>; j = 0, ... , wfa->states; i = 0, ... ,n,
  */
-static real_t rem_denominator [MAXSTATES];     
+static real_t rem_denominator [MAXSTATES];
 static real_t rem_numerator [MAXSTATES];
 /*
  *  At step n of the orthogonalization the comparative value
@@ -280,7 +280,7 @@ static real_t rem_numerator [MAXSTATES];
  *  the constant (remaining) parts of every domain are
  *  stored in 'rem_numerator' and 'rem_denominator' separately
  */
-static bool_t used [MAXSTATES];    
+static bool_t used [MAXSTATES];
 /*
  *  Shows whether a domain image was already used in a
  *  linear combination (YES) or not (NO)
@@ -289,10 +289,10 @@ static bool_t used [MAXSTATES];
 /*****************************************************************************
 
                 private code
-  
+
 *****************************************************************************/
 
-static void 
+static void
 matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                   unsigned max_edges, int y_state, const range_t *range,
                   const domain_pool_t *domain_pool, const coeff_t *coeff,
@@ -313,7 +313,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
  *  elements in the linear combination is limited by 'max_edges'. In
  *  'mp', vectors may be specified which should be excluded during the
  *  approximation.
- *  
+ *
  *  No return value.
  *
  *  Side effects:
@@ -329,7 +329,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
     const real_t  min_norm = 2e-3;   /* lower bound of norm */
     unsigned      best_n   = 0;
     unsigned  size     = size_of_level (range->level);
- 
+
     /*
      *  Initialize domain pool and inner product arrays
      */
@@ -378,7 +378,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                         + additional_bits) * price + mp->err;
 
     n = 0;
-    do 
+    do
     {
         /*
          *  Current approximation is: b = d_0 o_0 + ... + d_(n-1) o_(n-1)
@@ -390,15 +390,15 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
          *  which has minimal costs: s_index.
          *  (No progress is indicated by index == -1)
          */
-      
+
         real_t min_matrix_bits  = 0;
         real_t min_weights_bits = 0;
         real_t min_error        = 0;
         real_t min_weight [MAXEDGES];
         real_t min_costs = full_search ? MAXCOSTS : mp->costs;
-      
-        for (index = -1, domain = 0; domain_blocks [domain] >= 0; domain++) 
-            if (!used [domain]) 
+
+        for (index = -1, domain = 0; domain_blocks [domain] >= 0; domain++)
+            if (!used [domain])
             {
                 real_t    matrix_bits, weights_bits;
                 /*
@@ -413,7 +413,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                     word_t   states [MAXEDGES + 1];
                     real_t   weights [MAXEDGES + 1];
                     unsigned i, k;
-          
+
                     for (i = 0, k = 0; k < n; k++)
                         if (mp->weight [k] != 0)
                         {
@@ -477,7 +477,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                         f[k] = ip_image_ortho_vector[k] / norm_ortho_vector[k];
                         v [k] = mp->indices [k];
                     }
-        
+
                     for (l = n; l >= 0; --l) {
                         rpf_t * const rpf = domain_blocks[v[l]]
                             ? coeff->rpf : coeff->dc_rpf;
@@ -488,13 +488,13 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
 
                         {
                             real_t const fl = f[l];
-             
+
                             for (k = 0; k < l; ++k) {
                                 f[k] -= fl * ip_domain_ortho_vector[v[l]][k]
                                     / norm_ortho_vector[k];
                             }
                         }
-                    } 
+                    }
 
                     /*
                      *  Compute the number of output bits of the linear
@@ -507,7 +507,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                         word_t states [MAXEDGES + 1];
                         real_t weights [MAXEDGES + 1];
                         int    i;
-          
+
                         for (i = 0, k = 0; k <= n; k++)
                             if (f [k] != 0)
                             {
@@ -525,10 +525,10 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                                                     range->level, y_state,
                                                     wfa, domain_pool->model);
                     }
-           
+
                     /*
                      *  To compute the approximation error, the corresponding
-                     *  linear factors of the linear combination 
+                     *  linear factors of the linear combination
                      *  b = r_0 o_0 + ... + r_(n-1) o_(n-1) + r_n o_'domain'
                      *  with orthogonal vectors must be computed with following
                      *  formula:
@@ -546,7 +546,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                         a = get_ip_state_state (domain_blocks [v [l]],
                                                 domain_blocks [domain],
                                                 range->level, c);
-                        for (k = 0; k < n; k++) 
+                        for (k = 0; k < n; k++)
                             a -= ip_domain_ortho_vector [v [l]][k]
                                 / norm_ortho_vector [k]
                                 * ip_domain_ortho_vector [domain][k];
@@ -554,7 +554,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                     }
                     norm_ortho_vector [n]     = rem_denominator [domain];
                     ip_image_ortho_vector [n] = rem_numerator [domain];
-        
+
                     for (k = 0; k <= n; k++)
                         for (l = k + 1; (unsigned) l <= n; l++)
                             r [k] += ip_domain_ortho_vector [v [l]][k] * r [l]
@@ -586,40 +586,40 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price,
                     }
                 }
             }
-      
+
         if (index >= 0)           /* found a better approximation */
         {
             if (min_costs < mp->costs)
             {
                 unsigned k;
-        
+
                 mp->costs        = min_costs;
                 mp->err          = min_error;
                 mp->matrix_bits  = min_matrix_bits;
                 mp->weights_bits = min_weights_bits;
-        
+
                 for (k = 0; k <= n; k++)
                     mp->weight [k] = min_weight [k];
 
                 best_n = n + 1;
             }
-     
+
             mp->indices [n] = index;
             mp->into [n]    = domain_blocks [index];
 
             used [index] = YES;
 
-            /* 
-             *  Gram-Schmidt orthogonalization step n 
+            /*
+             *  Gram-Schmidt orthogonalization step n
              */
             orthogonalize (index, n, range->level, min_norm, domain_blocks, c);
             n++;
-        } 
-    } 
+        }
+    }
     while (n < max_edges && index >= 0);
 
     mp->indices [best_n] = NO_EDGE;
-   
+
     mp->costs = (mp->matrix_bits + mp->weights_bits + additional_bits) * price
         + mp->err;
 
@@ -641,31 +641,31 @@ orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm,
  *
  *  Side effects:
  *  The remainder values (numerator and denominator) of
- *  all 'domain_blocks' are updated. 
+ *  all 'domain_blocks' are updated.
  */
 {
    unsigned domain;
-   
+
    ip_image_ortho_vector [n] = rem_numerator [index];
    norm_ortho_vector [n]     = rem_denominator [index];
 
    /*
-    *  Compute inner products between all domain images and 
+    *  Compute inner products between all domain images and
     *  vector n of the orthogonal basis:
-    *  for (i = 0, ... , wfa->states)  
+    *  for (i = 0, ... , wfa->states)
     *  <s_i, o_n> := <s_i, v_n> -
     *      \sum (k = 0, ... , n - 1){ <v_n, o_k> <s_i, o_k> / ||o_k||^2}
     *  Moreover the denominator and numerator parts of the comparative
     *  value are updated.
     */
-   for (domain = 0; domain_blocks [domain] >= 0; domain++) 
-      if (!used [domain]) 
+   for (domain = 0; domain_blocks [domain] >= 0; domain++)
+      if (!used [domain])
       {
      unsigned k;
      real_t   tmp = get_ip_state_state (domain_blocks [index],
                         domain_blocks [domain], level, c);
-     
-     for (k = 0; k < n; k++) 
+
+     for (k = 0; k < n; k++)
         tmp -= ip_domain_ortho_vector [domain][k] / norm_ortho_vector [k]
            * ip_domain_ortho_vector [index][k];
      ip_domain_ortho_vector [domain][n] = tmp;
@@ -677,8 +677,8 @@ orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm,
      /*
       *  Exclude vectors with small denominator
       */
-     if (!used [domain]) 
-        if (rem_denominator [domain] / size_of_level (level) < min_norm) 
+     if (!used [domain])
+        if (rem_denominator [domain] / size_of_level (level) < min_norm)
            used [domain] = YES;
       }
 }
diff --git a/converter/other/fiasco/codec/approx.h b/converter/other/fiasco/codec/approx.h
index 42f1458a..cce27eb6 100644
--- a/converter/other/fiasco/codec/approx.h
+++ b/converter/other/fiasco/codec/approx.h
@@ -1,8 +1,8 @@
 /*
  *  approx.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -21,10 +21,10 @@
 #include "cwfa.h"
 #include "domain-pool.h"
 
-real_t 
+real_t
 approximate_range (real_t max_costs, real_t price, int max_edges,
-		   int y_state, range_t *range, domain_pool_t *domain_pool,
-		   coeff_t *coeff, const wfa_t *wfa, const coding_t *c);
+                   int y_state, range_t *range, domain_pool_t *domain_pool,
+                   coeff_t *coeff, const wfa_t *wfa, const coding_t *c);
 
 #endif /* not _APPROX_H */
 
diff --git a/converter/other/fiasco/codec/bintree.c b/converter/other/fiasco/codec/bintree.c
index b050ab63..ca828fb2 100644
--- a/converter/other/fiasco/codec/bintree.c
+++ b/converter/other/fiasco/codec/bintree.c
@@ -1,8 +1,8 @@
 /*
- *  bintree.c:		Bintree model of WFA tree	
+ *  bintree.c:          Bintree model of WFA tree
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -28,8 +28,8 @@
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 void
@@ -40,7 +40,7 @@ tree_update (bool_t child, unsigned level, tree_t *model)
  *  No return value.
  *
  *  Side effects:
- *	tree model is changed.
+ *      tree model is changed.
  */
 {
    if (!child)
@@ -59,7 +59,7 @@ tree_bits (bool_t child, unsigned level, const tree_t *model)
  *  For each 'level' a different context is used.
  *
  *  Return value:
- *	# bits
+ *      # bits
  */
 {
    real_t prob = model->counts [level] / (real_t) model->total [level];
@@ -80,13 +80,13 @@ init_tree_model (tree_t *tree_model)
 {
    unsigned level;
    unsigned counts_0 [MAXLEVEL] = {20, 17, 15, 10, 5,  4,  3,
-				   2,  1,  1,  1,  1,  1,  1,  1,
-				   1,  1,  1,  1 , 1,  1,  1};
+                                   2,  1,  1,  1,  1,  1,  1,  1,
+                                   1,  1,  1,  1 , 1,  1,  1};
    unsigned counts_1 [MAXLEVEL] = {1 , 1,  1,  1,  1,  1,  1,
-				   1,  1,  2,  3,  5,  10, 15, 20,
-				   25, 30, 35, 60, 60, 60, 60};
-   
-   for (level = 0; level < MAXLEVEL ; level++) 
+                                   1,  1,  2,  3,  5,  10, 15, 20,
+                                   25, 30, 35, 60, 60, 60, 60};
+
+   for (level = 0; level < MAXLEVEL ; level++)
    {
       tree_model->counts [level] = counts_1 [level];
       tree_model->total [level]  = counts_0 [level] + counts_1 [level];
diff --git a/converter/other/fiasco/codec/bintree.h b/converter/other/fiasco/codec/bintree.h
index 3dc88ac1..c68b2e7b 100644
--- a/converter/other/fiasco/codec/bintree.h
+++ b/converter/other/fiasco/codec/bintree.h
@@ -1,8 +1,8 @@
 /*
  *  bintree.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -28,8 +28,8 @@ typedef struct tree
  *  which indicate whether there exists a tree edge or not.
  */
 {
-   unsigned counts [MAXLEVEL];		/* # NO_RANGE symbols at given level */
-   unsigned total [MAXLEVEL];		/* total number of symbols at  ''   */
+   unsigned counts [MAXLEVEL];          /* # NO_RANGE symbols at given level */
+   unsigned total [MAXLEVEL];           /* total number of symbols at  ''   */
 } tree_t;
 
 real_t
diff --git a/converter/other/fiasco/codec/coder.h b/converter/other/fiasco/codec/coder.h
index 2fe81d81..4e8e400d 100644
--- a/converter/other/fiasco/codec/coder.h
+++ b/converter/other/fiasco/codec/coder.h
@@ -1,8 +1,8 @@
 /*
  *  coder.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/codec/coeff.c b/converter/other/fiasco/codec/coeff.c
index 6d33bad5..3a5a6a0a 100644
--- a/converter/other/fiasco/codec/coeff.c
+++ b/converter/other/fiasco/codec/coeff.c
@@ -1,8 +1,8 @@
 /*
- *  coeff.c:		Matching pursuit coefficients probability model
+ *  coeff.c:            Matching pursuit coefficients probability model
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -28,9 +28,9 @@
 /*
  *  Coefficient model interface:
  *  Implementing the coefficients model interface requires the
- *  following steps: 
+ *  following steps:
  *  - Add a constructor that initializes the coeff_t structure
- *  - Allocate new model with default_alloc() 
+ *  - Allocate new model with default_alloc()
  *  - Fill the c_array_t coeff_models[] array with constructor and name
  *  - Write code for methods bits() and update()
  *  - Either use default functions for remaining methods or override them
@@ -38,21 +38,21 @@
  */
 
 /*****************************************************************************
-		  uniform distribution coefficients model
+                  uniform distribution coefficients model
 *****************************************************************************/
 
 static coeff_t *
 alloc_uniform_coeff_model (rpf_t *rpf, rpf_t *dc_rpf,
-			   unsigned min_level, unsigned max_level);
+                           unsigned min_level, unsigned max_level);
 static void
 uniform_update (const real_t *used_coeff, const word_t *used_states,
-		unsigned level, coeff_t *coeff);
+                unsigned level, coeff_t *coeff);
 static real_t
 uniform_bits (const real_t *used_coeff, const word_t *used_states,
-	      unsigned level, const coeff_t *coeff);
+              unsigned level, const coeff_t *coeff);
 
 /*****************************************************************************
-			  default functions
+                          default functions
 *****************************************************************************/
 
 static void
@@ -63,15 +63,15 @@ static void
 default_free (coeff_t *coeff);
 static coeff_t *
 default_alloc (rpf_t *rpf, rpf_t *dc_rpf,
-	       unsigned min_level, unsigned max_level);
+               unsigned min_level, unsigned max_level);
 
 /*****************************************************************************
-		adaptive arithmetic coding model
+                adaptive arithmetic coding model
 *****************************************************************************/
 
 static coeff_t *
 alloc_aac_coeff_model (rpf_t *rpf, rpf_t *dc_rpf,
-		       unsigned min_level, unsigned max_level);
+                       unsigned min_level, unsigned max_level);
 static void
 aac_model_free (void *model);
 static void *
@@ -80,70 +80,70 @@ static void *
 aac_model_duplicate (const coeff_t *coeff, const void *model);
 static void
 aac_update (const real_t *used_coeff, const word_t *used_states,
-	    unsigned level, coeff_t *coeff);
+            unsigned level, coeff_t *coeff);
 static real_t
 aac_bits (const real_t *used_coeff, const word_t *used_states,
-	  unsigned level, const coeff_t *coeff);
+          unsigned level, const coeff_t *coeff);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 typedef struct c_array
 {
    const char *identifier;
    coeff_t    *(*function) (rpf_t *rpf, rpf_t *dc_rpf,
-			    unsigned min_level, unsigned max_level);
+                            unsigned min_level, unsigned max_level);
 } c_array_t;
 
 c_array_t coeff_models[] = {{"adaptive", alloc_aac_coeff_model},
-			    {"uniform",	 alloc_uniform_coeff_model},
-			    {NULL,	 NULL}};
+                            {"uniform",  alloc_uniform_coeff_model},
+                            {NULL,       NULL}};
 
 coeff_t *
 alloc_coeff_model (const char *coeff_model_name, rpf_t *rpf, rpf_t *dc_rpf,
-		   unsigned min_level, unsigned max_level)
+                   unsigned min_level, unsigned max_level)
 /*
  *  Allocate a new coefficients model which is identified by the string
  *  'coeff_model_name'.  'rpf' and 'dc_rpf' define the reduced
  *  precision formats the should be used to quantize normal and DC
  *  components, respectively. 'min_level' and 'max_level' define the
  *  range of range approximations.
- * 
+ *
  *  Return value:
- *	pointer to the allocated coefficients model
+ *      pointer to the allocated coefficients model
  *
  *  Note:
  *      Refer to 'coeff.h' for a short description of the member functions.  */
 {
    unsigned n;
-   
+
    for (n = 0; coeff_models [n].identifier; n++) /* step through all id's */
-      if (strcaseeq (coeff_models [n].identifier, coeff_model_name)) 
-	 return coeff_models [n].function (rpf, dc_rpf, min_level, max_level);
+      if (strcaseeq (coeff_models [n].identifier, coeff_model_name))
+         return coeff_models [n].function (rpf, dc_rpf, min_level, max_level);
 
    warning ("Can't initialize coefficients model '%s'. "
-	    "Using default value '%s'.",
-	    coeff_model_name, coeff_models [0].identifier);
+            "Using default value '%s'.",
+            coeff_model_name, coeff_models [0].identifier);
 
    return coeff_models [0].function (rpf, dc_rpf, min_level, max_level);
 }
 
 /*****************************************************************************
 
-				private code
-  
+                                private code
+
 *****************************************************************************/
 
 /*****************************************************************************
-		  uniform distribution coefficients model
+                  uniform distribution coefficients model
 *****************************************************************************/
 
 static coeff_t *
 alloc_uniform_coeff_model (rpf_t *rpf, rpf_t *dc_rpf,
-			   unsigned min_level, unsigned max_level)
+                           unsigned min_level, unsigned max_level)
 /*
  *  Underlying probability model: uniform distribution.
  *  I.e. each coefficient is written as such with
@@ -154,21 +154,21 @@ alloc_uniform_coeff_model (rpf_t *rpf, rpf_t *dc_rpf,
 
    coeff->bits   = uniform_bits;
    coeff->update = uniform_update;
-   
+
    return coeff;
 }
 
 static real_t
 uniform_bits (const real_t *used_coeff, const word_t *used_states,
-	      unsigned level, const coeff_t *coeff)
+              unsigned level, const coeff_t *coeff)
 {
    unsigned edge;
-   real_t   bits = 0;			/* #bits to store coefficients */
-   
+   real_t   bits = 0;                   /* #bits to store coefficients */
+
    for (edge = 0; isedge (used_states [edge]); edge++)
    {
       rpf_t *rpf = used_states [edge] ? coeff->rpf : coeff->dc_rpf;
-      
+
       bits += rpf->mantissa_bits + 1;
    }
 
@@ -177,13 +177,13 @@ uniform_bits (const real_t *used_coeff, const word_t *used_states,
 
 static void
 uniform_update (const real_t *used_coeff, const word_t *used_states,
-		unsigned level, coeff_t *coeff)
+                unsigned level, coeff_t *coeff)
 {
-   return;				/* nothing to do */
+   return;                              /* nothing to do */
 }
 
 /*****************************************************************************
-		adaptive arithmetic coding  model
+                adaptive arithmetic coding  model
 *****************************************************************************/
 
 typedef struct aac_model
@@ -194,74 +194,74 @@ typedef struct aac_model
 
 static coeff_t *
 alloc_aac_coeff_model (rpf_t *rpf, rpf_t *dc_rpf,
-		       unsigned min_level, unsigned max_level)
+                       unsigned min_level, unsigned max_level)
 /*
  *  Underlying probability model: adaptive arithmetic coding using
  *  the level of a range as context.
  */
 {
    coeff_t *coeff = default_alloc (rpf, dc_rpf, min_level, max_level);
-   
+
    coeff->bits            = aac_bits;
    coeff->update          = aac_update;
    coeff->model_free      = aac_model_free;
    coeff->model_duplicate = aac_model_duplicate;
-   coeff->model		  = aac_model_alloc (coeff);
-   
+   coeff->model           = aac_model_alloc (coeff);
+
    return coeff;
 }
 
 static real_t
 aac_bits (const real_t *used_coeff, const word_t *used_states,
-	  unsigned level, const coeff_t *coeff)
+          unsigned level, const coeff_t *coeff)
 {
-   real_t	bits  = 0;		/* # bits to store coefficients */
-   unsigned	edge;
-   int		state;
+   real_t       bits  = 0;              /* # bits to store coefficients */
+   unsigned     edge;
+   int          state;
    word_t      *counts;
    aac_model_t *model = (aac_model_t *) coeff->model;
 
    counts = model->counts
-	    + (1 << (1 + coeff->dc_rpf->mantissa_bits))
-	    + ((level - coeff->min_level)
-	       * (1 << (1 + coeff->rpf->mantissa_bits)));
-   
+            + (1 << (1 + coeff->dc_rpf->mantissa_bits))
+            + ((level - coeff->min_level)
+               * (1 << (1 + coeff->rpf->mantissa_bits)));
+
    for (edge = 0; isedge (state = used_states [edge]); edge++)
       if (state)
-	 bits -= log2 (counts [rtob (used_coeff [edge], coeff->rpf)]
-		       / (real_t) model->totals [level
-						- coeff->min_level + 1]);
+         bits -= log2 (counts [rtob (used_coeff [edge], coeff->rpf)]
+                       / (real_t) model->totals [level
+                                                - coeff->min_level + 1]);
       else
-	 bits -= log2 (model->counts [rtob (used_coeff [edge], coeff->dc_rpf)]
-		       / (real_t) model->totals [0]);
-   
+         bits -= log2 (model->counts [rtob (used_coeff [edge], coeff->dc_rpf)]
+                       / (real_t) model->totals [0]);
+
    return bits;
 }
 
 static void
 aac_update (const real_t *used_coeff, const word_t *used_states,
-	    unsigned level, coeff_t *coeff)
+            unsigned level, coeff_t *coeff)
 {
-   unsigned	edge;
-   int		state;
+   unsigned     edge;
+   int          state;
    word_t      *counts;
    aac_model_t *model = (aac_model_t *) coeff->model;
 
    counts = model->counts
-	    + (1 << (1 + coeff->dc_rpf->mantissa_bits))
-	    + ((level - coeff->min_level)
-	       * (1 << (1 + coeff->rpf->mantissa_bits)));
+            + (1 << (1 + coeff->dc_rpf->mantissa_bits))
+            + ((level - coeff->min_level)
+               * (1 << (1 + coeff->rpf->mantissa_bits)));
 
    for (edge = 0; isedge (state = used_states [edge]); edge++)
       if (state)
       {
-	 counts [rtob (used_coeff [edge], coeff->rpf)]++;
-	 model->totals [level - coeff->min_level + 1]++;
+         counts [rtob (used_coeff [edge], coeff->rpf)]++;
+         model->totals [level - coeff->min_level + 1]++;
       }
       else
       {
-	 model->counts [rtob (used_coeff [edge], coeff->dc_rpf)]++;
-	 model->totals [0]++;
+         model->counts [rtob (used_coeff [edge], coeff->dc_rpf)]++;
+         model->totals [0]++;
       }
 }
 
@@ -272,12 +272,12 @@ aac_model_duplicate (const coeff_t *coeff, const void *model)
    aac_model_t *dst = aac_model_alloc (coeff);
 
    memcpy (dst->counts, src->counts,
-	   sizeof (word_t) * ((coeff->max_level - coeff->min_level + 1)
-			      * (1 << (1 + coeff->rpf->mantissa_bits))
-			      + (1 << (1 + coeff->dc_rpf->mantissa_bits))));
+           sizeof (word_t) * ((coeff->max_level - coeff->min_level + 1)
+                              * (1 << (1 + coeff->rpf->mantissa_bits))
+                              + (1 << (1 + coeff->dc_rpf->mantissa_bits))));
    memcpy (dst->totals, src->totals,
-	   sizeof (word_t) * (coeff->max_level - coeff->min_level + 1 + 1));
-   
+           sizeof (word_t) * (coeff->max_level - coeff->min_level + 1 + 1));
+
    return dst;
 }
 
@@ -285,36 +285,36 @@ static void *
 aac_model_alloc (const coeff_t *coeff)
 {
    aac_model_t *model;
-   unsigned	size = (coeff->max_level - coeff->min_level + 1)
-		       * (1 << (1 + coeff->rpf->mantissa_bits))
-		       + (1 << (1 + coeff->dc_rpf->mantissa_bits));
-   
-   model 	 = Calloc (1, sizeof (aac_model_t));
+   unsigned     size = (coeff->max_level - coeff->min_level + 1)
+                       * (1 << (1 + coeff->rpf->mantissa_bits))
+                       + (1 << (1 + coeff->dc_rpf->mantissa_bits));
+
+   model         = Calloc (1, sizeof (aac_model_t));
    model->counts = Calloc (size, sizeof (word_t));
    model->totals = Calloc (coeff->max_level - coeff->min_level + 1 + 1,
-			   sizeof (word_t));
+                           sizeof (word_t));
    /*
     *  Initialize model
     */
    {
       unsigned  n;
       word_t   *ptr = model->counts;
-      
+
       for (n = size; n; n--)
-	 *ptr++ = 1;
+         *ptr++ = 1;
       model->totals [0] = 1 << (1 + coeff->dc_rpf->mantissa_bits);
       for (n = coeff->min_level; n <= coeff->max_level; n++)
-	 model->totals [n - coeff->min_level + 1]
-	    = 1 << (1 + coeff->rpf->mantissa_bits);
+         model->totals [n - coeff->min_level + 1]
+            = 1 << (1 + coeff->rpf->mantissa_bits);
    }
-   
+
    return (void *) model;
 }
 
 static void
 aac_model_free (void *model)
 {
-   aac_model_t	*aac_model = (aac_model_t *) model;
+   aac_model_t  *aac_model = (aac_model_t *) model;
 
    if (aac_model)
    {
@@ -325,26 +325,26 @@ aac_model_free (void *model)
 }
 
 /*****************************************************************************
-				default functions
+                                default functions
 *****************************************************************************/
 
 static coeff_t *
 default_alloc (rpf_t *rpf, rpf_t *dc_rpf,
-	       unsigned min_level, unsigned max_level)
+               unsigned min_level, unsigned max_level)
 {
    coeff_t *coeff = Calloc (1, sizeof (coeff_t));
 
-   coeff->rpf 	      	  = rpf;
-   coeff->dc_rpf       	  = dc_rpf;
-   coeff->min_level	  = min_level;
-   coeff->max_level	  = max_level;
-   coeff->model	      	  = NULL;
-   coeff->bits	      	  = NULL;
-   coeff->update      	  = NULL;
-   coeff->free	      	  = default_free;
-   coeff->model_free  	  = default_model_free;
+   coeff->rpf             = rpf;
+   coeff->dc_rpf          = dc_rpf;
+   coeff->min_level       = min_level;
+   coeff->max_level       = max_level;
+   coeff->model           = NULL;
+   coeff->bits            = NULL;
+   coeff->update          = NULL;
+   coeff->free            = default_free;
+   coeff->model_free      = default_model_free;
    coeff->model_duplicate = default_model_duplicate;
-   
+
    return coeff;
 }
 
diff --git a/converter/other/fiasco/codec/coeff.h b/converter/other/fiasco/codec/coeff.h
index 6193e2ee..f22de2d7 100644
--- a/converter/other/fiasco/codec/coeff.h
+++ b/converter/other/fiasco/codec/coeff.h
@@ -1,8 +1,8 @@
 /*
  *  coeff.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -23,23 +23,23 @@
 
 typedef struct coeff
 {
-   rpf_t    *rpf;			/* reduced precision format */
-   rpf_t    *dc_rpf;			/* RPF of DC (state 0) component */
-   unsigned min_level, max_level;	/* allocate memory for [min,..,max] */
-   void	    *model;			/* generic pointer to prob. model */
+   rpf_t    *rpf;                       /* reduced precision format */
+   rpf_t    *dc_rpf;                    /* RPF of DC (state 0) component */
+   unsigned min_level, max_level;       /* allocate memory for [min,..,max] */
+   void     *model;                     /* generic pointer to prob. model */
    real_t (*bits) (const real_t *used_coeff, const word_t *used_domains,
-		   unsigned level, const struct coeff *coeff);
+                   unsigned level, const struct coeff *coeff);
    /*
     *  Compute bit-rate of a range approximation with coefficients given by
     *  -1 terminated list 'used_domains'.
     */
    void   (*update) (const real_t *used_coeff, const word_t *used_domains,
-		       unsigned level, struct coeff *coeff);
+                       unsigned level, struct coeff *coeff);
    /*
     *  Update the probability model according to the chosen approximation.
     *  (given by the -1 terminated list 'used_domains').
     */
-   void	  (*free) (struct coeff *coeff);
+   void   (*free) (struct coeff *coeff);
    /*
     *  Discard the given coefficients struct.
     */
@@ -55,7 +55,7 @@ typedef struct coeff
 
 coeff_t *
 alloc_coeff_model (const char *coeff_model_name, rpf_t *rpf, rpf_t *dc_rpf,
-		   unsigned min_level, unsigned max_level);
+                   unsigned min_level, unsigned max_level);
 
 #endif /* not _COEFF_H */
 
diff --git a/converter/other/fiasco/codec/control.c b/converter/other/fiasco/codec/control.c
index 2ea06052..0588623f 100644
--- a/converter/other/fiasco/codec/control.c
+++ b/converter/other/fiasco/codec/control.c
@@ -1,8 +1,8 @@
 /*
- *  control.c:		Control unit of WFA structure
+ *  control.c:          Control unit of WFA structure
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -17,7 +17,7 @@
 #include "config.h"
 
 #include <string.h>
- 
+
 #include "types.h"
 #include "macros.h"
 #include "error.h"
@@ -30,24 +30,24 @@
 
 /*****************************************************************************
 
-				prototypes
-  
+                                prototypes
+
 *****************************************************************************/
 
-static void 
+static void
 clear_or_alloc (real_t **ptr, size_t size);
-static void 
+static void
 compute_images (unsigned from, unsigned to, const wfa_t *wfa, coding_t *c);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
-void    
+void
 append_state (bool_t auxiliary_state, real_t final, unsigned level_of_state,
-	      wfa_t *wfa, coding_t *c)
+              wfa_t *wfa, coding_t *c)
 /*
  *  Append a 'wfa' state. If 'auxiliary_state' == YES then
  *  allocate memory for inner products and state images.  'final' is
@@ -57,13 +57,13 @@ append_state (bool_t auxiliary_state, real_t final, unsigned level_of_state,
  *  No return value.
  *
  *  Side effects:
- *	The WFA information are updated in structure 'wfa'
- *	State images are computed and inner products are cleared (in 'c')
+ *      The WFA information are updated in structure 'wfa'
+ *      State images are computed and inner products are cleared (in 'c')
  */
 {
    wfa->final_distribution [wfa->states] = final;
    wfa->level_of_state [wfa->states]     = level_of_state;
-   
+
    if (!auxiliary_state)
    {
       unsigned level;
@@ -74,63 +74,63 @@ append_state (bool_t auxiliary_state, real_t final, unsigned level_of_state,
        *  Allocate memory for inner products and for state images
        */
       clear_or_alloc (&c->images_of_state [wfa->states],
-		      size_of_tree (c->options.images_level));
-	 
+                      size_of_tree (c->options.images_level));
+
       for (level = c->options.images_level + 1;
-	   level <= c->options.lc_max_level; level++)
-	 clear_or_alloc (&c->ip_states_state [wfa->states][level],
-			 wfa->states + 1);
+           level <= c->options.lc_max_level; level++)
+         clear_or_alloc (&c->ip_states_state [wfa->states][level],
+                         wfa->states + 1);
 
       clear_or_alloc (&c->ip_images_state [wfa->states],
-		      size_of_tree (c->products_level));
+                      size_of_tree (c->products_level));
 
       /*
        *  Compute the images of the current state at level 0,..,'imageslevel'
        */
-      
+
       c->images_of_state [wfa->states][0] = final;
-      compute_images (wfa->states, wfa->states, wfa, c);  
+      compute_images (wfa->states, wfa->states, wfa, c);
 
       /*
        *  Compute the inner products between the current state and the
        *  old states 0,...,'states'-1
-       */ 
-      
+       */
+
       compute_ip_states_state (wfa->states, wfa->states, wfa, c);
    }
    else
    {
       unsigned level;
-      
+
       wfa->domain_type [wfa->states] = 0;
-	    
+
       /*
        *  Free the allocated memory
        */
       if (c->images_of_state [wfa->states] != NULL)
       {
-	 Free (c->images_of_state [wfa->states]);
-	 c->images_of_state [wfa->states] = NULL;
+         Free (c->images_of_state [wfa->states]);
+         c->images_of_state [wfa->states] = NULL;
       }
       for (level = 0; level <= c->options.lc_max_level; level++)
-	 if (c->ip_states_state [wfa->states][level])
-	 {
-	    Free (c->ip_states_state [wfa->states][level]);
-	    c->ip_states_state [wfa->states][level] = NULL;
-	 }
+         if (c->ip_states_state [wfa->states][level])
+         {
+            Free (c->ip_states_state [wfa->states][level]);
+            c->ip_states_state [wfa->states][level] = NULL;
+         }
       if (c->ip_images_state [wfa->states])
       {
-	 Free (c->ip_images_state [wfa->states]);
-	 c->ip_images_state [wfa->states] = NULL;
+         Free (c->ip_images_state [wfa->states]);
+         c->ip_images_state [wfa->states] = NULL;
       }
    }
-   
+
    wfa->states++;
-   if (wfa->states >= MAXSTATES) 
+   if (wfa->states >= MAXSTATES)
       error ("Maximum number of states reached!");
-}	
- 
-void 
+}
+
+void
 append_basis_states (unsigned basis_states, wfa_t *wfa, coding_t *c)
 /*
  *  Append the WFA basis states 0, ... , ('basis_states' - 1).
@@ -138,8 +138,8 @@ append_basis_states (unsigned basis_states, wfa_t *wfa, coding_t *c)
  *  No return value.
  *
  *  Side effects:
- *	The WFA information are updated in structure 'wfa'
- *	State images and inner products are computed (in 'c')
+ *      The WFA information are updated in structure 'wfa'
+ *      State images and inner products are computed (in 'c')
  */
 {
    unsigned level, state;
@@ -151,30 +151,30 @@ append_basis_states (unsigned basis_states, wfa_t *wfa, coding_t *c)
    for (state = 0; state < basis_states; state++)
    {
       clear_or_alloc (&c->images_of_state [state],
-		      size_of_tree (c->options.images_level));
+                      size_of_tree (c->options.images_level));
 
       for (level = c->options.images_level + 1;
-	   level <= c->options.lc_max_level; level++)
-	 clear_or_alloc (&c->ip_states_state [state][level], state + 1);
+           level <= c->options.lc_max_level; level++)
+         clear_or_alloc (&c->ip_states_state [state][level], state + 1);
 
       clear_or_alloc (&c->ip_images_state [state],
-		      size_of_tree (c->products_level));
+                      size_of_tree (c->products_level));
 
       c->images_of_state [state][0] = wfa->final_distribution [state];
       wfa->level_of_state [state]   = -1;
    }
-   
-   compute_images (0, basis_states - 1, wfa, c);  
+
+   compute_images (0, basis_states - 1, wfa, c);
    compute_ip_states_state (0, basis_states - 1, wfa, c);
    wfa->states = basis_states;
-   
-   if (wfa->states >= MAXSTATES) 
+
+   if (wfa->states >= MAXSTATES)
       error ("Maximum number of states reached!");
-}	
- 
-void 
+}
+
+void
 append_transitions (unsigned state, unsigned label, const real_t *weight,
-		    const word_t *into, wfa_t *wfa)
+                    const word_t *into, wfa_t *wfa)
 /*
  *  Append the 'wfa' transitions (given by the arrays 'weight' and 'into')
  *  of the range ('state','label').
@@ -182,7 +182,7 @@ append_transitions (unsigned state, unsigned label, const real_t *weight,
  *  No return value.
  *
  *  Side effects:
- *	new 'wfa' edges are appended
+ *      new 'wfa' edges are appended
  */
 {
    unsigned edge;
@@ -192,81 +192,81 @@ append_transitions (unsigned state, unsigned label, const real_t *weight,
    {
       append_edge (state, into [edge], weight [edge], label, wfa);
       if (into [edge] == wfa->y_state [state][label])
-	 wfa->y_column [state][label] = 1;
+         wfa->y_column [state][label] = 1;
    }
 }
 
 /*****************************************************************************
 
-				private code
-  
+                                private code
+
 *****************************************************************************/
 
-static void 
+static void
 compute_images (unsigned from, unsigned to, const wfa_t *wfa, coding_t *c)
 /*
- *  Computes the images of the given states 'from', ... , 'to' 
+ *  Computes the images of the given states 'from', ... , 'to'
  *  at level 0,...,'c->imagelevel'.
  *  Uses the fact that each state image is a linear combination of state
  *  images, i.e. s_i := c_0 s_0 + ... + c_i s_i.
  */
 {
    unsigned label, level, state;
-   
+
    /*
     *  Compute the images Phi(state)
-    *  #		level = 0
-    *  ##		level = 1
-    *  ####		level = 2
-    *  ########    	level = 3
+    *  #                level = 0
+    *  ##               level = 1
+    *  ####             level = 2
+    *  ########         level = 3
     *  ...
     *  ########...##    level = imageslevel
     */
-   
+
    for (level = 1; level <= c->options.images_level; level++)
       for (state = from; state <= to; state++)
-	 for (label = 0; label < MAXLABELS; label++)
-	 {
-	    real_t   *dst, *src;
-	    unsigned  edge;
-	    int	      domain;		/* current domain */
-	    
-	    if (ischild (domain = wfa->tree[state][label]))
-	    {
-	       dst = c->images_of_state [state] + address_of_level (level) +
-		     label * size_of_level (level - 1);
-	       src = c->images_of_state [domain]
-		     + address_of_level (level - 1);
-	       memcpy (dst, src, size_of_level (level - 1) * sizeof (real_t));
-	    }
-	    for (edge = 0; isedge (domain = wfa->into[state][label][edge]);
-		 edge++)
-	    {
-	       unsigned n;
-	       real_t 	weight = wfa->weight [state][label][edge];
-	       
-	       dst = c->images_of_state [state] + address_of_level (level) +
-		     label * size_of_level (level - 1);
-	       src = c->images_of_state [domain]
-		     + address_of_level (level - 1);
-		  
-	       for (n = size_of_level (level - 1); n; n--)
-		  *dst++ += *src++ * weight;
-	    }
-	 }
+         for (label = 0; label < MAXLABELS; label++)
+         {
+            real_t   *dst, *src;
+            unsigned  edge;
+            int       domain;           /* current domain */
+
+            if (ischild (domain = wfa->tree[state][label]))
+            {
+               dst = c->images_of_state [state] + address_of_level (level) +
+                     label * size_of_level (level - 1);
+               src = c->images_of_state [domain]
+                     + address_of_level (level - 1);
+               memcpy (dst, src, size_of_level (level - 1) * sizeof (real_t));
+            }
+            for (edge = 0; isedge (domain = wfa->into[state][label][edge]);
+                 edge++)
+            {
+               unsigned n;
+               real_t   weight = wfa->weight [state][label][edge];
+
+               dst = c->images_of_state [state] + address_of_level (level) +
+                     label * size_of_level (level - 1);
+               src = c->images_of_state [domain]
+                     + address_of_level (level - 1);
+
+               for (n = size_of_level (level - 1); n; n--)
+                  *dst++ += *src++ * weight;
+            }
+         }
 
 }
 
-static void 
+static void
 clear_or_alloc (real_t **ptr, size_t size)
 /*
- *  if *ptr == NULL 	allocate memory with Calloc 
- *  otherwise 		fill the real_t-array ptr[] with 0
+ *  if *ptr == NULL     allocate memory with Calloc
+ *  otherwise           fill the real_t-array ptr[] with 0
  */
 {
-   if (*ptr == NULL) 
+   if (*ptr == NULL)
       *ptr = Calloc (size, sizeof (real_t));
-   else 
+   else
       memset (*ptr, 0, size * sizeof (real_t));
-    
+
 }
diff --git a/converter/other/fiasco/codec/control.h b/converter/other/fiasco/codec/control.h
index 6c0834a1..9bfc9b50 100644
--- a/converter/other/fiasco/codec/control.h
+++ b/converter/other/fiasco/codec/control.h
@@ -1,8 +1,8 @@
 /*
  *  control.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -20,14 +20,14 @@
 #include "cwfa.h"
 #include "types.h"
 
-void 
+void
 append_transitions (unsigned state, unsigned label, const real_t *weight,
-		    const word_t *into, wfa_t *wfa);
-void 
+                    const word_t *into, wfa_t *wfa);
+void
 append_basis_states (unsigned basis_states, wfa_t *wfa, coding_t *c);
-void    
+void
 append_state (bool_t auxiliary_state, real_t final, unsigned level_of_state,
-	      wfa_t *wfa, coding_t *c);
+              wfa_t *wfa, coding_t *c);
 
 #endif /* not _CONTROL_H */
 
diff --git a/converter/other/fiasco/codec/cwfa.h b/converter/other/fiasco/codec/cwfa.h
index e8e2d474..4fed343c 100644
--- a/converter/other/fiasco/codec/cwfa.h
+++ b/converter/other/fiasco/codec/cwfa.h
@@ -1,8 +1,8 @@
 /*
  *  cwfa.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -32,15 +32,15 @@ extern const real_t MAXCOSTS;
 
 typedef struct motion
 {
-   image_t	 *original;		/* Current image */
-   image_t	 *past;			/* Preceding image */
-   image_t	 *future;		/* Succeeding image */
-   frame_type_e	  frame_type;		/* frame type: B_, P_ I_FRAME */
-   unsigned	  number;		/* display number of frame */
-   real_t        *xbits;		/* # bits for mv x-component */
-   real_t        *ybits;		/* # bits for mv y-component */
-   real_t       **mc_forward_norms; 	/* norms of mcpe */
-   real_t       **mc_backward_norms; 	/* norms of mcpe */
+   image_t       *original;             /* Current image */
+   image_t       *past;                 /* Preceding image */
+   image_t       *future;               /* Succeeding image */
+   frame_type_e   frame_type;           /* frame type: B_, P_ I_FRAME */
+   unsigned       number;               /* display number of frame */
+   real_t        *xbits;                /* # bits for mv x-component */
+   real_t        *ybits;                /* # bits for mv y-component */
+   real_t       **mc_forward_norms;     /* norms of mcpe */
+   real_t       **mc_backward_norms;    /* norms of mcpe */
 } motion_t;
 
 typedef struct range
@@ -48,30 +48,30 @@ typedef struct range
  *  Information about current range in the original image.
  *  Approximation data (error, encoding bits, approximation type and factors
  *  of the linear combination) are also saved.
- */ 
+ */
 {
    unsigned global_address;             /* We need absolute image addresses
-				           for distance calculations. */
-   unsigned x, y;			/* Coordinates of upper left corner */
-   unsigned image;			/* Position in the tree */
-   unsigned address;			/* Address of the pixel data */
-   unsigned level;			/* Level of the range */
-   real_t   weight [MAXEDGES + 1];	/* coeff. of the approximation */
-   word_t   into [MAXEDGES + 1];	/* used domains of the approximation */
-   int	    tree;			/* == domain : range is approximated
-					   with new state 'domain'
-					   == RANGE  :
-					   with a linear comb. */
-   real_t   err;			/* approximation error */
-   real_t   tree_bits;			/* # bits to encode tree */
-   real_t   matrix_bits;		/* # bits to encode matrices */
-   real_t   weights_bits;		/* # bits to encode weights */
-   mv_t	    mv;				/* motion vector */
-   real_t   mv_tree_bits;		/* # bits to encode mv tree */
-   real_t   mv_coord_bits;		/* # bits to encode mv coordinates */
-   real_t   nd_tree_bits;		/* # bits to encode nd tree */
-   real_t   nd_weights_bits;		/* # bits to encode nd factors */
-   bool_t   prediction;			/* range is predicted? */
+                                           for distance calculations. */
+   unsigned x, y;                       /* Coordinates of upper left corner */
+   unsigned image;                      /* Position in the tree */
+   unsigned address;                    /* Address of the pixel data */
+   unsigned level;                      /* Level of the range */
+   real_t   weight [MAXEDGES + 1];      /* coeff. of the approximation */
+   word_t   into [MAXEDGES + 1];        /* used domains of the approximation */
+   int      tree;                       /* == domain : range is approximated
+                                           with new state 'domain'
+                                           == RANGE  :
+                                           with a linear comb. */
+   real_t   err;                        /* approximation error */
+   real_t   tree_bits;                  /* # bits to encode tree */
+   real_t   matrix_bits;                /* # bits to encode matrices */
+   real_t   weights_bits;               /* # bits to encode weights */
+   mv_t     mv;                         /* motion vector */
+   real_t   mv_tree_bits;               /* # bits to encode mv tree */
+   real_t   mv_coord_bits;              /* # bits to encode mv coordinates */
+   real_t   nd_tree_bits;               /* # bits to encode nd tree */
+   real_t   nd_weights_bits;            /* # bits to encode nd factors */
+   bool_t   prediction;                 /* range is predicted? */
 } range_t;
 
 typedef struct coding
@@ -80,27 +80,27 @@ typedef struct coding
  *  process.
  */
 {
-   real_t     	   price;		/* determines quality of approx. */
-   real_t   	 **images_of_state;	/* image of state i at level
-					   0, ... , imageslevel */
+   real_t          price;               /* determines quality of approx. */
+   real_t        **images_of_state;     /* image of state i at level
+                                           0, ... , imageslevel */
    real_t   *(*ip_states_state)[MAXLEVEL]; /* inner products between state i
-					      and states 0, ... , i
-					      at all image levels */
-   real_t   	 **ip_images_state;	/* inner products between all
-					   ranges and state i */
-   real_t    	  *pixels;		/* current image pixels stored in tree
-					   order (only leaves are stored) */
-   unsigned   	   products_level;	/* inner products are stored up to
-					   this level */
-   tiling_t   	  *tiling;		/* tiling of the entire image */
-   tree_t     	   tree;		/* probability model */
-   tree_t     	   p_tree;		/* prediction probability model */
-   motion_t   	  *mt;			/* motion compensation information */
-   coeff_t   	  *coeff;
-   coeff_t   	  *d_coeff;
+                                              and states 0, ... , i
+                                              at all image levels */
+   real_t        **ip_images_state;     /* inner products between all
+                                           ranges and state i */
+   real_t         *pixels;              /* current image pixels stored in tree
+                                           order (only leaves are stored) */
+   unsigned        products_level;      /* inner products are stored up to
+                                           this level */
+   tiling_t       *tiling;              /* tiling of the entire image */
+   tree_t          tree;                /* probability model */
+   tree_t          p_tree;              /* prediction probability model */
+   motion_t       *mt;                  /* motion compensation information */
+   coeff_t        *coeff;
+   coeff_t        *d_coeff;
    domain_pool_t  *domain_pool;
    domain_pool_t  *d_domain_pool;
-   c_options_t     options;		/* global options */
+   c_options_t     options;             /* global options */
 } coding_t;
 
 #endif /* not _CWFA_H */
diff --git a/converter/other/fiasco/codec/decoder.h b/converter/other/fiasco/codec/decoder.h
index 7823ab91..d11ccefd 100644
--- a/converter/other/fiasco/codec/decoder.h
+++ b/converter/other/fiasco/codec/decoder.h
@@ -1,8 +1,8 @@
 /*
  *  decode.h
- *		
- *  Written by:		Ullrich Hafner
- *		
+ *              
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -23,41 +23,41 @@
 
 typedef struct video
 {
-   unsigned  future_display;		/* number of a future frame */
-   unsigned  display;			/* current display number */
-   image_t  *frame;			/* current frame */
-   image_t  *sframe;			/* current smoothed frame */
-   image_t  *future;			/* future reference */
-   image_t  *sfuture;			/* future (smmothed) reference */
-   image_t  *past ;			/* past reference */
-   wfa_t    *wfa;			/* current wfa */
-   wfa_t    *wfa_future;		/* future wfa */
-   wfa_t    *wfa_past;			/* past wfa */
+   unsigned  future_display;            /* number of a future frame */
+   unsigned  display;                   /* current display number */
+   image_t  *frame;                     /* current frame */
+   image_t  *sframe;                    /* current smoothed frame */
+   image_t  *future;                    /* future reference */
+   image_t  *sfuture;                   /* future (smmothed) reference */
+   image_t  *past ;                     /* past reference */
+   wfa_t    *wfa;                       /* current wfa */
+   wfa_t    *wfa_future;                /* future wfa */
+   wfa_t    *wfa_past;                  /* past wfa */
 } video_t;
 
 typedef struct dectimer
 {
-   unsigned int	input [3];
-   unsigned int	preprocessing [3];
-   unsigned int	decoder [3];
-   unsigned int	cleanup [3];
-   unsigned int	motion [3];
-   unsigned int	smooth [3];
-   unsigned int	display [3];
-   unsigned int	frames [3];
+   unsigned int input [3];
+   unsigned int preprocessing [3];
+   unsigned int decoder [3];
+   unsigned int cleanup [3];
+   unsigned int motion [3];
+   unsigned int smooth [3];
+   unsigned int display [3];
+   unsigned int frames [3];
 } dectimer_t;
 
 image_t *
 get_next_frame (bool_t store_wfa, int enlarge_factor,
-		int smoothing, const char *reference_frame,
-		format_e format, video_t *video, dectimer_t *timer,
-		wfa_t *orig_wfa, bitfile_t *input);
+                int smoothing, const char *reference_frame,
+                format_e format, video_t *video, dectimer_t *timer,
+                wfa_t *orig_wfa, bitfile_t *input);
 image_t *
 decode_image (unsigned orig_width, unsigned orig_height, format_e format,
-	      unsigned *dec_timer, const wfa_t *wfa);
+              unsigned *dec_timer, const wfa_t *wfa);
 word_t *
 decode_range (unsigned range_state, unsigned range_label, unsigned range_level,
-	      word_t **domain, wfa_t *wfa);
+              word_t **domain, wfa_t *wfa);
 image_t *
 decode_state (unsigned state, unsigned level, wfa_t *wfa);
 void
diff --git a/converter/other/fiasco/codec/dfiasco.c b/converter/other/fiasco/codec/dfiasco.c
index ce25654a..3f5d3fcc 100644
--- a/converter/other/fiasco/codec/dfiasco.c
+++ b/converter/other/fiasco/codec/dfiasco.c
@@ -1,7 +1,7 @@
 /*
- *  dfiasco.c:		Decoder public interface
+ *  dfiasco.c:          Decoder public interface
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -37,7 +37,7 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
@@ -47,11 +47,11 @@ static void
 free_dfiasco (dfiasco_t *dfiasco);
 static dfiasco_t *
 alloc_dfiasco (wfa_t *wfa, video_t *video, bitfile_t *input,
-	       int enlarge_factor, int smoothing, format_e image_format);
+               int enlarge_factor, int smoothing, format_e image_format);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -60,24 +60,24 @@ fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options)
 {
    try
    {
-      bitfile_t        	 *input;	/* pointer to WFA FIASCO stream */
-      wfa_t            	 *wfa;		/* wfa structure */
-      video_t          	 *video;	/* information about decoder state */
-      const d_options_t  *dop;		/* decoder additional options */
-      dfiasco_t	       	 *dfiasco;	/* decoder internal state */
-      fiasco_decoder_t 	 *decoder;	/* public interface to decoder */
+      bitfile_t          *input;        /* pointer to WFA FIASCO stream */
+      wfa_t              *wfa;          /* wfa structure */
+      video_t            *video;        /* information about decoder state */
+      const d_options_t  *dop;          /* decoder additional options */
+      dfiasco_t          *dfiasco;      /* decoder internal state */
+      fiasco_decoder_t   *decoder;      /* public interface to decoder */
       fiasco_d_options_t *default_options = NULL;
 
       if (options)
       {
-	 dop = cast_d_options ((fiasco_d_options_t *) options);
-	 if (!dop)
-	    return NULL;
+         dop = cast_d_options ((fiasco_d_options_t *) options);
+         if (!dop)
+            return NULL;
       }
       else
       {
-	 default_options = fiasco_d_options_new ();
-	 dop 		 = cast_d_options (default_options);
+         default_options = fiasco_d_options_new ();
+         dop             = cast_d_options (default_options);
       }
 
       wfa   = alloc_wfa (NO);
@@ -85,8 +85,8 @@ fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options)
       input = open_wfa (filename, wfa->wfainfo);
       read_basis (wfa->wfainfo->basis_name, wfa);
 
-      decoder 	       	   = Calloc (1, sizeof (fiasco_decoder_t));
-      decoder->delete  	   = fiasco_decoder_delete;
+      decoder              = Calloc (1, sizeof (fiasco_decoder_t));
+      decoder->delete      = fiasco_decoder_delete;
       decoder->write_frame = fiasco_decoder_write_frame;
       decoder->get_frame   = fiasco_decoder_get_frame;
       decoder->get_length  = fiasco_decoder_get_length;
@@ -98,46 +98,46 @@ fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options)
       decoder->is_color    = fiasco_decoder_is_color;
 
       decoder->private = dfiasco
-		       = alloc_dfiasco (wfa, video, input,
-					dop->magnification,
-					dop->smoothing,
-					dop->image_format);
+                       = alloc_dfiasco (wfa, video, input,
+                                        dop->magnification,
+                                        dop->smoothing,
+                                        dop->image_format);
 
       if (default_options)
-	 fiasco_d_options_delete (default_options);
+         fiasco_d_options_delete (default_options);
       if (dfiasco->enlarge_factor >= 0)
       {
-	 int 	       n;
-	 unsigned long pixels = wfa->wfainfo->width * wfa->wfainfo->height;
-
-	 for (n = 1; n <= (int) dfiasco->enlarge_factor; n++)
-	 {
-	    if (pixels << (n << 1) > 2048 * 2048)
-	    {
-	       set_error (_("Magnifaction factor `%d' is too large. "
-			    "Maximum value is %d."),
-			  dfiasco->enlarge_factor, MAX(0, n - 1));
-	       fiasco_decoder_delete (decoder);
-	       return NULL;
-	    }
-	 }
+         int           n;
+         unsigned long pixels = wfa->wfainfo->width * wfa->wfainfo->height;
+
+         for (n = 1; n <= (int) dfiasco->enlarge_factor; n++)
+         {
+            if (pixels << (n << 1) > 2048 * 2048)
+            {
+               set_error (_("Magnifaction factor `%d' is too large. "
+                            "Maximum value is %d."),
+                          dfiasco->enlarge_factor, MAX(0, n - 1));
+               fiasco_decoder_delete (decoder);
+               return NULL;
+            }
+         }
       }
       else
       {
-	 int n;
-
-	 for (n = 0; n <= (int) - dfiasco->enlarge_factor; n++)
-	 {
-	    if (wfa->wfainfo->width >> n < 32
-		|| wfa->wfainfo->height >> n < 32)
-	    {
-	       set_error (_("Magnifaction factor `%d' is too small. "
-			    "Minimum value is %d."),
-			  dfiasco->enlarge_factor, - MAX(0, n - 1));
-	       fiasco_decoder_delete (decoder);
-	       return NULL;
-	    }
-	 }
+         int n;
+
+         for (n = 0; n <= (int) - dfiasco->enlarge_factor; n++)
+         {
+            if (wfa->wfainfo->width >> n < 32
+                || wfa->wfainfo->height >> n < 32)
+            {
+               set_error (_("Magnifaction factor `%d' is too small. "
+                            "Minimum value is %d."),
+                          dfiasco->enlarge_factor, - MAX(0, n - 1));
+               fiasco_decoder_delete (decoder);
+               return NULL;
+            }
+         }
       }
       return (fiasco_decoder_t *) decoder;
    }
@@ -149,7 +149,7 @@ fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options)
 
 int
 fiasco_decoder_write_frame (fiasco_decoder_t *decoder,
-			    const char *filename)
+                            const char *filename)
 {
    dfiasco_t *dfiasco = cast_dfiasco (decoder);
 
@@ -159,15 +159,15 @@ fiasco_decoder_write_frame (fiasco_decoder_t *decoder,
    {
       try
       {
-	 image_t *frame = get_next_frame (NO, dfiasco->enlarge_factor,
-					  dfiasco->smoothing, NULL,
-					  FORMAT_4_4_4, dfiasco->video, NULL,
-					  dfiasco->wfa, dfiasco->input);
-	 write_image (filename, frame);
+         image_t *frame = get_next_frame (NO, dfiasco->enlarge_factor,
+                                          dfiasco->smoothing, NULL,
+                                          FORMAT_4_4_4, dfiasco->video, NULL,
+                                          dfiasco->wfa, dfiasco->input);
+         write_image (filename, frame);
       }
       catch
       {
-	 return 0;
+         return 0;
       }
       return 1;
    }
@@ -184,25 +184,25 @@ fiasco_decoder_get_frame (fiasco_decoder_t *decoder)
    {
       try
       {
-	 fiasco_image_t *image = Calloc (1, sizeof (fiasco_image_t));
-	 image_t 	*frame = get_next_frame (NO, dfiasco->enlarge_factor,
-						 dfiasco->smoothing, NULL,
-						 dfiasco->image_format,
-						 dfiasco->video, NULL,
-						 dfiasco->wfa, dfiasco->input);
-
-	 frame->reference_count++;	/* for motion compensation */
-	 image->private    = frame;
-	 image->delete     = fiasco_image_delete;
-	 image->get_width  = fiasco_image_get_width;
-	 image->get_height = fiasco_image_get_height;
-	 image->is_color   = fiasco_image_is_color;
-
-	 return image;
+         fiasco_image_t *image = Calloc (1, sizeof (fiasco_image_t));
+         image_t        *frame = get_next_frame (NO, dfiasco->enlarge_factor,
+                                                 dfiasco->smoothing, NULL,
+                                                 dfiasco->image_format,
+                                                 dfiasco->video, NULL,
+                                                 dfiasco->wfa, dfiasco->input);
+
+         frame->reference_count++;      /* for motion compensation */
+         image->private    = frame;
+         image->delete     = fiasco_image_delete;
+         image->get_width  = fiasco_image_get_width;
+         image->get_height = fiasco_image_get_height;
+         image->is_color   = fiasco_image_is_color;
+
+         return image;
       }
       catch
       {
-	 return NULL;
+         return NULL;
       }
    }
 }
@@ -241,9 +241,9 @@ fiasco_decoder_get_width (fiasco_decoder_t *decoder)
       unsigned width;
 
       if (dfiasco->enlarge_factor >= 0)
-	 width = dfiasco->wfa->wfainfo->width << dfiasco->enlarge_factor;
+         width = dfiasco->wfa->wfainfo->width << dfiasco->enlarge_factor;
       else
-	 width = dfiasco->wfa->wfainfo->width >> - dfiasco->enlarge_factor;
+         width = dfiasco->wfa->wfainfo->width >> - dfiasco->enlarge_factor;
 
       return width & 1 ? width + 1 : width;
    }
@@ -261,9 +261,9 @@ fiasco_decoder_get_height (fiasco_decoder_t *decoder)
       unsigned height;
 
       if (dfiasco->enlarge_factor >= 0)
-	 height = dfiasco->wfa->wfainfo->height << dfiasco->enlarge_factor;
+         height = dfiasco->wfa->wfainfo->height << dfiasco->enlarge_factor;
       else
-	 height = dfiasco->wfa->wfainfo->height >> - dfiasco->enlarge_factor;
+         height = dfiasco->wfa->wfainfo->height >> - dfiasco->enlarge_factor;
 
       return height & 1 ? height + 1 : height;
    }
@@ -329,30 +329,30 @@ fiasco_decoder_delete (fiasco_decoder_t *decoder)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static dfiasco_t *
 alloc_dfiasco (wfa_t *wfa, video_t *video, bitfile_t *input,
-	       int enlarge_factor, int smoothing, format_e image_format)
+               int enlarge_factor, int smoothing, format_e image_format)
 /*
  *  FIASCO decoder constructor:
  *  Initialize decoder structure.
  *
  *  Return value:
- *	pointer to the new decoder structure
+ *      pointer to the new decoder structure
  */
 {
    dfiasco_t *dfiasco = Calloc (1, sizeof (dfiasco_t));
 
    strcpy (dfiasco->id, "DFIASCO");
 
-   dfiasco->wfa 	   = wfa;
-   dfiasco->video 	   = video;
-   dfiasco->input 	   = input;
+   dfiasco->wfa            = wfa;
+   dfiasco->video          = video;
+   dfiasco->input          = input;
    dfiasco->enlarge_factor = enlarge_factor;
-   dfiasco->smoothing  	   = smoothing;
+   dfiasco->smoothing      = smoothing;
    dfiasco->image_format   = image_format;
 
    return dfiasco;
@@ -367,7 +367,7 @@ free_dfiasco (dfiasco_t *dfiasco)
  *  No return value.
  *
  *  Side effects:
- *	'video' struct is discarded.
+ *      'video' struct is discarded.
  */
 {
    Free (dfiasco);
@@ -380,7 +380,7 @@ cast_dfiasco (fiasco_decoder_t *dfiasco)
  *  Check whether `dfiasco' is a valid object of type dfiasco_t.
  *
  *  Return value:
- *	pointer to dfiasco_t struct on success
+ *      pointer to dfiasco_t struct on success
  *      NULL otherwise
  */
 {
@@ -389,8 +389,8 @@ cast_dfiasco (fiasco_decoder_t *dfiasco)
    {
       if (!streq (this->id, "DFIASCO"))
       {
-	 set_error (_("Parameter `dfiasco' doesn't match required type."));
-	 return NULL;
+         set_error (_("Parameter `dfiasco' doesn't match required type."));
+         return NULL;
       }
    }
    else
diff --git a/converter/other/fiasco/codec/dfiasco.h b/converter/other/fiasco/codec/dfiasco.h
index eed12b6b..765a09d4 100644
--- a/converter/other/fiasco/codec/dfiasco.h
+++ b/converter/other/fiasco/codec/dfiasco.h
@@ -1,8 +1,8 @@
 /*
  *  dfiasco.h
- *		
- *  Written by:		Ullrich Hafner
- *		
+ *              
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -29,7 +29,7 @@ typedef struct dfiasco
    wfa_t     *wfa;
    video_t   *video;
    bitfile_t *input;
-   int	      enlarge_factor;
+   int        enlarge_factor;
    int        smoothing;
    format_e   image_format;
 } dfiasco_t;
diff --git a/converter/other/fiasco/codec/domain-pool.c b/converter/other/fiasco/codec/domain-pool.c
index 1c14a30c..e9986269 100644
--- a/converter/other/fiasco/codec/domain-pool.c
+++ b/converter/other/fiasco/codec/domain-pool.c
@@ -2,7 +2,7 @@
  *  domain-pool.c:  Domain pool management (probability model)
  *
  *  Written by:     Ullrich Hafner
- *      
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -34,9 +34,9 @@
 /*
  *  Domain pool model interface:
  *  Implementing the domain pool model interface requires the
- *  following steps: 
+ *  following steps:
  *  - Add a constructor that initializes the domain_pool_t structure
- *  - Allocate new model with default_alloc() 
+ *  - Allocate new model with default_alloc()
  *  - Fill the dp_array_t domain_pools array with constructor and name
  *  - Write code for methods bits() and generate()
  *  - Either use default functions for remaining methods or override them
@@ -44,9 +44,9 @@
  */
 
 /*****************************************************************************
-                                          
+
                   local variables
-                  
+
 *****************************************************************************/
 
 static real_t *matrix_0 = NULL;
@@ -174,7 +174,7 @@ default_alloc (void);
 /*****************************************************************************
 
                 public code
-  
+
 *****************************************************************************/
 
 typedef struct dp_array
@@ -185,7 +185,7 @@ typedef struct dp_array
 } dp_array_t;
 
 dp_array_t const domain_pools[] = {{"adaptive", alloc_qac_domain_pool},
-                                   {"constant",   alloc_const_domain_pool}, 
+                                   {"constant",   alloc_const_domain_pool},
                                    {"basis",      alloc_basis_domain_pool},
                                    {"uniform",    alloc_uniform_domain_pool},
                                    {"rle",        alloc_rle_domain_pool},
@@ -199,8 +199,8 @@ alloc_domain_pool (const char *domain_pool_name, unsigned max_domains,
  *  Allocate a new domain pool identified by the string
  *  'domain_pool_name'.  Maximum number of domain images (each one
  *  represented by one state of the given 'wfa') is specified by
- *  'max_domains'. 
- * 
+ *  'max_domains'.
+ *
  *  Return value:
  *  pointer to the allocated domain pool
  *
@@ -209,16 +209,16 @@ alloc_domain_pool (const char *domain_pool_name, unsigned max_domains,
  */
 {
     unsigned n;
-   
+
     if (!max_domains)
     {
         warning ("Can't generate empty domain pool. "
                  "Using at least DC component.");
         max_domains = 1;
     }
-   
+
     for (n = 0; domain_pools [n].identifier; n++) /* step through all id's */
-        if (strcaseeq (domain_pools [n].identifier, domain_pool_name)) 
+        if (strcaseeq (domain_pools [n].identifier, domain_pool_name))
             return domain_pools [n].function (max_domains, max_edges, wfa);
 
     warning ("Can't initialize domain pool '%s'. Using default value '%s'.",
@@ -230,7 +230,7 @@ alloc_domain_pool (const char *domain_pool_name, unsigned max_domains,
 /*****************************************************************************
 
                 private code
-  
+
 *****************************************************************************/
 
 /*****************************************************************************
@@ -256,7 +256,7 @@ alloc_qac_domain_pool (unsigned max_domains, unsigned max_edges,
 {
     domain_pool_t *pool;
     unsigned   state;
-   
+
     pool                  = default_alloc ();
     pool->model           = qac_model_alloc (max_domains);
     pool->generate        = qac_generate;
@@ -266,7 +266,7 @@ alloc_qac_domain_pool (unsigned max_domains, unsigned max_edges,
     pool->chroma      = qac_chroma;
     pool->model_free      = qac_model_free;
     pool->model_duplicate = qac_model_duplicate;
-   
+
     for (state = 0; state < wfa->basis_states; state++)
         if (usedomain (state, wfa))
             qac_append (state, -1, wfa, pool->model);
@@ -308,7 +308,7 @@ qac_model_duplicate (const void *src)
     qdst      = qac_model_alloc (qsrc->max_domains);
     qdst->y_index = qsrc->y_index;
     qdst->n       = qsrc->n;
-   
+
     memcpy (qdst->index, qsrc->index, qsrc->n * sizeof (word_t));
     memcpy (qdst->states, qsrc->states, qsrc->n * sizeof (word_t));
 
@@ -325,14 +325,14 @@ qac_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model)
 
     if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */
         y_state = -1;
-   
+
     domains = Calloc (qac_model->n + 2, sizeof (word_t));
 
     memcpy (domains, qac_model->states, qac_model->n * sizeof (word_t));
 
     for (n = 0; n < qac_model->n; n++)
         if (domains [n] == y_state)   /* match */
-            y_state_is_domain = YES;       
+            y_state_is_domain = YES;
 
     if (y_state_is_domain)
         domains [qac_model->n] = -1;  /* end marker */
@@ -361,11 +361,11 @@ qac_bits (const word_t *domains, const word_t *used_domains,
             bits += matrix_0 [qac_model->index [domain]];
     if (y_state >= 0)
         bits += matrix_0 [qac_model->y_index];
-   
+
     if (used_domains != NULL)
     {
         unsigned edge;
-      
+
         for (edge = 0; isedge (domain = used_domains [edge]); edge++)
             if (domains [domain] == y_state)
             {
@@ -377,8 +377,8 @@ qac_bits (const word_t *domains, const word_t *used_domains,
                 bits -= matrix_0 [qac_model->index [domain]];
                 bits += matrix_1 [qac_model->index [domain]];
             }
-    } 
-   
+    }
+
     return bits;
 }
 
@@ -391,7 +391,7 @@ qac_update (const word_t *domains, const word_t *used_domains,
     bool_t   used_y_state      = NO;
     qac_model_t *qac_model     = (qac_model_t *) model;
     bool_t   y_state_is_domain = NO;
-   
+
     if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */
         y_state = -1;
 
@@ -399,9 +399,9 @@ qac_update (const word_t *domains, const word_t *used_domains,
     {
         qac_model->index [domain]++;  /* mark domains unused. */
         if (qac_model->states [domain] == y_state) /* match */
-            y_state_is_domain = YES;       
+            y_state_is_domain = YES;
     }
-   
+
     for (edge = 0; isedge (domain = used_domains [edge]); edge++)
         if (domains [domain] == y_state) /* chroma coding */
         {
@@ -413,24 +413,24 @@ qac_update (const word_t *domains, const word_t *used_domains,
         else              /* luminance coding */
         {
             qac_model->index [used_domains [edge]]--; /* undo */
-            qac_model->index [used_domains [edge]] >>= 1;      
+            qac_model->index [used_domains [edge]] >>= 1;
         }
 
     if (y_state >= 0 && !used_y_state)
         qac_model->y_index++;     /* update y-state model */
-   
+
     for (domain = 0; domain < qac_model->n; domain++)
         if (qac_model->index [domain] > 1020) /* check for overflow */
-            qac_model->index [domain] = 1020; 
+            qac_model->index [domain] = 1020;
     if (qac_model->y_index > 1020)   /* check for overflow */
-        qac_model->y_index = 1020; 
+        qac_model->y_index = 1020;
 }
 
 static bool_t
 qac_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model)
 {
     qac_model_t  *qac_model = (qac_model_t *) model; /* probability model */
-   
+
     if (qac_model->n >= qac_model->max_domains)
         return NO;            /* don't use state in domain pool */
     else
@@ -448,14 +448,14 @@ static void
 qac_chroma (unsigned max_domains, const wfa_t *wfa, void *model)
 {
     qac_model_t *qac_model = (qac_model_t *) model; /* probability model */
-   
+
     if (max_domains < qac_model->n)  /* choose most probable domains */
     {
         word_t   *domains;
         unsigned  n, new, old;
         word_t   *states = Calloc (max_domains, sizeof (word_t));
         word_t   *index  = Calloc (max_domains, sizeof (word_t));
-   
+
         domains = compute_hits (wfa->basis_states, wfa->states - 1,
                                 max_domains, wfa);
         for (n = 0; n < max_domains && domains [n] >= 0; n++)
@@ -491,11 +491,11 @@ alloc_const_domain_pool (unsigned max_domains, unsigned max_edges,
  */
 {
     domain_pool_t *pool;
-   
-    pool           = default_alloc ();   
+
+    pool           = default_alloc ();
     pool->generate = const_generate;
     pool->bits     = const_bits;
-   
+
     return pool;
 }
 
@@ -504,10 +504,10 @@ const_generate (unsigned level, int y_state, const wfa_t *wfa,
                 const void *model)
 {
     word_t *domains = Calloc (2, sizeof (word_t));
-   
+
     domains [0] = 0;
     domains [1] = -1;
-   
+
     return domains;
 }
 
@@ -548,11 +548,11 @@ alloc_uniform_domain_pool (unsigned max_domains, unsigned max_edges,
  */
 {
     domain_pool_t *pool;
-   
-    pool           = default_alloc ();   
+
+    pool           = default_alloc ();
     pool->generate = uniform_generate;
     pool->bits     = uniform_bits;
-   
+
     return pool;
 }
 
@@ -567,17 +567,17 @@ uniform_generate (unsigned level, int y_state, const wfa_t *wfa,
         if (usedomain (state, wfa))
             domains [n++] = state;
     domains [n] = -1;
-   
+
     return domains;
 }
- 
+
 static real_t
 uniform_bits (const word_t *domains, const word_t *used_domains,
               unsigned level, int y_state, const wfa_t *wfa, const void *model)
 {
     unsigned state, n;
     real_t   bits = 0;
-   
+
     for (state = 0, n = 0; state < wfa->states; state++)
         if (usedomain (state, wfa))
             n++;
@@ -587,7 +587,7 @@ uniform_bits (const word_t *domains, const word_t *used_domains,
     if (used_domains != NULL)
     {
         int edge;
-      
+
         for (edge = 0; isedge (used_domains [edge]); edge++)
             bits -= log2 (1.0 / n);
     }
@@ -615,13 +615,13 @@ alloc_rle_domain_pool (unsigned max_domains, unsigned max_edges,
                        const wfa_t *wfa)
 /*
  *  Domain pool with state images {0, ..., 'max_domains').
- *  Underlying probability model: rle 
+ *  Underlying probability model: rle
  */
 {
     domain_pool_t *pool;
     unsigned   state;
-   
-    pool                  = default_alloc ();    
+
+    pool                  = default_alloc ();
     pool->model           = rle_model_alloc (max_domains);
     pool->model_free      = rle_model_free;
     pool->model_duplicate = rle_model_duplicate;
@@ -643,7 +643,7 @@ rle_model_alloc (unsigned max_domains)
 {
     unsigned m;
     rle_model_t *model = Calloc (1, sizeof (rle_model_t));
-   
+
     for (m = model->total = 0; m < MAXEDGES + 1; m++, model->total++)
         model->count [m] = 1;
 
@@ -652,7 +652,7 @@ rle_model_alloc (unsigned max_domains)
     model->n       = 0;
     model->y_index     = 0;
     model->max_domains = max_domains;
-   
+
     return model;
 }
 
@@ -676,12 +676,12 @@ rle_model_duplicate (const void *src)
     model->states      = Calloc (model->max_domains, sizeof (word_t));
     model->total       = rle_src->total;
     model->y_index     = rle_src->y_index;
-   
+
     memcpy (model->states, rle_src->states,
             model->max_domains * sizeof (word_t));
     memcpy (model->count, rle_src->count,
             (MAXEDGES + 1) * sizeof (word_t));
-   
+
     return model;
 }
 
@@ -692,17 +692,17 @@ rle_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model)
     unsigned n;
     rle_model_t *rle_model     = (rle_model_t *) model;
     bool_t   y_state_is_domain = NO;
-   
+
     if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */
         y_state = -1;
-   
+
     domains = Calloc (rle_model->n + 2, sizeof (word_t));
 
     memcpy (domains, rle_model->states, rle_model->n * sizeof (word_t));
 
     for (n = 0; n < rle_model->n; n++)
         if (domains [n] == y_state)   /* match */
-            y_state_is_domain = YES;       
+            y_state_is_domain = YES;
 
     if (y_state_is_domain)
         domains [rle_model->n] = -1;  /* end marker */
@@ -726,17 +726,17 @@ rle_bits (const word_t *domains, const word_t *used_domains,
     rle_model_t *rle_model = (rle_model_t *) model;
     unsigned last;
     int      into;
-   
+
     if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */
         y_state = -1;
 
     if (used_domains)
     {
         word_t domain;
-      
+
         if (y_state >= 0)
             bits += matrix_0 [rle_model->y_index];
-      
+
         for (edge = n = 0; isedge (domain = used_domains [edge]); edge++)
             if (domains [domain] != y_state)
                 sorted [n++] = used_domains [edge];
@@ -745,7 +745,7 @@ rle_bits (const word_t *domains, const word_t *used_domains,
                 bits -= matrix_0 [rle_model->y_index];
                 bits += matrix_1 [rle_model->y_index];
             }
-      
+
         if (n > 1)
             qsort (sorted, n, sizeof (word_t), sort_asc_word);
     }
@@ -761,7 +761,7 @@ rle_bits (const word_t *domains, const word_t *used_domains,
         word_t array0 [2] = {NO_EDGE};
         bits += qac_bits (array0, array0, level, y_state, wfa, rle_model->domain_0);
     }
-   
+
     last = 1;
     for (edge = 0; edge < n; edge++)
         if ((into = sorted [edge]) && rle_model->n - 1 - last)
@@ -769,7 +769,7 @@ rle_bits (const word_t *domains, const word_t *used_domains,
             bits += bits_bin_code (into - last, rle_model->n - 1 - last);
             last  = into + 1;
         }
-   
+
     return bits;
 }
 
@@ -781,21 +781,21 @@ rle_update (const word_t *domains, const word_t *used_domains,
     bool_t   state_0    = NO, state_y = NO;
     word_t   array0 [2] = {0, NO_EDGE};
     unsigned     edge = 0;
-   
+
     if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */
         y_state = -1;
 
     if (used_domains)
     {
         word_t   domain;
-      
+
         for (edge = 0; isedge (domain = used_domains [edge]); edge++)
             if (domains [domain] == 0)
                 state_0 = YES;
             else if (domains [domain] == y_state)
                 state_y = YES;
     }
-   
+
     rle_model->count [edge]++;
     rle_model->total++;
 
@@ -807,14 +807,14 @@ rle_update (const word_t *domains, const word_t *used_domains,
     else
         rle_model->y_index++;
     if (rle_model->y_index > 1020)   /* check for overflow */
-        rle_model->y_index = 1020; 
+        rle_model->y_index = 1020;
 }
 
 static bool_t
 rle_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model)
 {
     rle_model_t *rle_model = (rle_model_t *) model; /* probability model */
-   
+
     if (rle_model->n >= rle_model->max_domains)
         return NO;            /* don't use state in domain pool */
     else
@@ -827,7 +827,7 @@ rle_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model)
             assert (rle_model->n == 1);
             qac_append (0, -1, wfa, rle_model->domain_0);
         }
-      
+
         return YES;           /* state will be used in domain pool */
     }
 }
@@ -836,14 +836,14 @@ static void
 rle_chroma (unsigned max_domains, const wfa_t *wfa, void *model)
 {
     rle_model_t *rle_model = (rle_model_t *) model; /* probability model */
-   
+
     if (max_domains < rle_model->n)  /* choose most probable domains */
     {
         unsigned  n;
         word_t   *states  = Calloc (max_domains, sizeof (word_t));
         word_t   *domains = compute_hits (wfa->basis_states, wfa->states - 1,
                                           max_domains, wfa);
-      
+
         for (n = 0; n < max_domains && domains [n] >= 0; n++)
             states [n] = domains [n];
 
@@ -868,12 +868,12 @@ alloc_rle_no_chroma_domain_pool (unsigned max_domains, unsigned max_edges,
                                  const wfa_t *wfa)
 /*
  *  Domain pool with state images {0, ..., 'max_domains').
- *  Underlying probability model: rle 
+ *  Underlying probability model: rle
  *  Domain pool is not changed for chroma bands
  */
 {
     domain_pool_t *pool = alloc_rle_domain_pool (max_domains, max_edges, wfa);
-   
+
     pool->chroma = default_chroma;
 
     return pool;
@@ -898,7 +898,7 @@ default_alloc (void)
     pool->free            = default_free;
     pool->model_free      = default_model_free;
     pool->model_duplicate = default_model_duplicate;
-   
+
     return pool;
 }
 
@@ -964,12 +964,12 @@ init_matrix_probabilities (void)
 {
     if (matrix_0 == NULL || matrix_1 == NULL)
     {
-        unsigned index;           
+        unsigned index;
         unsigned n, exp;
-      
+
         matrix_0 = Calloc (1 << (MAX_PROB + 1), sizeof (real_t));
         matrix_1 = Calloc (1 << (MAX_PROB + 1), sizeof (real_t));
-   
+
         for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++)
             for (exp = 0; exp < (unsigned) 1 << n; exp++, index++)
             {
diff --git a/converter/other/fiasco/codec/domain-pool.h b/converter/other/fiasco/codec/domain-pool.h
index a2c46141..b3258b67 100644
--- a/converter/other/fiasco/codec/domain-pool.h
+++ b/converter/other/fiasco/codec/domain-pool.h
@@ -1,8 +1,8 @@
 /*
  *  domain-pool.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -22,42 +22,42 @@
 
 typedef struct domain_pool
 {
-   void	  *model;			/* probability model */
+   void   *model;                       /* probability model */
    word_t *(*generate) (unsigned level, int y_state, const wfa_t *wfa,
-			const void  *model);
+                        const void  *model);
    /*
     *  Generate set of domain images which may be used for an approximation.
     *  Use parameters 'level', 'y_state' and 'wfa' to make the decision.
     */
    real_t (*bits) (const word_t *domains, const word_t *used_domains,
-		   unsigned level, int y_state, const wfa_t *wfa,
-		   const void *model);
+                   unsigned level, int y_state, const wfa_t *wfa,
+                   const void *model);
    /*
     *  Compute bit-rate of a range approximation with domains given by
     *  the -1 terminated list 'used_domains'.
     */
-   void	  (*update) (const word_t *domains, const word_t *used_domains,
-		     unsigned level, int y_state, const wfa_t *wfa,
-		     void *model);
+   void   (*update) (const word_t *domains, const word_t *used_domains,
+                     unsigned level, int y_state, const wfa_t *wfa,
+                     void *model);
    /*
     *  Update the probability model according to the chosen approximation.
     *  (given by the -1 terminated list 'used_domains').
     */
    bool_t (*append) (unsigned state, unsigned level, const wfa_t *wfa,
-		     void *model);
+                     void *model);
    /*
     *  Try to append a new state to the domain pool.
     */
-   void	  (*chroma) (unsigned max_domains, const wfa_t *wfa, void *model);
+   void   (*chroma) (unsigned max_domains, const wfa_t *wfa, void *model);
    /*
     *  Derive a new domain pool that will be used for chroma channel
-    *  coding 
+    *  coding
     */
    void   (*free) (struct domain_pool *pool);
    /*
     *  Discard the given domain pool struct.
     */
-   void   (*model_free)	(void *model);
+   void   (*model_free) (void *model);
    /*
     *  Free given probability model.
     */
@@ -69,7 +69,7 @@ typedef struct domain_pool
 
 domain_pool_t *
 alloc_domain_pool (const char *domain_pool_name, unsigned max_domains,
-		   unsigned max_edges, const wfa_t *wfa);
+                   unsigned max_edges, const wfa_t *wfa);
 
 #endif /* not _DOMAIN_POOL_H */
 
diff --git a/converter/other/fiasco/codec/ip.c b/converter/other/fiasco/codec/ip.c
index 18257a06..4209ab21 100644
--- a/converter/other/fiasco/codec/ip.c
+++ b/converter/other/fiasco/codec/ip.c
@@ -1,7 +1,7 @@
 /*
- *  ip.c:		Computation of inner products
+ *  ip.c:               Computation of inner products
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -26,29 +26,29 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static real_t
 standard_ip_image_state (unsigned address, unsigned level, unsigned domain,
-			 const coding_t *c);
+                         const coding_t *c);
 static real_t
 standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level,
-			 const coding_t *c);
+                         const coding_t *c);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
 real_t
 get_ip_image_state (unsigned image, unsigned address, unsigned level,
-		    unsigned domain, const coding_t *c)
+                    unsigned domain, const coding_t *c)
 /*
  *  Return value:
- *	Inner product between 'image' ('address') and
+ *      Inner product between 'image' ('address') and
  *      'domain' at given 'level'
  */
 {
@@ -71,8 +71,8 @@ get_ip_image_state (unsigned image, unsigned address, unsigned level,
 
 void
 compute_ip_images_state (unsigned image, unsigned address, unsigned level,
-			 unsigned n, unsigned from,
-			 const wfa_t *wfa, coding_t *c)
+                         unsigned n, unsigned from,
+                         const wfa_t *wfa, coding_t *c)
 /*
  *  Compute the inner products between all states
  *  'from', ... , 'wfa->max_states' and the range images 'image'
@@ -81,84 +81,84 @@ compute_ip_images_state (unsigned image, unsigned address, unsigned level,
  *  No return value.
  *
  *  Side effects:
- *	inner product tables 'c->ip_images_states' are updated
+ *      inner product tables 'c->ip_images_states' are updated
  */
 {
    if (level > c->options.images_level)
    {
       unsigned state, label;
 
-      if (level > c->options.images_level + 1)	/* recursive computation */
-	 compute_ip_images_state (MAXLABELS * image + 1, address * MAXLABELS,
-				  level - 1, MAXLABELS * n, from, wfa, c);
+      if (level > c->options.images_level + 1)  /* recursive computation */
+         compute_ip_images_state (MAXLABELS * image + 1, address * MAXLABELS,
+                                  level - 1, MAXLABELS * n, from, wfa, c);
 
       /*
        *  Compute inner product <f, Phi_i>
        */
       for (label = 0; label < MAXLABELS; label++)
-	 for (state = from; state < wfa->states; state++)
-	    if (need_image (state, wfa))
-	    {
-	       unsigned  edge, count;
-	       int     	 domain;
-	       real_t 	*dst, *src;
-
-	       if (ischild (domain = wfa->tree [state][label]))
-	       {
-		  if (level > c->options.images_level + 1)
-		  {
-		     dst = c->ip_images_state [state] + image;
-		     src = c->ip_images_state [domain]
-			   + image * MAXLABELS + label + 1;
-		     for (count = n; count; count--, src += MAXLABELS)
-			*dst++ += *src;
-		  }
-		  else
-		  {
-		     unsigned newadr = address * MAXLABELS + label;
-
-		     dst = c->ip_images_state [state] + image;
-
-		     for (count = n; count; count--, newadr += MAXLABELS)
-			*dst++ += standard_ip_image_state (newadr, level - 1,
-							   domain, c);
-		  }
-	       }
-	       for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
-		    edge++)
-	       {
-		  real_t weight = wfa->weight [state][label][edge];
-
-		  if (level > c->options.images_level + 1)
-		  {
-		     dst = c->ip_images_state [state] + image;
-		     src = c->ip_images_state [domain]
-			   + image * MAXLABELS + label + 1;
-		     for (count = n; count; count--, src += MAXLABELS)
-			*dst++ += *src * weight;
-		  }
-		  else
-		  {
-		     unsigned newadr = address * MAXLABELS + label;
-
-		     dst = c->ip_images_state [state] + image;
-
-		     for (count = n; count; count--, newadr += MAXLABELS)
-			*dst++ += weight *
-				  standard_ip_image_state (newadr, level - 1,
-							   domain, c);
-		  }
-	       }
-	    }
+         for (state = from; state < wfa->states; state++)
+            if (need_image (state, wfa))
+            {
+               unsigned  edge, count;
+               int       domain;
+               real_t   *dst, *src;
+
+               if (ischild (domain = wfa->tree [state][label]))
+               {
+                  if (level > c->options.images_level + 1)
+                  {
+                     dst = c->ip_images_state [state] + image;
+                     src = c->ip_images_state [domain]
+                           + image * MAXLABELS + label + 1;
+                     for (count = n; count; count--, src += MAXLABELS)
+                        *dst++ += *src;
+                  }
+                  else
+                  {
+                     unsigned newadr = address * MAXLABELS + label;
+
+                     dst = c->ip_images_state [state] + image;
+
+                     for (count = n; count; count--, newadr += MAXLABELS)
+                        *dst++ += standard_ip_image_state (newadr, level - 1,
+                                                           domain, c);
+                  }
+               }
+               for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
+                    edge++)
+               {
+                  real_t weight = wfa->weight [state][label][edge];
+
+                  if (level > c->options.images_level + 1)
+                  {
+                     dst = c->ip_images_state [state] + image;
+                     src = c->ip_images_state [domain]
+                           + image * MAXLABELS + label + 1;
+                     for (count = n; count; count--, src += MAXLABELS)
+                        *dst++ += *src * weight;
+                  }
+                  else
+                  {
+                     unsigned newadr = address * MAXLABELS + label;
+
+                     dst = c->ip_images_state [state] + image;
+
+                     for (count = n; count; count--, newadr += MAXLABELS)
+                        *dst++ += weight *
+                                  standard_ip_image_state (newadr, level - 1,
+                                                           domain, c);
+                  }
+               }
+            }
    }
 }
 
 real_t
 get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level,
-		    const coding_t *c)
+                    const coding_t *c)
 /*
  *  Return value:
- *	Inner product between 'domain1' and 'domain2' at given 'level'.
+ *      Inner product between 'domain1' and 'domain2' at given 'level'.
  */
 {
    if (level <= c->options.images_level)
@@ -175,15 +175,15 @@ get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level,
        *  Use already computed inner products stored in 'ip_images_states'
        */
       if (domain2 < domain1)
-	 return c->ip_states_state [domain1][level][domain2];
+         return c->ip_states_state [domain1][level][domain2];
       else
-	 return c->ip_states_state [domain2][level][domain1];
+         return c->ip_states_state [domain2][level][domain1];
    }
 }
 
 void
 compute_ip_states_state (unsigned from, unsigned to,
-			 const wfa_t *wfa, coding_t *c)
+                         const wfa_t *wfa, coding_t *c)
 /*
  *  Computes the inner products between the current state 'state1' and the
  *  old states 0,...,'state1'-1
@@ -191,7 +191,7 @@ compute_ip_states_state (unsigned from, unsigned to,
  *  No return value.
  *
  *  Side effects:
- *	inner product tables 'c->ip_states_state' are computed.
+ *      inner product tables 'c->ip_states_state' are computed.
  */
 {
    unsigned level;
@@ -202,72 +202,72 @@ compute_ip_states_state (unsigned from, unsigned to,
     */
 
    for (level = c->options.images_level + 1;
-	level <= c->options.lc_max_level; level++)
+        level <= c->options.lc_max_level; level++)
       for (state1 = from; state1 <= to; state1++)
-	 for (state2 = 0; state2 <= state1; state2++)
-	    if (need_image (state2, wfa))
-	    {
-	       unsigned	label;
-	       real_t	ip = 0;
-
-	       for (label = 0; label < MAXLABELS; label++)
-	       {
-		  int	   domain1, domain2;
-		  unsigned edge1, edge2;
-		  real_t   sum, weight2;
-
-		  if (ischild (domain1 = wfa->tree [state1][label]))
-		  {
-		     sum = 0;
-		     if (ischild (domain2 = wfa->tree [state2][label]))
-			sum = get_ip_state_state (domain1, domain2,
-						  level - 1, c);
-
-		     for (edge2 = 0;
-			  isedge (domain2 = wfa->into [state2][label][edge2]);
-			  edge2++)
-		     {
-			weight2 = wfa->weight [state2][label][edge2];
-			sum += weight2 * get_ip_state_state (domain1, domain2,
-							     level - 1, c);
-		     }
-		     ip += sum;
-		  }
-		  for (edge1 = 0;
-		       isedge (domain1 = wfa->into [state1][label][edge1]);
-		       edge1++)
-		  {
-		     real_t weight1 = wfa->weight [state1][label][edge1];
-
-		     sum = 0;
-		     if (ischild (domain2 = wfa->tree [state2][label]))
-			sum = get_ip_state_state (domain1, domain2,
-						  level - 1, c);
-
-		     for (edge2 = 0;
-			  isedge (domain2 = wfa->into [state2][label][edge2]);
-			  edge2++)
-		     {
-			weight2 = wfa->weight [state2][label][edge2];
-			sum += weight2 * get_ip_state_state (domain1, domain2,
-							     level - 1, c);
-		     }
-		     ip += weight1 * sum;
-		  }
-	       }
-	       c->ip_states_state [state1][level][state2] = ip;
-	    }
+         for (state2 = 0; state2 <= state1; state2++)
+            if (need_image (state2, wfa))
+            {
+               unsigned label;
+               real_t   ip = 0;
+
+               for (label = 0; label < MAXLABELS; label++)
+               {
+                  int      domain1, domain2;
+                  unsigned edge1, edge2;
+                  real_t   sum, weight2;
+
+                  if (ischild (domain1 = wfa->tree [state1][label]))
+                  {
+                     sum = 0;
+                     if (ischild (domain2 = wfa->tree [state2][label]))
+                        sum = get_ip_state_state (domain1, domain2,
+                                                  level - 1, c);
+
+                     for (edge2 = 0;
+                          isedge (domain2 = wfa->into [state2][label][edge2]);
+                          edge2++)
+                     {
+                        weight2 = wfa->weight [state2][label][edge2];
+                        sum += weight2 * get_ip_state_state (domain1, domain2,
+                                                             level - 1, c);
+                     }
+                     ip += sum;
+                  }
+                  for (edge1 = 0;
+                       isedge (domain1 = wfa->into [state1][label][edge1]);
+                       edge1++)
+                  {
+                     real_t weight1 = wfa->weight [state1][label][edge1];
+
+                     sum = 0;
+                     if (ischild (domain2 = wfa->tree [state2][label]))
+                        sum = get_ip_state_state (domain1, domain2,
+                                                  level - 1, c);
+
+                     for (edge2 = 0;
+                          isedge (domain2 = wfa->into [state2][label][edge2]);
+                          edge2++)
+                     {
+                        weight2 = wfa->weight [state2][label][edge2];
+                        sum += weight2 * get_ip_state_state (domain1, domain2,
+                                                             level - 1, c);
+                     }
+                     ip += weight1 * sum;
+                  }
+               }
+               c->ip_states_state [state1][level][state2] = ip;
+            }
 }
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static real_t
 standard_ip_image_state (unsigned address, unsigned level, unsigned domain,
-			 const coding_t *c)
+                         const coding_t *c)
 /*
  *  Returns the inner product between the subimage 'address' and the
  *  state image 'domain' at given 'level'.  The stored state images
@@ -275,7 +275,7 @@ standard_ip_image_state (unsigned address, unsigned level, unsigned domain,
  *  standard way by multiplying the corresponding pixel values.
  *
  *  Return value:
- *	computed inner product
+ *      computed inner product
  */
 {
    unsigned i;
@@ -296,7 +296,7 @@ standard_ip_image_state (unsigned address, unsigned level, unsigned domain,
 
 static real_t
 standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level,
-			 const coding_t *c)
+                         const coding_t *c)
 /*
  *  Returns the inner product between the subimage 'address' and the
  *  state image 'state' at given 'level'.  The stored state images are
@@ -304,7 +304,7 @@ standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level,
  *  multiplying the corresponding pixel values.
  *
  *  Return value:
- *	computed inner product
+ *      computed inner product
  */
 {
    unsigned i;
diff --git a/converter/other/fiasco/codec/ip.h b/converter/other/fiasco/codec/ip.h
index 0c693826..f7d7efac 100644
--- a/converter/other/fiasco/codec/ip.h
+++ b/converter/other/fiasco/codec/ip.h
@@ -1,8 +1,8 @@
 /*
  *  ip.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -19,19 +19,19 @@
 
 #include "cwfa.h"
 
-void 
+void
 compute_ip_states_state (unsigned from, unsigned to,
-			 const wfa_t *wfa, coding_t *c);
-real_t 
+                         const wfa_t *wfa, coding_t *c);
+real_t
 get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level,
-		    const coding_t *c);
-void 
+                    const coding_t *c);
+void
 compute_ip_images_state (unsigned image, unsigned address, unsigned level,
-			 unsigned n, unsigned from,
-			 const wfa_t *wfa, coding_t *c);
-real_t 
+                         unsigned n, unsigned from,
+                         const wfa_t *wfa, coding_t *c);
+real_t
 get_ip_image_state (unsigned image, unsigned address, unsigned level,
-		    unsigned domain, const coding_t *c);
+                    unsigned domain, const coding_t *c);
 
 #endif /* not _IP_H */
 
diff --git a/converter/other/fiasco/codec/motion.c b/converter/other/fiasco/codec/motion.c
index 0d1fa099..18d3bdd3 100644
--- a/converter/other/fiasco/codec/motion.c
+++ b/converter/other/fiasco/codec/motion.c
@@ -1,9 +1,9 @@
 /*
- *  motion.c:		Motion compensation code	
+ *  motion.c:           Motion compensation code
+ *
+ *  Written by:         Ullrich Hafner
+ *                      Michael Unger
  *
- *  Written by:		Ullrich Hafner
- *			Michael Unger
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -31,13 +31,13 @@
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 void
 restore_mc (int enlarge_factor, image_t *image, const image_t *past,
-	    const image_t *future, const wfa_t *wfa)
+            const image_t *future, const wfa_t *wfa)
 /*
  *  Restore motion compensated prediction of 'image' represented by 'wfa'.
  *  If 'enlarge_factor' != 0 then enlarge image by given amount.
@@ -48,193 +48,193 @@ restore_mc (int enlarge_factor, image_t *image, const image_t *past,
 {
    unsigned  state, label;
    unsigned  root_state;
-   word_t   *mcblock1, *mcblock2;	/* MC blocks */
+   word_t   *mcblock1, *mcblock2;       /* MC blocks */
 
 #define FX(v) ((image->format == FORMAT_4_2_0) && band != Y ? ((v) / 2) : v)
-   
+
    mcblock1 = Calloc (size_of_level (MAX((int) wfa->wfainfo->p_max_level
-					  + 2 * enlarge_factor, 0)),
-		      sizeof (word_t));
+                                          + 2 * enlarge_factor, 0)),
+                      sizeof (word_t));
    mcblock2 = Calloc (size_of_level (MAX((int) wfa->wfainfo->p_max_level
-					  + 2 * enlarge_factor, 0)),
-		      sizeof (word_t));
+                                          + 2 * enlarge_factor, 0)),
+                      sizeof (word_t));
 
    if (!image->color)
       root_state = wfa->root_state;
    else
       root_state  = wfa->tree [wfa->tree [wfa->root_state][0]][0];
-   
+
    for (state = wfa->basis_states; state <= root_state; state++)
       for (label = 0; label < MAXLABELS; label++)
-	 if (wfa->mv_tree[state][label].type != NONE)
-	 {
-	    color_e band;
-	    unsigned level  = wfa->level_of_state [state] - 1;
-	    unsigned width  = width_of_level (level);
-	    unsigned height = height_of_level (level);
-	    unsigned offset = image->width - width;
-	    
-	    switch (wfa->mv_tree [state][label].type)
-	    {
-	       case FORWARD:
-		  for (band  = first_band (image->color);
-		       band <= last_band (image->color); band++)
-		  {
-		     extract_mc_block (mcblock1, FX (width), FX (height),
-				       past->pixels [band], FX (past->width),
-				       wfa->wfainfo->half_pixel,
-				       FX (wfa->x [state][label]),
-				       FX (wfa->y [state][label]),
-				       FX (wfa->mv_tree [state][label].fx),
-				       FX (wfa->mv_tree [state][label].fy));
-		     {
-			word_t   *mc1;	/* current pixel in MC block */
-			word_t 	 *orig;	/* current pixel in original image */
-			unsigned  x, y;	/* pixel coordinates */
-			
-			mc1  = mcblock1;
-			orig = (word_t *) image->pixels [band]
-			       + FX (wfa->x[state][label])
-			       + FX (wfa->y[state][label]) * FX (image->width);
-		     
-			for (y = FX (height); y; y--)
-			{
-			   for (x = FX (width); x; x--)
-			      *orig++ += *mc1++;
-
-			   orig += FX (offset);
-			}
-		     }
-		  }
-		  break;
-	       case BACKWARD:
-		  for (band  = first_band (image->color);
-		       band <= last_band (image->color); band++)
-		  {
-		     extract_mc_block (mcblock1, FX (width), FX (height),
-				       future->pixels [band],
-				       FX (future->width),
-				       wfa->wfainfo->half_pixel,
-				       FX (wfa->x [state][label]),
-				       FX (wfa->y [state][label]),
-				       FX (wfa->mv_tree [state][label].bx),
-				       FX (wfa->mv_tree [state][label].by));
-		     {
-			word_t   *mc1;	/* current pixel in MC block 1 */
-			word_t   *orig;	/* current pixel in original image */
-			unsigned  x, y;	/* pixel coordinates */
-			
-			mc1  = mcblock1;
-			orig = (word_t *) image->pixels [band]
-			       + FX (wfa->x[state][label])
-			       + FX (wfa->y[state][label]) * FX (image->width);
-		     
-			for (y = FX (height); y; y--)
-			{
-			   for (x = FX (width); x; x--)
-			      *orig++ += *mc1++;
-
-			   orig += FX (offset);
-			}
-		     }
-		  }
-		  break;
-	       case INTERPOLATED:
-		  for (band  = first_band (image->color);
-		       band <= last_band (image->color); band++)
-		  {
-		     extract_mc_block (mcblock1, FX (width), FX (height),
-				       past->pixels [band], FX (past->width),
-				       wfa->wfainfo->half_pixel,
-				       FX (wfa->x[state][label]),
-				       FX (wfa->y[state][label]),
-				       FX (wfa->mv_tree[state][label].fx),
-				       FX (wfa->mv_tree[state][label].fy));
-		     extract_mc_block (mcblock2, FX (width), FX (height),
-				       future->pixels [band],
-				       FX (future->width),
-				       wfa->wfainfo->half_pixel,
-				       FX (wfa->x[state][label]),
-				       FX (wfa->y[state][label]),
-				       FX (wfa->mv_tree[state][label].bx),
-				       FX (wfa->mv_tree[state][label].by));
-		     {
-			word_t   *mc1;	/* current pixel in MC block 1 */
-			word_t   *mc2;	/* current pixel in MC block 1 */
-			word_t   *orig;	/* current pixel in original image */
-			unsigned  x, y;	/* pixel coordinates */
-			
-			mc1  = mcblock1;
-			mc2  = mcblock2;
-			orig = (word_t *) image->pixels [band]
-			       + FX (wfa->x[state][label])
-			       + FX (wfa->y[state][label]) * FX (image->width);
-			
-			for (y = FX (height); y; y--)
-			{
-			   for (x = FX (width); x; x--)
+         if (wfa->mv_tree[state][label].type != NONE)
+         {
+            color_e band;
+            unsigned level  = wfa->level_of_state [state] - 1;
+            unsigned width  = width_of_level (level);
+            unsigned height = height_of_level (level);
+            unsigned offset = image->width - width;
+
+            switch (wfa->mv_tree [state][label].type)
+            {
+               case FORWARD:
+                  for (band  = first_band (image->color);
+                       band <= last_band (image->color); band++)
+                  {
+                     extract_mc_block (mcblock1, FX (width), FX (height),
+                                       past->pixels [band], FX (past->width),
+                                       wfa->wfainfo->half_pixel,
+                                       FX (wfa->x [state][label]),
+                                       FX (wfa->y [state][label]),
+                                       FX (wfa->mv_tree [state][label].fx),
+                                       FX (wfa->mv_tree [state][label].fy));
+                     {
+                        word_t   *mc1;  /* current pixel in MC block */
+                        word_t   *orig; /* current pixel in original image */
+                        unsigned  x, y; /* pixel coordinates */
+
+                        mc1  = mcblock1;
+                        orig = (word_t *) image->pixels [band]
+                               + FX (wfa->x[state][label])
+                               + FX (wfa->y[state][label]) * FX (image->width);
+
+                        for (y = FX (height); y; y--)
+                        {
+                           for (x = FX (width); x; x--)
+                              *orig++ += *mc1++;
+
+                           orig += FX (offset);
+                        }
+                     }
+                  }
+                  break;
+               case BACKWARD:
+                  for (band  = first_band (image->color);
+                       band <= last_band (image->color); band++)
+                  {
+                     extract_mc_block (mcblock1, FX (width), FX (height),
+                                       future->pixels [band],
+                                       FX (future->width),
+                                       wfa->wfainfo->half_pixel,
+                                       FX (wfa->x [state][label]),
+                                       FX (wfa->y [state][label]),
+                                       FX (wfa->mv_tree [state][label].bx),
+                                       FX (wfa->mv_tree [state][label].by));
+                     {
+                        word_t   *mc1;  /* current pixel in MC block 1 */
+                        word_t   *orig; /* current pixel in original image */
+                        unsigned  x, y; /* pixel coordinates */
+
+                        mc1  = mcblock1;
+                        orig = (word_t *) image->pixels [band]
+                               + FX (wfa->x[state][label])
+                               + FX (wfa->y[state][label]) * FX (image->width);
+
+                        for (y = FX (height); y; y--)
+                        {
+                           for (x = FX (width); x; x--)
+                              *orig++ += *mc1++;
+
+                           orig += FX (offset);
+                        }
+                     }
+                  }
+                  break;
+               case INTERPOLATED:
+                  for (band  = first_band (image->color);
+                       band <= last_band (image->color); band++)
+                  {
+                     extract_mc_block (mcblock1, FX (width), FX (height),
+                                       past->pixels [band], FX (past->width),
+                                       wfa->wfainfo->half_pixel,
+                                       FX (wfa->x[state][label]),
+                                       FX (wfa->y[state][label]),
+                                       FX (wfa->mv_tree[state][label].fx),
+                                       FX (wfa->mv_tree[state][label].fy));
+                     extract_mc_block (mcblock2, FX (width), FX (height),
+                                       future->pixels [band],
+                                       FX (future->width),
+                                       wfa->wfainfo->half_pixel,
+                                       FX (wfa->x[state][label]),
+                                       FX (wfa->y[state][label]),
+                                       FX (wfa->mv_tree[state][label].bx),
+                                       FX (wfa->mv_tree[state][label].by));
+                     {
+                        word_t   *mc1;  /* current pixel in MC block 1 */
+                        word_t   *mc2;  /* current pixel in MC block 1 */
+                        word_t   *orig; /* current pixel in original image */
+                        unsigned  x, y; /* pixel coordinates */
+
+                        mc1  = mcblock1;
+                        mc2  = mcblock2;
+                        orig = (word_t *) image->pixels [band]
+                               + FX (wfa->x[state][label])
+                               + FX (wfa->y[state][label]) * FX (image->width);
+
+                        for (y = FX (height); y; y--)
+                        {
+                           for (x = FX (width); x; x--)
 #ifdef HAVE_SIGNED_SHIFT
-			      *orig++ += (*mc1++ + *mc2++) >> 1;
+                              *orig++ += (*mc1++ + *mc2++) >> 1;
 #else /* not HAVE_SIGNED_SHIFT */
-			   *orig++ += (*mc1++ + *mc2++) / 2;
+                           *orig++ += (*mc1++ + *mc2++) / 2;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-			   orig += FX (offset);
-			}
-		     }
-		  }
-		  break;
-	       default:
-		  break;
-	    }
-	 }
+                           orig += FX (offset);
+                        }
+                     }
+                  }
+                  break;
+               default:
+                  break;
+            }
+         }
 
    if (image->color)
    {
-      unsigned	  n;
-      word_t	 *ptr;
+      unsigned    n;
+      word_t     *ptr;
       static int *clipping = NULL;
-      unsigned	  shift    = image->format == FORMAT_4_2_0 ? 2 : 0;
+      unsigned    shift    = image->format == FORMAT_4_2_0 ? 2 : 0;
 
-      if (!clipping)			/* initialize clipping table */
+      if (!clipping)                    /* initialize clipping table */
       {
-	 int i;
-	    
-	 clipping = Calloc (256 * 3, sizeof (int));
-	 for (i = -128; i < 128; i++)
-	    clipping [256 + i + 128] = i;
-	 for (i = 0; i < 256; i++)
-	    clipping [i] = clipping [256];
-	 for (i = 512; i < 512 + 256; i++)
-	    clipping [i] = clipping [511];
-	 clipping += 256 + 128;
+         int i;
+
+         clipping = Calloc (256 * 3, sizeof (int));
+         for (i = -128; i < 128; i++)
+            clipping [256 + i + 128] = i;
+         for (i = 0; i < 256; i++)
+            clipping [i] = clipping [256];
+         for (i = 512; i < 512 + 256; i++)
+            clipping [i] = clipping [511];
+         clipping += 256 + 128;
       }
-	 
+
       ptr = image->pixels [Cb];
       for (n = (image->width * image->height) >> shift; n; n--, ptr++)
 #ifdef HAVE_SIGNED_SHIFT
-	 *ptr = clipping [*ptr >> 4] << 4;
+         *ptr = clipping [*ptr >> 4] << 4;
 #else /* not HAVE_SIGNED_SHIFT */
-	 *ptr = clipping [*ptr / 16] * 16;
+         *ptr = clipping [*ptr / 16] * 16;
 #endif /* not HAVE_SIGNED_SHIFT */
       ptr = image->pixels [Cr];
       for (n = (image->width * image->height) >> shift; n; n--, ptr++)
 #ifdef HAVE_SIGNED_SHIFT
-	*ptr = clipping [*ptr >> 4] << 4;
+        *ptr = clipping [*ptr >> 4] << 4;
 #else /* not HAVE_SIGNED_SHIFT */
         *ptr = clipping [*ptr / 16] * 16;
 #endif /* not HAVE_SIGNED_SHIFT */
    }
-   
+
    Free (mcblock1);
    Free (mcblock2);
 }
 
 void
 extract_mc_block (word_t *mcblock, unsigned width, unsigned height,
-		  const word_t *reference, unsigned ref_width,
-		  bool_t half_pixel, unsigned xo, unsigned yo,
-		  unsigned mx, unsigned my)
+                  const word_t *reference, unsigned ref_width,
+                  bool_t half_pixel, unsigned xo, unsigned yo,
+                  unsigned mx, unsigned my)
 /*
  *  Extract motion compensation image 'mcblock' of size 'width'x'height'
  *  from 'reference' image (width is given by 'ref_width').
@@ -244,93 +244,93 @@ extract_mc_block (word_t *mcblock, unsigned width, unsigned height,
  *  No return value.
  *
  *  Side effects:
- *	'mcblock[]'	MCPE block is filled with reference pixels 
+ *      'mcblock[]'     MCPE block is filled with reference pixels
  */
 {
-   if (!half_pixel)			/* Fullpixel precision */
+   if (!half_pixel)                     /* Fullpixel precision */
    {
-      const word_t *rblock;		/* pointer to reference image */
-      unsigned	    y;			/* current row */
-      
+      const word_t *rblock;             /* pointer to reference image */
+      unsigned      y;                  /* current row */
+
       rblock  = reference + (yo + my) * ref_width + (xo + mx);
-      for (y = height; y; y--) 
+      for (y = height; y; y--)
       {
-	 memcpy (mcblock, rblock, width * sizeof (word_t));
+         memcpy (mcblock, rblock, width * sizeof (word_t));
 
-	 mcblock += width;
-	 rblock  += ref_width;
+         mcblock += width;
+         rblock  += ref_width;
       }
    }
-   else					/* Halfpixel precision */
+   else                                 /* Halfpixel precision */
    {
-      unsigned	    x, y;		/* current coordinates */
-      unsigned	    offset;		/* remaining pixels in row */
-      const word_t *rblock;		/* pointer to reference image */
-      const word_t *ryblock;		/* pointer to next line */
-      const word_t *rxblock;		/* pointer to next column */
-      const word_t *rxyblock;		/* pointer to next column & row */
-   
+      unsigned      x, y;               /* current coordinates */
+      unsigned      offset;             /* remaining pixels in row */
+      const word_t *rblock;             /* pointer to reference image */
+      const word_t *ryblock;            /* pointer to next line */
+      const word_t *rxblock;            /* pointer to next column */
+      const word_t *rxyblock;           /* pointer to next column & row */
+
       rblock   = reference + (yo + my / 2) * ref_width + (xo + mx / 2);
-      ryblock  = rblock + ref_width;	/* pixel in next row */
-      rxblock  = rblock + 1;		/* pixel in next column */
-      rxyblock = ryblock + 1;		/* pixel in next row & column */
+      ryblock  = rblock + ref_width;    /* pixel in next row */
+      rxblock  = rblock + 1;            /* pixel in next column */
+      rxyblock = ryblock + 1;           /* pixel in next row & column */
       offset   = ref_width - width;
-      
+
       if ((mx & 1) == 0)
       {
-	 if ((my & 1) == 0)		/* Don't use halfpixel refinement */
-	    for (y = height; y; y--) 
-	    {
-	       memcpy (mcblock, rblock, width * sizeof (word_t));
-	       
-	       mcblock += width;
-	       rblock  += ref_width;
-	    }
-	 else				/* Halfpixel in y direction */
-	    for (y = height; y; y--) 
-	    {
-	       for (x = width; x; x--)
+         if ((my & 1) == 0)             /* Don't use halfpixel refinement */
+            for (y = height; y; y--)
+            {
+               memcpy (mcblock, rblock, width * sizeof (word_t));
+
+               mcblock += width;
+               rblock  += ref_width;
+            }
+         else                           /* Halfpixel in y direction */
+            for (y = height; y; y--)
+            {
+               for (x = width; x; x--)
 #ifdef HAVE_SIGNED_SHIFT
-		  *mcblock++ = (*rblock++ + *ryblock++) >> 1;
+                  *mcblock++ = (*rblock++ + *ryblock++) >> 1;
 #else /* not HAVE_SIGNED_SHIFT */
-		  *mcblock++ = (*rblock++ + *ryblock++) / 2;
+                  *mcblock++ = (*rblock++ + *ryblock++) / 2;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       rblock  += offset;
-	       ryblock += offset;
-	    }
+               rblock  += offset;
+               ryblock += offset;
+            }
       }
       else
       {
-	 if ((my & 1) == 0)		/* Halfpixel in x direction */
-	    for (y = height; y; y--) 
-	    {
-	       for (x = width; x; x--)
+         if ((my & 1) == 0)             /* Halfpixel in x direction */
+            for (y = height; y; y--)
+            {
+               for (x = width; x; x--)
 #ifdef HAVE_SIGNED_SHIFT
-		  *mcblock++ = (*rblock++ + *rxblock++) >> 1;
+                  *mcblock++ = (*rblock++ + *rxblock++) >> 1;
 #else /* not HAVE_SIGNED_SHIFT */
-		  *mcblock++ = (*rblock++ + *rxblock++) / 2;
+                  *mcblock++ = (*rblock++ + *rxblock++) / 2;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       rblock  += offset;
-	       rxblock += offset;
-	    }
-	 else				/* Halfpixel in xy direction */
-	    for (y = height; y; y--) 
-	    {
-	       for (x = width; x; x--)
+               rblock  += offset;
+               rxblock += offset;
+            }
+         else                           /* Halfpixel in xy direction */
+            for (y = height; y; y--)
+            {
+               for (x = width; x; x--)
 #ifdef HAVE_SIGNED_SHIFT
-		  *mcblock++ = (*rblock++ + *rxblock++
-				+ *ryblock++ + *rxyblock++) >> 2;
+                  *mcblock++ = (*rblock++ + *rxblock++
+                                + *ryblock++ + *rxyblock++) >> 2;
 #else /* not HAVE_SIGNED_SHIFT */
-		  *mcblock++ = (*rblock++ + *rxblock++
-				+ *ryblock++ + *rxyblock++) / 4;
+                  *mcblock++ = (*rblock++ + *rxblock++
+                                + *ryblock++ + *rxyblock++) / 4;
 #endif /* not HAVE_SIGNED_SHIFT */
-	       rblock   += offset;
-	       ryblock  += offset;
-	       rxblock  += offset;
-	       rxyblock += offset;
-	    }
+               rblock   += offset;
+               ryblock  += offset;
+               rxblock  += offset;
+               rxyblock += offset;
+            }
       }
    }
 }
diff --git a/converter/other/fiasco/codec/motion.h b/converter/other/fiasco/codec/motion.h
index 82d1f1ec..f913c65d 100644
--- a/converter/other/fiasco/codec/motion.h
+++ b/converter/other/fiasco/codec/motion.h
@@ -1,9 +1,9 @@
 /*
  *  motion.h
  *
- *  Written by:		Ullrich Hafner
- *			Michael Unger
- *		
+ *  Written by:         Ullrich Hafner
+ *                      Michael Unger
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -24,12 +24,12 @@
 
 void
 restore_mc (int enlarge_factor, image_t *image, const image_t *past,
-	    const image_t *future, const wfa_t *wfa);
+            const image_t *future, const wfa_t *wfa);
 void
 extract_mc_block (word_t *mcblock, unsigned width, unsigned height,
-		  const word_t *reference, unsigned ref_width,
-		  bool_t half_pixel, unsigned xo, unsigned yo,
-		  unsigned mx, unsigned my);
+                  const word_t *reference, unsigned ref_width,
+                  bool_t half_pixel, unsigned xo, unsigned yo,
+                  unsigned mx, unsigned my);
 
 #endif /* not _MOTION_H */
 
diff --git a/converter/other/fiasco/codec/mwfa.c b/converter/other/fiasco/codec/mwfa.c
index 0be08a4f..f83f2d00 100644
--- a/converter/other/fiasco/codec/mwfa.c
+++ b/converter/other/fiasco/codec/mwfa.c
@@ -1,9 +1,9 @@
 /*
- *  mwfa.c:		Initialization of MWFA coder
+ *  mwfa.c:             Initialization of MWFA coder
+ *
+ *  Written by:         Michael Unger
+ *                      Ullrich Hafner
  *
- *  Written by:		Michael Unger
- *			Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -38,33 +38,33 @@ static const unsigned local_range = 6;
 
 /*****************************************************************************
 
-				prototypes
-  
+                                prototypes
+
 *****************************************************************************/
 
 static void
 get_mcpe (word_t *mcpe, const image_t *original,
-	  unsigned x0, unsigned y0, unsigned width, unsigned height,
-	  const word_t *mcblock1, const word_t *mcblock2);
+          unsigned x0, unsigned y0, unsigned width, unsigned height,
+          const word_t *mcblock1, const word_t *mcblock2);
 static real_t
 mcpe_norm (const image_t *original, unsigned x0, unsigned y0, unsigned width,
-	   unsigned height, const word_t *mcblock1, const word_t *mcblock2);
-static real_t 
+           unsigned height, const word_t *mcblock1, const word_t *mcblock2);
+static real_t
 find_best_mv (real_t price, const image_t *original, const image_t *reference,
-	      unsigned x0, unsigned y0, unsigned width, unsigned height,
-	      real_t *bits, int *mx, int *my, const real_t *mc_norms,
-	      const wfa_info_t *wi, const motion_t *mt);
+              unsigned x0, unsigned y0, unsigned width, unsigned height,
+              real_t *bits, int *mx, int *my, const real_t *mc_norms,
+              const wfa_info_t *wi, const motion_t *mt);
 static real_t
 find_second_mv (real_t price, const image_t *original,
-		const image_t *reference, const word_t *mcblock1,
-		unsigned xr, unsigned yr, unsigned width, unsigned height,
-		real_t *bits, int *mx, int *my, const wfa_info_t *wi,
-		const motion_t *mt);
+                const image_t *reference, const word_t *mcblock1,
+                unsigned xr, unsigned yr, unsigned width, unsigned height,
+                real_t *bits, int *mx, int *my, const wfa_info_t *wi,
+                const motion_t *mt);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 motion_t *
@@ -75,32 +75,32 @@ alloc_motion (const wfa_info_t *wi)
  *  fill in default values specified by 'wi'.
  *
  *  Return value:
- *	pointer to the new option structure or NULL on error
+ *      pointer to the new option structure or NULL on error
  */
 {
-   int	     dx;			/* motion vector coordinate */
+   int       dx;                        /* motion vector coordinate */
    unsigned  level;
    unsigned range_size = wi->half_pixel
-			 ? square (wi->search_range)
-			 : square (2 * wi->search_range);
+                         ? square (wi->search_range)
+                         : square (2 * wi->search_range);
    motion_t *mt        = Calloc (1, sizeof (motion_t));
-   
+
    mt->original = NULL;
    mt->past     = NULL;
    mt->future   = NULL;
-   mt->xbits 	= Calloc (2 * wi->search_range, sizeof (real_t));
-   mt->ybits 	= Calloc (2 * wi->search_range, sizeof (real_t));
+   mt->xbits    = Calloc (2 * wi->search_range, sizeof (real_t));
+   mt->ybits    = Calloc (2 * wi->search_range, sizeof (real_t));
 
    for (dx = -wi->search_range; dx < (int) wi->search_range; dx++)
    {
       mt->xbits [dx + wi->search_range]
-	 = mt->ybits [dx + wi->search_range]
-	 = mv_code_table [dx + wi->search_range][1];
+         = mt->ybits [dx + wi->search_range]
+         = mv_code_table [dx + wi->search_range][1];
    }
-   
+
    mt->mc_forward_norms = Calloc (MAXLEVEL, sizeof (real_t *));
    mt->mc_backward_norms = Calloc (MAXLEVEL, sizeof (real_t *));
-   
+
    for (level = wi->p_min_level; level <= wi->p_max_level; level++)
    {
       mt->mc_forward_norms  [level] = Calloc (range_size, sizeof (real_t));
@@ -119,7 +119,7 @@ free_motion (motion_t *mt)
  *  No return value.
  *
  *  Side effects:
- *	structure 'motion' is discarded.
+ *      structure 'motion' is discarded.
  */
 {
    unsigned level;
@@ -129,9 +129,9 @@ free_motion (motion_t *mt)
    for (level = 0; level < MAXLEVEL; level++)
    {
       if (mt->mc_forward_norms [level])
-	 Free (mt->mc_forward_norms [level]);
+         Free (mt->mc_forward_norms [level]);
       if (mt->mc_backward_norms [level])
-	 Free (mt->mc_backward_norms [level]);
+         Free (mt->mc_backward_norms [level]);
    }
    Free (mt->mc_forward_norms);
    Free (mt->mc_backward_norms);
@@ -140,7 +140,7 @@ free_motion (motion_t *mt)
 
 void
 subtract_mc (image_t *image, const image_t *past, const image_t *future,
-	     const wfa_t *wfa)
+             const wfa_t *wfa)
 /*
  *  Subtract motion compensation from chrom channels of 'image'.
  *  Reference frames are given by 'past' and 'future'.
@@ -150,135 +150,135 @@ subtract_mc (image_t *image, const image_t *past, const image_t *future,
 {
    unsigned  state, label;
    word_t   *mcblock1 = Calloc (size_of_level (wfa->wfainfo->p_max_level),
-				sizeof (word_t));
+                                sizeof (word_t));
    word_t   *mcblock2 = Calloc (size_of_level (wfa->wfainfo->p_max_level),
-				sizeof (word_t));
+                                sizeof (word_t));
 
    for (state = wfa->basis_states; state < wfa->states; state++)
       for (label = 0; label < MAXLABELS; label++)
-	 if (wfa->mv_tree [state][label].type != NONE)
-	 {
-	    color_e  band;		/* current color band */
-	    unsigned width, height;	/* size of mcblock */
-	    unsigned offset;		/* remaining pixels in original */
-	    
-	    width  = width_of_level (wfa->level_of_state [state] - 1);
-	    height = height_of_level (wfa->level_of_state [state] - 1);
-	    offset = image->width - width;
-	    
-	    switch (wfa->mv_tree [state][label].type)
-	    {
-	       case FORWARD:
-		  for (band  = first_band (image->color) + 1;
-		       band <= last_band (image->color); band++)
-		  {
-		     unsigned  y;	/* row of block */
-		     word_t   *mc1;	/* pixel in MC block 1 */
-		     word_t   *orig;	/* pixel in original image */
-		     
-		     extract_mc_block (mcblock1, width, height,
-				       past->pixels [band], past->width,
-				       wfa->wfainfo->half_pixel,
-				       wfa->x [state][label],
-				       wfa->y [state][label],
-				       (wfa->mv_tree [state][label].fx / 2)
-				       * 2,
-				       (wfa->mv_tree [state][label].fy / 2)
-				       * 2);
-		     mc1  = mcblock1;
-		     orig = image->pixels [band] + wfa->x [state][label]
-			    + wfa->y [state][label] * image->width;
-		     
- 		     for (y = height; y; y--)
-		     {
-			unsigned x;	/* column of block */
-			
-			for (x = width; x; x--)
-			   *orig++ -= *mc1++;
-
-			orig += offset;
-		     }
-		  }
-		  break;
-	       case BACKWARD:
-		  for (band  = first_band (image->color) + 1;
-		       band <= last_band (image->color); band++)
-		  {
-		     unsigned  y;	/* row of block */
-		     word_t   *mc1;	/* pixel in MC block 1 */
-		     word_t   *orig;	/* pixel in original image */
-		     
-		     extract_mc_block (mcblock1, width, height,
-				       future->pixels [band], future->width,
-				       wfa->wfainfo->half_pixel,
-				       wfa->x [state][label],
-				       wfa->y [state][label],
-				       (wfa->mv_tree [state][label].bx / 2)
-				       * 2,
-				       (wfa->mv_tree [state][label].by / 2)
-				       * 2);
-		     mc1  = mcblock1;
-		     orig = image->pixels [band] + wfa->x [state][label]
-			    + wfa->y [state][label] * image->width;
-		     
-		     for (y = height; y; y--)
-		     {
-			unsigned x;	/* column of block */
-			
-			for (x = width; x; x--)
-			   *orig++ -= *mc1++;
-
-			orig += offset;
-		     }
-		  }
-		  break;
-	       case INTERPOLATED:
-		  for (band  = first_band (image->color) + 1;
-		       band <= last_band (image->color); band++)
-		  {
-		     unsigned  y;	/* row of block */
-		     word_t   *mc1;	/* pixel in MC block 1 */
-		     word_t   *mc2;	/* pixel in MC block 2 */
-		     word_t   *orig;	/* pixel in original image */
-		     
-		     extract_mc_block (mcblock1, width, height,
-				       past->pixels [band], past->width,
-				       wfa->wfainfo->half_pixel,
-				       wfa->x [state][label],
-				       wfa->y [state][label],
-				       (wfa->mv_tree[state][label].fx / 2)
-				       * 2,
-				       (wfa->mv_tree[state][label].fy / 2)
-				       * 2);
-		     extract_mc_block (mcblock2, width, height,
-				       future->pixels [band], future->width,
-				       wfa->wfainfo->half_pixel,
-				       wfa->x [state][label],
-				       wfa->y [state][label],
-				       (wfa->mv_tree[state][label].bx / 2)
-				       * 2,
-				       (wfa->mv_tree[state][label].by / 2)
-				       * 2);
-		     mc1  = mcblock1;
-		     mc2  = mcblock2;
-		     orig = image->pixels [band] + wfa->x [state][label]
-			    + wfa->y [state][label] * image->width;
-		     
-		     for (y = height; y; y--)
-		     {
-			unsigned x;	/* column of block */
-			
-			for (x = width; x; x--)
-			   *orig++ -= (*mc1++ + *mc2++) / 2;
-
-			orig += offset;
-		     }
-		  }
-		  break;
-	       default:
-		  break;
-	    }
-	 }
+         if (wfa->mv_tree [state][label].type != NONE)
+         {
+            color_e  band;              /* current color band */
+            unsigned width, height;     /* size of mcblock */
+            unsigned offset;            /* remaining pixels in original */
+
+            width  = width_of_level (wfa->level_of_state [state] - 1);
+            height = height_of_level (wfa->level_of_state [state] - 1);
+            offset = image->width - width;
+
+            switch (wfa->mv_tree [state][label].type)
+            {
+               case FORWARD:
+                  for (band  = first_band (image->color) + 1;
+                       band <= last_band (image->color); band++)
+                  {
+                     unsigned  y;       /* row of block */
+                     word_t   *mc1;     /* pixel in MC block 1 */
+                     word_t   *orig;    /* pixel in original image */
+
+                     extract_mc_block (mcblock1, width, height,
+                                       past->pixels [band], past->width,
+                                       wfa->wfainfo->half_pixel,
+                                       wfa->x [state][label],
+                                       wfa->y [state][label],
+                                       (wfa->mv_tree [state][label].fx / 2)
+                                       * 2,
+                                       (wfa->mv_tree [state][label].fy / 2)
+                                       * 2);
+                     mc1  = mcblock1;
+                     orig = image->pixels [band] + wfa->x [state][label]
+                            + wfa->y [state][label] * image->width;
+
+                     for (y = height; y; y--)
+                     {
+                        unsigned x;     /* column of block */
+
+                        for (x = width; x; x--)
+                           *orig++ -= *mc1++;
+
+                        orig += offset;
+                     }
+                  }
+                  break;
+               case BACKWARD:
+                  for (band  = first_band (image->color) + 1;
+                       band <= last_band (image->color); band++)
+                  {
+                     unsigned  y;       /* row of block */
+                     word_t   *mc1;     /* pixel in MC block 1 */
+                     word_t   *orig;    /* pixel in original image */
+
+                     extract_mc_block (mcblock1, width, height,
+                                       future->pixels [band], future->width,
+                                       wfa->wfainfo->half_pixel,
+                                       wfa->x [state][label],
+                                       wfa->y [state][label],
+                                       (wfa->mv_tree [state][label].bx / 2)
+                                       * 2,
+                                       (wfa->mv_tree [state][label].by / 2)
+                                       * 2);
+                     mc1  = mcblock1;
+                     orig = image->pixels [band] + wfa->x [state][label]
+                            + wfa->y [state][label] * image->width;
+
+                     for (y = height; y; y--)
+                     {
+                        unsigned x;     /* column of block */
+
+                        for (x = width; x; x--)
+                           *orig++ -= *mc1++;
+
+                        orig += offset;
+                     }
+                  }
+                  break;
+               case INTERPOLATED:
+                  for (band  = first_band (image->color) + 1;
+                       band <= last_band (image->color); band++)
+                  {
+                     unsigned  y;       /* row of block */
+                     word_t   *mc1;     /* pixel in MC block 1 */
+                     word_t   *mc2;     /* pixel in MC block 2 */
+                     word_t   *orig;    /* pixel in original image */
+
+                     extract_mc_block (mcblock1, width, height,
+                                       past->pixels [band], past->width,
+                                       wfa->wfainfo->half_pixel,
+                                       wfa->x [state][label],
+                                       wfa->y [state][label],
+                                       (wfa->mv_tree[state][label].fx / 2)
+                                       * 2,
+                                       (wfa->mv_tree[state][label].fy / 2)
+                                       * 2);
+                     extract_mc_block (mcblock2, width, height,
+                                       future->pixels [band], future->width,
+                                       wfa->wfainfo->half_pixel,
+                                       wfa->x [state][label],
+                                       wfa->y [state][label],
+                                       (wfa->mv_tree[state][label].bx / 2)
+                                       * 2,
+                                       (wfa->mv_tree[state][label].by / 2)
+                                       * 2);
+                     mc1  = mcblock1;
+                     mc2  = mcblock2;
+                     orig = image->pixels [band] + wfa->x [state][label]
+                            + wfa->y [state][label] * image->width;
+
+                     for (y = height; y; y--)
+                     {
+                        unsigned x;     /* column of block */
+
+                        for (x = width; x; x--)
+                           *orig++ -= (*mc1++ + *mc2++) / 2;
+
+                        orig += offset;
+                     }
+                  }
+                  break;
+               default:
+                  break;
+            }
+         }
 
    Free (mcblock1);
    Free (mcblock2);
@@ -286,7 +286,7 @@ subtract_mc (image_t *image, const image_t *past, const image_t *future,
 
 void
 find_P_frame_mc (word_t *mcpe, real_t price, range_t *range,
-		 const wfa_info_t *wi, const motion_t *mt)
+                 const wfa_info_t *wi, const motion_t *mt)
 /*
  *  Determine best motion vector for P-frame.
  *
@@ -301,7 +301,7 @@ find_P_frame_mc (word_t *mcpe, real_t price, range_t *range,
    unsigned  width   = width_of_level (range->level);
    unsigned  height  = height_of_level (range->level);
    word_t   *mcblock = Calloc (width * height, sizeof (word_t));
-   
+
    range->mv_tree_bits = 1;
    range->mv.type      = FORWARD;
 
@@ -309,24 +309,24 @@ find_P_frame_mc (word_t *mcpe, real_t price, range_t *range,
     *  Find best matching forward prediction
     */
    find_best_mv (price, mt->original, mt->past, range->x, range->y,
-		 width, height, &range->mv_coord_bits, &range->mv.fx,
-		 &range->mv.fy, mt->mc_forward_norms [range->level], wi, mt);
+                 width, height, &range->mv_coord_bits, &range->mv.fx,
+                 &range->mv.fy, mt->mc_forward_norms [range->level], wi, mt);
 
    /*
     *  Compute MCPE
     */
    extract_mc_block (mcblock, width, height, mt->past->pixels [GRAY],
-		     mt->past->width, wi->half_pixel, range->x, range->y,
-		     range->mv.fx, range->mv.fy);
+                     mt->past->width, wi->half_pixel, range->x, range->y,
+                     range->mv.fx, range->mv.fy);
    get_mcpe (mcpe, mt->original, range->x, range->y, width, height,
-	     mcblock, NULL);
+             mcblock, NULL);
 
    Free (mcblock);
 }
 
 void
 find_B_frame_mc (word_t *mcpe, real_t price, range_t *range,
-		 const wfa_info_t *wi, const motion_t *mt)
+                 const wfa_info_t *wi, const motion_t *mt)
 /*
  *  Determines best motion compensation for B-frame.
  *  Steps:
@@ -338,104 +338,104 @@ find_B_frame_mc (word_t *mcpe, real_t price, range_t *range,
  *    FORWARD      000
  *    BACKWARD     001
  *    INTERPOLATED  01
- *  
+ *
  *  Return values:
  *            range->mvt_bits  (# of mv-tree bits)
  *            range->mvxybits  (# of bits for vector components)
  *            mt->mcpe         (MCPE in scan-order)
  */
 {
-   mc_type_e  mctype;			/* type of motion compensation */
-   real_t     forward_costs;		/* costs of FORWARD mc */
-   real_t     backward_costs;		/* costs of BACKWARD mc */
-   real_t     interp_costs;		/* costs of INTERPOLATED mc */
-   real_t     forward_bits;		/* bits for FORWARD mc */
-   real_t     backward_bits;		/* bits for BACKWARD mc */
-   real_t     interp_bits;		/* bits for INTERPOLATED mc */
-   int	      fx,  fy;			/* coordinates FORWARD mc */
-   int	      bx,  by;			/* coordinates BACKWARD mc */
-   int	      ifx, ify;			/* coordinates forw. INTERPOLATED mc */
-   int	      ibx, iby;			/* coordinates back. INTERPOLATED mc */
+   mc_type_e  mctype;                   /* type of motion compensation */
+   real_t     forward_costs;            /* costs of FORWARD mc */
+   real_t     backward_costs;           /* costs of BACKWARD mc */
+   real_t     interp_costs;             /* costs of INTERPOLATED mc */
+   real_t     forward_bits;             /* bits for FORWARD mc */
+   real_t     backward_bits;            /* bits for BACKWARD mc */
+   real_t     interp_bits;              /* bits for INTERPOLATED mc */
+   int        fx,  fy;                  /* coordinates FORWARD mc */
+   int        bx,  by;                  /* coordinates BACKWARD mc */
+   int        ifx, ify;                 /* coordinates forw. INTERPOLATED mc */
+   int        ibx, iby;                 /* coordinates back. INTERPOLATED mc */
    unsigned   width    = width_of_level (range->level);
    unsigned   height   = height_of_level (range->level);
    word_t    *mcblock1 = Calloc (width * height, sizeof (word_t));
    word_t    *mcblock2 = Calloc (width * height, sizeof (word_t));
-   
+
    /*
     *  Forward interpolation: use past frame as reference
     */
    forward_costs = find_best_mv (price, mt->original, mt->past,
-				 range->x, range->y, width, height,
-				 &forward_bits, &fx, &fy,
-				 mt->mc_forward_norms [range->level], wi, mt)
-		   + 3 * price; /* code 000 */
+                                 range->x, range->y, width, height,
+                                 &forward_bits, &fx, &fy,
+                                 mt->mc_forward_norms [range->level], wi, mt)
+                   + 3 * price; /* code 000 */
 
    /*
     *  Backward interpolation: use future frame as reference
     */
    backward_costs = find_best_mv (price, mt->original, mt->future,
-				  range->x, range->y, width, height,
-				  &backward_bits, &bx, &by,
-				  mt->mc_backward_norms [range->level], wi, mt)
-		    + 3 * price; /* code 001 */
+                                  range->x, range->y, width, height,
+                                  &backward_bits, &bx, &by,
+                                  mt->mc_backward_norms [range->level], wi, mt)
+                    + 3 * price; /* code 001 */
 
    /*
     *  Bidirectional interpolation: use both past and future frame as reference
     */
-   if (wi->cross_B_search) 
+   if (wi->cross_B_search)
    {
-      real_t icosts1;			/* costs interpolation alternative 1 */
-      real_t icosts2;			/* costs interpolation alternative 2 */
-      real_t ibackward_bits;		/* additional bits alternative 1 */
-      real_t iforward_bits;		/* additional bits alternative 1 */
-      
+      real_t icosts1;                   /* costs interpolation alternative 1 */
+      real_t icosts2;                   /* costs interpolation alternative 2 */
+      real_t ibackward_bits;            /* additional bits alternative 1 */
+      real_t iforward_bits;             /* additional bits alternative 1 */
+
       /*
        *  Alternative 1: keep forward mv and vary backward mv locally
        */
       extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY],
-			mt->past->width, wi->half_pixel,
-			range->x, range->y, fx, fy);
+                        mt->past->width, wi->half_pixel,
+                        range->x, range->y, fx, fy);
 
-      ibx = bx;				/* start with backward coordinates */
+      ibx = bx;                         /* start with backward coordinates */
       iby = by;
       icosts1 = find_second_mv (price, mt->original, mt->future,
-				mcblock1, range->x, range->y, width, height,
-				&ibackward_bits, &ibx, &iby, wi, mt)
-		+ (forward_bits + 2) * price; /* code 01 */
+                                mcblock1, range->x, range->y, width, height,
+                                &ibackward_bits, &ibx, &iby, wi, mt)
+                + (forward_bits + 2) * price; /* code 01 */
 
       /*
        *  Alternative 2: Keep backward mv and vary forward mv locally
        */
       extract_mc_block (mcblock1, width, height, mt->future->pixels [GRAY],
-			mt->future->width, wi->half_pixel,
-			range->x, range->y, bx, by);
+                        mt->future->width, wi->half_pixel,
+                        range->x, range->y, bx, by);
 
       ifx = fx;
       ify = fy;
       icosts2 = find_second_mv (price, mt->original, mt->past,
-				mcblock1, range->x, range->y, width, height,
-				&iforward_bits, &ifx, &ify, wi, mt)
-		+ (backward_bits + 2) * price; /* code 01 */
-      
+                                mcblock1, range->x, range->y, width, height,
+                                &iforward_bits, &ifx, &ify, wi, mt)
+                + (backward_bits + 2) * price; /* code 01 */
+
       /*
        *  Choose best alternative
        */
       if (icosts1 < icosts2)
       {
-	 ifx 	      = fx;
-	 ify 	      = fy;
-	 interp_bits  = forward_bits + ibackward_bits;
-	 interp_costs = icosts1;
+         ifx          = fx;
+         ify          = fy;
+         interp_bits  = forward_bits + ibackward_bits;
+         interp_costs = icosts1;
       }
       else
       {
-	 ibx 	      = bx;
-	 iby 	      = by;
-	 interp_bits  = iforward_bits + backward_bits;
-	 interp_costs = icosts2;
+         ibx          = bx;
+         iby          = by;
+         interp_bits  = iforward_bits + backward_bits;
+         interp_costs = icosts2;
       }
    }
-   else					/* local exhaustive search */
+   else                                 /* local exhaustive search */
    {
       /*
        *  Keep forward and backward mv because of time constraints
@@ -448,14 +448,14 @@ find_B_frame_mc (word_t *mcpe, real_t price, range_t *range,
       interp_bits = forward_bits + backward_bits;
 
       extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY],
-			mt->past->width, wi->half_pixel,
-			range->x, range->y, fx, fy);
+                        mt->past->width, wi->half_pixel,
+                        range->x, range->y, fx, fy);
       extract_mc_block (mcblock2, width, height, mt->future->pixels [GRAY],
-			mt->future->width, wi->half_pixel,
-			range->x, range->y, bx, by);
+                        mt->future->width, wi->half_pixel,
+                        range->x, range->y, bx, by);
       interp_costs = mcpe_norm (mt->original, range->x, range->y,
-				width, height, mcblock1, mcblock2)
-		     + (interp_bits + 2) * price; /* code 01 */
+                                width, height, mcblock1, mcblock2)
+                     + (interp_bits + 2) * price; /* code 01 */
    }
 
    /*
@@ -464,63 +464,63 @@ find_B_frame_mc (word_t *mcpe, real_t price, range_t *range,
    if (forward_costs <= interp_costs)
    {
       if (forward_costs <= backward_costs)
-	 mctype = FORWARD;
+         mctype = FORWARD;
       else
-	 mctype = BACKWARD;
+         mctype = BACKWARD;
    }
    else
    {
       if (backward_costs <= interp_costs)
-	 mctype = BACKWARD;
+         mctype = BACKWARD;
       else
-	 mctype = INTERPOLATED;
+         mctype = INTERPOLATED;
    }
 
    switch (mctype)
    {
       case FORWARD:
-	 range->mv_tree_bits  = 3;
-	 range->mv_coord_bits = forward_bits;
-	 range->mv.type       = FORWARD;
-	 range->mv.fx         = fx;
-	 range->mv.fy         = fy;
-	 extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY],
-			   mt->past->width, wi->half_pixel,
-			   range->x, range->y, range->mv.fx, range->mv.fy);
-	 get_mcpe (mcpe, mt->original, range->x, range->y, width, height,
-		   mcblock1, NULL);
-	 break;
+         range->mv_tree_bits  = 3;
+         range->mv_coord_bits = forward_bits;
+         range->mv.type       = FORWARD;
+         range->mv.fx         = fx;
+         range->mv.fy         = fy;
+         extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY],
+                           mt->past->width, wi->half_pixel,
+                           range->x, range->y, range->mv.fx, range->mv.fy);
+         get_mcpe (mcpe, mt->original, range->x, range->y, width, height,
+                   mcblock1, NULL);
+         break;
       case BACKWARD:
-	 range->mv_tree_bits  = 3;
-	 range->mv_coord_bits = backward_bits;
-	 range->mv.type       = BACKWARD;
-	 range->mv.bx         = bx;
-	 range->mv.by         = by;
-	 extract_mc_block (mcblock1, width, height, mt->future->pixels [GRAY],
-			   mt->future->width, wi->half_pixel,
-			   range->x, range->y, range->mv.bx, range->mv.by);
-	 get_mcpe (mcpe, mt->original, range->x, range->y, width, height,
-		   mcblock1, NULL);
-	 break;
+         range->mv_tree_bits  = 3;
+         range->mv_coord_bits = backward_bits;
+         range->mv.type       = BACKWARD;
+         range->mv.bx         = bx;
+         range->mv.by         = by;
+         extract_mc_block (mcblock1, width, height, mt->future->pixels [GRAY],
+                           mt->future->width, wi->half_pixel,
+                           range->x, range->y, range->mv.bx, range->mv.by);
+         get_mcpe (mcpe, mt->original, range->x, range->y, width, height,
+                   mcblock1, NULL);
+         break;
       case INTERPOLATED:
-	 range->mv_tree_bits  = 2;
-	 range->mv_coord_bits = interp_bits;
-	 range->mv.type       = INTERPOLATED;
-	 range->mv.fx         = ifx;
-	 range->mv.fy         = ify;
-	 range->mv.bx         = ibx;
-	 range->mv.by         = iby;
-	 extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY],
-			   mt->past->width, wi->half_pixel,
-			   range->x, range->y, range->mv.fx, range->mv.fy);
-	 extract_mc_block (mcblock2, width, height, mt->future->pixels [GRAY],
-			   mt->future->width, wi->half_pixel,
-			   range->x, range->y, range->mv.bx, range->mv.by);
-	 get_mcpe (mcpe, mt->original, range->x, range->y, width, height,
-		   mcblock1, mcblock2);
-	 break;
+         range->mv_tree_bits  = 2;
+         range->mv_coord_bits = interp_bits;
+         range->mv.type       = INTERPOLATED;
+         range->mv.fx         = ifx;
+         range->mv.fy         = ify;
+         range->mv.bx         = ibx;
+         range->mv.by         = iby;
+         extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY],
+                           mt->past->width, wi->half_pixel,
+                           range->x, range->y, range->mv.fx, range->mv.fy);
+         extract_mc_block (mcblock2, width, height, mt->future->pixels [GRAY],
+                           mt->future->width, wi->half_pixel,
+                           range->x, range->y, range->mv.bx, range->mv.by);
+         get_mcpe (mcpe, mt->original, range->x, range->y, width, height,
+                   mcblock1, mcblock2);
+         break;
       default:
-	 break;
+         break;
    }
 
    Free (mcblock1);
@@ -529,7 +529,7 @@ find_B_frame_mc (word_t *mcpe, real_t price, range_t *range,
 
 void
 fill_norms_table (unsigned x0, unsigned y0, unsigned level,
-		  const wfa_info_t *wi, motion_t *mt)
+                  const wfa_info_t *wi, motion_t *mt)
 /*
  *  Compute norms of difference images for all possible displacements
  *  in 'mc_forward_norm' and 'mc_backward_norm'.
@@ -537,50 +537,50 @@ fill_norms_table (unsigned x0, unsigned y0, unsigned level,
  *  No return value.
  *
  *  Side effects:
- *	'mt->mc_backward_norms' are computed
- *	'mt->mc_forward_norms' are computed 
+ *      'mt->mc_backward_norms' are computed
+ *      'mt->mc_forward_norms' are computed
  */
 {
-   int	     mx, my;			/* coordinates of motion vector */
-   unsigned  sr;			/* mv search range +-'sr' pixels */
-   unsigned  index   = 0;		/* index of motion vector */
+   int       mx, my;                    /* coordinates of motion vector */
+   unsigned  sr;                        /* mv search range +-'sr' pixels */
+   unsigned  index   = 0;               /* index of motion vector */
    unsigned  width   = width_of_level (level);
    unsigned  height  = height_of_level (level);
    word_t   *mcblock = Calloc (width * height, sizeof (word_t));
 
    sr = wi->half_pixel ? wi->search_range / 2 :  wi->search_range;
-   
+
    for (my = -sr; my < (int) sr; my++)
       for (mx = -sr; mx < (int) sr; mx++, index++)
       {
-	  if ((int) x0 + mx < 0 ||	/* block outside visible area */
-	      x0 + mx + width > mt->original->width || 
-	      (int) y0 + my < 0 ||
-	      y0 + my + height > mt->original->height)
-	  {
-	     mt->mc_forward_norms [level][index]  = 0.0;
-	     mt->mc_backward_norms [level][index] = 0.0;
-	  }
-	  else
-	  {
-	     extract_mc_block (mcblock, width, height, mt->past->pixels [GRAY],
-			       mt->past->width, wi->half_pixel,
-			       x0, y0, mx, my);
-	     mt->mc_forward_norms [level][index]
-		= mcpe_norm (mt->original, x0, y0, width, height,
-			     mcblock, NULL);
-
-	     if (mt->frame_type == B_FRAME)
-	     {
-		extract_mc_block (mcblock, width, height,
-				  mt->future->pixels [GRAY],
-				  mt->future->width, wi->half_pixel,
-				  x0, y0, mx, my);
-		mt->mc_backward_norms[level][index]
-		   = mcpe_norm (mt->original, x0, y0, width, height,
-				mcblock, NULL); 
-	     }
-	  }
+          if ((int) x0 + mx < 0 ||      /* block outside visible area */
+              x0 + mx + width > mt->original->width ||
+              (int) y0 + my < 0 ||
+              y0 + my + height > mt->original->height)
+          {
+             mt->mc_forward_norms [level][index]  = 0.0;
+             mt->mc_backward_norms [level][index] = 0.0;
+          }
+          else
+          {
+             extract_mc_block (mcblock, width, height, mt->past->pixels [GRAY],
+                               mt->past->width, wi->half_pixel,
+                               x0, y0, mx, my);
+             mt->mc_forward_norms [level][index]
+                = mcpe_norm (mt->original, x0, y0, width, height,
+                             mcblock, NULL);
+
+             if (mt->frame_type == B_FRAME)
+             {
+                extract_mc_block (mcblock, width, height,
+                                  mt->future->pixels [GRAY],
+                                  mt->future->width, wi->half_pixel,
+                                  x0, y0, mx, my);
+                mt->mc_backward_norms[level][index]
+                   = mcpe_norm (mt->original, x0, y0, width, height,
+                                mcblock, NULL);
+             }
+          }
        }
 
    Free (mcblock);
@@ -588,14 +588,14 @@ fill_norms_table (unsigned x0, unsigned y0, unsigned level,
 
 /*****************************************************************************
 
-				private code
-  
+                                private code
+
 *****************************************************************************/
 
 static void
 get_mcpe (word_t *mcpe, const image_t *original, unsigned x0, unsigned y0,
-	  unsigned width, unsigned height, const word_t *mcblock1,
-	  const word_t *mcblock2)
+          unsigned width, unsigned height, const word_t *mcblock1,
+          const word_t *mcblock2)
 /*
  *  Compute MCPE image 'original' - reference. The reference is either
  *  composed of 'mcblock1' or of ('mcblock1' + 'mcblock2') / 2 (if
@@ -605,44 +605,44 @@ get_mcpe (word_t *mcpe, const image_t *original, unsigned x0, unsigned y0,
  *  No return value.
  *
  *  Side effects:
- *	'mcpe []' is filled with the delta image
+ *      'mcpe []' is filled with the delta image
  */
 {
-   const word_t	*oblock;		/* pointer to original image */
+   const word_t *oblock;                /* pointer to original image */
 
    assert (mcpe);
-   
+
    oblock = original->pixels [GRAY] + y0 * original->width + x0;
 
-   if (mcblock2 != NULL)		/* interpolated prediction */
+   if (mcblock2 != NULL)                /* interpolated prediction */
    {
-      unsigned x, y;			/* current coordinates */
-      
-      for (y = height; y; y--) 
+      unsigned x, y;                    /* current coordinates */
+
+      for (y = height; y; y--)
       {
-	 for (x = width; x; x--)
-	    *mcpe++ = *oblock++ - (*mcblock1++ + *mcblock2++) / 2;
+         for (x = width; x; x--)
+            *mcpe++ = *oblock++ - (*mcblock1++ + *mcblock2++) / 2;
 
-	 oblock += original->width - width;
+         oblock += original->width - width;
       }
    }
-   else					/* forward or backward prediction */
+   else                                 /* forward or backward prediction */
    {
-      unsigned x, y;			/* current coordinates */
-      
-      for (y = height; y; y--) 
+      unsigned x, y;                    /* current coordinates */
+
+      for (y = height; y; y--)
       {
-	 for (x = width; x; x--)
-	    *mcpe++ = *oblock++ - *mcblock1++;
-      
-	 oblock += original->width - width;
+         for (x = width; x; x--)
+            *mcpe++ = *oblock++ - *mcblock1++;
+
+         oblock += original->width - width;
       }
    }
 }
 
 static real_t
 mcpe_norm (const image_t *original, unsigned x0, unsigned y0, unsigned width,
-	   unsigned height, const word_t *mcblock1, const word_t *mcblock2)
+           unsigned height, const word_t *mcblock1, const word_t *mcblock2)
 /*
  *  Compute norm of motion compensation prediction error.
  *  Coordinates of 'original' block are given by ('x0', 'y0')
@@ -650,79 +650,79 @@ mcpe_norm (const image_t *original, unsigned x0, unsigned y0, unsigned width,
  *  Reference blocks are stored in 'mcimage1' and 'mcimage2'.
  *
  *  Return value:
- *	square of norm of difference image
+ *      square of norm of difference image
  */
 {
    unsigned  n;
    real_t    norm = 0;
    word_t   *mcpe = Calloc (width * height, sizeof (word_t));
    word_t   *ptr  = mcpe;
-   
+
    get_mcpe (mcpe, original, x0, y0, width, height, mcblock1, mcblock2);
 
-   for (n = height * width; n; n--, ptr++) 
+   for (n = height * width; n; n--, ptr++)
       norm += square (*ptr / 16);
-   
+
    Free (mcpe);
-   
+
    return norm;
 }
 
-static real_t 
+static real_t
 find_best_mv (real_t price, const image_t *original, const image_t *reference,
-	      unsigned x0, unsigned y0, unsigned width, unsigned height,
-	      real_t *bits, int *mx, int *my, const real_t *mc_norms,
-	      const wfa_info_t *wi, const motion_t *mt)
+              unsigned x0, unsigned y0, unsigned width, unsigned height,
+              real_t *bits, int *mx, int *my, const real_t *mc_norms,
+              const wfa_info_t *wi, const motion_t *mt)
 /*
  *  Find best matching motion vector in image 'reference' to predict
  *  the block ('x0', 'y0') of size 'width'x'height in image 'original'.
  *
  *  Return values:
- *	prediction costs
+ *      prediction costs
  *
  *  Side effects:
- *	'mx', 'my'		coordinates of motion vector
- *	'bits'			number of bits to encode mv
+ *      'mx', 'my'              coordinates of motion vector
+ *      'bits'                  number of bits to encode mv
  */
 {
-   unsigned sr;				/* mv search range +/- 'sr' pixels */
-   unsigned index;			/* index of motion vector */
-   int 	    x, y;			/* coordinates of motion vector */
-   real_t   costs;			/* costs arising if mv is chosen */
-   real_t   mincosts = MAXCOSTS;	/* best costs so far  */
-   unsigned bitshift;			/* half_pixel coordinates multiplier */
-   
+   unsigned sr;                         /* mv search range +/- 'sr' pixels */
+   unsigned index;                      /* index of motion vector */
+   int      x, y;                       /* coordinates of motion vector */
+   real_t   costs;                      /* costs arising if mv is chosen */
+   real_t   mincosts = MAXCOSTS;        /* best costs so far  */
+   unsigned bitshift;                   /* half_pixel coordinates multiplier */
+
    *mx = *my = 0;
 
    /*
     *  Find best fitting motion vector:
     *  Use exhaustive search in the interval x,y +- sr (no halfpixel accuracy)
-    *					  or x,y +- sr/2  (halfpixel accuracy)
+    *                                     or x,y +- sr/2  (halfpixel accuracy)
     */
-   sr 	    = wi->half_pixel ? wi->search_range / 2 :  wi->search_range;
-   bitshift = (wi->half_pixel ? 2 : 1);	/* bit0 reserved for halfpixel pred. */
-   
+   sr       = wi->half_pixel ? wi->search_range / 2 :  wi->search_range;
+   bitshift = (wi->half_pixel ? 2 : 1); /* bit0 reserved for halfpixel pred. */
+
    for (index = 0, y = -sr; y < (int) sr; y++)
       for (x = -sr; x < (int) sr; x++, index++)
-	 if ((int) x0 + x >= 0 && (int) y0 + y >= 0 &&	
-	     x0 + x + width  <= original->width && 
-	     y0 + y + height <= original->height)
-	 {
-	    /*
-	     *  Block is inside visible area.
-	     *  Compare current costs with 'mincosts'
-	     */
-	    costs = mc_norms [index]
-		    + (mt->xbits [(x + sr) * bitshift]
-		       + mt->ybits [(y + sr) * bitshift]) * price;
-
-	     if (costs < mincosts)
-	     {
-		mincosts = costs;
-		*mx      = x * bitshift;
-		*my      = y * bitshift;
-	     }
-	 }
+         if ((int) x0 + x >= 0 && (int) y0 + y >= 0 &&
+             x0 + x + width  <= original->width &&
+             y0 + y + height <= original->height)
+         {
+            /*
+             *  Block is inside visible area.
+             *  Compare current costs with 'mincosts'
+             */
+            costs = mc_norms [index]
+                    + (mt->xbits [(x + sr) * bitshift]
+                       + mt->ybits [(y + sr) * bitshift]) * price;
+
+             if (costs < mincosts)
+             {
+                mincosts = costs;
+                *mx      = x * bitshift;
+                *my      = y * bitshift;
+             }
+         }
 
    /*
     *  Halfpixel prediction:
@@ -730,53 +730,53 @@ find_best_mv (real_t price, const image_t *original, const image_t *reference,
     */
    if (wi->half_pixel)
    {
-      int	rx, ry;			/* halfpixel refinement */
-      unsigned	bestrx, bestry;		/* coordinates of best mv */
+      int       rx, ry;                 /* halfpixel refinement */
+      unsigned  bestrx, bestry;         /* coordinates of best mv */
       word_t   *mcblock = Calloc (width * height, sizeof (word_t));
-      
+
       bestrx = bestry = 0;
       for (rx = -1; rx <= 1; rx++)
-	 for (ry = -1; ry <= 1; ry++)
-	 {
-	    /*
-	     *  Check if the new motion vector is in allowed area
-	     */
-	    if (rx == 0 && ry == 0)	/* already tested */
-	       continue;
-	    if ((int) x0 + (*mx / 2) + rx < 0 || /* outside visible area */
-		x0 + (*mx / 2) + rx + width > original->width ||
-		(int) y0 + (*my / 2) + ry < 0 || 
-		y0 + (*my / 2) + ry + height > original->height)
-	       continue;
-	    if (*mx + rx < (int) -sr || *mx + rx >= (int) sr ||
-		*my + ry < (int) -sr || *my + ry >= (int) sr) 
-	       continue;		/* out of bounds */
-
-	    /*
-	     *  Compute costs of new motion compensation
-	     */
-	    extract_mc_block (mcblock, width, height,
-			      reference->pixels [GRAY],
-			      reference->width, wi->half_pixel,
-			      x0, y0, *mx + rx, *my + ry);
-	    costs = mcpe_norm (mt->original, x0, y0, width, height, mcblock,
-			       NULL)
-		    + (mt->xbits [*mx + rx + sr * bitshift]
-		       + mt->ybits [*my + ry + sr * bitshift]) * price;
-	    if (costs < mincosts)
-	    {
-	       bestrx   = rx;
-	       bestry   = ry;
-	       mincosts = costs;
-	    }
-	 }
+         for (ry = -1; ry <= 1; ry++)
+         {
+            /*
+             *  Check if the new motion vector is in allowed area
+             */
+            if (rx == 0 && ry == 0)     /* already tested */
+               continue;
+            if ((int) x0 + (*mx / 2) + rx < 0 || /* outside visible area */
+                x0 + (*mx / 2) + rx + width > original->width ||
+                (int) y0 + (*my / 2) + ry < 0 ||
+                y0 + (*my / 2) + ry + height > original->height)
+               continue;
+            if (*mx + rx < (int) -sr || *mx + rx >= (int) sr ||
+                *my + ry < (int) -sr || *my + ry >= (int) sr)
+               continue;                /* out of bounds */
+
+            /*
+             *  Compute costs of new motion compensation
+             */
+            extract_mc_block (mcblock, width, height,
+                              reference->pixels [GRAY],
+                              reference->width, wi->half_pixel,
+                              x0, y0, *mx + rx, *my + ry);
+            costs = mcpe_norm (mt->original, x0, y0, width, height, mcblock,
+                               NULL)
+                    + (mt->xbits [*mx + rx + sr * bitshift]
+                       + mt->ybits [*my + ry + sr * bitshift]) * price;
+            if (costs < mincosts)
+            {
+               bestrx   = rx;
+               bestry   = ry;
+               mincosts = costs;
+            }
+         }
 
       *mx += bestrx;
       *my += bestry;
 
       Free (mcblock);
    } /* halfpixel */
-	     
+
    *bits = mt->xbits [*mx + sr * bitshift] + mt->ybits [*my + sr * bitshift];
 
    return mincosts;
@@ -784,28 +784,28 @@ find_best_mv (real_t price, const image_t *original, const image_t *reference,
 
 static real_t
 find_second_mv (real_t price, const image_t *original,
-		const image_t *reference, const word_t *mcblock1,
-		unsigned xr, unsigned yr, unsigned width, unsigned height,
-		real_t *bits, int *mx, int *my, const wfa_info_t *wi,
-		const motion_t *mt)
+                const image_t *reference, const word_t *mcblock1,
+                unsigned xr, unsigned yr, unsigned width, unsigned height,
+                real_t *bits, int *mx, int *my, const wfa_info_t *wi,
+                const motion_t *mt)
 /*
  *  Search local area (*mx,*my) for best additional mv.
  *  Overwrite mt->tmpblock.
  *  TODO check sr = search_range
  *
  *  Return values:
- *	prediction costs
+ *      prediction costs
  *
  *  Side effects:
- *	'mx','my'	coordinates of mv
- *      'bits'		number of bits to encode mv
+ *      'mx','my'       coordinates of mv
+ *      'bits'          number of bits to encode mv
  */
 {
-   real_t    mincosts = MAXCOSTS;	/* best costs so far  */
-   unsigned  sr;			/* MV search range +/- 'sr' pixels */
-   int       x, y;			/* coordinates of motion vector */
-   int       y0, y1, x0, x1;		/* start/end coord. of search range */
-   unsigned  bitshift;			/* half_pixel coordinates multiplier */
+   real_t    mincosts = MAXCOSTS;       /* best costs so far  */
+   unsigned  sr;                        /* MV search range +/- 'sr' pixels */
+   int       x, y;                      /* coordinates of motion vector */
+   int       y0, y1, x0, x1;            /* start/end coord. of search range */
+   unsigned  bitshift;                  /* half_pixel coordinates multiplier */
    word_t   *mcblock2 = Calloc (width * height, sizeof (word_t));
 
    sr = wi->search_range;
@@ -817,40 +817,40 @@ find_second_mv (real_t price, const image_t *original,
 
    *mx = *my = 0;
 
-   bitshift = (wi->half_pixel ? 2 : 1);	/* bit0 reserved for halfpixel pred. */
+   bitshift = (wi->half_pixel ? 2 : 1); /* bit0 reserved for halfpixel pred. */
+
 
-   
    for (y = y0; y < y1; y++)
       for (x = x0; x < x1; x++)
       {
-	 real_t costs;			/* costs arising if mv is chosen */
-	 
-	 /*
-	  *  Test each mv ('x', 'y') in the given search range:
-	  *  Get the new motion compensation image from 'reference' and compute
-	  *  the norm of the motion compensation prediction error
-	  *  'original' - 0.5 * ('firstmc' + 'reference')
-	  */
-	 if ((int) (xr * bitshift) + x < 0 ||	/* outside visible area */
-	     xr * bitshift + x > (original->width - width) * bitshift ||
-	     (int) (yr * bitshift) + y < 0 ||
-	     yr * bitshift + y > (original->height - height) * bitshift)
-	    continue;
-	 
-	 extract_mc_block (mcblock2, width, height,
-			   reference->pixels [GRAY], reference->width,
-			   wi->half_pixel, x0, y0, x, y);
-
-	 costs  = mcpe_norm (mt->original, x0, y0, width, height,
-			     mcblock1, mcblock2)
-		  + (mt->xbits [x + sr] + mt->ybits [y + sr]) * price;
-	 
-	 if (costs < mincosts)
-	 {
-	    mincosts = costs;
-	    *mx      = x;
-	    *my      = y;
-	 }
+         real_t costs;                  /* costs arising if mv is chosen */
+
+         /*
+          *  Test each mv ('x', 'y') in the given search range:
+          *  Get the new motion compensation image from 'reference' and compute
+          *  the norm of the motion compensation prediction error
+          *  'original' - 0.5 * ('firstmc' + 'reference')
+          */
+         if ((int) (xr * bitshift) + x < 0 ||   /* outside visible area */
+             xr * bitshift + x > (original->width - width) * bitshift ||
+             (int) (yr * bitshift) + y < 0 ||
+             yr * bitshift + y > (original->height - height) * bitshift)
+            continue;
+
+         extract_mc_block (mcblock2, width, height,
+                           reference->pixels [GRAY], reference->width,
+                           wi->half_pixel, x0, y0, x, y);
+
+         costs  = mcpe_norm (mt->original, x0, y0, width, height,
+                             mcblock1, mcblock2)
+                  + (mt->xbits [x + sr] + mt->ybits [y + sr]) * price;
+
+         if (costs < mincosts)
+         {
+            mincosts = costs;
+            *mx      = x;
+            *my      = y;
+         }
       }
 
    *bits = mt->xbits [*mx + sr] + mt->ybits [*my + sr];
diff --git a/converter/other/fiasco/codec/mwfa.h b/converter/other/fiasco/codec/mwfa.h
index 2c1e7c9f..1e35eef2 100644
--- a/converter/other/fiasco/codec/mwfa.h
+++ b/converter/other/fiasco/codec/mwfa.h
@@ -1,9 +1,9 @@
 /*
  *  mwfa.h
  *
- *  Written by:		Michael Unger
- *			Ullrich Hafner
- *		
+ *  Written by:         Michael Unger
+ *                      Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -25,16 +25,16 @@
 
 void
 fill_norms_table (unsigned x0, unsigned y0, unsigned level,
-		  const wfa_info_t *wi, motion_t *mt);
+                  const wfa_info_t *wi, motion_t *mt);
 void
 find_B_frame_mc (word_t *mcpe, real_t price, range_t *range,
-		 const wfa_info_t *wi, const motion_t *mt);
+                 const wfa_info_t *wi, const motion_t *mt);
 void
 find_P_frame_mc (word_t *mcpe, real_t price, range_t *range,
-		 const wfa_info_t *wi, const motion_t *mt);
+                 const wfa_info_t *wi, const motion_t *mt);
 void
 subtract_mc (image_t *image, const image_t *past, const image_t *future,
-	     const wfa_t *wfa);
+             const wfa_t *wfa);
 void
 free_motion (motion_t *mt);
 motion_t *
diff --git a/converter/other/fiasco/codec/options.c b/converter/other/fiasco/codec/options.c
index b9c64efd..8029a48e 100644
--- a/converter/other/fiasco/codec/options.c
+++ b/converter/other/fiasco/codec/options.c
@@ -1,8 +1,8 @@
 /*
- *  options.c:		FIASCO options handling
+ *  options.c:          FIASCO options handling
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -44,10 +44,10 @@ fiasco_c_options_new (void)
  *  fill in default values.
  *
  *  Return value:
- *	pointer to the new option structure
+ *      pointer to the new option structure
  */
 {
-   c_options_t 	      *options = calloc (1, sizeof (c_options_t));
+   c_options_t        *options = calloc (1, sizeof (c_options_t));
    fiasco_c_options_t *public  = calloc (1, sizeof (fiasco_c_options_t));
 
    if (!options || !public)
@@ -55,9 +55,9 @@ fiasco_c_options_new (void)
       set_error (_("Out of memory."));
       return NULL;
    }
-   public->private 	      = options;
-   public->delete 	      = fiasco_c_options_delete;
-   public->set_tiling 	      = fiasco_c_options_set_tiling;
+   public->private            = options;
+   public->delete             = fiasco_c_options_delete;
+   public->set_tiling         = fiasco_c_options_set_tiling;
    public->set_frame_pattern  = fiasco_c_options_set_frame_pattern;
    public->set_basisfile      = fiasco_c_options_set_basisfile;
    public->set_chroma_quality = fiasco_c_options_set_chroma_quality;
@@ -66,57 +66,57 @@ fiasco_c_options_new (void)
    public->set_quantization   = fiasco_c_options_set_quantization;
    public->set_progress_meter = fiasco_c_options_set_progress_meter;
    public->set_smoothing      = fiasco_c_options_set_smoothing;
-   public->set_title   	      = fiasco_c_options_set_title;
+   public->set_title          = fiasco_c_options_set_title;
    public->set_comment        = fiasco_c_options_set_comment;
-   
+
    strcpy (options->id, "COFIASCO");
 
    /*
     *  Set default value of fiasco options
     */
-   options->basis_name 		  = strdup ("small.fco");
-   options->lc_min_level 	  = 4;
-   options->lc_max_level 	  = 12;
-   options->p_min_level 	  = 8;
-   options->p_max_level 	  = 10;
-   options->images_level 	  = 5;
-   options->max_states 		  = MAXSTATES;
-   options->chroma_max_states 	  = 40;
-   options->max_elements 	  = MAXEDGES;
-   options->tiling_exponent 	  = 4;
-   options->tiling_method 	  = FIASCO_TILING_VARIANCE_DSC;
-   options->id_domain_pool 	  = strdup ("rle");
-   options->id_d_domain_pool 	  = strdup ("rle");
-   options->id_rpf_model 	  = strdup ("adaptive");
-   options->id_d_rpf_model 	  = strdup ("adaptive");
-   options->rpf_mantissa 	  = 3;
-   options->rpf_range 		  = FIASCO_RPF_RANGE_1_50;
-   options->dc_rpf_mantissa 	  = 5;
-   options->dc_rpf_range 	  = FIASCO_RPF_RANGE_1_00;
-   options->d_rpf_mantissa 	  = 3;
-   options->d_rpf_range 	  = FIASCO_RPF_RANGE_1_50;
-   options->d_dc_rpf_mantissa 	  = 5;
-   options->d_dc_rpf_range 	  = FIASCO_RPF_RANGE_1_00;
-   options->chroma_decrease 	  = 2.0;
-   options->prediction 		  = NO;
-   options->delta_domains 	  = YES;
-   options->normal_domains 	  = YES;
-   options->search_range 	  = 16;
-   options->fps 		  = 25;
-   options->pattern 		  = strdup ("IPPPPPPPPP");
-   options->reference_filename 	  = NULL;
+   options->basis_name            = strdup ("small.fco");
+   options->lc_min_level          = 4;
+   options->lc_max_level          = 12;
+   options->p_min_level           = 8;
+   options->p_max_level           = 10;
+   options->images_level          = 5;
+   options->max_states            = MAXSTATES;
+   options->chroma_max_states     = 40;
+   options->max_elements          = MAXEDGES;
+   options->tiling_exponent       = 4;
+   options->tiling_method         = FIASCO_TILING_VARIANCE_DSC;
+   options->id_domain_pool        = strdup ("rle");
+   options->id_d_domain_pool      = strdup ("rle");
+   options->id_rpf_model          = strdup ("adaptive");
+   options->id_d_rpf_model        = strdup ("adaptive");
+   options->rpf_mantissa          = 3;
+   options->rpf_range             = FIASCO_RPF_RANGE_1_50;
+   options->dc_rpf_mantissa       = 5;
+   options->dc_rpf_range          = FIASCO_RPF_RANGE_1_00;
+   options->d_rpf_mantissa        = 3;
+   options->d_rpf_range           = FIASCO_RPF_RANGE_1_50;
+   options->d_dc_rpf_mantissa     = 5;
+   options->d_dc_rpf_range        = FIASCO_RPF_RANGE_1_00;
+   options->chroma_decrease       = 2.0;
+   options->prediction            = NO;
+   options->delta_domains         = YES;
+   options->normal_domains        = YES;
+   options->search_range          = 16;
+   options->fps                   = 25;
+   options->pattern               = strdup ("IPPPPPPPPP");
+   options->reference_filename    = NULL;
    options->half_pixel_prediction = NO;
-   options->cross_B_search 	  = YES;
-   options->B_as_past_ref 	  = YES;
+   options->cross_B_search        = YES;
+   options->B_as_past_ref         = YES;
    options->check_for_underflow   = NO;
-   options->check_for_overflow 	  = NO;
+   options->check_for_overflow    = NO;
    options->second_domain_block   = NO;
-   options->full_search 	  = NO;
-   options->progress_meter 	  = FIASCO_PROGRESS_NONE;
-   options->smoothing 	 	  = 70;
-   options->comment 		  = strdup ("");
-   options->title 		  = strdup ("");
-   
+   options->full_search           = NO;
+   options->progress_meter        = FIASCO_PROGRESS_NONE;
+   options->smoothing             = 70;
+   options->comment               = strdup ("");
+   options->title                 = strdup ("");
+
    return public;
 }
 
@@ -129,14 +129,14 @@ fiasco_c_options_delete (fiasco_c_options_t *options)
  *  No return value.
  *
  *  Side effects:
- *	structure 'options' is discarded.
+ *      structure 'options' is discarded.
  */
 {
    c_options_t *this = cast_c_options (options);
 
    if (!this)
       return;
-   
+
    Free (this->id_domain_pool);
    Free (this->id_d_domain_pool);
    Free (this->id_rpf_model);
@@ -144,7 +144,7 @@ fiasco_c_options_delete (fiasco_c_options_t *options)
    Free (this->pattern);
    Free (this->comment);
    Free (this->title);
-   
+
    Free (this);
 
    return;
@@ -152,15 +152,15 @@ fiasco_c_options_delete (fiasco_c_options_t *options)
 
 int
 fiasco_c_options_set_tiling (fiasco_c_options_t *options,
-			     fiasco_tiling_e method, unsigned exponent)
+                             fiasco_tiling_e method, unsigned exponent)
 /*
  *  Set tiling `method' and `exponent'.
  *  See type `fiasco_tiling_e' for a list of valid  tiling `methods'.
  *  The image is subdivied into 2^`exponent' tiles
  *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -175,21 +175,21 @@ fiasco_c_options_set_tiling (fiasco_c_options_t *options,
       case FIASCO_TILING_SPIRAL_DSC:
       case FIASCO_TILING_VARIANCE_ASC:
       case FIASCO_TILING_VARIANCE_DSC:
-	 this->tiling_method = method;
-	 break;
+         this->tiling_method = method;
+         break;
       default:
-	 set_error (_("Invalid tiling method `%d' specified "
-		      "(valid methods are 0, 1, 2, or 3)."), method);
-	 return 0;
+         set_error (_("Invalid tiling method `%d' specified "
+                      "(valid methods are 0, 1, 2, or 3)."), method);
+         return 0;
    }
    this->tiling_exponent = exponent;
-   
+
    return 1;
 }
 
 int
 fiasco_c_options_set_frame_pattern (fiasco_c_options_t *options,
-				    const char *pattern)
+                                    const char *pattern)
 /*
  *  Set `pattern' of input frames.
  *  `pattern' has to be a sequence of the following
@@ -201,10 +201,10 @@ fiasco_c_options_set_frame_pattern (fiasco_c_options_t *options,
  *
  *  When coding video frames the prediction type of input frame N is determined
  *  by reading `pattern' [N] (`pattern' is periodically extended).
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -226,49 +226,49 @@ fiasco_c_options_set_frame_pattern (fiasco_c_options_t *options,
    else
    {
       const char *str;
-      bool_t 	  parse_error = NO;
-      int	  c 	      = 0;
-      
+      bool_t      parse_error = NO;
+      int         c           = 0;
+
       for (str = pattern; *str && !parse_error; str++)
-	 switch (*str)
-	 {
-	    case 'i':
-	    case 'I':
-	    case 'b':
-	    case 'B':
-	    case 'p':
-	    case 'P':
-	       break;
-	    default:
-	       c = *str;
-	       parse_error = YES;
-	 }
+         switch (*str)
+         {
+            case 'i':
+            case 'I':
+            case 'b':
+            case 'B':
+            case 'p':
+            case 'P':
+               break;
+            default:
+               c = *str;
+               parse_error = YES;
+         }
 
       if (parse_error)
       {
-	 set_error (_("Frame type pattern contains invalid character `%c' "
-		      "(choose I, B or P)."), c);
-	 return 0;
+         set_error (_("Frame type pattern contains invalid character `%c' "
+                      "(choose I, B or P)."), c);
+         return 0;
       }
       else
       {
-	 Free (this->pattern);
-	 this->pattern = strdup (pattern);
+         Free (this->pattern);
+         this->pattern = strdup (pattern);
 
-	 return 1;
+         return 1;
       }
    }
 }
 
 int
 fiasco_c_options_set_basisfile (fiasco_c_options_t *options,
-				const char *filename)
+                                const char *filename)
 /*
  *  Set `filename' of FIASCO initial basis.
- *  
+ *
  *  Return value:
- *	1 on success (if the file is readable)
- *	0 otherwise
+ *      1 on success (if the file is readable)
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -289,14 +289,14 @@ fiasco_c_options_set_basisfile (fiasco_c_options_t *options,
       FILE *file = open_file (filename, "FIASCO_DATA", READ_ACCESS);
       if (file)
       {
-	 fclose (file);
-	 return 1;
+         fclose (file);
+         return 1;
       }
       else
       {
-	 set_error (_("Can't read basis file `%s'.\n%s."), filename,
-		    get_system_error ());
-	 return 0;
+         set_error (_("Can't read basis file `%s'.\n%s."), filename,
+                    get_system_error ());
+         return 0;
       }
       */ return 1;
    }
@@ -304,20 +304,20 @@ fiasco_c_options_set_basisfile (fiasco_c_options_t *options,
 
 int
 fiasco_c_options_set_chroma_quality (fiasco_c_options_t *options,
-				     float quality_factor,
-				     unsigned dictionary_size)
+                                     float quality_factor,
+                                     unsigned dictionary_size)
 /*
  *  Set color compression parameters.
  *  When coding chroma channels (Cb and Cr)
  *  - approximation quality is given by `quality_factor' * `Y quality' and
  *  - `dictionary_size' gives the number of dictionary elements.
- *  
+ *
  *  If 'quality' <= 0 then the luminancy coding quality is also during
  *  chroma channel coding.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -329,13 +329,13 @@ fiasco_c_options_set_chroma_quality (fiasco_c_options_t *options,
    else if (!dictionary_size)
    {
       set_error (_("Size of chroma compression dictionary has to be "
-		   "a positive number."));
+                   "a positive number."));
       return 0;
    }
    else if (quality_factor <= 0)
    {
       set_error (_("Quality of chroma channel compression has to be "
-		   "positive value."));
+                   "positive value."));
       return 0;
    }
    else
@@ -349,32 +349,32 @@ fiasco_c_options_set_chroma_quality (fiasco_c_options_t *options,
 
 int
 fiasco_c_options_set_optimizations (fiasco_c_options_t *options,
-				    unsigned min_block_level,
-				    unsigned max_block_level,
-				    unsigned max_elements,
-				    unsigned dictionary_size,
-				    unsigned optimization_level)
+                                    unsigned min_block_level,
+                                    unsigned max_block_level,
+                                    unsigned max_elements,
+                                    unsigned dictionary_size,
+                                    unsigned optimization_level)
 /*
  *  Set various optimization parameters.
  *  - During compression only image blocks of size
  *    {`min_block_level', ... ,`max_block_level'} are considered.
  *    The smaller this set of blocks is the faster the coder runs
- *    and the worse the image quality will be.  
+ *    and the worse the image quality will be.
  *  - An individual approximation may use at most `max_elements'
  *    elements of the dictionary which itself contains at most
  *    `dictionary_size' elements. The smaller these values are
- *    the faster the coder runs and the worse the image quality will be. 
+ *    the faster the coder runs and the worse the image quality will be.
  *  - `optimization_level' enables some additional low level optimizations.
  *    0: standard approximation method
  *    1: significantly increases the approximation quality,
  *       running time is twice as high as with the standard method
- *    2: hardly increases the approximation quality of method 1, 
+ *    2: hardly increases the approximation quality of method 1,
  *       running time is twice as high as with method 1
  *       (this method just remains for completeness)
  *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -391,7 +391,7 @@ fiasco_c_options_set_optimizations (fiasco_c_options_t *options,
    else if (!max_elements)
    {
       set_error (_("At least one dictionary element has to be used "
-		   "in an approximation."));
+                   "in an approximation."));
       return 0;
    }
    else if (max_block_level < 4)
@@ -407,19 +407,19 @@ fiasco_c_options_set_optimizations (fiasco_c_options_t *options,
    else if (max_block_level < min_block_level)
    {
       set_error (_("Maximum block size has to be larger or "
-		   "equal minimum block size."));
+                   "equal minimum block size."));
       return 0;
    }
    else
    {
-      this->lc_min_level 	= min_block_level;
-      this->lc_max_level 	= max_block_level;
-      this->max_states 	 	= dictionary_size;
-      this->max_elements 	= max_elements;
+      this->lc_min_level        = min_block_level;
+      this->lc_max_level        = max_block_level;
+      this->max_states          = dictionary_size;
+      this->max_elements        = max_elements;
       this->second_domain_block = optimization_level > 0 ? YES : NO;
       this->check_for_overflow  = optimization_level > 1 ? YES : NO;
       this->check_for_underflow = optimization_level > 1 ? YES : NO;
-      this->full_search 	= optimization_level > 1 ? YES : NO;
+      this->full_search         = optimization_level > 1 ? YES : NO;
 
       return 1;
    }
@@ -427,9 +427,9 @@ fiasco_c_options_set_optimizations (fiasco_c_options_t *options,
 
 int
 fiasco_c_options_set_prediction (fiasco_c_options_t *options,
-				 int intra_prediction,
-				 unsigned min_block_level,
-				 unsigned max_block_level)
+                                 int intra_prediction,
+                                 unsigned min_block_level,
+                                 unsigned max_block_level)
 /*
  *  Set minimum and maximum size of image block prediction to
  *  `min_block_level' and `max_block_level'.
@@ -438,8 +438,8 @@ fiasco_c_options_set_prediction (fiasco_c_options_t *options,
  *  Prediction of intra frames is only used if `intra_prediction' != 0.
  *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -451,19 +451,19 @@ fiasco_c_options_set_prediction (fiasco_c_options_t *options,
    else if (max_block_level < 6)
    {
       set_error (_("Maximum prediction block size has to be "
-		   "at least level 6"));
+                   "at least level 6"));
       return 0;
    }
    else if (min_block_level < 6)
    {
       set_error (_("Minimum prediction block size has to be "
-		   "at least level 6"));
+                   "at least level 6"));
       return 0;
    }
    else if (max_block_level < min_block_level)
    {
       set_error (_("Maximum prediction block size has to be larger or "
-		   "equal minimum block size."));
+                   "equal minimum block size."));
       return 0;
    }
    else
@@ -471,17 +471,17 @@ fiasco_c_options_set_prediction (fiasco_c_options_t *options,
       this->p_min_level = min_block_level;
       this->p_max_level = max_block_level;
       this->prediction  = intra_prediction;
-      
+
       return 1;
    }
 }
 
 int
 fiasco_c_options_set_video_param (fiasco_c_options_t *options,
-				  unsigned frames_per_second,
-				  int half_pixel_prediction,
-				  int cross_B_search,
-				  int B_as_past_ref)
+                                  unsigned frames_per_second,
+                                  int half_pixel_prediction,
+                                  int cross_B_search,
+                                  int B_as_past_ref)
 /*
  *  Set various parameters used for video compensation.
  *  'frames_per_second' defines the frame rate which should be
@@ -494,10 +494,10 @@ fiasco_c_options_set_video_param (fiasco_c_options_t *options,
  *  exhaustive search (in the given search range) is used.
  *  If 'B_as_past_ref' is not 0 then B frames are allowed to be used
  *  for B frame predicion.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -508,10 +508,10 @@ fiasco_c_options_set_video_param (fiasco_c_options_t *options,
    }
    else
    {
-      this->fps 	  	  = frames_per_second;
+      this->fps                   = frames_per_second;
       this->half_pixel_prediction = half_pixel_prediction;
-      this->cross_B_search 	  = cross_B_search;
-      this->B_as_past_ref 	  = B_as_past_ref;
+      this->cross_B_search        = cross_B_search;
+      this->B_as_past_ref         = B_as_past_ref;
 
       return 1;
    }
@@ -519,20 +519,20 @@ fiasco_c_options_set_video_param (fiasco_c_options_t *options,
 
 int
 fiasco_c_options_set_quantization (fiasco_c_options_t *options,
-				   unsigned mantissa,
-				   fiasco_rpf_range_e range,
-				   unsigned dc_mantissa,
-				   fiasco_rpf_range_e dc_range)
+                                   unsigned mantissa,
+                                   fiasco_rpf_range_e range,
+                                   unsigned dc_mantissa,
+                                   fiasco_rpf_range_e dc_range)
 /*
  *  Set accuracy of coefficients quantization.
  *  DC coefficients (of the constant dictionary vector f(x,y) = 1)
  *  are quantized to values of the interval [-`dc_range', `dc_range'] using
  *  #`dc_mantissa' bits. All other quantized coefficients are quantized in
  *  an analogous way using the parameters `range' and `mantissa'.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -544,46 +544,46 @@ fiasco_c_options_set_quantization (fiasco_c_options_t *options,
    else if (mantissa < 2 || mantissa > 8 || dc_mantissa < 2 || dc_mantissa > 8)
    {
       set_error (_("Number of RPF mantissa bits `%d', `%d' have to be in "
-		   "the interval [2,8]."), mantissa, dc_mantissa);
+                   "the interval [2,8]."), mantissa, dc_mantissa);
       return 0;
    }
    else
    {
       if ((range == FIASCO_RPF_RANGE_0_75
-	  || range == FIASCO_RPF_RANGE_1_00
-	  || range == FIASCO_RPF_RANGE_1_50
-	   || range == FIASCO_RPF_RANGE_2_00)
-	  &&
-	  (dc_range == FIASCO_RPF_RANGE_0_75
-	   || dc_range == FIASCO_RPF_RANGE_1_00
-	   || dc_range == FIASCO_RPF_RANGE_1_50
-	   || dc_range == FIASCO_RPF_RANGE_2_00))
+          || range == FIASCO_RPF_RANGE_1_00
+          || range == FIASCO_RPF_RANGE_1_50
+           || range == FIASCO_RPF_RANGE_2_00)
+          &&
+          (dc_range == FIASCO_RPF_RANGE_0_75
+           || dc_range == FIASCO_RPF_RANGE_1_00
+           || dc_range == FIASCO_RPF_RANGE_1_50
+           || dc_range == FIASCO_RPF_RANGE_2_00))
       {
-	 this->rpf_range       = range;
-	 this->dc_rpf_range    = dc_range;
-	 this->rpf_mantissa    = mantissa;
-	 this->dc_rpf_mantissa = dc_mantissa;
+         this->rpf_range       = range;
+         this->dc_rpf_range    = dc_range;
+         this->rpf_mantissa    = mantissa;
+         this->dc_rpf_mantissa = dc_mantissa;
 
-	 return 1;
+         return 1;
       }
       else
       {
-	 set_error (_("Invalid RPF ranges `%d', `%d' specified."),
-		    range, dc_range);
-	 return 0;
+         set_error (_("Invalid RPF ranges `%d', `%d' specified."),
+                    range, dc_range);
+         return 0;
       }
    }
 }
 
 int
 fiasco_c_options_set_progress_meter (fiasco_c_options_t *options,
-				     fiasco_progress_e type)
+                                     fiasco_progress_e type)
 /*
  *  Set type of progress meter.
  *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -597,12 +597,12 @@ fiasco_c_options_set_progress_meter (fiasco_c_options_t *options,
       case FIASCO_PROGRESS_BAR:
       case FIASCO_PROGRESS_PERCENT:
       case FIASCO_PROGRESS_NONE:
-	 this->progress_meter = type;
-	 break;
+         this->progress_meter = type;
+         break;
       default:
-	 set_error (_("Invalid progress meter `%d' specified "
-		      "(valid values are 0, 1, or 2)."), type);
-	 return 0;
+         set_error (_("Invalid progress meter `%d' specified "
+                      "(valid values are 0, 1, or 2)."), type);
+         return 0;
    }
    return 1;
 }
@@ -611,10 +611,10 @@ int
 fiasco_c_options_set_smoothing (fiasco_c_options_t *options, int smoothing)
 /*
  *  Define `smoothing'-percentage along partitioning borders.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -639,10 +639,10 @@ int
 fiasco_c_options_set_comment (fiasco_c_options_t *options, const char *comment)
 /*
  *  Define `comment' of FIASCO stream.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -667,10 +667,10 @@ int
 fiasco_c_options_set_title (fiasco_c_options_t *options, const char *title)
 /*
  *  Define `title' of FIASCO stream.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    c_options_t *this = (c_options_t *) cast_c_options (options);
@@ -698,7 +698,7 @@ cast_c_options (fiasco_c_options_t *options)
  *  Check whether `options' is a valid object of type c_options_t.
  *
  *  Return value:
- *	pointer to options struct on success
+ *      pointer to options struct on success
  *      NULL otherwise
  */
 {
@@ -707,8 +707,8 @@ cast_c_options (fiasco_c_options_t *options)
    {
       if (!streq (this->id, "COFIASCO"))
       {
-	 set_error (_("Parameter `options' doesn't match required type."));
-	 return NULL;
+         set_error (_("Parameter `options' doesn't match required type."));
+         return NULL;
       }
    }
    else
@@ -721,7 +721,7 @@ cast_c_options (fiasco_c_options_t *options)
 
 /**************************************************************************
 ***************************************************************************
-			       DECODER
+                               DECODER
 ***************************************************************************
 **************************************************************************/
 
@@ -733,10 +733,10 @@ fiasco_d_options_new (void)
  *  fill in default values.
  *
  *  Return value:
- *	pointer to the new option structure
+ *      pointer to the new option structure
  */
 {
-   d_options_t 	      *options = calloc (1, sizeof (d_options_t));
+   d_options_t        *options = calloc (1, sizeof (d_options_t));
    fiasco_d_options_t *public  = calloc (1, sizeof (fiasco_d_options_t));
 
    if (!options || !public)
@@ -744,21 +744,21 @@ fiasco_d_options_new (void)
       set_error (_("Out of memory."));
       return NULL;
    }
-   public->private 	      = options;
-   public->delete 	      = fiasco_d_options_delete;
+   public->private            = options;
+   public->delete             = fiasco_d_options_delete;
    public->set_smoothing      = fiasco_d_options_set_smoothing;
    public->set_magnification  = fiasco_d_options_set_magnification;
    public->set_4_2_0_format   = fiasco_d_options_set_4_2_0_format;
-   
+
    strcpy (options->id, "DOFIASCO");
 
    /*
     *  Set default value of fiasco decoder options
     */
-   options->smoothing 	  = 70;
+   options->smoothing     = 70;
    options->magnification = 0;
    options->image_format  = FORMAT_4_4_4;
-   
+
    return public;
 }
 
@@ -771,14 +771,14 @@ fiasco_d_options_delete (fiasco_d_options_t *options)
  *  No return value.
  *
  *  Side effects:
- *	structure 'options' is discarded.
+ *      structure 'options' is discarded.
  */
 {
    d_options_t *this = cast_d_options (options);
 
    if (!this)
       return;
-   
+
    Free (this);
 
    return;
@@ -788,10 +788,10 @@ int
 fiasco_d_options_set_smoothing (fiasco_d_options_t *options, int smoothing)
 /*
  *  Define `smoothing'-percentage along partitioning borders.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    d_options_t *this = (d_options_t *) cast_d_options (options);
@@ -822,8 +822,8 @@ fiasco_d_options_set_magnification (fiasco_d_options_t *options, int level)
  *  etc.
  *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    d_options_t *this = (d_options_t *) cast_d_options (options);
@@ -843,10 +843,10 @@ int
 fiasco_d_options_set_4_2_0_format (fiasco_d_options_t *options, int format)
 /*
  *  Set image format to 4:2:0 or 4:4:4.
- *  
+ *
  *  Return value:
- *	1 on success
- *	0 otherwise
+ *      1 on success
+ *      0 otherwise
  */
 {
    d_options_t *this = (d_options_t *) cast_d_options (options);
@@ -869,18 +869,18 @@ cast_d_options (fiasco_d_options_t *options)
  *  Check whether `options' is a valid object of type d_options_t.
  *
  *  Return value:
- *	pointer to options struct on success
+ *      pointer to options struct on success
  *      NULL otherwise
  */
 {
    d_options_t *this = (d_options_t *) options->private;
-   
+
    if (this)
    {
       if (!streq (this->id, "DOFIASCO"))
       {
-	 set_error (_("Parameter `options' doesn't match required type."));
-	 return NULL;
+         set_error (_("Parameter `options' doesn't match required type."));
+         return NULL;
       }
    }
    else
diff --git a/converter/other/fiasco/codec/options.h b/converter/other/fiasco/codec/options.h
index 783c41ef..e39550f6 100644
--- a/converter/other/fiasco/codec/options.h
+++ b/converter/other/fiasco/codec/options.h
@@ -1,8 +1,8 @@
 /*
  *  options.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -19,49 +19,49 @@
 
 typedef struct c_options
 {
-   char      	       id [9];
-   char  	      *basis_name;
-   unsigned  	       lc_min_level;
-   unsigned  	       lc_max_level;
-   unsigned  	       p_min_level;
-   unsigned  	       p_max_level;
-   unsigned  	       images_level;
-   unsigned  	       max_states;
-   unsigned  	       chroma_max_states;
-   unsigned  	       max_elements;
-   unsigned  	       tiling_exponent;
+   char                id [9];
+   char               *basis_name;
+   unsigned            lc_min_level;
+   unsigned            lc_max_level;
+   unsigned            p_min_level;
+   unsigned            p_max_level;
+   unsigned            images_level;
+   unsigned            max_states;
+   unsigned            chroma_max_states;
+   unsigned            max_elements;
+   unsigned            tiling_exponent;
    fiasco_tiling_e     tiling_method;
-   char        	      *id_domain_pool;
-   char        	      *id_d_domain_pool;
-   char        	      *id_rpf_model;
-   char        	      *id_d_rpf_model;
-   unsigned  	       rpf_mantissa;
-   real_t    	       rpf_range;
-   unsigned  	       dc_rpf_mantissa;
+   char               *id_domain_pool;
+   char               *id_d_domain_pool;
+   char               *id_rpf_model;
+   char               *id_d_rpf_model;
+   unsigned            rpf_mantissa;
+   real_t              rpf_range;
+   unsigned            dc_rpf_mantissa;
    fiasco_rpf_range_e  dc_rpf_range;
-   unsigned  	       d_rpf_mantissa;
+   unsigned            d_rpf_mantissa;
    fiasco_rpf_range_e  d_rpf_range;
-   unsigned  	       d_dc_rpf_mantissa;
+   unsigned            d_dc_rpf_mantissa;
    fiasco_rpf_range_e  d_dc_rpf_range;
-   real_t    	       chroma_decrease;
-   bool_t    	       prediction;
-   bool_t    	       delta_domains;
-   bool_t    	       normal_domains;
-   unsigned  	       search_range;
-   unsigned  	       fps;
-   char        	      *pattern;
-   char        	      *reference_filename;
-   bool_t    	       half_pixel_prediction;
-   bool_t    	       cross_B_search;
-   bool_t    	       B_as_past_ref;
-   bool_t    	       check_for_underflow;
-   bool_t    	       check_for_overflow;
-   bool_t    	       second_domain_block;
-   bool_t    	       full_search;
+   real_t              chroma_decrease;
+   bool_t              prediction;
+   bool_t              delta_domains;
+   bool_t              normal_domains;
+   unsigned            search_range;
+   unsigned            fps;
+   char               *pattern;
+   char               *reference_filename;
+   bool_t              half_pixel_prediction;
+   bool_t              cross_B_search;
+   bool_t              B_as_past_ref;
+   bool_t              check_for_underflow;
+   bool_t              check_for_overflow;
+   bool_t              second_domain_block;
+   bool_t              full_search;
    fiasco_progress_e   progress_meter;
-   char 	      *title;
-   char 	      *comment;
-   unsigned    	       smoothing;
+   char               *title;
+   char               *comment;
+   unsigned            smoothing;
 } c_options_t;
 
 typedef struct d_options
diff --git a/converter/other/fiasco/codec/prediction.c b/converter/other/fiasco/codec/prediction.c
index c592baa5..c321391a 100644
--- a/converter/other/fiasco/codec/prediction.c
+++ b/converter/other/fiasco/codec/prediction.c
@@ -1,8 +1,8 @@
 /*
- *  prediction.c:	Range image prediction with MC or ND
+ *  prediction.c:       Range image prediction with MC or ND
  *
- *  Written by:		Ullrich Hafner
- *			Michael Unger
+ *  Written by:         Ullrich Hafner
+ *                      Michael Unger
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -40,7 +40,7 @@
 
 /*****************************************************************************
 
-			     local variables
+                             local variables
 
 *****************************************************************************/
 
@@ -55,7 +55,7 @@ typedef struct state_data
    real_t *ip_states_state [MAXLEVEL];
 
    word_t tree [MAXLABELS];
-   mv_t	  mv_tree [MAXLABELS];
+   mv_t   mv_tree [MAXLABELS];
    word_t y_state [MAXLABELS];
    byte_t y_column [MAXLABELS];
    byte_t prediction [MAXLABELS];
@@ -70,49 +70,49 @@ typedef struct state_data
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static real_t
 nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
-	       range_t *range, wfa_t *wfa, coding_t *c);
+               range_t *range, wfa_t *wfa, coding_t *c);
 static real_t
 mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
-	       range_t *range, wfa_t *wfa, coding_t *c);
+               range_t *range, wfa_t *wfa, coding_t *c);
 static state_data_t *
 store_state_data (unsigned from, unsigned to, unsigned max_level,
-		  wfa_t *wfa, coding_t *c);
+                  wfa_t *wfa, coding_t *c);
 static void
 restore_state_data (unsigned from, unsigned to, unsigned max_level,
-		    state_data_t *data, wfa_t *wfa, coding_t *c);
+                    state_data_t *data, wfa_t *wfa, coding_t *c);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
 real_t
 predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa,
-	       coding_t *c, unsigned band, int y_state, unsigned states,
-	       const tree_t *tree_model, const tree_t *p_tree_model,
-	       const void *domain_model, const void *d_domain_model,
-	       const void *coeff_model, const void *d_coeff_model)
+               coding_t *c, unsigned band, int y_state, unsigned states,
+               const tree_t *tree_model, const tree_t *p_tree_model,
+               const void *domain_model, const void *d_domain_model,
+               const void *coeff_model, const void *d_coeff_model)
 {
-   unsigned	 state;		     	/* counter */
-   void		*rec_domain_model;   	/* domain model after recursion */
-   void		*rec_d_domain_model; 	/* p domain model after recursion */
-   void		*rec_coeff_model;    	/* coeff model after recursion */
-   void		*rec_d_coeff_model;  	/* d coeff model after recursion */
-   tree_t	 rec_tree_model;	/* tree_model after '' */
-   tree_t	 rec_p_tree_model;    	/* p_tree_model after '' */
-   unsigned	 rec_states;	     	/* wfa->states after '' */
-   real_t	*rec_pixels;	     	/* c->pixels after '' */
-   state_data_t	*rec_state_data;     	/* state_data struct after '' */
-   real_t	 costs;		     	/* current approximation costs */
-   unsigned	 level;		     	/* counter */
-   state_data_t	*sd;		     	/* pointer to state_data field */
+   unsigned      state;                 /* counter */
+   void         *rec_domain_model;      /* domain model after recursion */
+   void         *rec_d_domain_model;    /* p domain model after recursion */
+   void         *rec_coeff_model;       /* coeff model after recursion */
+   void         *rec_d_coeff_model;     /* d coeff model after recursion */
+   tree_t        rec_tree_model;        /* tree_model after '' */
+   tree_t        rec_p_tree_model;      /* p_tree_model after '' */
+   unsigned      rec_states;            /* wfa->states after '' */
+   real_t       *rec_pixels;            /* c->pixels after '' */
+   state_data_t *rec_state_data;        /* state_data struct after '' */
+   real_t        costs;                 /* current approximation costs */
+   unsigned      level;                 /* counter */
+   state_data_t *sd;                    /* pointer to state_data field */
 
    /*
     *  Store WFA data from state 'lc_states' to 'wfa->states' - 1 and
@@ -127,7 +127,7 @@ predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa,
    rec_states         = wfa->states;
    rec_pixels         = c->pixels;
    rec_state_data     = store_state_data (states, rec_states - 1,
-					  c->options.lc_max_level, wfa, c);
+                                          c->options.lc_max_level, wfa, c);
 
    /*
     *  Restore probability models to the state before the recursive subdivision
@@ -138,9 +138,9 @@ predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa,
    c->p_tree               = *p_tree_model;
    c->domain_pool->model   = c->domain_pool->model_duplicate (domain_model);
    c->d_domain_pool->model = c->d_domain_pool->model_duplicate (d_domain_model);
-   c->coeff->model   	   = c->coeff->model_duplicate (c->coeff, coeff_model);
-   c->d_coeff->model   	   = c->d_coeff->model_duplicate (c->d_coeff,
-							  d_coeff_model);
+   c->coeff->model         = c->coeff->model_duplicate (c->coeff, coeff_model);
+   c->d_coeff->model       = c->d_coeff->model_duplicate (c->d_coeff,
+                                                          d_coeff_model);
 
    if (c->mt->frame_type == I_FRAME)
       costs = nd_prediction (max_costs, price, band, y_state, range, wfa, c);
@@ -156,27 +156,27 @@ predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa,
        */
       for (state = states; state < rec_states; state++)
       {
-	 sd = &rec_state_data [state - states];
-	 for (level = c->options.images_level + 1;
-	      level <= c->options.lc_max_level; level++)
-	    if (sd->ip_states_state [level] != NULL)
-	       Free (sd->ip_states_state [level]);
-	 if (sd->images_of_state != NULL)
-	    Free (sd->images_of_state);
-	 if (sd->inner_products != NULL)
-	    Free (sd->inner_products);
+         sd = &rec_state_data [state - states];
+         for (level = c->options.images_level + 1;
+              level <= c->options.lc_max_level; level++)
+            if (sd->ip_states_state [level] != NULL)
+               Free (sd->ip_states_state [level]);
+         if (sd->images_of_state != NULL)
+            Free (sd->images_of_state);
+         if (sd->inner_products != NULL)
+            Free (sd->inner_products);
       }
       if (states < rec_states)
-	 Free (rec_state_data);
+         Free (rec_state_data);
       c->domain_pool->model_free (rec_domain_model);
       c->d_domain_pool->model_free (rec_d_domain_model);
       c->coeff->model_free (rec_coeff_model);
       c->d_coeff->model_free (rec_d_coeff_model);
 
       costs = (range->tree_bits + range->matrix_bits + range->weights_bits
-	       + range->mv_tree_bits + range->mv_coord_bits
-	       + range->nd_tree_bits + range->nd_weights_bits) * price
-	      + range->err;
+               + range->mv_tree_bits + range->mv_coord_bits
+               + range->nd_tree_bits + range->nd_weights_bits) * price
+              + range->err;
    }
    else
    {
@@ -198,9 +198,9 @@ predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa,
       range->prediction = NO;
 
       if (wfa->states != states)
-	 remove_states (states, wfa);
+         remove_states (states, wfa);
       restore_state_data (states, rec_states - 1, c->options.lc_max_level,
-			  rec_state_data, wfa, c);
+                          rec_state_data, wfa, c);
       costs = MAXCOSTS;
    }
 
@@ -216,8 +216,8 @@ clear_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt)
  */
 {
    unsigned  range_size = wi->half_pixel
-			  ? square (wi->search_range)
-			  : square (2 * wi->search_range);
+                          ? square (wi->search_range)
+                          : square (2 * wi->search_range);
 
    if (level > wi->p_min_level)
    {
@@ -236,34 +236,34 @@ update_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt)
  */
 {
    unsigned  range_size = wi->half_pixel
-			  ? square (wi->search_range)
-			  : square (2 * wi->search_range);
+                          ? square (wi->search_range)
+                          : square (2 * wi->search_range);
 
    if (level > wi->p_min_level)
    {
-      unsigned index;			/* index of motion vector */
+      unsigned index;                   /* index of motion vector */
 
       for (index = 0; index < range_size; index++)
-	 mt->mc_forward_norms [level][index]
-	    += mt->mc_forward_norms [level - 1][index];
+         mt->mc_forward_norms [level][index]
+            += mt->mc_forward_norms [level - 1][index];
       if (mt->frame_type == B_FRAME)
-	 for (index = 0; index < range_size; index++)
-	    mt->mc_backward_norms [level][index]
-	       += mt->mc_backward_norms [level - 1][index];
+         for (index = 0; index < range_size; index++)
+            mt->mc_backward_norms [level][index]
+               += mt->mc_backward_norms [level - 1][index];
    }
 }
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static real_t
 mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
-	       range_t *range, wfa_t *wfa, coding_t *c)
+               range_t *range, wfa_t *wfa, coding_t *c)
 {
-   real_t    costs;		   	/* current approximation costs */
+   real_t    costs;                     /* current approximation costs */
    range_t   prange = *range;
    unsigned  width  = width_of_level (range->level);
    unsigned  height = height_of_level (range->level);
@@ -286,12 +286,12 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
 
    costs = (prange.mv_tree_bits + prange.mv_coord_bits) * price;
 
-   if (costs < max_costs)		/* motion vector not too expensive */
+   if (costs < max_costs)               /* motion vector not too expensive */
    {
-      unsigned  last_state;		/* last WFA state before recursion */
-      real_t   *ipi [MAXSTATES];	/* inner products pointers */
+      unsigned  last_state;             /* last WFA state before recursion */
+      real_t   *ipi [MAXSTATES];        /* inner products pointers */
       unsigned  state;
-      real_t  	mvt, mvc;
+      real_t    mvt, mvc;
 
       c->pixels = Calloc (width * height, sizeof (real_t));
       cut_to_bintree (c->pixels, mcpe, width, height, 0, 0, width, height);
@@ -301,12 +301,12 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
        */
       last_state = wfa->states - 1;
       for (state = 0; state <= last_state; state++)
-	 if (need_image (state, wfa))
-	 {
-	    ipi [state] = c->ip_images_state[state];
-	    c->ip_images_state[state]
-	       = Calloc (size_of_tree (c->products_level), sizeof (real_t));
-	 }
+         if (need_image (state, wfa))
+         {
+            ipi [state] = c->ip_images_state[state];
+            c->ip_images_state[state]
+               = Calloc (size_of_tree (c->products_level), sizeof (real_t));
+         }
 
       mvc = prange.mv_coord_bits;
       mvt = prange.mv_tree_bits;
@@ -322,42 +322,42 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
       prange.nd_tree_bits    = 0;
 
       compute_ip_images_state (prange.image, prange.address, prange.level,
-			       1, 0, wfa, c);
+                               1, 0, wfa, c);
       costs += subdivide (max_costs - costs, band, y_state, &prange,
-			  wfa, c, NO, YES);
+                          wfa, c, NO, YES);
 
-      if (costs < max_costs)		/* use motion compensation */
+      if (costs < max_costs)            /* use motion compensation */
       {
-	 unsigned img, adr;		/* temp. values */
-
-	 img                  = range->image;
-	 adr                  = range->address;
-	 *range               = prange;
-	 range->image         = img;
-	 range->address       = adr;
-	 range->mv_coord_bits = mvc;
-	 range->mv_tree_bits  = mvt;
-	 range->prediction    = YES;
-
-	 for (state = last_state + 1; state < wfa->states; state++)
-	    if (need_image (state, wfa))
-	       memset (c->ip_images_state [state], 0,
-		       size_of_tree (c->products_level) * sizeof (real_t));
-
-	 costs = (range->tree_bits + range->matrix_bits + range->weights_bits
-		  + range->mv_tree_bits + range->mv_coord_bits
-		  + range->nd_tree_bits + range->nd_weights_bits) * price
-		 + range->err;
+         unsigned img, adr;             /* temp. values */
+
+         img                  = range->image;
+         adr                  = range->address;
+         *range               = prange;
+         range->image         = img;
+         range->address       = adr;
+         range->mv_coord_bits = mvc;
+         range->mv_tree_bits  = mvt;
+         range->prediction    = YES;
+
+         for (state = last_state + 1; state < wfa->states; state++)
+            if (need_image (state, wfa))
+               memset (c->ip_images_state [state], 0,
+                       size_of_tree (c->products_level) * sizeof (real_t));
+
+         costs = (range->tree_bits + range->matrix_bits + range->weights_bits
+                  + range->mv_tree_bits + range->mv_coord_bits
+                  + range->nd_tree_bits + range->nd_weights_bits) * price
+                 + range->err;
       }
       else
-	 costs = MAXCOSTS;
+         costs = MAXCOSTS;
 
       for (state = 0; state <= last_state; state++)
-	 if (need_image (state, wfa))
-	 {
-	    Free (c->ip_images_state[state]);
-	    c->ip_images_state[state] = ipi [state];
-	 }
+         if (need_image (state, wfa))
+         {
+            Free (c->ip_images_state[state]);
+            c->ip_images_state[state] = ipi [state];
+         }
       Free (c->pixels);
    }
    else
@@ -370,9 +370,9 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
 
 static real_t
 nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
-	       range_t *range, wfa_t *wfa, coding_t *c)
+               range_t *range, wfa_t *wfa, coding_t *c)
 {
-   real_t  costs;			/* current approximation costs */
+   real_t  costs;                       /* current approximation costs */
    range_t lrange = *range;
 
    /*
@@ -380,13 +380,13 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
     */
    {
       real_t x = get_ip_image_state (range->image, range->address,
-				     range->level, 0, c);
+                                     range->level, 0, c);
       real_t y = get_ip_state_state (0, 0, range->level, c);
       real_t w = btor (rtob (x / y, c->coeff->dc_rpf), c->coeff->dc_rpf);
       word_t s [2] = {0, -1};
 
-      lrange.into [0] 	     = 0;
-      lrange.into [1] 	     = NO_EDGE;
+      lrange.into [0]        = 0;
+      lrange.into [1]        = NO_EDGE;
       lrange.weight [0]      = w;
       lrange.mv_coord_bits   = 0;
       lrange.mv_tree_bits    = 0;
@@ -404,10 +404,10 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
    if (costs < max_costs)
    {
       unsigned  state;
-      range_t  	rrange;			/* range: recursive subdivision */
-      unsigned  last_state;		/* last WFA state before recursion */
-      real_t   *ipi [MAXSTATES];	/* inner products pointers */
-      unsigned 	width  = width_of_level (range->level);
+      range_t   rrange;                 /* range: recursive subdivision */
+      unsigned  last_state;             /* last WFA state before recursion */
+      real_t   *ipi [MAXSTATES];        /* inner products pointers */
+      unsigned  width  = width_of_level (range->level);
       unsigned  height = height_of_level (range->level);
       real_t   *pixels;
 
@@ -415,15 +415,15 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
        *  Generate difference image original - approximation
        */
       {
-	 unsigned  n;
-	 real_t *src, *dst;		/* pointers to image data */
-	 real_t w = - lrange.weight [0] * c->images_of_state [0][0];
+         unsigned  n;
+         real_t *src, *dst;             /* pointers to image data */
+         real_t w = - lrange.weight [0] * c->images_of_state [0][0];
 
-	 src = c->pixels + range->address * size_of_level (range->level);
-	 dst = c->pixels = pixels = Calloc (width * height, sizeof (real_t));
+         src = c->pixels + range->address * size_of_level (range->level);
+         dst = c->pixels = pixels = Calloc (width * height, sizeof (real_t));
 
-	 for (n = width * height; n; n--)
-	    *dst++ = *src++ + w;
+         for (n = width * height; n; n--)
+            *dst++ = *src++ + w;
       }
 
       /*
@@ -442,56 +442,56 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
 
       last_state = wfa->states - 1;
       for (state = 0; state <= last_state; state++)
-	 if (need_image (state, wfa))
-	 {
-	    ipi [state] = c->ip_images_state[state];
-	    c->ip_images_state[state]
-	       = Calloc (size_of_tree (c->products_level), sizeof (real_t));
-	 }
+         if (need_image (state, wfa))
+         {
+            ipi [state] = c->ip_images_state[state];
+            c->ip_images_state[state]
+               = Calloc (size_of_tree (c->products_level), sizeof (real_t));
+         }
 
       compute_ip_images_state (rrange.image, rrange.address, rrange.level,
-			       1, 0, wfa, c);
+                               1, 0, wfa, c);
 
       costs += subdivide (max_costs - costs, band, y_state, &rrange, wfa, c,
-			  NO, YES);
+                          NO, YES);
 
       Free (pixels);
 
       if (costs < max_costs && ischild (rrange.tree)) /* use prediction */
       {
-	 unsigned img, adr;
-	 unsigned edge;
-
-	 img                     = range->image;
-	 adr                     = range->address;
-	 *range                  = rrange;
-	 range->image            = img;
-	 range->address          = adr;
-	 range->nd_tree_bits    += lrange.nd_tree_bits;
-	 range->nd_weights_bits += lrange.weights_bits;
-
-	 for (edge = 0; isedge (lrange.into [edge]); edge++)
-	 {
-	    range->into [edge]   = lrange.into [edge];
-	    range->weight [edge] = lrange.weight [edge];
-	 }
-	 range->into [edge] = NO_EDGE;
-	 range->prediction  = edge;
-
-	 for (state = last_state + 1; state < wfa->states; state++)
-	    if (need_image (state, wfa))
-	       memset (c->ip_images_state [state], 0,
-		       size_of_tree (c->products_level) * sizeof (real_t));
+         unsigned img, adr;
+         unsigned edge;
+
+         img                     = range->image;
+         adr                     = range->address;
+         *range                  = rrange;
+         range->image            = img;
+         range->address          = adr;
+         range->nd_tree_bits    += lrange.nd_tree_bits;
+         range->nd_weights_bits += lrange.weights_bits;
+
+         for (edge = 0; isedge (lrange.into [edge]); edge++)
+         {
+            range->into [edge]   = lrange.into [edge];
+            range->weight [edge] = lrange.weight [edge];
+         }
+         range->into [edge] = NO_EDGE;
+         range->prediction  = edge;
+
+         for (state = last_state + 1; state < wfa->states; state++)
+            if (need_image (state, wfa))
+               memset (c->ip_images_state [state], 0,
+                       size_of_tree (c->products_level) * sizeof (real_t));
       }
       else
-	 costs = MAXCOSTS;
+         costs = MAXCOSTS;
 
       for (state = 0; state <= last_state; state++)
-	 if (need_image (state, wfa))
-	 {
-	    Free (c->ip_images_state [state]);
-	    c->ip_images_state [state] = ipi [state];
-	 }
+         if (need_image (state, wfa))
+         {
+            Free (c->ip_images_state [state]);
+            c->ip_images_state [state] = ipi [state];
+         }
    }
    else
       costs = MAXCOSTS;
@@ -501,20 +501,20 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state,
 
 static state_data_t *
 store_state_data (unsigned from, unsigned to, unsigned max_level,
-		  wfa_t *wfa, coding_t *c)
+                  wfa_t *wfa, coding_t *c)
 /*
  *  Save and remove all states starting from state 'from'.
  *
  *  Return value:
- *	pointer to array of state_data structs
+ *      pointer to array of state_data structs
  */
 {
-   state_data_t *data;			/* array of savestates */
-   state_data_t *sd;			/* pointer to current savestates */
-   unsigned	 state, label, level;
+   state_data_t *data;                  /* array of savestates */
+   state_data_t *sd;                    /* pointer to current savestates */
+   unsigned      state, label, level;
 
    if (to < from)
-      return NULL;			/* nothing to do */
+      return NULL;                      /* nothing to do */
 
    data = Calloc (to - from + 1, sizeof (state_data_t));
 
@@ -534,30 +534,30 @@ store_state_data (unsigned from, unsigned to, unsigned max_level,
 
       for (label = 0; label < MAXLABELS; label++)
       {
-	 sd->tree [label]     	= wfa->tree [state][label];
-	 sd->y_state [label]  	= wfa->y_state [state][label];
-	 sd->y_column [label] 	= wfa->y_column [state][label];
-	 sd->mv_tree [label]  	= wfa->mv_tree [state][label];
-	 sd->x [label]        	= wfa->x [state][label];
-	 sd->y [label]        	= wfa->y [state][label];
-	 sd->prediction [label] = wfa->prediction [state][label];
-
-	 memcpy (sd->weight [label], wfa->weight [state][label],
-		 sizeof (real_t) * (MAXEDGES + 1));
-	 memcpy (sd->int_weight [label], wfa->int_weight [state][label],
-		 sizeof (word_t) * (MAXEDGES + 1));
-	 memcpy (sd->into [label], wfa->into [state][label],
-		 sizeof (word_t) * (MAXEDGES + 1));
-
-	 wfa->into [state][label][0] = NO_EDGE;
-	 wfa->tree [state][label]    = RANGE;
-	 wfa->y_state [state][label] = RANGE;
+         sd->tree [label]       = wfa->tree [state][label];
+         sd->y_state [label]    = wfa->y_state [state][label];
+         sd->y_column [label]   = wfa->y_column [state][label];
+         sd->mv_tree [label]    = wfa->mv_tree [state][label];
+         sd->x [label]          = wfa->x [state][label];
+         sd->y [label]          = wfa->y [state][label];
+         sd->prediction [label] = wfa->prediction [state][label];
+
+         memcpy (sd->weight [label], wfa->weight [state][label],
+                 sizeof (real_t) * (MAXEDGES + 1));
+         memcpy (sd->int_weight [label], wfa->int_weight [state][label],
+                 sizeof (word_t) * (MAXEDGES + 1));
+         memcpy (sd->into [label], wfa->into [state][label],
+                 sizeof (word_t) * (MAXEDGES + 1));
+
+         wfa->into [state][label][0] = NO_EDGE;
+         wfa->tree [state][label]    = RANGE;
+         wfa->y_state [state][label] = RANGE;
       }
       for (level = c->options.images_level + 1; level <= max_level;
-	   level++)
+           level++)
       {
-	 sd->ip_states_state [level]       = c->ip_states_state [state][level];
-	 c->ip_states_state [state][level] = NULL;
+         sd->ip_states_state [level]       = c->ip_states_state [state][level];
+         c->ip_states_state [state][level] = NULL;
       }
    }
 
@@ -566,18 +566,18 @@ store_state_data (unsigned from, unsigned to, unsigned max_level,
 
 static void
 restore_state_data (unsigned from, unsigned to, unsigned max_level,
-		    state_data_t *data, wfa_t *wfa, coding_t *c)
+                    state_data_t *data, wfa_t *wfa, coding_t *c)
 /*
  *  Restore all state data starting from state 'from'.
  *
  *  No return value.
  */
 {
-   state_data_t *sd;			/* pointer to state_data item */
-   unsigned	 state, label, level;
+   state_data_t *sd;                    /* pointer to state_data item */
+   unsigned      state, label, level;
 
    if (to < from)
-      return;				/* nothing to do */
+      return;                           /* nothing to do */
 
    for (state = from; state <= to; state++)
    {
@@ -588,35 +588,35 @@ restore_state_data (unsigned from, unsigned to, unsigned max_level,
       wfa->domain_type [state]        = sd->domain_type;
 
       if (c->images_of_state [state] != NULL)
-	 Free (c->images_of_state [state]);
+         Free (c->images_of_state [state]);
       c->images_of_state [state] = sd->images_of_state;
       if (c->ip_images_state [state] != NULL)
-	 Free (c->ip_images_state [state]);
+         Free (c->ip_images_state [state]);
       c->ip_images_state [state] = sd->inner_products;
 
       for (label = 0; label < MAXLABELS; label++)
       {
-	 wfa->tree [state][label]     	= sd->tree [label];
-	 wfa->y_state [state][label]  	= sd->y_state [label];
-	 wfa->y_column [state][label] 	= sd->y_column [label];
-	 wfa->mv_tree [state][label]  	= sd->mv_tree [label];
-	 wfa->x [state][label]        	= sd->x [label];
-	 wfa->y [state][label]        	= sd->y [label];
-	 wfa->prediction [state][label] = sd->prediction [label];
-
-	 memcpy (wfa->weight [state][label], sd->weight [label],
-		 sizeof(real_t) * (MAXEDGES + 1));
-	 memcpy (wfa->int_weight [state][label], sd->int_weight [label],
-		 sizeof(word_t) * (MAXEDGES + 1));
-	 memcpy (wfa->into [state][label], sd->into [label],
-		 sizeof(word_t) * (MAXEDGES + 1));
+         wfa->tree [state][label]       = sd->tree [label];
+         wfa->y_state [state][label]    = sd->y_state [label];
+         wfa->y_column [state][label]   = sd->y_column [label];
+         wfa->mv_tree [state][label]    = sd->mv_tree [label];
+         wfa->x [state][label]          = sd->x [label];
+         wfa->y [state][label]          = sd->y [label];
+         wfa->prediction [state][label] = sd->prediction [label];
+
+         memcpy (wfa->weight [state][label], sd->weight [label],
+                 sizeof(real_t) * (MAXEDGES + 1));
+         memcpy (wfa->int_weight [state][label], sd->int_weight [label],
+                 sizeof(word_t) * (MAXEDGES + 1));
+         memcpy (wfa->into [state][label], sd->into [label],
+                 sizeof(word_t) * (MAXEDGES + 1));
       }
       for (level = c->options.images_level + 1; level <= max_level;
-	   level++)
+           level++)
       {
-	 if (c->ip_states_state [state][level] != NULL)
-	    Free (c->ip_states_state [state][level]);
-	 c->ip_states_state [state][level] = sd->ip_states_state [level];
+         if (c->ip_states_state [state][level] != NULL)
+            Free (c->ip_states_state [state][level]);
+         c->ip_states_state [state][level] = sd->ip_states_state [level];
       }
    }
 
diff --git a/converter/other/fiasco/codec/prediction.h b/converter/other/fiasco/codec/prediction.h
index 0646dfd8..10b432b3 100644
--- a/converter/other/fiasco/codec/prediction.h
+++ b/converter/other/fiasco/codec/prediction.h
@@ -1,9 +1,9 @@
 /*
  *  prediction.h
  *
- *  Written by:		Ullrich Hafner
- *			Michael Unger
- *		
+ *  Written by:         Ullrich Hafner
+ *                      Michael Unger
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -23,10 +23,10 @@
 
 real_t
 predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa,
-	       coding_t *c, unsigned band, int y_state, unsigned states,
-	       const tree_t *tree_model, const tree_t *p_tree_model,
-	       const void *domain_model, const void *d_domain_model,
-	       const void *coeff_model, const void *d_coeff_model);
+               coding_t *c, unsigned band, int y_state, unsigned states,
+               const tree_t *tree_model, const tree_t *p_tree_model,
+               const void *domain_model, const void *d_domain_model,
+               const void *coeff_model, const void *d_coeff_model);
 void
 update_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt);
 void
diff --git a/converter/other/fiasco/codec/subdivide.c b/converter/other/fiasco/codec/subdivide.c
index 3ddf1ffc..7eb951c0 100644
--- a/converter/other/fiasco/codec/subdivide.c
+++ b/converter/other/fiasco/codec/subdivide.c
@@ -1,7 +1,7 @@
 /*
- *  subdivide.c:	Recursive subdivision of range images
+ *  subdivide.c:        Recursive subdivision of range images
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -41,27 +41,27 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static void
 init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range,
-		const range_t *child, const int *y_state,
-		wfa_t *wfa, coding_t *c);
+                const range_t *child, const int *y_state,
+                wfa_t *wfa, coding_t *c);
 static void
 init_range (range_t *range, const image_t *image, unsigned band,
-	    const wfa_t *wfa, coding_t *c);
+            const wfa_t *wfa, coding_t *c);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
 real_t
 subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
-	   wfa_t *wfa, coding_t *c, bool_t prediction, bool_t delta)
+           wfa_t *wfa, coding_t *c, bool_t prediction, bool_t delta)
 /*
  *  Subdivide the current 'range' recursively and decide whether
  *  a linear combination, a recursive subdivision, or a prediction is
@@ -73,46 +73,46 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
  *  If 'delta' is TRUE then current range is already predicted.
  *
  *  Return value:
- *	costs of the best approximation or MAXCOSTS if costs exceed 'max_costs'
+ *      costs of the best approximation or MAXCOSTS if costs exceed 'max_costs'
  *
  *  Side effects:
- *	'range'	factors and costs of linear combination are modified
- *      'wfa'	new transitions and prediction coefficients are added
- *	'c'	pixels and inner products are updated
+ *      'range' factors and costs of linear combination are modified
+ *      'wfa'   new transitions and prediction coefficients are added
+ *      'c'     pixels and inner products are updated
  */
 {
    real_t    subdivide_costs;        /* Costs arising from approx. the current
-				       range with two children */
+                                       range with two children */
    real_t    lincomb_costs;          /* Costs arising from approx. the current
-				       range with a linear combination */
-   int	     new_y_state [MAXLABELS];	/* Corresponding state of Y */
-   real_t    price;			/* Approximation costs multiplier */
-   bool_t    try_mc;			/* YES: try MC prediction */
-   bool_t    try_nd;			/* YES: try ND prediction */
-   unsigned  states;			/* Number of states before the
-					   recursive subdivision starts */
-   void     *domain_model;		/* copy of domain pool model */
-   void     *d_domain_model;		/* copy of delta domain pool model */
-   void     *lc_domain_model;		/* copy of domain pool model */
-   void     *lc_d_domain_model;		/* copy of delta domain pool model */
-   void	    *coeff_model;	        /* copy of coefficients model */
-   void	    *d_coeff_model;		/* copy of delta coefficients model */
-   void	    *lc_coeff_model;	        /* copy of coefficients model */
-   void	    *lc_d_coeff_model;		/* copy of delta coefficients model */
-   tree_t    tree_model;		/* copy of tree model */
-   tree_t    p_tree_model;		/* copy of pred. tree model */
-   range_t   lrange;			/* range of lin. comb. approx. */
-   range_t   rrange;			/* range of recursive approx. */
-   range_t   child [MAXLABELS];		/* new children of the current range */
-   static unsigned percent = 0;		/* status of progress meter */
+                                       range with a linear combination */
+   int       new_y_state [MAXLABELS];   /* Corresponding state of Y */
+   real_t    price;                     /* Approximation costs multiplier */
+   bool_t    try_mc;                    /* YES: try MC prediction */
+   bool_t    try_nd;                    /* YES: try ND prediction */
+   unsigned  states;                    /* Number of states before the
+                                           recursive subdivision starts */
+   void     *domain_model;              /* copy of domain pool model */
+   void     *d_domain_model;            /* copy of delta domain pool model */
+   void     *lc_domain_model;           /* copy of domain pool model */
+   void     *lc_d_domain_model;         /* copy of delta domain pool model */
+   void     *coeff_model;               /* copy of coefficients model */
+   void     *d_coeff_model;             /* copy of delta coefficients model */
+   void     *lc_coeff_model;            /* copy of coefficients model */
+   void     *lc_d_coeff_model;          /* copy of delta coefficients model */
+   tree_t    tree_model;                /* copy of tree model */
+   tree_t    p_tree_model;              /* copy of pred. tree model */
+   range_t   lrange;                    /* range of lin. comb. approx. */
+   range_t   rrange;                    /* range of recursive approx. */
+   range_t   child [MAXLABELS];         /* new children of the current range */
+   static unsigned percent = 0;         /* status of progress meter */
 
    if (wfa->wfainfo->level == range->level)
       percent = 0;
 
-   range->into [0] = NO_EDGE;		/* default approximation: empty */
+   range->into [0] = NO_EDGE;           /* default approximation: empty */
    range->tree     = RANGE;
 
-   if (range->level < 3)		/* Don't process small ranges */
+   if (range->level < 3)                /* Don't process small ranges */
       return MAXCOSTS;
 
    /*
@@ -122,35 +122,35 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
    if (c->tiling->exponent
        && range->level == wfa->wfainfo->level - c->tiling->exponent)
    {
-      unsigned width, height;		/* size of range (dummies)*/
+      unsigned width, height;           /* size of range (dummies)*/
 
       if (c->tiling->vorder [range->global_address] < 0)
-	 return 0;			/* nothing to do */
+         return 0;                      /* nothing to do */
       else
-	 locate_subimage (wfa->wfainfo->level, range->level,
-			  c->tiling->vorder [range->global_address],
-			  &range->x, &range->y, &width, &height);
+         locate_subimage (wfa->wfainfo->level, range->level,
+                          c->tiling->vorder [range->global_address],
+                          &range->x, &range->y, &width, &height);
    }
 
    if (range->x >= c->mt->original->width ||
        range->y >= c->mt->original->height)
-      return 0;				/* range is not visible */
+      return 0;                         /* range is not visible */
 
    /*
     *  Check whether prediction is allowed or not
     *  mc == motion compensation, nd == nondeterminism
     */
    try_mc = (prediction && c->mt->frame_type != I_FRAME
-	     && range->level >= wfa->wfainfo->p_min_level
-	     && range->level <= wfa->wfainfo->p_max_level
-	     && (range->x + width_of_level (range->level)
-		 <= c->mt->original->width)
-	     && (range->y + height_of_level (range->level)
-		 <= c->mt->original->height));
+             && range->level >= wfa->wfainfo->p_min_level
+             && range->level <= wfa->wfainfo->p_max_level
+             && (range->x + width_of_level (range->level)
+                 <= c->mt->original->width)
+             && (range->y + height_of_level (range->level)
+                 <= c->mt->original->height));
 
    try_nd = (prediction && c->mt->frame_type == I_FRAME
-	     && range->level >= wfa->wfainfo->p_min_level
-	     && range->level <= wfa->wfainfo->p_max_level);
+             && range->level >= wfa->wfainfo->p_min_level
+             && range->level <= wfa->wfainfo->p_max_level);
 
    if (try_mc)
       clear_norms_table (range->level, wfa->wfainfo, c->mt);
@@ -171,15 +171,15 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
    /*
     *  Compute children of corresponding state in Y band
     */
-   if (band != Y)			/* Cb and Cr bands only */
+   if (band != Y)                       /* Cb and Cr bands only */
    {
       unsigned label;
 
       for (label = 0; label < MAXLABELS; label++)
-	 if (ischild (y_state))
-	    new_y_state [label] = wfa->tree [y_state][label];
-	 else
-	    new_y_state [label] = RANGE;
+         if (ischild (y_state))
+            new_y_state [label] = wfa->tree [y_state][label];
+         else
+            new_y_state [label] = RANGE;
    }
    else
       new_y_state [0] = new_y_state [1] = RANGE;
@@ -210,13 +210,13 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
       lrange.mv_coord_bits   = 0;
       lrange.nd_tree_bits    = 0;
       lrange.nd_weights_bits = 0;
-      lrange.prediction	     = NO;
+      lrange.prediction      = NO;
 
       lincomb_costs
-	 = approximate_range (max_costs, price, c->options.max_elements,
-			      y_state, &lrange,
-			      (delta ? c->d_domain_pool : c->domain_pool),
-			      (delta ? c->d_coeff : c->coeff), wfa, c);
+         = approximate_range (max_costs, price, c->options.max_elements,
+                              y_state, &lrange,
+                              (delta ? c->d_domain_pool : c->domain_pool),
+                              (delta ? c->d_coeff : c->coeff), wfa, c);
    }
    else
       lincomb_costs = MAXCOSTS;
@@ -236,7 +236,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
    c->d_domain_pool->model = c->d_domain_pool->model_duplicate (d_domain_model);
    c->coeff->model         = c->coeff->model_duplicate (c->coeff, coeff_model);
    c->d_coeff->model       = c->d_coeff->model_duplicate (c->d_coeff,
-							  d_coeff_model);
+                                                          d_coeff_model);
 
    /*
     *  Second alternative of range approximation:
@@ -256,122 +256,122 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
       rrange.matrix_bits     = 0;
       rrange.weights_bits    = 0;
       rrange.err             = 0;
-      rrange.mv_tree_bits    = try_mc ? 1 : 0;	/* mc allowed but not used */
+      rrange.mv_tree_bits    = try_mc ? 1 : 0;  /* mc allowed but not used */
       rrange.mv_coord_bits   = 0;
       rrange.nd_tree_bits    = try_nd ?
-			       tree_bits (CHILD, lrange.level, &c->p_tree): 0;
+                               tree_bits (CHILD, lrange.level, &c->p_tree): 0;
       rrange.nd_weights_bits = 0;
-      rrange.prediction	     = NO;
+      rrange.prediction      = NO;
 
       /*
        *  Initialize the cost function and subdivide the current range.
        *  Every child is approximated by a recursive call of subdivide()
        */
       subdivide_costs = (rrange.tree_bits + rrange.weights_bits
-			 + rrange.matrix_bits + rrange.mv_tree_bits
-			 + rrange.mv_coord_bits + rrange.nd_tree_bits
-			 + rrange.nd_weights_bits) * price;
+                         + rrange.matrix_bits + rrange.mv_tree_bits
+                         + rrange.mv_coord_bits + rrange.nd_tree_bits
+                         + rrange.nd_weights_bits) * price;
 
       for (label = 0; label < MAXLABELS; label++)
       {
-	 real_t remaining_costs;	/* upper limit for next recursion */
-
-	 child[label].image          = rrange.image * MAXLABELS + label + 1;
-	 child[label].address        = rrange.address * MAXLABELS + label;
-	 child[label].global_address = rrange.global_address * MAXLABELS
-				       + label;
-	 child[label].level          = rrange.level - 1;
-	 child[label].x	= rrange.level & 1
-			  ? rrange.x
-			  : (rrange.x
-			     + label * width_of_level (rrange.level - 1));
-	 child[label].y = rrange.level & 1
-			  ? (rrange.y
-			     + label * height_of_level (rrange.level - 1))
-			  : rrange.y;
-
-	 /*
-	  *  If necessary compute the inner products of the new states
-	  *  (generated during the recursive approximation of child [0])
-	  */
-	 if (label && rrange.level <= c->options.lc_max_level)
-	    compute_ip_images_state (child[label].image, child[label].address,
-				     child[label].level, 1, states, wfa, c);
-	 /*
-	  *  Call subdivide() for both children.
-	  *  Abort the recursion if 'subdivide_costs' exceed 'lincomb_costs'
-	  *  or 'max_costs'.
-	  */
-	 remaining_costs = MIN(lincomb_costs, max_costs) - subdivide_costs;
-
-	 if (remaining_costs > 0)	/* still a way for improvement */
-	 {
-	    subdivide_costs += subdivide (remaining_costs, band,
-					  new_y_state [label], &child [label],
-					  wfa, c, prediction, delta);
-	 }
-	 else if (try_mc && child[label].level >= wfa->wfainfo->p_min_level)
-	 {
-	    fill_norms_table (child[label].x, child[label].y,
-			      child[label].level, wfa->wfainfo, c->mt);
-	 }
-
-	 if (try_mc)
-	    update_norms_table (rrange.level, wfa->wfainfo, c->mt);
-
-	 /*
-	  *  Update of progress meter
-	  */
-	 if (c->options.progress_meter != FIASCO_PROGRESS_NONE)
-	 {
-	    if (c->options.progress_meter == FIASCO_PROGRESS_PERCENT)
-	    {
-	       unsigned	new_percent; 	/* new status of progress meter */
-
-	       new_percent = (child[label].global_address + 1) * 100.0
-			     / (1 << (wfa->wfainfo->level - child[label].level));
-	       if (new_percent > percent)
-	       {
-		  percent = new_percent;
-		  info ("%3d%%  \r", percent);
-	       }
-	    }
-	    else if (c->options.progress_meter == FIASCO_PROGRESS_BAR)
-	    {
-	       unsigned	new_percent;	/* new status of progress meter */
-
-	       new_percent = (child[label].global_address + 1) * 50.0
-			     / (1 << (wfa->wfainfo->level
-				      - child[label].level));
-	       for (; new_percent > percent; percent++)
-	       {
-		  info ("#");
-	       }
-	    }
-	 }
-
-	 /*
-	  *  If costs of subdivision exceed costs of linear combination
-	  *  then abort recursion.
-	  */
-	 if (subdivide_costs >= MIN(lincomb_costs, max_costs))
-	 {
-	    subdivide_costs = MAXCOSTS;
-	    break;
-	 }
-	 rrange.err             += child [label].err;
-	 rrange.tree_bits       += child [label].tree_bits;
-	 rrange.matrix_bits     += child [label].matrix_bits;
-	 rrange.weights_bits    += child [label].weights_bits;
-	 rrange.mv_tree_bits    += child [label].mv_tree_bits;
-	 rrange.mv_coord_bits   += child [label].mv_coord_bits;
-	 rrange.nd_weights_bits += child [label].nd_weights_bits;
-	 rrange.nd_tree_bits    += child [label].nd_tree_bits;
-
-	 tree_update (ischild (child [label].tree) ? CHILD : LEAF,
-		      child [label].level, &c->tree);
-	 tree_update (child [label].prediction ? LEAF : CHILD,
-		      child [label].level, &c->p_tree);
+         real_t remaining_costs;        /* upper limit for next recursion */
+
+         child[label].image          = rrange.image * MAXLABELS + label + 1;
+         child[label].address        = rrange.address * MAXLABELS + label;
+         child[label].global_address = rrange.global_address * MAXLABELS
+                                       + label;
+         child[label].level          = rrange.level - 1;
+         child[label].x = rrange.level & 1
+                          ? rrange.x
+                          : (rrange.x
+                             + label * width_of_level (rrange.level - 1));
+         child[label].y = rrange.level & 1
+                          ? (rrange.y
+                             + label * height_of_level (rrange.level - 1))
+                          : rrange.y;
+
+         /*
+          *  If necessary compute the inner products of the new states
+          *  (generated during the recursive approximation of child [0])
+          */
+         if (label && rrange.level <= c->options.lc_max_level)
+            compute_ip_images_state (child[label].image, child[label].address,
+                                     child[label].level, 1, states, wfa, c);
+         /*
+          *  Call subdivide() for both children.
+          *  Abort the recursion if 'subdivide_costs' exceed 'lincomb_costs'
+          *  or 'max_costs'.
+          */
+         remaining_costs = MIN(lincomb_costs, max_costs) - subdivide_costs;
+
+         if (remaining_costs > 0)       /* still a way for improvement */
+         {
+            subdivide_costs += subdivide (remaining_costs, band,
+                                          new_y_state [label], &child [label],
+                                          wfa, c, prediction, delta);
+         }
+         else if (try_mc && child[label].level >= wfa->wfainfo->p_min_level)
+         {
+            fill_norms_table (child[label].x, child[label].y,
+                              child[label].level, wfa->wfainfo, c->mt);
+         }
+
+         if (try_mc)
+            update_norms_table (rrange.level, wfa->wfainfo, c->mt);
+
+         /*
+          *  Update of progress meter
+          */
+         if (c->options.progress_meter != FIASCO_PROGRESS_NONE)
+         {
+            if (c->options.progress_meter == FIASCO_PROGRESS_PERCENT)
+            {
+               unsigned new_percent;    /* new status of progress meter */
+
+               new_percent = (child[label].global_address + 1) * 100.0
+                             / (1 << (wfa->wfainfo->level - child[label].level));
+               if (new_percent > percent)
+               {
+                  percent = new_percent;
+                  info ("%3d%%  \r", percent);
+               }
+            }
+            else if (c->options.progress_meter == FIASCO_PROGRESS_BAR)
+            {
+               unsigned new_percent;    /* new status of progress meter */
+
+               new_percent = (child[label].global_address + 1) * 50.0
+                             / (1 << (wfa->wfainfo->level
+                                      - child[label].level));
+               for (; new_percent > percent; percent++)
+               {
+                  info ("#");
+               }
+            }
+         }
+
+         /*
+          *  If costs of subdivision exceed costs of linear combination
+          *  then abort recursion.
+          */
+         if (subdivide_costs >= MIN(lincomb_costs, max_costs))
+         {
+            subdivide_costs = MAXCOSTS;
+            break;
+         }
+         rrange.err             += child [label].err;
+         rrange.tree_bits       += child [label].tree_bits;
+         rrange.matrix_bits     += child [label].matrix_bits;
+         rrange.weights_bits    += child [label].weights_bits;
+         rrange.mv_tree_bits    += child [label].mv_tree_bits;
+         rrange.mv_coord_bits   += child [label].mv_coord_bits;
+         rrange.nd_weights_bits += child [label].nd_weights_bits;
+         rrange.nd_tree_bits    += child [label].nd_tree_bits;
+
+         tree_update (ischild (child [label].tree) ? CHILD : LEAF,
+                      child [label].level, &c->tree);
+         tree_update (child [label].prediction ? LEAF : CHILD,
+                      child [label].level, &c->p_tree);
       }
    }
    else
@@ -382,9 +382,9 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
     *  Predict range via motion compensation or nondeterminism and
     *  approximate delta image.
     */
-   if (try_mc || try_nd)		/* try prediction */
+   if (try_mc || try_nd)                /* try prediction */
    {
-       real_t prediction_costs;	/* Costs arising from approx. the current
+       real_t prediction_costs; /* Costs arising from approx. the current
                                    range with prediction */
 
        prediction_costs
@@ -393,7 +393,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
                             price, range, wfa, c, band, y_state, states,
                             &tree_model, &p_tree_model, domain_model,
                             d_domain_model, coeff_model, d_coeff_model);
-       if (prediction_costs < MAXCOSTS)	/* prediction has smallest costs */
+       if (prediction_costs < MAXCOSTS) /* prediction has smallest costs */
        {
            c->domain_pool->model_free (domain_model);
            c->d_domain_pool->model_free (d_domain_model);
@@ -426,13 +426,13 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
 
       c->domain_pool->model   = domain_model;
       c->d_domain_pool->model = d_domain_model;
-      c->coeff->model	      = coeff_model;
-      c->d_coeff->model	      = d_coeff_model;
+      c->coeff->model         = coeff_model;
+      c->d_coeff->model       = d_coeff_model;
       c->tree                 = tree_model;
       c->p_tree               = p_tree_model;
 
       if (wfa->states != states)
-	 remove_states (states, wfa);
+         remove_states (states, wfa);
 
       return MAXCOSTS;
    }
@@ -455,15 +455,15 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
 
       c->domain_pool->model   = lc_domain_model;
       c->d_domain_pool->model = lc_d_domain_model;
-      c->coeff->model	      = lc_coeff_model;
-      c->d_coeff->model	      = lc_d_coeff_model;
+      c->coeff->model         = lc_coeff_model;
+      c->d_coeff->model       = lc_d_coeff_model;
       c->tree                 = tree_model;
       c->p_tree               = p_tree_model;
 
       *range = lrange;
 
       if (wfa->states != states)
-	 remove_states (states, wfa);
+         remove_states (states, wfa);
 
       return lincomb_costs;
    }
@@ -478,15 +478,15 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
        *  - if state is (partially) outside image geometry
        */
       if (band > Y
-	  || (c->tiling->exponent
-	      && rrange.level > wfa->wfainfo->level - c->tiling->exponent)
-	  || (range->x + width_of_level (range->level)
-	      > c->mt->original->width)
-	  || (range->y + height_of_level (range->level)
-	      > c->mt->original->height))
-	 init_new_state (YES, delta, &rrange, child, new_y_state, wfa, c);
+          || (c->tiling->exponent
+              && rrange.level > wfa->wfainfo->level - c->tiling->exponent)
+          || (range->x + width_of_level (range->level)
+              > c->mt->original->width)
+          || (range->y + height_of_level (range->level)
+              > c->mt->original->height))
+         init_new_state (YES, delta, &rrange, child, new_y_state, wfa, c);
       else
-	 init_new_state (NO, delta, &rrange, child, new_y_state, wfa, c);
+         init_new_state (NO, delta, &rrange, child, new_y_state, wfa, c);
 
       *range = rrange;
 
@@ -505,8 +505,8 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
 
 void
 cut_to_bintree (real_t *dst, const word_t *src,
-		unsigned src_width, unsigned src_height,
-		unsigned x0, unsigned y0, unsigned width, unsigned height)
+                unsigned src_width, unsigned src_height,
+                unsigned x0, unsigned y0, unsigned width, unsigned height)
 /*
  *  Cut region ('x0', 'y0', 'width', 'height') of the pixel array 'src'.
  *  Size of image is given by 'src_width' x 'src_height'.
@@ -515,15 +515,15 @@ cut_to_bintree (real_t *dst, const word_t *src,
  *  No return value.
  *
  *  Side effects:
- *	'dst []' is filled with corresponding region.
+ *      'dst []' is filled with corresponding region.
  */
 {
    const unsigned mask01      = 0x555555; /* binary ...010101010101 */
    const unsigned mask10      = 0xaaaaaa; /* binary ...101010101010 */
    const unsigned mask01plus1 = mask01 + 1; /* binary ...010101010110 */
    const unsigned mask10plus1 = mask10 + 1; /* binary ...101010101011 */
-   unsigned  	  x, y;			/* pixel coordinates */
-   unsigned  	  xmask, ymask;		/* address conversion */
+   unsigned       x, y;                 /* pixel coordinates */
+   unsigned       xmask, ymask;         /* address conversion */
 
    if (width != height && width != (height >> 1))
       error ("Bintree cutting requires special type of images.");
@@ -534,24 +534,24 @@ cut_to_bintree (real_t *dst, const word_t *src,
       xmask = 0;
       for (x = x0; x < x0 + width; x++, xmask = (xmask + mask01plus1) & mask10)
       {
-	 if (y >= src_height || x >= src_width)
-	    dst [xmask | ymask] = 0;
-	 else
-	    dst [xmask | ymask] = src [y * src_width + x] / 16;
+         if (y >= src_height || x >= src_width)
+            dst [xmask | ymask] = 0;
+         else
+            dst [xmask | ymask] = src [y * src_width + x] / 16;
       }
    }
 }
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static void
 init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range,
-		const range_t *child, const int *y_state,
-		wfa_t *wfa, coding_t *c)
+                const range_t *child, const int *y_state,
+                wfa_t *wfa, coding_t *c)
 /*
  *  Initializes a new state with all parameters needed for the encoding step.
  *  If flag 'auxiliary_state' is set then don't insert state into domain pools.
@@ -563,7 +563,7 @@ init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range,
  *  No return value.
  *
  *  Side effects:
- *	New state is appended to 'wfa' (and also its inner products and images
+ *      New state is appended to 'wfa' (and also its inner products and images
  *      are computed and stored in 'c')
  */
 {
@@ -573,13 +573,13 @@ init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range,
    if (!auxiliary_state)
    {
       if (!delta || c->options.delta_domains)
-	 state_is_domain = c->domain_pool->append (wfa->states, range->level,
-						   wfa, c->domain_pool->model);
+         state_is_domain = c->domain_pool->append (wfa->states, range->level,
+                                                   wfa, c->domain_pool->model);
       if (delta || c->options.normal_domains)
-	 state_is_domain = c->d_domain_pool->append (wfa->states, range->level,
-						     wfa,
-						     c->d_domain_pool->model)
-			   || state_is_domain;
+         state_is_domain = c->d_domain_pool->append (wfa->states, range->level,
+                                                     wfa,
+                                                     c->d_domain_pool->model)
+                           || state_is_domain;
    }
    else
       state_is_domain = NO;
@@ -597,7 +597,7 @@ init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range,
       wfa->prediction [wfa->states][label] = child [label].prediction;
 
       append_transitions (wfa->states, label, child [label].weight,
-			  child [label].into, wfa);
+                          child [label].into, wfa);
    }
    wfa->delta_state [wfa->states] = delta;
 
@@ -607,13 +607,13 @@ init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range,
 /*    state_is_domain = YES; */
 
    append_state (!state_is_domain,
-		 compute_final_distribution (wfa->states, wfa),
-		 range->level, wfa, c);
+                 compute_final_distribution (wfa->states, wfa),
+                 range->level, wfa, c);
 }
 
 static void
 init_range (range_t *range, const image_t *image, unsigned band,
-	    const wfa_t *wfa, coding_t *c)
+            const wfa_t *wfa, coding_t *c)
 /*
  *  Read a new 'range' of the image 'image_name' (current color component
  *  is 'band') and compute the new inner product arrays.
@@ -621,9 +621,9 @@ init_range (range_t *range, const image_t *image, unsigned band,
  *  No return value.
  *
  *  Side effects:
- *	'c->pixels' are filled with pixel values of image block
- *	'c->ip_images_state' are computed with respect to new image block
- *	'range->address' and 'range->image' are initialized with zero
+ *      'c->pixels' are filled with pixel values of image block
+ *      'c->ip_images_state' are computed with respect to new image block
+ *      'range->address' and 'range->image' are initialized with zero
  */
 {
    unsigned state;
@@ -633,13 +633,13 @@ init_range (range_t *range, const image_t *image, unsigned band,
     */
    for (state = 0; state < wfa->states; state++)
       if (need_image (state, wfa))
-	 memset (c->ip_images_state[state], 0,
-		 size_of_tree (c->products_level) * sizeof(real_t));
+         memset (c->ip_images_state[state], 0,
+                 size_of_tree (c->products_level) * sizeof(real_t));
 
    cut_to_bintree (c->pixels, image->pixels [band],
-		   image->width, image->height,
-		   range->x, range->y, width_of_level (range->level),
-		   height_of_level (range->level));
+                   image->width, image->height,
+                   range->x, range->y, width_of_level (range->level),
+                   height_of_level (range->level));
 
    range->address = range->image = 0;
    compute_ip_images_state (0, 0, range->level, 1, 0, wfa, c);
diff --git a/converter/other/fiasco/codec/subdivide.h b/converter/other/fiasco/codec/subdivide.h
index bd9cd10e..dbd5620a 100644
--- a/converter/other/fiasco/codec/subdivide.h
+++ b/converter/other/fiasco/codec/subdivide.h
@@ -1,8 +1,8 @@
 /*
  *  subdivide.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -20,13 +20,13 @@
 #include "types.h"
 #include "cwfa.h"
 
-real_t 
+real_t
 subdivide (real_t max_costs, unsigned band, int y_state, range_t *range,
-	   wfa_t *wfa, coding_t *c, bool_t prediction, bool_t delta);
+           wfa_t *wfa, coding_t *c, bool_t prediction, bool_t delta);
 void
 cut_to_bintree (real_t *dst, const word_t *src,
-		unsigned src_width, unsigned src_height,
-		unsigned x0, unsigned y0, unsigned width, unsigned height);
+                unsigned src_width, unsigned src_height,
+                unsigned x0, unsigned y0, unsigned width, unsigned height);
 
 #endif /* not _SUBDIVIDE_H */
 
diff --git a/converter/other/fiasco/codec/tiling.c b/converter/other/fiasco/codec/tiling.c
index 9af43da0..08423b24 100644
--- a/converter/other/fiasco/codec/tiling.c
+++ b/converter/other/fiasco/codec/tiling.c
@@ -1,8 +1,8 @@
 /*
- *  tiling.c:		Subimage permutation
+ *  tiling.c:           Subimage permutation
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -33,8 +33,8 @@
 
 typedef struct var_list
 {
-   int	  address;			/* bintree address */
-   real_t variance;			/* variance of tile */
+   int    address;                      /* bintree address */
+   real_t variance;                     /* variance of tile */
 } var_list_t;
 
 #ifndef LITERAL_FN_DEF_MATCH
@@ -71,17 +71,17 @@ cmpdecvar(const void * const value1,
 
 tiling_t *
 alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent,
-	      unsigned image_level)
+              unsigned image_level)
 /*
  *  Image tiling constructor.
  *  Allocate memory for the tiling_t structure.
  *  `method' defines the tiling method (spiral or variance,
  *  ascending or descending).
  *  In case of invalid parameters, a structure with tiling.exponent == 0 is
- *  returned. 
+ *  returned.
  *
  *  Return value
- *	pointer to the new tiling structure on success
+ *      pointer to the new tiling structure on success
  */
 {
    tiling_t *tiling = Calloc (1, sizeof (tiling_t));
@@ -90,21 +90,21 @@ alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent,
    {
       tiling_exponent = 6;
       warning (_("Image tiles must be at least 8x8 pixels large.\n"
-		 "Setting tiling size to 8x8 pixels."));
+                 "Setting tiling size to 8x8 pixels."));
    }
-   
+
    switch (method)
    {
       case FIASCO_TILING_SPIRAL_ASC:
       case FIASCO_TILING_SPIRAL_DSC:
       case FIASCO_TILING_VARIANCE_ASC:
       case FIASCO_TILING_VARIANCE_DSC:
-	 tiling_exponent = tiling_exponent;
-	 break;
+         tiling_exponent = tiling_exponent;
+         break;
       default:
-	 warning (_("Invalid tiling method specified. Disabling tiling."));
-	 tiling_exponent = 0;
-	 break;
+         warning (_("Invalid tiling method specified. Disabling tiling."));
+         tiling_exponent = 0;
+         break;
    }
 
    return tiling;
@@ -119,7 +119,7 @@ free_tiling (tiling_t *tiling)
  *  No return value.
  *
  *  Side effects:
- *	structure 'tiling' is discarded.
+ *      structure 'tiling' is discarded.
  */
 {
    if (tiling->vorder)
@@ -145,88 +145,88 @@ perform_tiling (const image_t *image, tiling_t *tiling)
  *  No return value.
  *
  *  Side effects:
- *	The tiling permutation is stored in 'tiling->vorder'.
+ *      The tiling permutation is stored in 'tiling->vorder'.
  */
 {
    if (tiling->exponent)
    {
-      unsigned 	tiles = 1 << tiling->exponent; /* number of image tiles */
-      bool_t   *tile_valid;		/* tile i is in valid range ? */
-      
+      unsigned  tiles = 1 << tiling->exponent; /* number of image tiles */
+      bool_t   *tile_valid;             /* tile i is in valid range ? */
+
       tiling->vorder = Calloc (tiles, sizeof (int));
       tile_valid     = Calloc (tiles, sizeof (bool_t));
 
       if (tiling->method == FIASCO_TILING_VARIANCE_ASC
-	  || tiling->method == FIASCO_TILING_VARIANCE_DSC)
+          || tiling->method == FIASCO_TILING_VARIANCE_DSC)
       {
-	 unsigned    address;		/* bintree address of tile */
-	 unsigned    number;		/* number of image tiles */
-	 unsigned    lx       = log2 (image->width - 1) + 1; /* x level */
-	 unsigned    ly       = log2 (image->height - 1) + 1; /* y level */
-	 unsigned    level    = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0);
-	 var_list_t *var_list = Calloc (tiles, sizeof (var_list_t));
-	 
-	 /*
-	  *  Compute variances of image tiles
-	  */
-	 for (number = 0, address = 0; address < tiles; address++)
-	 {
-	    unsigned width, height;	/* size of image tile */
-	    unsigned x0, y0;		/* NW corner of image tile */
-      
-	    locate_subimage (level, level - tiling->exponent, address,
-			     &x0, &y0, &width, &height);
-	    if (x0 < image->width && y0 < image->height) /* valid range */
-	    {
-	       if (x0 + width > image->width)	/* outside image area */
-		  width = image->width - x0;
-	       if (y0 + height > image->height) /* outside image area */
-		  height = image->height - y0;
-
-	       var_list [number].variance
-		  = variance (image->pixels [GRAY], x0, y0,
-			      width, height, image->width);
-	       var_list [number].address  = address;
-	       number++;
-	       tile_valid [address] = YES;
-	    }
-	    else
-	       tile_valid [address] = NO;
-	 }
-
-	 /*
-	  *  Sort image tiles according to sign of 'tiling->exp'
-	  */
-	 if (tiling->method == FIASCO_TILING_VARIANCE_DSC)
-	    qsort (var_list, number, sizeof (var_list_t), cmpdecvar);
-	 else
-	    qsort (var_list, number, sizeof (var_list_t), cmpincvar);
-
-	 for (number = 0, address = 0; address < tiles; address++)
-	    if (tile_valid [address])
-	    {
-	       tiling->vorder [address] = var_list [number].address;
-	       number++;
-	       debug_message ("tile number %d has original address %d",
-			      number, tiling->vorder [address]);
-	    }
-	    else
-	       tiling->vorder [address] = -1;
-
-	 Free (var_list);
+         unsigned    address;           /* bintree address of tile */
+         unsigned    number;            /* number of image tiles */
+         unsigned    lx       = log2 (image->width - 1) + 1; /* x level */
+         unsigned    ly       = log2 (image->height - 1) + 1; /* y level */
+         unsigned    level    = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0);
+         var_list_t *var_list = Calloc (tiles, sizeof (var_list_t));
+
+         /*
+          *  Compute variances of image tiles
+          */
+         for (number = 0, address = 0; address < tiles; address++)
+         {
+            unsigned width, height;     /* size of image tile */
+            unsigned x0, y0;            /* NW corner of image tile */
+
+            locate_subimage (level, level - tiling->exponent, address,
+                             &x0, &y0, &width, &height);
+            if (x0 < image->width && y0 < image->height) /* valid range */
+            {
+               if (x0 + width > image->width)   /* outside image area */
+                  width = image->width - x0;
+               if (y0 + height > image->height) /* outside image area */
+                  height = image->height - y0;
+
+               var_list [number].variance
+                  = variance (image->pixels [GRAY], x0, y0,
+                              width, height, image->width);
+               var_list [number].address  = address;
+               number++;
+               tile_valid [address] = YES;
+            }
+            else
+               tile_valid [address] = NO;
+         }
+
+         /*
+          *  Sort image tiles according to sign of 'tiling->exp'
+          */
+         if (tiling->method == FIASCO_TILING_VARIANCE_DSC)
+            qsort (var_list, number, sizeof (var_list_t), cmpdecvar);
+         else
+            qsort (var_list, number, sizeof (var_list_t), cmpincvar);
+
+         for (number = 0, address = 0; address < tiles; address++)
+            if (tile_valid [address])
+            {
+               tiling->vorder [address] = var_list [number].address;
+               number++;
+               debug_message ("tile number %d has original address %d",
+                              number, tiling->vorder [address]);
+            }
+            else
+               tiling->vorder [address] = -1;
+
+         Free (var_list);
       }
       else if (tiling->method == FIASCO_TILING_SPIRAL_DSC
-	       || tiling->method == FIASCO_TILING_SPIRAL_ASC)
+               || tiling->method == FIASCO_TILING_SPIRAL_ASC)
       {
-	 compute_spiral (tiling->vorder, image->width, image->height,
-			 tiling->exponent,
-			 tiling->method == FIASCO_TILING_SPIRAL_ASC);
+         compute_spiral (tiling->vorder, image->width, image->height,
+                         tiling->exponent,
+                         tiling->method == FIASCO_TILING_SPIRAL_ASC);
       }
       else
       {
-	 warning ("We do not know the tiling method.\n"
-		  "Skipping image tiling step.");
-	 tiling->exponent = 0;
+         warning ("We do not know the tiling method.\n"
+                  "Skipping image tiling step.");
+         tiling->exponent = 0;
       }
    }
 }
diff --git a/converter/other/fiasco/codec/tiling.h b/converter/other/fiasco/codec/tiling.h
index 6668ad8b..ef6d426d 100644
--- a/converter/other/fiasco/codec/tiling.h
+++ b/converter/other/fiasco/codec/tiling.h
@@ -1,8 +1,8 @@
 /*
  *  tiling.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -22,17 +22,17 @@
 
 typedef struct tiling
 {
-   unsigned    	    exponent;		/* Image is split in 2^exp tiles */
-   fiasco_tiling_e  method;		/* Method of Image tiling */
-   int	      	   *vorder;		/* Block permutation (size = 2^exp)
-					   -1 indicates empty block */
+   unsigned         exponent;           /* Image is split in 2^exp tiles */
+   fiasco_tiling_e  method;             /* Method of Image tiling */
+   int             *vorder;             /* Block permutation (size = 2^exp)
+                                           -1 indicates empty block */
 } tiling_t;
 
 void
 perform_tiling (const image_t *image, tiling_t *tiling);
 tiling_t *
 alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent,
-	      unsigned image_level);
+              unsigned image_level);
 void
 free_tiling (tiling_t *tiling);
 
diff --git a/converter/other/fiasco/codec/wfa.h b/converter/other/fiasco/codec/wfa.h
index 4e66ccbd..ae86d216 100644
--- a/converter/other/fiasco/codec/wfa.h
+++ b/converter/other/fiasco/codec/wfa.h
@@ -1,7 +1,7 @@
 /*
  *  wfa.h
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -19,38 +19,38 @@
 
 #define MAXEDGES  5
 #define MAXSTATES 6000
-#define MAXLABELS 2			/* only bintree possible anymore */
+#define MAXLABELS 2                     /* only bintree possible anymore */
 #define MAXLEVEL  22
 
 #define FIASCO_BINFILE_RELEASE   2
-#define FIASCO_MAGIC	         "FIASCO" /* FIASCO magic number */
+#define FIASCO_MAGIC             "FIASCO" /* FIASCO magic number */
 #define FIASCO_BASIS_MAGIC       "Fiasco" /* FIASCO initial basis */
 
-#define NO_EDGE		-1
-#define RANGE		-1
-#define NO_RANGE	 0
+#define NO_EDGE         -1
+#define RANGE           -1
+#define NO_RANGE         0
 
-#define CHILD		 1
-#define LEAF		 0
+#define CHILD            1
+#define LEAF             0
 
-#define MAX_PROB	 9
-#define MIN_PROB	 1
+#define MAX_PROB         9
+#define MIN_PROB         1
 
 /*
  *  WFA state types:
- *	0:		 state is not allowed to be used in an
- *			 approximation and it's image is not needed
- *			 for ip computations.
- *	AUXILIARY_MASK:  state is required for computation of ip's but is not
- *			 allowed to be used in an approximation.
- *	USE_DOMAIN_MASK: state is allowed to be used in an approximation.
+ *      0:               state is not allowed to be used in an
+ *                       approximation and it's image is not needed
+ *                       for ip computations.
+ *      AUXILIARY_MASK:  state is required for computation of ip's but is not
+ *                       allowed to be used in an approximation.
+ *      USE_DOMAIN_MASK: state is allowed to be used in an approximation.
  */
 enum state_types {AUXILIARY_MASK = 1 << 0, USE_DOMAIN_MASK = 1 << 1};
 
-#define isedge(x)	   ((x) != NO_EDGE)
-#define isdomain(x)	   ((x) != NO_EDGE)
-#define isrange(x)	   ((x) == RANGE)
-#define ischild(x)	   ((x) != RANGE)
+#define isedge(x)          ((x) != NO_EDGE)
+#define isdomain(x)        ((x) != NO_EDGE)
+#define isrange(x)         ((x) == RANGE)
+#define ischild(x)         ((x) != RANGE)
 #define isauxiliary(d,wfa) ((wfa)->domain_type[d] & AUXILIARY_MASK)
 #define usedomain(d, wfa)  ((wfa)->domain_type[d] & USE_DOMAIN_MASK)
 #define need_image(d,wfa)  (isauxiliary ((d), (wfa)) || usedomain ((d), (wfa)))
@@ -64,15 +64,15 @@ typedef struct mv
  *  Motion vector components
  */
 {
-   mc_type_e type;			/* motion compensation type */
-   int       fx, fy;			/* forward vector coordinates */
-   int       bx, by;			/* backward vector coordinates */
+   mc_type_e type;                      /* motion compensation type */
+   int       fx, fy;                    /* forward vector coordinates */
+   int       bx, by;                    /* backward vector coordinates */
 } mv_t;
 
 typedef struct range_info
 {
-   unsigned x, y;			/* coordinates of upper left corner */
-   unsigned level;			/* bintree level of range */
+   unsigned x, y;                       /* coordinates of upper left corner */
+   unsigned level;                      /* bintree level of range */
 } range_info_t;
 
 #include "image.h"
@@ -81,32 +81,32 @@ typedef struct range_info
 
 typedef struct wfa_info
 {
-   char	    *wfa_name;			/* filename of the WFA */
-   char	    *basis_name;		/* filename of the initial basis */
-   char     *title;			/* title of FIASCO stream */
-   char     *comment;			/* comment for FIASCO stream */
-
-   unsigned  max_states;		/* max. cardinality of domain pool */
-   unsigned  chroma_max_states;		/* max. cardinality of domain pool for
-					   chroma band coding */
-   bool_t    color;			/* color image */
-   unsigned  width;			/* image width */
-   unsigned  height;			/* image height */
-   unsigned  level;			/* image level */
-   rpf_t    *rpf;			/* Standard reduced precision format */
-   rpf_t    *dc_rpf;			/* DC reduced precision format */
-   rpf_t    *d_rpf;			/* Delta reduced precision format */
-   rpf_t    *d_dc_rpf;			/* Delta DC reduced precision format */
-   unsigned  frames;			/* number of frames in the video */
-   unsigned  fps;			/* number of frames per second */
-   unsigned  p_min_level;		/* min. level of prediction */
-   unsigned  p_max_level;		/* max. level of prediction */
-   unsigned  search_range;		/* motion vector interval */
-   bool_t    half_pixel;		/* usage of half pixel precision */
-   bool_t    cross_B_search;		/* usage of Cross-B-Search */
-   bool_t    B_as_past_ref;		/* usage of B frames as ref's */
-   unsigned  smoothing;			/* smoothing of image along borders */
-   unsigned  release;			/* FIASCO file format release */
+   char     *wfa_name;                  /* filename of the WFA */
+   char     *basis_name;                /* filename of the initial basis */
+   char     *title;                     /* title of FIASCO stream */
+   char     *comment;                   /* comment for FIASCO stream */
+
+   unsigned  max_states;                /* max. cardinality of domain pool */
+   unsigned  chroma_max_states;         /* max. cardinality of domain pool for
+                                           chroma band coding */
+   bool_t    color;                     /* color image */
+   unsigned  width;                     /* image width */
+   unsigned  height;                    /* image height */
+   unsigned  level;                     /* image level */
+   rpf_t    *rpf;                       /* Standard reduced precision format */
+   rpf_t    *dc_rpf;                    /* DC reduced precision format */
+   rpf_t    *d_rpf;                     /* Delta reduced precision format */
+   rpf_t    *d_dc_rpf;                  /* Delta DC reduced precision format */
+   unsigned  frames;                    /* number of frames in the video */
+   unsigned  fps;                       /* number of frames per second */
+   unsigned  p_min_level;               /* min. level of prediction */
+   unsigned  p_max_level;               /* max. level of prediction */
+   unsigned  search_range;              /* motion vector interval */
+   bool_t    half_pixel;                /* usage of half pixel precision */
+   bool_t    cross_B_search;            /* usage of Cross-B-Search */
+   bool_t    B_as_past_ref;             /* usage of B frames as ref's */
+   unsigned  smoothing;                 /* smoothing of image along borders */
+   unsigned  release;                   /* FIASCO file format release */
 } wfa_info_t;
 
 typedef struct wfa
@@ -114,27 +114,27 @@ typedef struct wfa
  *  Used to store all information and data structures of a WFA
  */
 {
-   wfa_info_t	*wfainfo;		/* misc. information about the WFA */
-   frame_type_e frame_type;		/* intra, predicted, bi-directional */
-   unsigned	states;			/* number of states */
-   unsigned	basis_states;		/* number of states in the basis */
-   unsigned	root_state;		/* root of the tree */
-   real_t	*final_distribution;    /* one pixel images */
-   byte_t	*level_of_state;	/* level of the image part which is
-					   represented by the current state */
-   byte_t	*domain_type;		/* Bit_0==1: auxiliary state
-					   Bit_1==1: used for Y compr */
-   mv_t		(*mv_tree)[MAXLABELS];	/* motion vectors */
-   word_t	(*tree)[MAXLABELS];	/* bintree partitioning */
-   u_word_t	(*x)[MAXLABELS];	/* range coordinate */
-   u_word_t	(*y)[MAXLABELS];	/* range coordinate */
-   word_t	(*into)[MAXLABELS][MAXEDGES + 1];   /* domain references */
-   real_t	(*weight)[MAXLABELS][MAXEDGES + 1]; /* lin.comb. coefficients */
-   word_t	(*int_weight)[MAXLABELS][MAXEDGES + 1]; /* bin. representation */
-   word_t	(*y_state)[MAXLABELS];	/* bintree of Y component */
-   byte_t	(*y_column)[MAXLABELS];	/* array for Y component references */
-   byte_t	(*prediction)[MAXLABELS]; /* DC prediction */
-   bool_t	(*delta_state);		/* delta state */
+   wfa_info_t   *wfainfo;               /* misc. information about the WFA */
+   frame_type_e frame_type;             /* intra, predicted, bi-directional */
+   unsigned     states;                 /* number of states */
+   unsigned     basis_states;           /* number of states in the basis */
+   unsigned     root_state;             /* root of the tree */
+   real_t       *final_distribution;    /* one pixel images */
+   byte_t       *level_of_state;        /* level of the image part which is
+                                           represented by the current state */
+   byte_t       *domain_type;           /* Bit_0==1: auxiliary state
+                                           Bit_1==1: used for Y compr */
+   mv_t         (*mv_tree)[MAXLABELS];  /* motion vectors */
+   word_t       (*tree)[MAXLABELS];     /* bintree partitioning */
+   u_word_t     (*x)[MAXLABELS];        /* range coordinate */
+   u_word_t     (*y)[MAXLABELS];        /* range coordinate */
+   word_t       (*into)[MAXLABELS][MAXEDGES + 1];   /* domain references */
+   real_t       (*weight)[MAXLABELS][MAXEDGES + 1]; /* lin.comb. coefficients */
+   word_t       (*int_weight)[MAXLABELS][MAXEDGES + 1]; /* bin. representation */
+   word_t       (*y_state)[MAXLABELS];  /* bintree of Y component */
+   byte_t       (*y_column)[MAXLABELS]; /* array for Y component references */
+   byte_t       (*prediction)[MAXLABELS]; /* DC prediction */
+   bool_t       (*delta_state);         /* delta state */
 } wfa_t;
 
 #endif /* not _WFA_H */
diff --git a/converter/other/fiasco/codec/wfalib.c b/converter/other/fiasco/codec/wfalib.c
index 90420d6f..fd73092f 100644
--- a/converter/other/fiasco/codec/wfalib.c
+++ b/converter/other/fiasco/codec/wfalib.c
@@ -1,8 +1,8 @@
 /*
- *  wfalib.c:		Library functions both for encoding and decoding
+ *  wfalib.c:           Library functions both for encoding and decoding
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -35,8 +35,8 @@
 
 /*****************************************************************************
 
-				prototypes
-  
+                                prototypes
+
 *****************************************************************************/
 
 static unsigned
@@ -44,8 +44,8 @@ xy_to_address (unsigned x, unsigned y, unsigned level, unsigned n);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 wfa_t *
@@ -56,11 +56,11 @@ alloc_wfa (bool_t coding)
  *  Flag 'coding' indicates whether WFA is used for coding or decoding.
  *
  *  Return value:
- *	pointer to the new WFA structure
+ *      pointer to the new WFA structure
  */
 {
    wfa_t *wfa = Calloc (1, sizeof (wfa_t));
-		 
+
    /*
     *  Allocate memory
     */
@@ -74,17 +74,17 @@ alloc_wfa (bool_t coding)
    wfa->mv_tree            = Calloc (MAXSTATES * MAXLABELS, sizeof (mv_t));
    wfa->y_state            = Calloc (MAXSTATES * MAXLABELS, sizeof (word_t));
    wfa->into               = Calloc (MAXSTATES * MAXLABELS * (MAXEDGES + 1),
-				     sizeof (word_t));
+                                     sizeof (word_t));
    wfa->weight             = Calloc (MAXSTATES * MAXLABELS * (MAXEDGES + 1),
-				     sizeof (real_t));
+                                     sizeof (real_t));
    wfa->int_weight         = Calloc (MAXSTATES * MAXLABELS * (MAXEDGES + 1),
-				     sizeof (word_t));
+                                     sizeof (word_t));
    wfa->wfainfo            = Calloc (1, sizeof (wfa_info_t));;
    wfa->prediction         = Calloc (MAXSTATES * MAXLABELS, sizeof (byte_t));
 
    wfa->wfainfo->wfa_name   = NULL;
    wfa->wfainfo->basis_name = NULL;
-   wfa->wfainfo->title 	    = strdup ("");
+   wfa->wfainfo->title      = strdup ("");
    wfa->wfainfo->comment    = strdup ("");
 
    /*
@@ -96,24 +96,24 @@ alloc_wfa (bool_t coding)
       wfa->states       = 0;
       wfa->basis_states = 0;
       wfa->root_state   = 0;
-      for (state = 0; state < MAXSTATES; state++) 
+      for (state = 0; state < MAXSTATES; state++)
       {
-	 wfa->final_distribution [state] = 0;
-	 wfa->domain_type [state]        = 0;
-	 for (label = 0; label < MAXLABELS; label++)
-	 {
-	    wfa->into [state][label][0] = NO_EDGE;
-	    wfa->tree [state][label]    = RANGE;
-	    wfa->y_state [state][label] = RANGE;
-	 }
+         wfa->final_distribution [state] = 0;
+         wfa->domain_type [state]        = 0;
+         for (label = 0; label < MAXLABELS; label++)
+         {
+            wfa->into [state][label][0] = NO_EDGE;
+            wfa->tree [state][label]    = RANGE;
+            wfa->y_state [state][label] = RANGE;
+         }
       }
    }
 
-   if (coding)				/* initialize additional variables */
+   if (coding)                          /* initialize additional variables */
       wfa->y_column = Calloc (MAXSTATES * MAXLABELS, sizeof (byte_t));
    else
       wfa->y_column = NULL;
-   
+
    return wfa;
 }
 
@@ -126,7 +126,7 @@ free_wfa (wfa_t *wfa)
  *  No return value.
  *
  *  Side effects:
- *	'wfa' struct is discarded.
+ *      'wfa' struct is discarded.
  */
 {
    if (wfa->wfainfo->wfa_name)
@@ -157,14 +157,14 @@ free_wfa (wfa_t *wfa)
    Free (wfa);
 }
 
-real_t 
+real_t
 compute_final_distribution (unsigned state, const wfa_t *wfa)
 /*
  *  Compute the final distribution of the given 'state'.
  *  Uses the fact that the generated 'wfa' is average preserving.
  *
  *  Return value:
- *	final distribution
+ *      final distribution
  */
 {
    unsigned label;
@@ -174,14 +174,14 @@ compute_final_distribution (unsigned state, const wfa_t *wfa)
    {
       unsigned edge;
       int      domain;
-      
+
       if (ischild (domain = wfa->tree [state][label]))
-	 final += wfa->final_distribution [domain];
+         final += wfa->final_distribution [domain];
       for (edge = 0; isedge (domain = wfa->into [state][label][edge]); edge++)
-	 final += wfa->weight [state][label][edge]
-		  * wfa->final_distribution [domain];
+         final += wfa->weight [state][label][edge]
+                  * wfa->final_distribution [domain];
    }
-   
+
    return final / MAXLABELS;
 }
 
@@ -193,10 +193,10 @@ compute_hits (unsigned from, unsigned to, unsigned n, const wfa_t *wfa)
  *  {i | 'from' <= i <= 'to'}. I.e. domains are in {i | from <= i < 'to'}
  *  Always ensure that state 0 is among selected states even though from
  *  may be > 0.
- *  
+ *
  *  Return value:
- *	pointer to array of the most popular state images
- *	sorted by increasing state numbers and terminated by -1
+ *      pointer to array of the most popular state images
+ *      sorted by increasing state numbers and terminated by -1
  */
 {
    word_t   *domains;
@@ -209,12 +209,12 @@ compute_hits (unsigned from, unsigned to, unsigned n, const wfa_t *wfa)
       hits [domain].value = domain;
       hits [domain].key   = 0;
    }
-   
+
    for (state = from; state <= to; state++)
       for (label = 0; label < MAXLABELS; label++)
-	 for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
-	      edge++)
-	    hits [domain].key++;
+         for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
+              edge++)
+            hits [domain].key++;
 
    qsort (hits + 1, to - 1, sizeof (pair_t), sort_desc_pair);
 
@@ -222,23 +222,23 @@ compute_hits (unsigned from, unsigned to, unsigned n, const wfa_t *wfa)
    domains = Calloc (n + 1, sizeof (word_t));
 
    for (domain = 0; domain < (int) n && (!domain || hits [domain].key);
-	domain++)
+        domain++)
       domains [domain] = hits [domain].value;
    if (n != domain)
       debug_message ("Only %d domains have been used in the luminance.",
-		     domain);
+                     domain);
    n = domain;
    qsort (domains, n, sizeof (word_t), sort_asc_word);
    domains [n] = -1;
-   
+
    Free (hits);
-   
+
    return domains;
 }
 
 void
 append_edge (unsigned from, unsigned into, real_t weight,
-	     unsigned label, wfa_t *wfa)
+             unsigned label, wfa_t *wfa)
 /*
  *  Append an edge from state 'from' to state 'into' with
  *  the given 'label' and 'weight' to the 'wfa'.
@@ -246,10 +246,10 @@ append_edge (unsigned from, unsigned into, real_t weight,
  *  No return value.
  *
  *  Side effects:
- *	'wfa' structure is changed.
+ *      'wfa' structure is changed.
  */
 {
-   unsigned new;			/* position of the new edge */
+   unsigned new;                        /* position of the new edge */
    unsigned edge;
 
    /*
@@ -257,7 +257,7 @@ append_edge (unsigned from, unsigned into, real_t weight,
     *  edges are sorted by increasing 'into' values
     */
    for (new = 0; (isedge (wfa->into [from][label][new])
-		  && wfa->into [from][label][new] < (int) into); new++)
+                  && wfa->into [from][label][new] < (int) into); new++)
       ;
    /*
     *  Move the edges 'n' to position 'n+1', for n = max, ..., 'new'
@@ -269,7 +269,7 @@ append_edge (unsigned from, unsigned into, real_t weight,
       wfa->into [from][label][edge]    = wfa->into [from][label][edge - 1];
       wfa->weight [from][label][edge]  = wfa->weight [from][label][edge - 1];
       wfa->int_weight [from][label][edge]
-	 = wfa->int_weight [from][label][edge - 1];
+         = wfa->int_weight [from][label][edge - 1];
    }
    /*
     *  Insert the new edge
@@ -279,15 +279,15 @@ append_edge (unsigned from, unsigned into, real_t weight,
    wfa->int_weight [from][label][edge] = weight * 512 + 0.5;
 }
 
-void 
+void
 remove_states (unsigned from, wfa_t *wfa)
-/* 
+/*
  *  Remove 'wfa' states 'wfa->basis_states',...,'wfa->states' - 1.
  *
  *  No return value.
  *
  *  Side effects:
- *	'wfa' structure is cleared for the given states.
+ *      'wfa' structure is cleared for the given states.
  */
 {
    unsigned state;
@@ -295,18 +295,18 @@ remove_states (unsigned from, wfa_t *wfa)
    for (state = from; state < wfa->states; state++)
    {
       unsigned label;
-      
-      for (label = 0; label < MAXLABELS; label++) 
+
+      for (label = 0; label < MAXLABELS; label++)
       {
-	 wfa->into [state][label][0]      = NO_EDGE;
-	 wfa->tree [state][label]         = RANGE;
-	 wfa->prediction [state][label]   = FALSE;
-	 wfa->y_state [state][label]      = RANGE;
-	 wfa->mv_tree [state][label].type = NONE;
-	 wfa->mv_tree [state][label].fx   = 0;
-	 wfa->mv_tree [state][label].fy   = 0;
-	 wfa->mv_tree [state][label].bx   = 0;
-	 wfa->mv_tree [state][label].by   = 0;
+         wfa->into [state][label][0]      = NO_EDGE;
+         wfa->tree [state][label]         = RANGE;
+         wfa->prediction [state][label]   = FALSE;
+         wfa->y_state [state][label]      = RANGE;
+         wfa->mv_tree [state][label].type = NONE;
+         wfa->mv_tree [state][label].fx   = 0;
+         wfa->mv_tree [state][label].fy   = 0;
+         wfa->mv_tree [state][label].bx   = 0;
+         wfa->mv_tree [state][label].by   = 0;
       }
       wfa->domain_type [state] = 0;
       wfa->delta_state [state] = FALSE;
@@ -323,7 +323,7 @@ copy_wfa (wfa_t *dst, const wfa_t *src)
  *  No return value.
  *
  *  Side effects:
- *	'dst' is filled with same data as 'src'
+ *      'dst' is filled with same data as 'src'
  *
  *  NOTE: size of WFA 'dst' must be at least size of WFA 'src'
  */
@@ -339,11 +339,11 @@ copy_wfa (wfa_t *dst, const wfa_t *src)
    memset (dst->y, 0, MAXSTATES * MAXLABELS * sizeof (word_t));
    memset (dst->y_state, 0, MAXSTATES * MAXLABELS * sizeof (word_t));
    memset (dst->into, NO_EDGE,
-	   MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
+           MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
    memset (dst->weight, 0,
-	   MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (real_t));
+           MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (real_t));
    memset (dst->int_weight, 0,
-	   MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
+           MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
    memset (dst->prediction, 0, MAXSTATES * MAXLABELS * sizeof (byte_t));
    memset (dst->delta_state, 0, MAXSTATES * sizeof (bool_t));
    if (dst->y_column)
@@ -352,62 +352,62 @@ copy_wfa (wfa_t *dst, const wfa_t *src)
    for (state = 0; state < MAXSTATES; state++) /* clear WFA struct */
    {
       unsigned label;
-      
+
       for (label = 0; label < MAXLABELS; label++)
       {
-	 dst->into [state][label][0]      = NO_EDGE;
-	 dst->tree [state][label]         = RANGE;
-	 dst->mv_tree [state][label].type = NONE;
-	 dst->y_state[state][label]       = RANGE;
+         dst->into [state][label][0]      = NO_EDGE;
+         dst->tree [state][label]         = RANGE;
+         dst->mv_tree [state][label].type = NONE;
+         dst->y_state[state][label]       = RANGE;
       }
       dst->delta_state [state] = NO;
       dst->domain_type [state] = 0;
    }
-   
+
    dst->frame_type   = src->frame_type;
-   dst->states 	     = src->states;
+   dst->states       = src->states;
    dst->basis_states = src->basis_states;
    dst->root_state   = src->root_state;
 
    memcpy (dst->wfainfo, src->wfainfo, sizeof (wfa_info_t));
 
-   if (dst->states == 0)		/* nothing to do */
+   if (dst->states == 0)                /* nothing to do */
       return;
 
    memcpy (dst->final_distribution, src->final_distribution,
-	   src->states * sizeof (real_t));
+           src->states * sizeof (real_t));
    memcpy (dst->level_of_state, src->level_of_state,
-	   src->states * sizeof (byte_t));
+           src->states * sizeof (byte_t));
    memcpy (dst->domain_type, src->domain_type,
-	   src->states * sizeof (byte_t));
+           src->states * sizeof (byte_t));
    memcpy (dst->delta_state, src->delta_state,
-	   src->states * sizeof (bool_t));
+           src->states * sizeof (bool_t));
    memcpy (dst->mv_tree, src->mv_tree,
-	   src->states * MAXLABELS * sizeof (mv_t));
+           src->states * MAXLABELS * sizeof (mv_t));
    memcpy (dst->tree, src->tree,
-	   src->states * MAXLABELS * sizeof (word_t));
+           src->states * MAXLABELS * sizeof (word_t));
    memcpy (dst->x, src->x,
-	   src->states * MAXLABELS * sizeof (word_t));
+           src->states * MAXLABELS * sizeof (word_t));
    memcpy (dst->y, src->y,
-	   src->states * MAXLABELS * sizeof (word_t));
+           src->states * MAXLABELS * sizeof (word_t));
    memcpy (dst->y_state, src->y_state,
-	   src->states * MAXLABELS * sizeof (word_t));
+           src->states * MAXLABELS * sizeof (word_t));
    memcpy (dst->into, src->into,
-	   src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
+           src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
    memcpy (dst->weight, src->weight,
-	   src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (real_t));
+           src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (real_t));
    memcpy (dst->int_weight, src->int_weight,
-	   src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
+           src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t));
    memcpy (dst->prediction, src->prediction,
-	   src->states * MAXLABELS * sizeof (byte_t));
+           src->states * MAXLABELS * sizeof (byte_t));
    if (dst->y_column)
       memcpy (dst->y_column, src->y_column,
-	      src->states * MAXLABELS * sizeof (byte_t));
+              src->states * MAXLABELS * sizeof (byte_t));
 }
 
 void
 locate_subimage (unsigned orig_level, unsigned level, unsigned bintree,
-		 unsigned *x, unsigned *y, unsigned *width, unsigned *height)
+                 unsigned *x, unsigned *y, unsigned *width, unsigned *height)
 /*
  *  Compute pixel coordinates of the subimage which 'bintree' address is given.
  *  The level of the original image is 'orig_level' and the level of the
@@ -416,14 +416,14 @@ locate_subimage (unsigned orig_level, unsigned level, unsigned bintree,
  *  No return value.
  *
  *  Side effects:
- *	'*x', '*y'		coordinates of the upper left corner
- *      '*width', '*height'	size of image
+ *      '*x', '*y'              coordinates of the upper left corner
+ *      '*width', '*height'     size of image
  */
 {
    /*
     *  Compute coordinates of the subimage
     */
-   *x = *y = 0;				/* start at NW corner */
+   *x = *y = 0;                         /* start at NW corner */
    *width  = width_of_level (level);
    *height = height_of_level (level);
 
@@ -439,31 +439,31 @@ locate_subimage (unsigned orig_level, unsigned level, unsigned bintree,
    }
    else if (level < orig_level)
    {
-      unsigned mask;			/* mask for bintree -> xy conversion */
-      bool_t   hor;			/* 1 next subdivision is horizontal
-					   0 next subdivision is vertical */
-      unsigned l = orig_level - 1;	/* current level */
-      
-      hor = orig_level % 2;		/* start with vertival subdivision
-					   for square image and vice versa */
-   
+      unsigned mask;                    /* mask for bintree -> xy conversion */
+      bool_t   hor;                     /* 1 next subdivision is horizontal
+                                           0 next subdivision is vertical */
+      unsigned l = orig_level - 1;      /* current level */
+
+      hor = orig_level % 2;             /* start with vertival subdivision
+                                           for square image and vice versa */
+
       for (mask = 1 << (orig_level - level - 1); mask; mask >>= 1, hor = !hor)
       {
-	 if (bintree & mask)		/* change coordinates */
-	 {
-	    if (hor)			/* horizontal subdivision */
-	       *y += height_of_level (l);
-	    else			/* vertical subdivision */
-	       *x += width_of_level (l);
-	 }
-	 l--;
+         if (bintree & mask)            /* change coordinates */
+         {
+            if (hor)                    /* horizontal subdivision */
+               *y += height_of_level (l);
+            else                        /* vertical subdivision */
+               *x += width_of_level (l);
+         }
+         l--;
       }
    }
 }
 
 void
 compute_spiral (int *vorder, unsigned image_width, unsigned image_height,
-		unsigned tiling_exp, bool_t inc_spiral)
+                unsigned tiling_exp, bool_t inc_spiral)
 /*
  *  Compute image tiling with spiral order.
  *  'inc_spiral' specifies whether the spiral starts in the middle
@@ -474,28 +474,28 @@ compute_spiral (int *vorder, unsigned image_width, unsigned image_height,
  *  No return value.
  *
  *  Side effects:
- *	vorder[] is filled with tiling permutation
+ *      vorder[] is filled with tiling permutation
  */
 {
-   unsigned x, y;			/* current position */
-   unsigned xmin, xmax, ymin, ymax;	/* boundaries for current line */
-   unsigned width, height;		/* offset for each tile */
-   unsigned lx, ly, level;		/* level x and y */
-   unsigned tiles;			/* total number of tiles */
-   unsigned address;			/* bintree address */
-   
+   unsigned x, y;                       /* current position */
+   unsigned xmin, xmax, ymin, ymax;     /* boundaries for current line */
+   unsigned width, height;              /* offset for each tile */
+   unsigned lx, ly, level;              /* level x and y */
+   unsigned tiles;                      /* total number of tiles */
+   unsigned address;                    /* bintree address */
+
    lx     = log2 (image_width - 1) + 1;
    ly     = log2 (image_height - 1) + 1;
    level  = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0);
-   tiles  = 1 << tiling_exp;		/* Number of image tiles */
+   tiles  = 1 << tiling_exp;            /* Number of image tiles */
    width  = width_of_level (level - tiling_exp);
    height = height_of_level (level - tiling_exp);
    for (address = 0; address < tiles; address++)
    {
       unsigned x0, y0, width, height;
-      
+
       locate_subimage (level, level - tiling_exp, address,
-		       &x0, &y0, &width, &height);
+                       &x0, &y0, &width, &height);
       vorder [address] = (x0 < image_width && y0 < image_height) ? 0 : -1;
    }
 
@@ -507,7 +507,7 @@ compute_spiral (int *vorder, unsigned image_width, unsigned image_height,
 
    /*
     *  1234
-    *  CDE5  Traverse image in spiral order 
+    *  CDE5  Traverse image in spiral order
     *  BGF6  starting at the top left corner
     *  A987
     */
@@ -515,59 +515,59 @@ compute_spiral (int *vorder, unsigned image_width, unsigned image_height,
    {
       for (x = xmin, y = ymin; x < xmax; x += width) /* W>E */
       {
-	 while (vorder [address] == -1)
-	    address++;
-	 if (x < image_width && y < image_height) /* valid range */
-	    vorder [address++] = xy_to_address (x, y, level, tiling_exp);
-	 while (address < tiles && vorder [address] == -1)
-	    address++;
+         while (vorder [address] == -1)
+            address++;
+         if (x < image_width && y < image_height) /* valid range */
+            vorder [address++] = xy_to_address (x, y, level, tiling_exp);
+         while (address < tiles && vorder [address] == -1)
+            address++;
       }
       ymin += height;
 
       if (address >= tiles)
-	 break;
-      
+         break;
+
       for (x = xmax - width, y = ymin; y < ymax; y += height) /* N>S  */
       {
-	 while (vorder [address] == -1)
-	    address++;
-	 if (x <= image_width && y <= image_height) /* valid range */
-	    vorder [address++] = xy_to_address (x, y, level, tiling_exp);
-	 while (address < tiles && vorder [address] == -1)
-	    address++;
+         while (vorder [address] == -1)
+            address++;
+         if (x <= image_width && y <= image_height) /* valid range */
+            vorder [address++] = xy_to_address (x, y, level, tiling_exp);
+         while (address < tiles && vorder [address] == -1)
+            address++;
       }
       xmax -= width;
 
       if (address >= tiles)
-	 break;
+         break;
 
       for (x = xmax - width, y = ymax - width; x >= xmin; x -= width) /* E<W */
       {
-	 while (vorder [address] == -1)
-	    address++;
-	 if (x <= image_width && y <= image_height) /* valid range */
-	    vorder [address++] = xy_to_address (x, y, level, tiling_exp);
-	 while (address < tiles && vorder [address] == -1)
-	    address++;
+         while (vorder [address] == -1)
+            address++;
+         if (x <= image_width && y <= image_height) /* valid range */
+            vorder [address++] = xy_to_address (x, y, level, tiling_exp);
+         while (address < tiles && vorder [address] == -1)
+            address++;
       }
       ymax -= height;
 
       if (address >= tiles)
-	 break;
+         break;
 
-      for (x = xmin, y = ymax - height; y >= ymin; y -= height)	/* S>N */
+      for (x = xmin, y = ymax - height; y >= ymin; y -= height) /* S>N */
       {
-	 while (vorder [address] == -1)
-	    address++;
-	 if (x <= image_width && y <= image_height) /* valid range */
-	    vorder [address++] = xy_to_address (x, y, level, tiling_exp);
-	 while (address < tiles && vorder [address] == -1)
-	    address++;
+         while (vorder [address] == -1)
+            address++;
+         if (x <= image_width && y <= image_height) /* valid range */
+            vorder [address++] = xy_to_address (x, y, level, tiling_exp);
+         while (address < tiles && vorder [address] == -1)
+            address++;
       }
       xmin += width;
-	 
+
       if (address >= tiles)
-	 break;
+         break;
    }
 
    if (inc_spiral)
@@ -576,18 +576,18 @@ compute_spiral (int *vorder, unsigned image_width, unsigned image_height,
 
       while (i < j)
       {
-	 int tmp;
-	    
-	 while (vorder [i] == -1)
-	    i++;
-	 while (vorder [j] == -1)
-	    j--;
-	    
-	 tmp 	       = vorder [i];
-	 vorder [i] = vorder [j];
-	 vorder [j] = tmp;
-	 i++;
-	 j--;
+         int tmp;
+
+         while (vorder [i] == -1)
+            i++;
+         while (vorder [j] == -1)
+            j--;
+
+         tmp           = vorder [i];
+         vorder [i] = vorder [j];
+         vorder [j] = tmp;
+         i++;
+         j--;
       }
    }
    /*
@@ -595,109 +595,109 @@ compute_spiral (int *vorder, unsigned image_width, unsigned image_height,
     */
    {
       unsigned number;
-      
+
       for (number = 0, address = 0; address < tiles; address++)
-	 if (vorder [address] != -1)
-	    debug_message ("number %d: address %d",
-			   number++, vorder [address]);
+         if (vorder [address] != -1)
+            debug_message ("number %d: address %d",
+                           number++, vorder [address]);
    }
 }
 
 bool_t
 find_range (unsigned x, unsigned y, unsigned band,
-	    const wfa_t *wfa, unsigned *range_state, unsigned *range_label)
+            const wfa_t *wfa, unsigned *range_state, unsigned *range_label)
 /*
  *  Find a range ('*range_state', '*range_label') that contains
  *  pixel ('x', 'y') in the iven color 'band'.
  *
  *  Return value:
- *	TRUE on success, or FALSE if there is no such range
+ *      TRUE on success, or FALSE if there is no such range
  *
  *  Side effects:
- *	'*range_state' and '*range_label' are modified on success.
+ *      '*range_state' and '*range_label' are modified on success.
  */
 {
    unsigned state, label;
    unsigned first_state, last_state;
    bool_t   success = NO;
-   
+
    first_state = wfa->basis_states;
    last_state  = wfa->states;
    if (wfa->wfainfo->color)
       switch (band)
       {
-	 case Y:
-	    first_state = wfa->basis_states;
-	    last_state  = wfa->tree [wfa->tree [wfa->root_state][0]][0];
-	    break;
-	 case Cb:
-	    first_state = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1;
-	    last_state  = wfa->tree [wfa->tree [wfa->root_state][0]][1];
-	    break;
-	 case Cr:
-	    first_state = wfa->tree [wfa->tree [wfa->root_state][0]][1] + 1;
-	    last_state  = wfa->states;
-	    break;
-	 default:
-	    error ("unknown color component.");
+         case Y:
+            first_state = wfa->basis_states;
+            last_state  = wfa->tree [wfa->tree [wfa->root_state][0]][0];
+            break;
+         case Cb:
+            first_state = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1;
+            last_state  = wfa->tree [wfa->tree [wfa->root_state][0]][1];
+            break;
+         case Cr:
+            first_state = wfa->tree [wfa->tree [wfa->root_state][0]][1] + 1;
+            last_state  = wfa->states;
+            break;
+         default:
+            error ("unknown color component.");
       }
 
    for (state = first_state; state < last_state; state++)
       for (label = 0; label < MAXLABELS; label++)
-	 if (isrange (wfa->tree [state][label]))
-	    if (x >= wfa->x [state][label] && y >= wfa->y [state][label]
-		&& x < (unsigned) (wfa->x [state][label]
-			+ width_of_level (wfa->level_of_state [state] - 1))
-		&& y < (unsigned) (wfa->y [state][label]
-			+ height_of_level (wfa->level_of_state [state] - 1))) 
-	    {
-	       success      = YES;
-	       *range_state = state;
-	       *range_label = label;
-
-	       return success;
-	    }
+         if (isrange (wfa->tree [state][label]))
+            if (x >= wfa->x [state][label] && y >= wfa->y [state][label]
+                && x < (unsigned) (wfa->x [state][label]
+                        + width_of_level (wfa->level_of_state [state] - 1))
+                && y < (unsigned) (wfa->y [state][label]
+                        + height_of_level (wfa->level_of_state [state] - 1)))
+            {
+               success      = YES;
+               *range_state = state;
+               *range_label = label;
+
+               return success;
+            }
 
    return success;
 }
 
 void
 sort_ranges (unsigned state, unsigned *domain,
-	     range_sort_t *rs, const wfa_t *wfa)
+             range_sort_t *rs, const wfa_t *wfa)
 /*
  *  Generate list of ranges in coder order.
  *  'state' is the current state of the call tree while 'domain' is the
  *  index of the last added WFA state.
  *
  *  Side effects:
- *	'domain' is incremented after recursion returns
- *	'rs'	 is filled accordingly
+ *      'domain' is incremented after recursion returns
+ *      'rs'     is filled accordingly
  *
  *  No return value.
  */
 {
    unsigned label;
-   
+
    for (label = 0; label < MAXLABELS; label++)
    {
       if (isrange (wfa->tree [state][label]))
-	 rs->range_subdivided [rs->range_no] = NO;
+         rs->range_subdivided [rs->range_no] = NO;
       else
       {
-	 sort_ranges (wfa->tree [state][label], domain, rs, wfa);
-	 rs->range_subdivided [rs->range_no] = YES;
+         sort_ranges (wfa->tree [state][label], domain, rs, wfa);
+         rs->range_subdivided [rs->range_no] = YES;
       }
 
       rs->range_state [rs->range_no]      = state;
       rs->range_label [rs->range_no]      = label;
       rs->range_max_domain [rs->range_no] = *domain;
       while (!usedomain (rs->range_max_domain [rs->range_no], wfa))
-	 rs->range_max_domain [rs->range_no]--;
+         rs->range_max_domain [rs->range_no]--;
 
       if (label == 1 || !rs->range_subdivided [rs->range_no])
-	 rs->range_no++;
+         rs->range_no++;
    }
-   
+
    (*domain)++;
 }
 
@@ -709,11 +709,11 @@ locate_delta_images (wfa_t *wfa)
  *  via MC or ND.
  *
  *  Return value:
- *	TRUE	at least one state is part of a delta approximation
- *	FALSE	no delta approximations in this WFA
+ *      TRUE    at least one state is part of a delta approximation
+ *      FALSE   no delta approximations in this WFA
  *
  *  Side effects:
- *	'wfa->delta [state][label]' is set accordingly.
+ *      'wfa->delta [state][label]' is set accordingly.
  */
 {
    unsigned state, label;
@@ -724,22 +724,22 @@ locate_delta_images (wfa_t *wfa)
 
    for (state = wfa->root_state; state >= wfa->basis_states; state--)
       for (label = 0; label < MAXLABELS; label++)
-	 if (ischild (wfa->tree [state][label]))
-	    if (wfa->mv_tree [state][label].type != NONE
-		|| isedge (wfa->into [state][label][0])
-		|| wfa->delta_state [state])
-	    {
-	       delta = YES;
-	       wfa->delta_state [wfa->tree [state][label]] = YES;
-	    }
+         if (ischild (wfa->tree [state][label]))
+            if (wfa->mv_tree [state][label].type != NONE
+                || isedge (wfa->into [state][label][0])
+                || wfa->delta_state [state])
+            {
+               delta = YES;
+               wfa->delta_state [wfa->tree [state][label]] = YES;
+            }
 
    return delta;
 }
 
 /*****************************************************************************
 
-				private code
-  
+                                private code
+
 ******************************************************************************/
 
 static unsigned
@@ -750,25 +750,25 @@ xy_to_address (unsigned x, unsigned y, unsigned level, unsigned n)
  *  'n' specifies number of iterations.
  *
  *  Return value:
- *	address of subimage
- */ 
-{ 
+ *      address of subimage
+ */
+{
    unsigned address = 0;
 
    while (n--)
    {
       address <<= 1;
-      if (--level % 2) 
+      if (--level % 2)
       {
-	 if (x & width_of_level (level))
-	    address++;
+         if (x & width_of_level (level))
+            address++;
       }
       else
       {
-	 if (y & height_of_level (level))
-	    address++;
+         if (y & height_of_level (level))
+            address++;
       }
    }
-   
+
    return address;
 }
diff --git a/converter/other/fiasco/codec/wfalib.h b/converter/other/fiasco/codec/wfalib.h
index 5c1e0907..63723f30 100644
--- a/converter/other/fiasco/codec/wfalib.h
+++ b/converter/other/fiasco/codec/wfalib.h
@@ -1,8 +1,8 @@
 /*
  *  wfalib.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -34,26 +34,26 @@ bool_t
 locate_delta_images (wfa_t *wfa);
 void
 sort_ranges (unsigned state, unsigned *domain,
-	     range_sort_t *rs, const wfa_t *wfa);
+             range_sort_t *rs, const wfa_t *wfa);
 bool_t
 find_range (unsigned x, unsigned y, unsigned band,
-	    const wfa_t *wfa, unsigned *range_state, unsigned *range_label);
+            const wfa_t *wfa, unsigned *range_state, unsigned *range_label);
 void
 compute_spiral (int *vorder, unsigned image_width, unsigned image_height,
-		unsigned tiling_exp, bool_t inc_spiral);
+                unsigned tiling_exp, bool_t inc_spiral);
 void
 locate_subimage (unsigned orig_level, unsigned level, unsigned bintree,
-		 unsigned *x, unsigned *y, unsigned *width, unsigned *height);
+                 unsigned *x, unsigned *y, unsigned *width, unsigned *height);
 void
 copy_wfa (wfa_t *dst, const wfa_t *src);
-void 
+void
 remove_states (unsigned from, wfa_t *wfa);
 void
 append_edge (unsigned from, unsigned into, real_t weight,
-	     unsigned label, wfa_t *wfa);
+             unsigned label, wfa_t *wfa);
 word_t *
 compute_hits (unsigned from, unsigned to, unsigned n, const wfa_t *wfa);
-real_t 
+real_t
 compute_final_distribution (unsigned state, const wfa_t *wfa);
 wfa_t *
 alloc_wfa (bool_t coding);
diff --git a/converter/other/fiasco/display.c b/converter/other/fiasco/display.c
index d8d32fa6..5eed6aeb 100644
--- a/converter/other/fiasco/display.c
+++ b/converter/other/fiasco/display.c
@@ -1,11 +1,11 @@
 /*
- *  display.c:		X11 display of frames
+ *  display.c:          X11 display of frames
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
- *		
+ *
  *  Based on mpeg2decode, (C) 1994, MPEG Software Simulation Group
  *  and      mpeg2play,   (C) 1994 Stefan Eckart
  *                                 <stefan@lis.e-technik.tu-muenchen.de>
@@ -37,8 +37,8 @@
 
 /*****************************************************************************
 
-	       shared memory functions (if USE_SHM is defined)
-  
+               shared memory functions (if USE_SHM is defined)
+
 *****************************************************************************/
 
 #ifdef USE_SHM
@@ -64,16 +64,16 @@ InstallXErrorHandler (x11_info_t *xinfo);
 static void
 DeInstallXErrorHandler (x11_info_t *xinfo);
 
-static int		shmem_flag;
-static XShmSegmentInfo	shminfo1, shminfo2;
-static int		gXErrorFlag;
-static int		CompletionType = -1;
+static int              shmem_flag;
+static XShmSegmentInfo  shminfo1, shminfo2;
+static int              gXErrorFlag;
+static int              CompletionType = -1;
 
 static int
 HandleXError (Display *dpy, XErrorEvent *event)
 {
    gXErrorFlag = 1;
-   
+
    return 0;
 }
 
@@ -95,21 +95,21 @@ DeInstallXErrorHandler (x11_info_t *xinfo)
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 void
 display_image (unsigned x0, unsigned y0, x11_info_t *xinfo)
 /*
  *  Display 'image' at pos ('x0', 'y0') in the current window
- *  (given by 'xinfo->window'). 
+ *  (given by 'xinfo->window').
  *
  *  No return value.
  */
 {
    int byte_order_check = 1;
-   
+
    /*
     *  Always work in native bit and byte order. This tells Xlib to
     *  reverse bit and byte order if necessary when crossing a
@@ -125,28 +125,28 @@ display_image (unsigned x0, unsigned y0, x11_info_t *xinfo)
    {
       xinfo->ximage->byte_order       = MSBFirst;
       xinfo->ximage->bitmap_bit_order = MSBFirst;
-   }    
+   }
 
    /* Display dithered image */
 #ifdef USE_SHM
    if (shmem_flag)
    {
       XEvent xev;
-      
+
       XShmPutImage (xinfo->display, xinfo->window, xinfo->gc, xinfo->ximage,
-		    0, 0, x0, y0, xinfo->ximage->width, xinfo->ximage->height,
-		    True);
+                    0, 0, x0, y0, xinfo->ximage->width, xinfo->ximage->height,
+                    True);
       XFlush (xinfo->display);
-      
+
       while (!XCheckTypedEvent (xinfo->display, CompletionType, &xev))
-	 ;
+         ;
    }
-   else 
+   else
 #endif /* USE_SHM */
    {
-      xinfo->ximage->data = (char *) xinfo->pixels; 
+      xinfo->ximage->data = (char *) xinfo->pixels;
       XPutImage (xinfo->display, xinfo->window, xinfo->gc, xinfo->ximage, 0, 0,
-		 x0, y0, xinfo->ximage->width, xinfo->ximage->height);
+                 x0, y0, xinfo->ximage->width, xinfo->ximage->height);
    }
 }
 
@@ -177,7 +177,7 @@ close_window (x11_info_t *xinfo)
 
 x11_info_t *
 open_window (const char *titlename, const char *iconname,
-	     unsigned width, unsigned height)
+             unsigned width, unsigned height)
 /*
  *  Open a X11 window of size 'width'x'height'.
  *  If 'color' is false then allocate a colormap with grayscales.
@@ -185,20 +185,20 @@ open_window (const char *titlename, const char *iconname,
  *  respectively.
  *
  *  Return value:
- *	X11 info struct containing display, gc, window ID and colormap.
+ *      X11 info struct containing display, gc, window ID and colormap.
  */
 {
-   XVisualInfo		visual_template; /* template for XGetVisualInfo() */
-   XVisualInfo		visual_info;	/* return value of XGetVisualInfo() */
-   int			visual_n;	/* # of matches of XGetVisualInfo */
-   XEvent		xev;		
-   XSizeHints		hint;		
-   XSetWindowAttributes xswa;		
-   unsigned int		fg, bg;		/* foreground and background color */
-   unsigned int		mask;		/* event mask */
-   x11_info_t		*xinfo = calloc (1, sizeof (x11_info_t));
+   XVisualInfo          visual_template; /* template for XGetVisualInfo() */
+   XVisualInfo          visual_info;    /* return value of XGetVisualInfo() */
+   int                  visual_n;       /* # of matches of XGetVisualInfo */
+   XEvent               xev;
+   XSizeHints           hint;
+   XSetWindowAttributes xswa;
+   unsigned int         fg, bg;         /* foreground and background color */
+   unsigned int         mask;           /* event mask */
+   x11_info_t           *xinfo = calloc (1, sizeof (x11_info_t));
    long                 visual_mask;
-   
+
    if (!xinfo)
       error ("Out of memory");
    /*
@@ -207,32 +207,32 @@ open_window (const char *titlename, const char *iconname,
    xinfo->display = XOpenDisplay (NULL);
    if (xinfo->display == NULL)
       error ("Can't open display.\n"
-	     "Make sure that your environment variable DISPLAY "
-	     "is set correctly.");
+             "Make sure that your environment variable DISPLAY "
+             "is set correctly.");
 
    xinfo->screen = DefaultScreen (xinfo->display);
    xinfo->gc     = DefaultGC (xinfo->display, xinfo->screen);
 
    {
-      unsigned   depth [] 	= {32, 24, 16};
-      int        class [] 	= {TrueColor, PseudoColor};
+      unsigned   depth []       = {32, 24, 16};
+      int        class []       = {TrueColor, PseudoColor};
       const char *class_text [] = {"TrueColor", "PseudoColor"};
-      Status     found 		= 0;
+      Status     found          = 0;
       unsigned   d, c;
 
       for (d = 0; !found && d < sizeof (depth) / sizeof (unsigned); d++)
-	 for (c = 0; !found && c < sizeof (class) / sizeof (int); c++)
-	 {
-	    found = XMatchVisualInfo (xinfo->display, xinfo->screen,
-				      depth [d], class [c], &visual_info);
-	    if (found)
-	       fprintf (stderr, "%s : %d bit colordepth.\n",
-			class_text [c], depth [d]);
-	 }
+         for (c = 0; !found && c < sizeof (class) / sizeof (int); c++)
+         {
+            found = XMatchVisualInfo (xinfo->display, xinfo->screen,
+                                      depth [d], class [c], &visual_info);
+            if (found)
+               fprintf (stderr, "%s : %d bit colordepth.\n",
+                        class_text [c], depth [d]);
+         }
       if (!found && fiasco_get_verbosity ())
-	 error ("Can't find a 16/24/32 bit TrueColor/DirectColor display");
+         error ("Can't find a 16/24/32 bit TrueColor/DirectColor display");
    }
-   
+
    /* Width and height of the display window */
    hint.x = hint.y = 0;
    hint.min_width  = hint.max_width  = hint.width  = width;
@@ -249,22 +249,22 @@ open_window (const char *titlename, const char *iconname,
    {
       mask |= CWColormap;
       xswa.colormap = XCreateColormap (xinfo->display,
-				       DefaultRootWindow (xinfo->display),
-				       visual_info.visual, AllocNone);
+                                       DefaultRootWindow (xinfo->display),
+                                       visual_info.visual, AllocNone);
    }
    xswa.background_pixel = bg;
    xswa.border_pixel     = fg;
    xinfo->window = XCreateWindow (xinfo->display,
-				  DefaultRootWindow (xinfo->display), 0, 0,
-				  width, height, 1, visual_info.depth,
-				  InputOutput, visual_info.visual,
-				  mask, &xswa);
+                                  DefaultRootWindow (xinfo->display), 0, 0,
+                                  width, height, 1, visual_info.depth,
+                                  InputOutput, visual_info.visual,
+                                  mask, &xswa);
 
    XSelectInput (xinfo->display, xinfo->window, StructureNotifyMask);
 
    /* Tell other applications about this window */
    XSetStandardProperties (xinfo->display, xinfo->window, titlename, iconname,
-			   None, NULL, 0, &hint);
+                           None, NULL, 0, &hint);
 
    /* Map window. */
    XMapWindow (xinfo->display, xinfo->window);
@@ -290,23 +290,23 @@ alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height)
  *  No return value.
  *
  *  Side effects:
- *	'ximage->ximage' and 'ximage->pixels' are set to useful values.
+ *      'ximage->ximage' and 'ximage->pixels' are set to useful values.
  */
 {
    char dummy;
-   
+
 #ifdef USE_SHM
    if (XShmQueryExtension(xinfo->display))
    {
       if (fiasco_get_verbosity ())
-	 fprintf (stderr, "Trying shared memory.\n");
+         fprintf (stderr, "Trying shared memory.\n");
       shmem_flag = 1;
    }
    else
    {
       shmem_flag = 0;
       if (fiasco_get_verbosity ())
-	 fprintf (stderr,
+         fprintf (stderr,
               "Shared memory does not work on this system\n"
               "Reverting to normal Xlib.\n");
    }
@@ -319,34 +319,34 @@ alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height)
    if (shmem_flag)
    {
       xinfo->ximage = XShmCreateImage (xinfo->display,
-				       DefaultVisual (xinfo->display,
-						      xinfo->screen),
-				       DefaultDepth (xinfo->display,
-						     xinfo->screen), ZPixmap,
-				       NULL, &shminfo1, width, height);
+                                       DefaultVisual (xinfo->display,
+                                                      xinfo->screen),
+                                       DefaultDepth (xinfo->display,
+                                                     xinfo->screen), ZPixmap,
+                                       NULL, &shminfo1, width, height);
 
       /* If no go, then revert to normal Xlib calls. */
 
       if (xinfo->ximage == NULL)
       {
-	 if (fiasco_get_verbosity ())
-	    fprintf (stderr,
-		     "Shared memory error, disabling (Ximage error).\n");
-	 goto shmemerror;
+         if (fiasco_get_verbosity ())
+            fprintf (stderr,
+                     "Shared memory error, disabling (Ximage error).\n");
+         goto shmemerror;
       }
 
       /* Success here, continue. */
 
       shminfo1.shmid = shmget (IPC_PRIVATE, xinfo->ximage->bytes_per_line
-			       * xinfo->ximage->height, IPC_CREAT | 0777);
+                               * xinfo->ximage->height, IPC_CREAT | 0777);
 
       if (shminfo1.shmid < 0)
       {
-	 XDestroyImage (xinfo->ximage);
-	 if (fiasco_get_verbosity ())
-	    fprintf (stderr,
-		     "Shared memory error, disabling (seg id error).\n");
-	 goto shmemerror;
+         XDestroyImage (xinfo->ximage);
+         if (fiasco_get_verbosity ())
+            fprintf (stderr,
+                     "Shared memory error, disabling (seg id error).\n");
+         goto shmemerror;
       }
 
       shminfo1.shmaddr = (char *) shmat (shminfo1.shmid, 0, 0);
@@ -354,13 +354,13 @@ alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height)
 
       if (shminfo1.shmaddr == ((char *) -1))
       {
-	 XDestroyImage (xinfo->ximage);
-	 if (shminfo1.shmaddr != ((char *) -1))
-	    shmdt (shminfo1.shmaddr);
-	 if (fiasco_get_verbosity ())
-	    fprintf (stderr,
-		     "Shared memory error, disabling (address error).\n");
-	 goto shmemerror;
+         XDestroyImage (xinfo->ximage);
+         if (shminfo1.shmaddr != ((char *) -1))
+            shmdt (shminfo1.shmaddr);
+         if (fiasco_get_verbosity ())
+            fprintf (stderr,
+                     "Shared memory error, disabling (address error).\n");
+         goto shmemerror;
       }
 
       xinfo->ximage->data = shminfo1.shmaddr;
@@ -372,18 +372,18 @@ alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height)
 
       if (gXErrorFlag)
       {
-	 /* Ultimate failure here. */
-	 XDestroyImage (xinfo->ximage);
-	 shmdt (shminfo1.shmaddr);
-	 if (fiasco_get_verbosity ())
-	    fprintf (stderr, "Shared memory error, disabling.\n");
-	 gXErrorFlag = 0;
-	 goto shmemerror;
+         /* Ultimate failure here. */
+         XDestroyImage (xinfo->ximage);
+         shmdt (shminfo1.shmaddr);
+         if (fiasco_get_verbosity ())
+            fprintf (stderr, "Shared memory error, disabling.\n");
+         gXErrorFlag = 0;
+         goto shmemerror;
       }
       else
-	 shmctl (shminfo1.shmid, IPC_RMID, 0);
+         shmctl (shminfo1.shmid, IPC_RMID, 0);
       if (fiasco_get_verbosity ())
-	 fprintf (stderr, "Sharing memory.\n");
+         fprintf (stderr, "Sharing memory.\n");
    }
    else
    {
@@ -392,19 +392,19 @@ alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height)
 #endif /* USE_SHM */
 
       xinfo->ximage = XCreateImage (xinfo->display,
-				    DefaultVisual (xinfo->display,
-						   xinfo->screen),
-				    DefaultDepth (xinfo->display,
-						  xinfo->screen),
-				    ZPixmap, 0, &dummy, width, height, 8, 0);
+                                    DefaultVisual (xinfo->display,
+                                                   xinfo->screen),
+                                    DefaultDepth (xinfo->display,
+                                                  xinfo->screen),
+                                    ZPixmap, 0, &dummy, width, height, 8, 0);
       xinfo->pixels = calloc (width * height,
-			      xinfo->ximage->depth <= 8
-			      ? sizeof (byte_t)
-			      : (xinfo->ximage->depth <= 16
-				 ? sizeof (u_word_t) : sizeof (unsigned int)));
+                              xinfo->ximage->depth <= 8
+                              ? sizeof (byte_t)
+                              : (xinfo->ximage->depth <= 16
+                                 ? sizeof (u_word_t) : sizeof (unsigned int)));
       if (!xinfo->pixels)
-	 error ("Out of memory.");
-    
+         error ("Out of memory.");
+
 #ifdef USE_SHM
    }
 
diff --git a/converter/other/fiasco/display.h b/converter/other/fiasco/display.h
index 8049456a..0f9c53dc 100644
--- a/converter/other/fiasco/display.h
+++ b/converter/other/fiasco/display.h
@@ -1,8 +1,8 @@
 /*
  *  display.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -27,10 +27,10 @@
 typedef struct x11_info
 {
    Display *display;
-   int	    screen;			/* default screen number */
-   Window   window;			
+   int      screen;                     /* default screen number */
+   Window   window;                     
    XImage  *ximage;
-   GC	    gc;
+   GC       gc;
    byte_t  *pixels;
 } x11_info_t;
 
@@ -40,7 +40,7 @@ void
 close_window (x11_info_t *xinfo);
 x11_info_t *
 open_window (const char *titlename, const char *iconname,
-	     unsigned width, unsigned height);
+             unsigned width, unsigned height);
 void
 alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height);
 
diff --git a/converter/other/fiasco/fiasco.h b/converter/other/fiasco/fiasco.h
index 88f999fc..48226c47 100644
--- a/converter/other/fiasco/fiasco.h
+++ b/converter/other/fiasco/fiasco.h
@@ -1,8 +1,8 @@
 /*
- *  fiasco.h		
+ *  fiasco.h
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  *
@@ -46,7 +46,7 @@
 __BEGIN_DECLS
 
 /****************************************************************************
-			  FIASCO data types
+                          FIASCO data types
 ****************************************************************************/
 
 /*
@@ -56,9 +56,9 @@ __BEGIN_DECLS
  *  FIASCO_ULTIMATE_VERBOSITY: Show debugging output
  */
 typedef enum {FIASCO_NO_VERBOSITY,
-	      FIASCO_SOME_VERBOSITY,
-	      FIASCO_ULTIMATE_VERBOSITY} fiasco_verbosity_e;
-  
+              FIASCO_SOME_VERBOSITY,
+              FIASCO_ULTIMATE_VERBOSITY} fiasco_verbosity_e;
+
 /*
  *  Image tiling methods:
  *  VARIANCE_ASC:  Tiles are sorted by variance.
@@ -71,9 +71,9 @@ typedef enum {FIASCO_NO_VERBOSITY,
  *                 in the upper left corner.
  */
 typedef enum {FIASCO_TILING_SPIRAL_ASC,
-	      FIASCO_TILING_SPIRAL_DSC,
-	      FIASCO_TILING_VARIANCE_ASC,
-	      FIASCO_TILING_VARIANCE_DSC} fiasco_tiling_e;
+              FIASCO_TILING_SPIRAL_DSC,
+              FIASCO_TILING_VARIANCE_ASC,
+              FIASCO_TILING_VARIANCE_DSC} fiasco_tiling_e;
 
 /*
  *  Range of reduced precision format:
@@ -83,29 +83,29 @@ typedef enum {FIASCO_TILING_SPIRAL_ASC,
  *  FIASCO_RPF_RANGE_2_00: use interval [-2.00,2.00]
  */
 typedef enum {FIASCO_RPF_RANGE_0_75,
-	      FIASCO_RPF_RANGE_1_00,
-	      FIASCO_RPF_RANGE_1_50,
-	      FIASCO_RPF_RANGE_2_00} fiasco_rpf_range_e;
+              FIASCO_RPF_RANGE_1_00,
+              FIASCO_RPF_RANGE_1_50,
+              FIASCO_RPF_RANGE_2_00} fiasco_rpf_range_e;
 
 /*
  *  Type of progress meter to be used during coding
  *  FIASCO_PROGRESS_NONE:    no output at all
- *  FIASCO_PROGRESS_BAR:     RPM style progress bar using 50 hash marks ###### 
- *  FIASCO_PROGRESS_PERCENT: percentage meter 50% 
+ *  FIASCO_PROGRESS_BAR:     RPM style progress bar using 50 hash marks ######
+ *  FIASCO_PROGRESS_PERCENT: percentage meter 50%
  */
 typedef enum {FIASCO_PROGRESS_NONE,
-	      FIASCO_PROGRESS_BAR,
-	      FIASCO_PROGRESS_PERCENT} fiasco_progress_e;
+              FIASCO_PROGRESS_BAR,
+              FIASCO_PROGRESS_PERCENT} fiasco_progress_e;
 
 /*
  * Class to encapsulate FIASCO images.
  */
 typedef struct fiasco_image
 {
-   void		(*delete)	(struct fiasco_image *image);
-   unsigned	(*get_width)	(struct fiasco_image *image);
-   unsigned	(*get_height)	(struct fiasco_image *image);
-   int		(*is_color)	(struct fiasco_image *image);
+   void         (*delete)       (struct fiasco_image *image);
+   unsigned     (*get_width)    (struct fiasco_image *image);
+   unsigned     (*get_height)   (struct fiasco_image *image);
+   int          (*is_color)     (struct fiasco_image *image);
    void *private;
 } fiasco_image_t;
 
@@ -114,17 +114,17 @@ typedef struct fiasco_image
  */
 typedef struct fiasco_decoder
 {
-   int			(*delete)	 (struct fiasco_decoder *decoder);
-   int			(*write_frame)   (struct fiasco_decoder *decoder,
-					  const char *filename);
-   fiasco_image_t *	(*get_frame)     (struct fiasco_decoder *decoder);
-   unsigned		(*get_length)    (struct fiasco_decoder *decoder);
-   unsigned		(*get_rate)	 (struct fiasco_decoder *decoder);
-   unsigned		(*get_width)	 (struct fiasco_decoder *decoder);
-   unsigned		(*get_height)	 (struct fiasco_decoder *decoder);
-   const char *		(*get_title)	 (struct fiasco_decoder *decoder);
-   const char *		(*get_comment)	 (struct fiasco_decoder *decoder);
-   int			(*is_color)	 (struct fiasco_decoder *decoder);
+   int                  (*delete)        (struct fiasco_decoder *decoder);
+   int                  (*write_frame)   (struct fiasco_decoder *decoder,
+                                          const char *filename);
+   fiasco_image_t *     (*get_frame)     (struct fiasco_decoder *decoder);
+   unsigned             (*get_length)    (struct fiasco_decoder *decoder);
+   unsigned             (*get_rate)      (struct fiasco_decoder *decoder);
+   unsigned             (*get_width)     (struct fiasco_decoder *decoder);
+   unsigned             (*get_height)    (struct fiasco_decoder *decoder);
+   const char *         (*get_title)     (struct fiasco_decoder *decoder);
+   const char *         (*get_comment)   (struct fiasco_decoder *decoder);
+   int                  (*is_color)      (struct fiasco_decoder *decoder);
    void *private;
 } fiasco_decoder_t;
 
@@ -135,43 +135,43 @@ typedef struct fiasco_c_options
 {
    void (*delete)            (struct fiasco_c_options *options);
    int (*set_tiling)         (struct fiasco_c_options *options,
-			      fiasco_tiling_e method,
-			      unsigned exponent);
+                              fiasco_tiling_e method,
+                              unsigned exponent);
    int (*set_frame_pattern)  (struct fiasco_c_options *options,
-			      const char *pattern);
+                              const char *pattern);
    int (*set_basisfile)      (struct fiasco_c_options *options,
-			      const char *filename);
+                              const char *filename);
    int (*set_chroma_quality) (struct fiasco_c_options *options,
-			      float quality_factor,
-			      unsigned dictionary_size);
+                              float quality_factor,
+                              unsigned dictionary_size);
    int (*set_optimizations)  (struct fiasco_c_options *options,
-			      unsigned min_block_level,
-			      unsigned max_block_level,
-			      unsigned max_elements,
-			      unsigned dictionary_size,
-			      unsigned optimization_level);
+                              unsigned min_block_level,
+                              unsigned max_block_level,
+                              unsigned max_elements,
+                              unsigned dictionary_size,
+                              unsigned optimization_level);
    int (*set_prediction)     (struct fiasco_c_options *options,
-			      int intra_prediction,
-			      unsigned min_block_level,
-			      unsigned max_block_level);
+                              int intra_prediction,
+                              unsigned min_block_level,
+                              unsigned max_block_level);
    int (*set_video_param)    (struct fiasco_c_options *options,
-			      unsigned frames_per_second,
-			      int half_pixel_prediction,
-			      int cross_B_search,
-			      int B_as_past_ref);
+                              unsigned frames_per_second,
+                              int half_pixel_prediction,
+                              int cross_B_search,
+                              int B_as_past_ref);
    int (*set_quantization)   (struct fiasco_c_options *options,
-			      unsigned mantissa,
-			      fiasco_rpf_range_e range,
-			      unsigned dc_mantissa,
-			      fiasco_rpf_range_e dc_range);
+                              unsigned mantissa,
+                              fiasco_rpf_range_e range,
+                              unsigned dc_mantissa,
+                              fiasco_rpf_range_e dc_range);
    int (*set_progress_meter) (struct fiasco_c_options *options,
-			      fiasco_progress_e type);
+                              fiasco_progress_e type);
    int (*set_smoothing)      (struct fiasco_c_options *options,
-			      int smoothing);
+                              int smoothing);
    int (*set_comment)        (struct fiasco_c_options *options,
-			      const char *comment);
+                              const char *comment);
    int (*set_title)          (struct fiasco_c_options *options,
-			      const char *title);
+                              const char *title);
    void *private;
 } fiasco_c_options_t;
 
@@ -182,32 +182,32 @@ typedef struct fiasco_d_options
 {
    void (*delete)            (struct fiasco_d_options *options);
    int (*set_smoothing)      (struct fiasco_d_options *options,
-			      int smoothing);
+                              int smoothing);
    int (*set_magnification)  (struct fiasco_d_options *options,
-			      int level);
+                              int level);
    int (*set_4_2_0_format)   (struct fiasco_d_options *options,
-			      int format);
+                              int format);
    void *private;
 } fiasco_d_options_t;
 
 /*
  * Class to convert internal FIASCO image structure to a XImage structure.
- * Method `renderer()' is used to convert internal image to XImage. 
- * Method `delete()' is used to delete and free internal image. 
+ * Method `renderer()' is used to convert internal image to XImage.
+ * Method `delete()' is used to delete and free internal image.
  */
 typedef struct fiasco_renderer
 {
    int  (*render) (const struct fiasco_renderer *this,
-		   unsigned char *data,
-		   const fiasco_image_t *fiasco_image);
+                   unsigned char *data,
+                   const fiasco_image_t *fiasco_image);
    void (*delete) (struct fiasco_renderer *this);
    void *private;
 } fiasco_renderer_t;
 
 /****************************************************************************
-		       miscellaneous functions
+                       miscellaneous functions
 ****************************************************************************/
-  
+
 /* Get last error message of FIASCO library */
 const char *fiasco_get_error_message (void);
 
@@ -218,19 +218,19 @@ void fiasco_set_verbosity (fiasco_verbosity_e level);
 fiasco_verbosity_e fiasco_get_verbosity (void);
 
 /****************************************************************************
-			  decoder functions
+                          decoder functions
 ****************************************************************************/
 
 /* Decode FIASCO image or sequence */
 fiasco_decoder_t *fiasco_decoder_new (const char *filename,
-				      const fiasco_d_options_t *options);
+                                      const fiasco_d_options_t *options);
 
 /* Flush and discard FIASCO decoder */
 int fiasco_decoder_delete (fiasco_decoder_t *decoder);
 
 /* Decode next FIASCO frame and write to PNM image 'filename' */
 int fiasco_decoder_write_frame (fiasco_decoder_t *decoder,
-				const char *filename);
+                                const char *filename);
 
 /* Decode next FIASCO frame to FIASCO image structure */
 fiasco_image_t *fiasco_decoder_get_frame (fiasco_decoder_t *decoder);
@@ -259,7 +259,7 @@ const char *
 fiasco_decoder_get_comment (fiasco_decoder_t *decoder);
 
 /****************************************************************************
-			  image functions
+                          image functions
 ****************************************************************************/
 
 /* Create FIASCO image (from PNM image file) */
@@ -275,7 +275,7 @@ fiasco_image_new_stream(FILE *       const ifP,
                         int          const format);
 
 /* Discard FIASCO image */
-void fiasco_image_delete (fiasco_image_t *image); 
+void fiasco_image_delete (fiasco_image_t *image);
 
 /* Get width of FIASCO image or sequence */
 unsigned fiasco_image_get_width (fiasco_image_t *image);
@@ -287,14 +287,14 @@ unsigned fiasco_image_get_height (fiasco_image_t *image);
 int fiasco_image_is_color (fiasco_image_t *image);
 
 /****************************************************************************
-			  renderer functions
+                          renderer functions
 ****************************************************************************/
 
 /* Constructor of FIASCO image structure to a XImage renderer */
 fiasco_renderer_t *
 fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask,
-		     unsigned long blue_mask, unsigned bpp,
-		     int double_resolution);
+                     unsigned long blue_mask, unsigned bpp,
+                     int double_resolution);
 
 /* Destructor of FIASCO image structure to a XImage renderer */
 void
@@ -303,21 +303,21 @@ fiasco_renderer_delete (fiasco_renderer_t *renderer);
 /* FIASCO image structure to a XImage renderer */
 int
 fiasco_renderer_render (const fiasco_renderer_t *renderer,
-			unsigned char *ximage,
-			const fiasco_image_t *fiasco_image);
+                        unsigned char *ximage,
+                        const fiasco_image_t *fiasco_image);
 
 /****************************************************************************
-			   coder functions
+                           coder functions
 ****************************************************************************/
 
 /* Encode image or sequence by FIASCO */
 int fiasco_coder (char const * const *inputname,
-		  const char *outputname,
-		  float quality,
-		  const fiasco_c_options_t *options);
+                  const char *outputname,
+                  float quality,
+                  const fiasco_c_options_t *options);
 
 /****************************************************************************
-		 coder options functions
+                 coder options functions
 ****************************************************************************/
 
 /* FIASCO additional options constructor */
@@ -328,25 +328,25 @@ void fiasco_c_options_delete (fiasco_c_options_t *options);
 
 /* Define `smoothing'-percentage along partitioning borders.*/
 int fiasco_c_options_set_smoothing (fiasco_c_options_t *options,
-				    int smoothing);
+                                    int smoothing);
 
 /* Set type of frame prediction for sequence of frames */
 int fiasco_c_options_set_frame_pattern (fiasco_c_options_t *options,
-					const char *pattern);
+                                        const char *pattern);
 
 /* Set method and number of tiles for image tiling */
 int fiasco_c_options_set_tiling (fiasco_c_options_t *options,
-				 fiasco_tiling_e method,
-				 unsigned exponent);
+                                 fiasco_tiling_e method,
+                                 unsigned exponent);
 
 /* Set FIASCO initial basis file */
 int fiasco_c_options_set_basisfile (fiasco_c_options_t *options,
-				    const char *filename);
+                                    const char *filename);
 
 /* Set quality and dictionary size of chroma compression */
 int fiasco_c_options_set_chroma_quality (fiasco_c_options_t *options,
-					 float quality_factor,
-					 unsigned dictionary_size);
+                                         float quality_factor,
+                                         unsigned dictionary_size);
 
 /*
  *  Since FIASCO internally works with binary trees, all functions
@@ -354,62 +354,62 @@ int fiasco_c_options_set_chroma_quality (fiasco_c_options_t *options,
  *  the corresponding binary tree than the traditional `width' and
  *  `height' arguments.  Refer to following table to convert these
  *  values:
- *  
+ *
  *  level | width | height
  *  ------+-------+--------
- *    0   |    1  |    1  
- *    1   |    1  |    2  
- *    2   |    2  |    2  
- *    3   |    2  |    4  
- *    4   |    4  |    4  
- *    5   |    4  |    8  
- *    6   |    8  |    8  
+ *    0   |    1  |    1
+ *    1   |    1  |    2
+ *    2   |    2  |    2
+ *    3   |    2  |    4
+ *    4   |    4  |    4
+ *    5   |    4  |    8
+ *    6   |    8  |    8
  *    7   |    8  |   16
  *
  */
-   
+
 /* Set various optimization parameters. */
 int fiasco_c_options_set_optimizations (fiasco_c_options_t *options,
-					unsigned min_block_level,
-					unsigned max_block_level,
-					unsigned max_elements,
-					unsigned dictionary_size,
-					unsigned optimization_level);
+                                        unsigned min_block_level,
+                                        unsigned max_block_level,
+                                        unsigned max_elements,
+                                        unsigned dictionary_size,
+                                        unsigned optimization_level);
 
 /* Set minimum and maximum size of image block prediction */
 int fiasco_c_options_set_prediction (fiasco_c_options_t *options,
-				     int intra_prediction,
-				     unsigned min_block_level,
-				     unsigned max_block_level);
+                                     int intra_prediction,
+                                     unsigned min_block_level,
+                                     unsigned max_block_level);
 
 /*  Set various parameters used for video compensation */
 int fiasco_c_options_set_video_param (fiasco_c_options_t *options,
-				      unsigned frames_per_second,
-				      int half_pixel_prediction,
-				      int cross_B_search,
-				      int B_as_past_ref);
+                                      unsigned frames_per_second,
+                                      int half_pixel_prediction,
+                                      int cross_B_search,
+                                      int B_as_past_ref);
 
 /* Set accuracy of coefficients quantization */
 int fiasco_c_options_set_quantization (fiasco_c_options_t *options,
-				       unsigned mantissa,
-				       fiasco_rpf_range_e range,
-				       unsigned dc_mantissa,
-				       fiasco_rpf_range_e dc_range);
+                                       unsigned mantissa,
+                                       fiasco_rpf_range_e range,
+                                       unsigned dc_mantissa,
+                                       fiasco_rpf_range_e dc_range);
 
 /* Set type of progress meter */
 int fiasco_c_options_set_progress_meter (fiasco_c_options_t *options,
-					 fiasco_progress_e type);
+                                         fiasco_progress_e type);
 
 /*  Set comment of FIASCO stream */
 int fiasco_c_options_set_comment (fiasco_c_options_t *options,
-				  const char *comment);
+                                  const char *comment);
 
 /*  Set title of FIASCO stream */
 int fiasco_c_options_set_title (fiasco_c_options_t *options,
-				const char *title);
+                                const char *title);
 
 /****************************************************************************
-		 decoder options functions
+                 decoder options functions
 ****************************************************************************/
 
 /* FIASCO additional options constructor */
@@ -421,15 +421,15 @@ void fiasco_d_options_delete (fiasco_d_options_t *options);
 
 /* Define `smoothing'-percentage along partitioning borders.*/
 int fiasco_d_options_set_smoothing (fiasco_d_options_t *options,
-				  int smoothing);
+                                  int smoothing);
 
 /* Set magnification-'level' of decoded image */
 int fiasco_d_options_set_magnification (fiasco_d_options_t *options,
-				      int level);
+                                      int level);
 
 /* Set image format to 4:2:0 or 4:4:4 */
 int fiasco_d_options_set_4_2_0_format (fiasco_d_options_t *options,
-				     int format);
+                                     int format);
 
 __END_DECLS
 
diff --git a/converter/other/fiasco/fiascotopnm.c b/converter/other/fiasco/fiascotopnm.c
index e95e27fc..c97e201b 100644
--- a/converter/other/fiasco/fiascotopnm.c
+++ b/converter/other/fiasco/fiascotopnm.c
@@ -3,11 +3,11 @@
  *
  *  Written by:     Ullrich Hafner
  *          Michael Unger
- *      
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
- 
+
 /*
  *  $Date: 2000/10/28 17:39:29 $
  *  $Author: hafner $
@@ -50,10 +50,10 @@ static x11_info_t *xinfo = NULL;
 /*****************************************************************************
 
                 prototypes
-  
+
 *****************************************************************************/
 
-static int 
+static int
 checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel,
            int *fps, char **image_name, fiasco_d_options_t **options);
 static void
@@ -75,10 +75,10 @@ show_stored_frames (unsigned char * const *frame_buffer, int last_frame,
 /*****************************************************************************
 
                 public code
-  
+
 *****************************************************************************/
 
-int 
+int
 main (int argc, char **argv)
 {
     char               *image_name        = NULL; /* output filename */
@@ -92,7 +92,7 @@ main (int argc, char **argv)
 
     last_arg = checkargs (argc, argv, &double_resolution, &panel, &fps,
                           &image_name, &options);
-   
+
     if (last_arg >= argc)
         video_decoder ("-", image_name, panel, double_resolution, fps, options);
     else
@@ -106,7 +106,7 @@ main (int argc, char **argv)
 /*****************************************************************************
 
                 private code
-  
+
 *****************************************************************************/
 
 static param_t params [] =
@@ -133,7 +133,7 @@ static param_t params [] =
     {NULL, NULL, 0, 0, {0}, NULL, NULL }
 };
 
-static int 
+static int
 checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel,
            int *fps, char **image_name, fiasco_d_options_t **options)
 /*
@@ -180,21 +180,21 @@ checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel,
 
     {
         int const n = *((int *) parameter_value (params, "smoothing"));
-      
+
         if (!fiasco_d_options_set_smoothing (*options, MAX(-1, n)))
             error (fiasco_get_error_message ());
     }
 
     {
         int const n = *((int *) parameter_value (params, "magnify"));
-      
+
         if (!fiasco_d_options_set_magnification (*options, n))
             error (fiasco_get_error_message ());
     }
-   
+
     {
         bool_t const n = *((bool_t *) parameter_value (params, "fast"));
-      
+
         if (!fiasco_d_options_set_4_2_0_format (*options, n > 0 ? YES : NO))
             error (fiasco_get_error_message ());
     }
@@ -211,7 +211,7 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
     unsigned char     **frame_buffer = NULL;
     binfo_t            *binfo        = NULL; /* buttons info */
 #endif /* not X_DISPLAY_MISSING */
-   
+
     do
     {
         unsigned      width, height, frames, n;
@@ -220,23 +220,23 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
         char             *basename;   /* basename of decoded frame */
         char             *suffix;     /* suffix of decoded frame */
         unsigned      frame_time;
-      
+
         if (!(decoder_state = fiasco_decoder_new (wfa_name, options)))
             error (fiasco_get_error_message ());
-   
-        if (fps <= 0)         /* then use value of FIASCO file */ 
+
+        if (fps <= 0)         /* then use value of FIASCO file */
             fps = fiasco_decoder_get_rate (decoder_state);
         frame_time = fps ? (1000 / fps) : (1000 / 25);
 
         if (!(width = fiasco_decoder_get_width (decoder_state)))
             error (fiasco_get_error_message ());
-      
+
         if (!(height = fiasco_decoder_get_height (decoder_state)))
             error (fiasco_get_error_message ());
 
         if (!(frames = fiasco_decoder_get_length (decoder_state)))
             error (fiasco_get_error_message ());
-      
+
         get_output_template (image_name, wfa_name,
                              fiasco_decoder_is_color (decoder_state),
                              &basename, &suffix);
@@ -249,9 +249,9 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
         for (n = 0; n < frames; n++)
         {
             clock_t fps_timer;     /* frames per second timer struct */
-     
+
             prg_timer (&fps_timer, START);
-     
+
             if (image_name)        /* just write frame to disk */
             {
                 if (frames == 1)        /* just one image */
@@ -277,23 +277,23 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
             else
             {
                 fiasco_image_t *frame;
-        
+
                 if (!(frame = fiasco_decoder_get_frame (decoder_state)))
                     error (fiasco_get_error_message ());
-        
+
                 if (frames == 1)
                     panel = NO;
 
                 if (xinfo == NULL)      /* initialize X11 window */
                 {
-                    const char * const title = 
+                    const char * const title =
                         fiasco_decoder_get_title (decoder_state);
                     char        titlename [MAXSTRLEN];
 
-           
+
                     sprintf (titlename, "dfiasco " VERSION ": %s",
                              strlen (title) > 0 ? title : wfa_name);
-                    xinfo = 
+                    xinfo =
                         open_window (titlename, "dfiasco",
                                      (width  << (double_resolution ? 1 : 0)),
                                      (height << (double_resolution ? 1 : 0))
@@ -302,7 +302,7 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
                                   height << (double_resolution ? 1 : 0));
                     if (panel)       /* initialize button panel */
                         binfo = init_buttons (xinfo, n, frames, 30, 10);
-                    renderer = 
+                    renderer =
                         fiasco_renderer_new (xinfo->ximage->red_mask,
                                              xinfo->ximage->green_mask,
                                              xinfo->ximage->blue_mask,
@@ -313,7 +313,7 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
                 }
                 renderer->render (renderer, xinfo->pixels, frame);
                 frame->delete (frame);
-        
+
                 if (frame_buffer != NULL) /* store next frame */
                 {
                     size_t size = (width  << (double_resolution ? 1 : 0))
@@ -343,17 +343,17 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
                 else if (panel)
                 {
                     check_events (xinfo, binfo, n, frames);
-                    if (binfo->pressed [QUIT_BUTTON]) 
+                    if (binfo->pressed [QUIT_BUTTON])
                         /* start from beginning */
                         break;
-                    if (binfo->pressed [STOP_BUTTON]) 
+                    if (binfo->pressed [STOP_BUTTON])
                         /* start from beginning */
                         n = frames;
-           
+
                     if (binfo->pressed [RECORD_BUTTON] && frame_buffer == NULL)
                     {
                         n = frames;
-                        frame_buffer = 
+                        frame_buffer =
                             calloc (frames, sizeof (unsigned char *));
                         if (!frame_buffer)
                             error ("Out of memory.");
@@ -364,17 +364,17 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
             }
 #else
             if (frame_time) {/* defeat compiler warning */}
-#endif /* not X_DISPLAY_MISSING */   
+#endif /* not X_DISPLAY_MISSING */
         }
         free (filename);
-   
+
         fiasco_decoder_delete (decoder_state);
     } while (panel
 
 #ifndef X_DISPLAY_MISSING
              && !binfo->pressed [QUIT_BUTTON]
 #endif /* not X_DISPLAY_MISSING */
-        
+
         );
 
 #ifndef X_DISPLAY_MISSING
@@ -408,7 +408,7 @@ get_output_template (const char *image_name, const char *wfa_name,
  */
 {
     if (!wfa_name || streq (wfa_name, "-"))
-        wfa_name = "stdin";       
+        wfa_name = "stdin";
     /*
      *  Generate filename template
      */
@@ -422,7 +422,7 @@ get_output_template (const char *image_name, const char *wfa_name,
         *basename = strdup (image_name);
         *suffix   = strrchr (*basename, '.');
     }
-    
+
     if (*suffix)         /* found name 'basename.suffix' */
     {
         **suffix = 0;         /* remove dot */
@@ -450,13 +450,13 @@ show_stored_frames (unsigned char * const *frame_buffer, int last_frame,
  */
 {
     int n = last_frame;          /* frame number */
-   
+
     while (1)
     {
         clock_t fps_timer;        /* frames per second timer struct */
-      
+
         prg_timer (&fps_timer, START);
-      
+
         display_image (0, 0, xinfo);
         check_events (xinfo, binfo, n, last_frame + 1);
 
diff --git a/converter/other/fiasco/getopt.c b/converter/other/fiasco/getopt.c
index 2f45c7cc..44fd03e6 100644
--- a/converter/other/fiasco/getopt.c
+++ b/converter/other/fiasco/getopt.c
@@ -66,12 +66,12 @@
 
 /* This needs to come after some library #include
    to get __GNU_LIBRARY__ defined.  */
-#ifdef	__GNU_LIBRARY__
+#ifdef  __GNU_LIBRARY__
 /* Don't include stdlib.h for non-GNU C libraries because some of them
    contain conflicting prototypes for getopt.  */
 #include <stdlib.h>
 #include <unistd.h>
-#endif	/* GNU C library.  */
+#endif  /* GNU C library.  */
 
 #if MSVCRT
 #include <windows.h>
@@ -83,9 +83,9 @@
    When compiling libc, the _ macro is predefined.  */
 #ifdef HAVE_LIBINTL_H
 # include <libintl.h>
-# define _(msgid)	gettext (msgid)
+# define _(msgid)       gettext (msgid)
 #else
-# define _(msgid)	(msgid)
+# define _(msgid)       (msgid)
 #endif
 #endif
 
@@ -191,13 +191,13 @@ static enum
 /* Value of POSIXLY_CORRECT environment variable.  */
 static char *posixly_correct;
 
-#ifdef	__GNU_LIBRARY__
+#ifdef  __GNU_LIBRARY__
 /* We want to avoid inclusion of string.h with non-GNU libraries
    because there are many ways it can cause trouble.
    On some systems, it contains special magic macros that don't work
    in GCC.  */
 #include <string.h>
-#define	my_index	strchr
+#define my_index        strchr
 #else
 
 /* Avoid depending on library functions or files
@@ -213,7 +213,7 @@ my_index (str, chr)
   while (*str)
     {
       if (*str == chr)
-	return (char *) str;
+        return (char *) str;
       str++;
     }
   return 0;
@@ -297,37 +297,37 @@ exchange (argv)
   while (top > middle && middle > bottom)
     {
       if (top - middle > middle - bottom)
-	{
-	  /* Bottom segment is the short one.  */
-	  int len = middle - bottom;
-	  register int i;
-
-	  /* Swap it with the top part of the top segment.  */
-	  for (i = 0; i < len; i++)
-	    {
-	      tem = argv[bottom + i];
-	      argv[bottom + i] = argv[top - (middle - bottom) + i];
-	      argv[top - (middle - bottom) + i] = tem;
-	    }
-	  /* Exclude the moved bottom segment from further swapping.  */
-	  top -= len;
-	}
+        {
+          /* Bottom segment is the short one.  */
+          int len = middle - bottom;
+          register int i;
+
+          /* Swap it with the top part of the top segment.  */
+          for (i = 0; i < len; i++)
+            {
+              tem = argv[bottom + i];
+              argv[bottom + i] = argv[top - (middle - bottom) + i];
+              argv[top - (middle - bottom) + i] = tem;
+            }
+          /* Exclude the moved bottom segment from further swapping.  */
+          top -= len;
+        }
       else
-	{
-	  /* Top segment is the short one.  */
-	  int len = top - middle;
-	  register int i;
-
-	  /* Swap it with the bottom part of the bottom segment.  */
-	  for (i = 0; i < len; i++)
-	    {
-	      tem = argv[bottom + i];
-	      argv[bottom + i] = argv[middle + i];
-	      argv[middle + i] = tem;
-	    }
-	  /* Exclude the moved top segment from further swapping.  */
-	  bottom += len;
-	}
+        {
+          /* Top segment is the short one.  */
+          int len = top - middle;
+          register int i;
+
+          /* Swap it with the bottom part of the bottom segment.  */
+          for (i = 0; i < len; i++)
+            {
+              tem = argv[bottom + i];
+              argv[bottom + i] = argv[middle + i];
+              argv[middle + i] = tem;
+            }
+          /* Exclude the moved top segment from further swapping.  */
+          bottom += len;
+        }
     }
 
   /* Update records for the slots the non-options now occupy.  */
@@ -379,16 +379,16 @@ _getopt_initialize (argc, argv, optstring)
       && argc == original_argc && argv == original_argv)
     {
       /* Bash 2.0 puts a special variable in the environment for each
-	 command it runs, specifying which ARGV elements are the results of
-	 file name wildcard expansion and therefore should not be
-	 considered as options.  */
+         command it runs, specifying which ARGV elements are the results of
+         file name wildcard expansion and therefore should not be
+         considered as options.  */
       char var[100];
       sprintf (var, "_%d_GNU_nonoption_argv_flags_", getpid ());
       nonoption_flags = getenv (var);
       if (nonoption_flags == NULL)
-	nonoption_flags_len = 0;
+        nonoption_flags_len = 0;
       else
-	nonoption_flags_len = strlen (nonoption_flags);
+        nonoption_flags_len = strlen (nonoption_flags);
     }
   else
     nonoption_flags_len = 0;
@@ -467,7 +467,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
   if (!__getopt_initialized || optind == 0)
     {
       optstring = _getopt_initialize (argc, argv, optstring);
-      optind = 1;		/* Don't scan ARGV[0], the program name.  */
+      optind = 1;               /* Don't scan ARGV[0], the program name.  */
       __getopt_initialized = 1;
     }
 
@@ -476,9 +476,9 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
      from the shell indicating it is not an option.  The later information
      is only used when the used in the GNU libc.  */
 #ifdef _LIBC
-#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'	      \
-		     || (optind < nonoption_flags_len			      \
-			 && nonoption_flags[optind] == '1'))
+#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'        \
+                     || (optind < nonoption_flags_len                         \
+                         && nonoption_flags[optind] == '1'))
 #else
 #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
 #endif
@@ -488,76 +488,76 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
       /* Advance to the next ARGV-element.  */
 
       /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
-	 moved back by the user (who may also have changed the arguments).  */
+         moved back by the user (who may also have changed the arguments).  */
       if (last_nonopt > optind)
-	last_nonopt = optind;
+        last_nonopt = optind;
       if (first_nonopt > optind)
-	first_nonopt = optind;
+        first_nonopt = optind;
 
       if (ordering == PERMUTE)
-	{
-	  /* If we have just processed some options following some non-options,
-	     exchange them so that the options come first.  */
+        {
+          /* If we have just processed some options following some non-options,
+             exchange them so that the options come first.  */
 
-	  if (first_nonopt != last_nonopt && last_nonopt != optind)
-	    exchange ((char **) argv);
-	  else if (last_nonopt != optind)
-	    first_nonopt = optind;
+          if (first_nonopt != last_nonopt && last_nonopt != optind)
+            exchange ((char **) argv);
+          else if (last_nonopt != optind)
+            first_nonopt = optind;
 
-	  /* Skip any additional non-options
-	     and extend the range of non-options previously skipped.  */
+          /* Skip any additional non-options
+             and extend the range of non-options previously skipped.  */
 
-	  while (optind < argc && NONOPTION_P)
-	    optind++;
-	  last_nonopt = optind;
-	}
+          while (optind < argc && NONOPTION_P)
+            optind++;
+          last_nonopt = optind;
+        }
 
       /* The special ARGV-element `--' means premature end of options.
-	 Skip it like a null option,
-	 then exchange with previous non-options as if it were an option,
-	 then skip everything else like a non-option.  */
+         Skip it like a null option,
+         then exchange with previous non-options as if it were an option,
+         then skip everything else like a non-option.  */
 
       if (optind != argc && !strcmp (argv[optind], "--"))
-	{
-	  optind++;
+        {
+          optind++;
 
-	  if (first_nonopt != last_nonopt && last_nonopt != optind)
-	    exchange ((char **) argv);
-	  else if (first_nonopt == last_nonopt)
-	    first_nonopt = optind;
-	  last_nonopt = argc;
+          if (first_nonopt != last_nonopt && last_nonopt != optind)
+            exchange ((char **) argv);
+          else if (first_nonopt == last_nonopt)
+            first_nonopt = optind;
+          last_nonopt = argc;
 
-	  optind = argc;
-	}
+          optind = argc;
+        }
 
       /* If we have done all the ARGV-elements, stop the scan
-	 and back over any non-options that we skipped and permuted.  */
+         and back over any non-options that we skipped and permuted.  */
 
       if (optind == argc)
-	{
-	  /* Set the next-arg-index to point at the non-options
-	     that we previously skipped, so the caller will digest them.  */
-	  if (first_nonopt != last_nonopt)
-	    optind = first_nonopt;
-	  return -1;
-	}
+        {
+          /* Set the next-arg-index to point at the non-options
+             that we previously skipped, so the caller will digest them.  */
+          if (first_nonopt != last_nonopt)
+            optind = first_nonopt;
+          return -1;
+        }
 
       /* If we have come to a non-option and did not permute it,
-	 either stop the scan or describe it to the caller and pass it by.  */
+         either stop the scan or describe it to the caller and pass it by.  */
 
       if (NONOPTION_P)
-	{
-	  if (ordering == REQUIRE_ORDER)
-	    return -1;
-	  optarg = argv[optind++];
-	  return 1;
-	}
+        {
+          if (ordering == REQUIRE_ORDER)
+            return -1;
+          optarg = argv[optind++];
+          return 1;
+        }
 
       /* We have found another option-ARGV-element.
-	 Skip the initial punctuation.  */
+         Skip the initial punctuation.  */
 
       nextchar = (argv[optind] + 1
-		  + (longopts != NULL && argv[optind][1] == '-'));
+                  + (longopts != NULL && argv[optind][1] == '-'));
     }
 
   /* Decode the current option-ARGV-element.  */
@@ -577,7 +577,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
 
   if (longopts != NULL
       && (argv[optind][1] == '-'
-	  || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
+          || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
     {
       char *nameend;
       const struct option *p;
@@ -588,124 +588,124 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
       int option_index;
 
       for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
-	/* Do nothing.  */ ;
+        /* Do nothing.  */ ;
 
       /* Test all long options for either exact match
-	 or abbreviated matches.  */
+         or abbreviated matches.  */
       for (p = longopts, option_index = 0; p->name; p++, option_index++)
-	if (!strncmp (p->name, nextchar, nameend - nextchar))
-	  {
-	    if ((unsigned int) (nameend - nextchar)
-		== (unsigned int) strlen (p->name))
-	      {
-		/* Exact match found.  */
-		pfound = p;
-		indfound = option_index;
-		exact = 1;
-		break;
-	      }
-	    else if (pfound == NULL)
-	      {
-		/* First nonexact match found.  */
-		pfound = p;
-		indfound = option_index;
-	      }
-	    else
-	      /* Second or later nonexact match found.  */
-	      ambig = 1;
-	  }
+        if (!strncmp (p->name, nextchar, nameend - nextchar))
+          {
+            if ((unsigned int) (nameend - nextchar)
+                == (unsigned int) strlen (p->name))
+              {
+                /* Exact match found.  */
+                pfound = p;
+                indfound = option_index;
+                exact = 1;
+                break;
+              }
+            else if (pfound == NULL)
+              {
+                /* First nonexact match found.  */
+                pfound = p;
+                indfound = option_index;
+              }
+            else
+              /* Second or later nonexact match found.  */
+              ambig = 1;
+          }
 
       if (ambig && !exact)
-	{
-	  if (opterr)
-	    fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
-		     argv[0], argv[optind]);
-	  nextchar += strlen (nextchar);
-	  optind++;
-	  optopt = 0;
-	  return '?';
-	}
+        {
+          if (opterr)
+            fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+                     argv[0], argv[optind]);
+          nextchar += strlen (nextchar);
+          optind++;
+          optopt = 0;
+          return '?';
+        }
 
       if (pfound != NULL)
-	{
-	  option_index = indfound;
-	  optind++;
-	  if (*nameend)
-	    {
-	      /* Don't test has_arg with >, because some C compilers don't
-		 allow it to be used on enums.  */
-	      if (pfound->has_arg)
-		optarg = nameend + 1;
-	      else
-		{
+        {
+          option_index = indfound;
+          optind++;
+          if (*nameend)
+            {
+              /* Don't test has_arg with >, because some C compilers don't
+                 allow it to be used on enums.  */
+              if (pfound->has_arg)
+                optarg = nameend + 1;
+              else
+                {
             if (opterr) {
-		   if (argv[optind - 1][1] == '-')
-		    /* --option */
-		    fprintf (stderr,
-		     _("%s: option `--%s' doesn't allow an argument\n"),
-		     argv[0], pfound->name);
-		   else
-		    /* +option or -option */
-		    fprintf (stderr,
-		     _("%s: option `%c%s' doesn't allow an argument\n"),
-		     argv[0], argv[optind - 1][0], pfound->name);
+                   if (argv[optind - 1][1] == '-')
+                    /* --option */
+                    fprintf (stderr,
+                     _("%s: option `--%s' doesn't allow an argument\n"),
+                     argv[0], pfound->name);
+                   else
+                    /* +option or -option */
+                    fprintf (stderr,
+                     _("%s: option `%c%s' doesn't allow an argument\n"),
+                     argv[0], argv[optind - 1][0], pfound->name);
             }
 
-		  nextchar += strlen (nextchar);
-
-		  optopt = pfound->val;
-		  return '?';
-		}
-	    }
-	  else if (pfound->has_arg == 1)
-	    {
-	      if (optind < argc)
-		optarg = argv[optind++];
-	      else
-		{
-		  if (opterr)
-		    fprintf (stderr,
-			   _("%s: option `%s' requires an argument\n"),
-			   argv[0], argv[optind - 1]);
-		  nextchar += strlen (nextchar);
-		  optopt = pfound->val;
-		  return optstring[0] == ':' ? ':' : '?';
-		}
-	    }
-	  nextchar += strlen (nextchar);
-	  if (longind != NULL)
-	    *longind = option_index;
-	  if (pfound->flag)
-	    {
-	      *(pfound->flag) = pfound->val;
-	      return 0;
-	    }
-	  return pfound->val;
-	}
+                  nextchar += strlen (nextchar);
+
+                  optopt = pfound->val;
+                  return '?';
+                }
+            }
+          else if (pfound->has_arg == 1)
+            {
+              if (optind < argc)
+                optarg = argv[optind++];
+              else
+                {
+                  if (opterr)
+                    fprintf (stderr,
+                           _("%s: option `%s' requires an argument\n"),
+                           argv[0], argv[optind - 1]);
+                  nextchar += strlen (nextchar);
+                  optopt = pfound->val;
+                  return optstring[0] == ':' ? ':' : '?';
+                }
+            }
+          nextchar += strlen (nextchar);
+          if (longind != NULL)
+            *longind = option_index;
+          if (pfound->flag)
+            {
+              *(pfound->flag) = pfound->val;
+              return 0;
+            }
+          return pfound->val;
+        }
 
       /* Can't find it as a long option.  If this is not getopt_long_only,
-	 or the option starts with '--' or is not a valid short
-	 option, then it's an error.
-	 Otherwise interpret it as a short option.  */
+         or the option starts with '--' or is not a valid short
+         option, then it's an error.
+         Otherwise interpret it as a short option.  */
       if (!long_only || argv[optind][1] == '-'
-	  || my_index (optstring, *nextchar) == NULL)
-	{
-	  if (opterr)
-	    {
-	      if (argv[optind][1] == '-')
-		/* --option */
-		fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
-			 argv[0], nextchar);
-	      else
-		/* +option or -option */
-		fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
-			 argv[0], argv[optind][0], nextchar);
-	    }
-	  nextchar = (char *) "";
-	  optind++;
-	  optopt = 0;
-	  return '?';
-	}
+          || my_index (optstring, *nextchar) == NULL)
+        {
+          if (opterr)
+            {
+              if (argv[optind][1] == '-')
+                /* --option */
+                fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+                         argv[0], nextchar);
+              else
+                /* +option or -option */
+                fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+                         argv[0], argv[optind][0], nextchar);
+            }
+          nextchar = (char *) "";
+          optind++;
+          optopt = 0;
+          return '?';
+        }
     }
 
   /* Look at and handle the next short option-character.  */
@@ -720,188 +720,188 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
 
     if (temp == NULL || c == ':')
       {
-	if (opterr)
-	  {
-	    if (posixly_correct)
-	      /* 1003.2 specifies the format of this message.  */
-	      fprintf (stderr, _("%s: illegal option -- %c\n"),
-		       argv[0], c);
-	    else
-	      fprintf (stderr, _("%s: invalid option -- %c\n"),
-		       argv[0], c);
-	  }
-	optopt = c;
-	return '?';
+        if (opterr)
+          {
+            if (posixly_correct)
+              /* 1003.2 specifies the format of this message.  */
+              fprintf (stderr, _("%s: illegal option -- %c\n"),
+                       argv[0], c);
+            else
+              fprintf (stderr, _("%s: invalid option -- %c\n"),
+                       argv[0], c);
+          }
+        optopt = c;
+        return '?';
       }
     /* Convenience. Treat POSIX -W foo same as long option --foo */
     if (temp[0] == 'W' && temp[1] == ';')
       {
-	char *nameend;
-	const struct option *p;
-	const struct option *pfound = NULL;
-	int exact = 0;
-	int ambig = 0;
-	int indfound = 0;
-	int option_index;
-
-	/* This is an option that requires an argument.  */
-	if (*nextchar != '\0')
-	  {
-	    optarg = nextchar;
-	    /* If we end this ARGV-element by taking the rest as an arg,
-	       we must advance to the next element now.  */
-	    optind++;
-	  }
-	else if (optind == argc)
-	  {
-	    if (opterr)
-	      {
-		/* 1003.2 specifies the format of this message.  */
-		fprintf (stderr, _("%s: option requires an argument -- %c\n"),
-			 argv[0], c);
-	      }
-	    optopt = c;
-	    if (optstring[0] == ':')
-	      c = ':';
-	    else
-	      c = '?';
-	    return c;
-	  }
-	else
-	  /* We already incremented `optind' once;
-	     increment it again when taking next ARGV-elt as argument.  */
-	  optarg = argv[optind++];
-
-	/* optarg is now the argument, see if it's in the
-	   table of longopts.  */
-
-	for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
-	  /* Do nothing.  */ ;
-
-	/* Test all long options for either exact match
-	   or abbreviated matches.  */
-	for (p = longopts, option_index = 0; p->name; p++, option_index++)
-	  if (!strncmp (p->name, nextchar, nameend - nextchar))
-	    {
-	      if ((unsigned int) (nameend - nextchar) == strlen (p->name))
-		{
-		  /* Exact match found.  */
-		  pfound = p;
-		  indfound = option_index;
-		  exact = 1;
-		  break;
-		}
-	      else if (pfound == NULL)
-		{
-		  /* First nonexact match found.  */
-		  pfound = p;
-		  indfound = option_index;
-		}
-	      else
-		/* Second or later nonexact match found.  */
-		ambig = 1;
-	    }
-	if (ambig && !exact)
-	  {
-	    if (opterr)
-	      fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
-		       argv[0], argv[optind]);
-	    nextchar += strlen (nextchar);
-	    optind++;
-	    return '?';
-	  }
-	if (pfound != NULL)
-	  {
-	    option_index = indfound;
-	    if (*nameend)
-	      {
-		/* Don't test has_arg with >, because some C compilers don't
-		   allow it to be used on enums.  */
-		if (pfound->has_arg)
-		  optarg = nameend + 1;
-		else
-		  {
-		    if (opterr)
-		      fprintf (stderr, _("\
+        char *nameend;
+        const struct option *p;
+        const struct option *pfound = NULL;
+        int exact = 0;
+        int ambig = 0;
+        int indfound = 0;
+        int option_index;
+
+        /* This is an option that requires an argument.  */
+        if (*nextchar != '\0')
+          {
+            optarg = nextchar;
+            /* If we end this ARGV-element by taking the rest as an arg,
+               we must advance to the next element now.  */
+            optind++;
+          }
+        else if (optind == argc)
+          {
+            if (opterr)
+              {
+                /* 1003.2 specifies the format of this message.  */
+                fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+                         argv[0], c);
+              }
+            optopt = c;
+            if (optstring[0] == ':')
+              c = ':';
+            else
+              c = '?';
+            return c;
+          }
+        else
+          /* We already incremented `optind' once;
+             increment it again when taking next ARGV-elt as argument.  */
+          optarg = argv[optind++];
+
+        /* optarg is now the argument, see if it's in the
+           table of longopts.  */
+
+        for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
+          /* Do nothing.  */ ;
+
+        /* Test all long options for either exact match
+           or abbreviated matches.  */
+        for (p = longopts, option_index = 0; p->name; p++, option_index++)
+          if (!strncmp (p->name, nextchar, nameend - nextchar))
+            {
+              if ((unsigned int) (nameend - nextchar) == strlen (p->name))
+                {
+                  /* Exact match found.  */
+                  pfound = p;
+                  indfound = option_index;
+                  exact = 1;
+                  break;
+                }
+              else if (pfound == NULL)
+                {
+                  /* First nonexact match found.  */
+                  pfound = p;
+                  indfound = option_index;
+                }
+              else
+                /* Second or later nonexact match found.  */
+                ambig = 1;
+            }
+        if (ambig && !exact)
+          {
+            if (opterr)
+              fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+                       argv[0], argv[optind]);
+            nextchar += strlen (nextchar);
+            optind++;
+            return '?';
+          }
+        if (pfound != NULL)
+          {
+            option_index = indfound;
+            if (*nameend)
+              {
+                /* Don't test has_arg with >, because some C compilers don't
+                   allow it to be used on enums.  */
+                if (pfound->has_arg)
+                  optarg = nameend + 1;
+                else
+                  {
+                    if (opterr)
+                      fprintf (stderr, _("\
 %s: option `-W %s' doesn't allow an argument\n"),
-			       argv[0], pfound->name);
-
-		    nextchar += strlen (nextchar);
-		    return '?';
-		  }
-	      }
-	    else if (pfound->has_arg == 1)
-	      {
-		if (optind < argc)
-		  optarg = argv[optind++];
-		else
-		  {
-		    if (opterr)
-		      fprintf (stderr,
-			       _("%s: option `%s' requires an argument\n"),
-			       argv[0], argv[optind - 1]);
-		    nextchar += strlen (nextchar);
-		    return optstring[0] == ':' ? ':' : '?';
-		  }
-	      }
-	    nextchar += strlen (nextchar);
-	    if (longind != NULL)
-	      *longind = option_index;
-	    if (pfound->flag)
-	      {
-		*(pfound->flag) = pfound->val;
-		return 0;
-	      }
-	    return pfound->val;
-	  }
-	  nextchar = NULL;
-	  return 'W';	/* Let the application handle it.   */
+                               argv[0], pfound->name);
+
+                    nextchar += strlen (nextchar);
+                    return '?';
+                  }
+              }
+            else if (pfound->has_arg == 1)
+              {
+                if (optind < argc)
+                  optarg = argv[optind++];
+                else
+                  {
+                    if (opterr)
+                      fprintf (stderr,
+                               _("%s: option `%s' requires an argument\n"),
+                               argv[0], argv[optind - 1]);
+                    nextchar += strlen (nextchar);
+                    return optstring[0] == ':' ? ':' : '?';
+                  }
+              }
+            nextchar += strlen (nextchar);
+            if (longind != NULL)
+              *longind = option_index;
+            if (pfound->flag)
+              {
+                *(pfound->flag) = pfound->val;
+                return 0;
+              }
+            return pfound->val;
+          }
+          nextchar = NULL;
+          return 'W';   /* Let the application handle it.   */
       }
     if (temp[1] == ':')
       {
-	if (temp[2] == ':')
-	  {
-	    /* This is an option that accepts an argument optionally.  */
-	    if (*nextchar != '\0')
-	      {
-		optarg = nextchar;
-		optind++;
-	      }
-	    else
-	      optarg = NULL;
-	    nextchar = NULL;
-	  }
-	else
-	  {
-	    /* This is an option that requires an argument.  */
-	    if (*nextchar != '\0')
-	      {
-		optarg = nextchar;
-		/* If we end this ARGV-element by taking the rest as an arg,
-		   we must advance to the next element now.  */
-		optind++;
-	      }
-	    else if (optind == argc)
-	      {
-		if (opterr)
-		  {
-		    /* 1003.2 specifies the format of this message.  */
-		    fprintf (stderr,
-			   _("%s: option requires an argument -- %c\n"),
-			   argv[0], c);
-		  }
-		optopt = c;
-		if (optstring[0] == ':')
-		  c = ':';
-		else
-		  c = '?';
-	      }
-	    else
-	      /* We already incremented `optind' once;
-		 increment it again when taking next ARGV-elt as argument.  */
-	      optarg = argv[optind++];
-	    nextchar = NULL;
-	  }
+        if (temp[2] == ':')
+          {
+            /* This is an option that accepts an argument optionally.  */
+            if (*nextchar != '\0')
+              {
+                optarg = nextchar;
+                optind++;
+              }
+            else
+              optarg = NULL;
+            nextchar = NULL;
+          }
+        else
+          {
+            /* This is an option that requires an argument.  */
+            if (*nextchar != '\0')
+              {
+                optarg = nextchar;
+                /* If we end this ARGV-element by taking the rest as an arg,
+                   we must advance to the next element now.  */
+                optind++;
+              }
+            else if (optind == argc)
+              {
+                if (opterr)
+                  {
+                    /* 1003.2 specifies the format of this message.  */
+                    fprintf (stderr,
+                           _("%s: option requires an argument -- %c\n"),
+                           argv[0], c);
+                  }
+                optopt = c;
+                if (optstring[0] == ':')
+                  c = ':';
+                else
+                  c = '?';
+              }
+            else
+              /* We already incremented `optind' once;
+                 increment it again when taking next ARGV-elt as argument.  */
+              optarg = argv[optind++];
+            nextchar = NULL;
+          }
       }
     return c;
   }
@@ -914,12 +914,12 @@ getopt (argc, argv, optstring)
      const char *optstring;
 {
   return _getopt_internal (argc, argv, optstring,
-			   (const struct option *) 0,
-			   (int *) 0,
-			   0);
+                           (const struct option *) 0,
+                           (int *) 0,
+                           0);
 }
 
-#endif	/* Not ELIDE_CODE.  */
+#endif  /* Not ELIDE_CODE.  */
 
 #ifdef TEST
 
@@ -940,51 +940,51 @@ main (argc, argv)
 
       c = getopt (argc, argv, "abc:d:0123456789");
       if (c == -1)
-	break;
+        break;
 
       switch (c)
-	{
-	case '0':
-	case '1':
-	case '2':
-	case '3':
-	case '4':
-	case '5':
-	case '6':
-	case '7':
-	case '8':
-	case '9':
-	  if (digit_optind != 0 && digit_optind != this_option_optind)
-	    printf ("digits occur in two different argv-elements.\n");
-	  digit_optind = this_option_optind;
-	  printf ("option %c\n", c);
-	  break;
-
-	case 'a':
-	  printf ("option a\n");
-	  break;
-
-	case 'b':
-	  printf ("option b\n");
-	  break;
-
-	case 'c':
-	  printf ("option c with value `%s'\n", optarg);
-	  break;
-
-	case '?':
-	  break;
-
-	default:
-	  printf ("?? getopt returned character code 0%o ??\n", c);
-	}
+        {
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+          if (digit_optind != 0 && digit_optind != this_option_optind)
+            printf ("digits occur in two different argv-elements.\n");
+          digit_optind = this_option_optind;
+          printf ("option %c\n", c);
+          break;
+
+        case 'a':
+          printf ("option a\n");
+          break;
+
+        case 'b':
+          printf ("option b\n");
+          break;
+
+        case 'c':
+          printf ("option c with value `%s'\n", optarg);
+          break;
+
+        case '?':
+          break;
+
+        default:
+          printf ("?? getopt returned character code 0%o ??\n", c);
+        }
     }
 
   if (optind < argc)
     {
       printf ("non-option ARGV-elements: ");
       while (optind < argc)
-	printf ("%s ", argv[optind++]);
+        printf ("%s ", argv[optind++]);
       printf ("\n");
     }
 
diff --git a/converter/other/fiasco/getopt.h b/converter/other/fiasco/getopt.h
index 9acca708..3c735e3d 100644
--- a/converter/other/fiasco/getopt.h
+++ b/converter/other/fiasco/getopt.h
@@ -22,7 +22,7 @@
 #ifndef _GETOPT_H
 #define _GETOPT_H 1
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 extern "C" {
 #endif
 
@@ -63,9 +63,9 @@ extern int optopt;
    zero.
 
    The field `has_arg' is:
-   no_argument		(or 0) if the option does not take an argument,
-   required_argument	(or 1) if the option requires an argument,
-   optional_argument 	(or 2) if the option takes an optional argument.
+   no_argument          (or 0) if the option does not take an argument,
+   required_argument    (or 1) if the option requires an argument,
+   optional_argument    (or 2) if the option takes an optional argument.
 
    If the field `flag' is not NULL, it points to a variable that is set
    to the value given in the field `val' when the option is found, but
@@ -90,9 +90,9 @@ struct option
 
 /* Names for the values of the `has_arg' field of `struct option'.  */
 
-#define	no_argument		0
-#define required_argument	1
-#define optional_argument	2
+#define no_argument             0
+#define required_argument       1
+#define optional_argument       2
 
 #if defined (__STDC__) && __STDC__
 #ifdef __GNU_LIBRARY__
@@ -104,16 +104,16 @@ extern int getopt (int argc, char *const *argv, const char *shortopts);
 extern int getopt ();
 #endif /* __GNU_LIBRARY__ */
 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
-		        const struct option *longopts, int *longind);
+                        const struct option *longopts, int *longind);
 extern int getopt_long_only (int argc, char *const *argv,
-			     const char *shortopts,
-		             const struct option *longopts, int *longind);
+                             const char *shortopts,
+                             const struct option *longopts, int *longind);
 
 /* Internal only.  Users should not call this directly.  */
 extern int _getopt_internal (int argc, char *const *argv,
-			     const char *shortopts,
-		             const struct option *longopts, int *longind,
-			     int long_only);
+                             const char *shortopts,
+                             const struct option *longopts, int *longind,
+                             int long_only);
 #else /* not __STDC__ */
 extern int getopt ();
 extern int getopt_long ();
@@ -122,7 +122,7 @@ extern int getopt_long_only ();
 extern int _getopt_internal ();
 #endif /* __STDC__ */
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 }
 #endif
 
diff --git a/converter/other/fiasco/getopt1.c b/converter/other/fiasco/getopt1.c
index 8347bb13..4ed64b8b 100644
--- a/converter/other/fiasco/getopt1.c
+++ b/converter/other/fiasco/getopt1.c
@@ -60,7 +60,7 @@
 #include <stdlib.h>
 #endif
 
-#ifndef	NULL
+#ifndef NULL
 #define NULL 0
 #endif
 
@@ -92,7 +92,7 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
 }
 
 
-#endif	/* Not ELIDE_CODE.  */
+#endif  /* Not ELIDE_CODE.  */
 
 #ifdef TEST
 
@@ -112,74 +112,74 @@ main (argc, argv)
       int option_index = 0;
       static struct option long_options[] =
       {
-	{"add", 1, 0, 0},
-	{"append", 0, 0, 0},
-	{"delete", 1, 0, 0},
-	{"verbose", 0, 0, 0},
-	{"create", 0, 0, 0},
-	{"file", 1, 0, 0},
-	{0, 0, 0, 0}
+        {"add", 1, 0, 0},
+        {"append", 0, 0, 0},
+        {"delete", 1, 0, 0},
+        {"verbose", 0, 0, 0},
+        {"create", 0, 0, 0},
+        {"file", 1, 0, 0},
+        {0, 0, 0, 0}
       };
 
       c = getopt_long (argc, argv, "abc:d:0123456789",
-		       long_options, &option_index);
+                       long_options, &option_index);
       if (c == -1)
-	break;
+        break;
 
       switch (c)
-	{
-	case 0:
-	  printf ("option %s", long_options[option_index].name);
-	  if (optarg)
-	    printf (" with arg %s", optarg);
-	  printf ("\n");
-	  break;
-
-	case '0':
-	case '1':
-	case '2':
-	case '3':
-	case '4':
-	case '5':
-	case '6':
-	case '7':
-	case '8':
-	case '9':
-	  if (digit_optind != 0 && digit_optind != this_option_optind)
-	    printf ("digits occur in two different argv-elements.\n");
-	  digit_optind = this_option_optind;
-	  printf ("option %c\n", c);
-	  break;
-
-	case 'a':
-	  printf ("option a\n");
-	  break;
-
-	case 'b':
-	  printf ("option b\n");
-	  break;
-
-	case 'c':
-	  printf ("option c with value `%s'\n", optarg);
-	  break;
-
-	case 'd':
-	  printf ("option d with value `%s'\n", optarg);
-	  break;
-
-	case '?':
-	  break;
-
-	default:
-	  printf ("?? getopt returned character code 0%o ??\n", c);
-	}
+        {
+        case 0:
+          printf ("option %s", long_options[option_index].name);
+          if (optarg)
+            printf (" with arg %s", optarg);
+          printf ("\n");
+          break;
+
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+          if (digit_optind != 0 && digit_optind != this_option_optind)
+            printf ("digits occur in two different argv-elements.\n");
+          digit_optind = this_option_optind;
+          printf ("option %c\n", c);
+          break;
+
+        case 'a':
+          printf ("option a\n");
+          break;
+
+        case 'b':
+          printf ("option b\n");
+          break;
+
+        case 'c':
+          printf ("option c with value `%s'\n", optarg);
+          break;
+
+        case 'd':
+          printf ("option d with value `%s'\n", optarg);
+          break;
+
+        case '?':
+          break;
+
+        default:
+          printf ("?? getopt returned character code 0%o ??\n", c);
+        }
     }
 
   if (optind < argc)
     {
       printf ("non-option ARGV-elements: ");
       while (optind < argc)
-	printf ("%s ", argv[optind++]);
+        printf ("%s ", argv[optind++]);
       printf ("\n");
     }
 
diff --git a/converter/other/fiasco/input/basis.c b/converter/other/fiasco/input/basis.c
index e5ced0d0..4be7f4ed 100644
--- a/converter/other/fiasco/input/basis.c
+++ b/converter/other/fiasco/input/basis.c
@@ -1,7 +1,7 @@
 /*
- *  basis.c:		WFA initial basis files
+ *  basis.c:            WFA initial basis files
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -43,7 +43,7 @@ typedef struct
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
@@ -58,7 +58,7 @@ static basis_file_t const basis_files[] = {
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -70,69 +70,69 @@ get_linked_basis (const char *basis_name, wfa_t *wfa)
  *  according to the stored data, otherwise print a warning message.
  *
  *  Return value:
- *	true on success, false if basis is not available yet.
+ *      true on success, false if basis is not available yet.
  *
  *  Side effects:
- *	'wfa' struct is filled on success.
+ *      'wfa' struct is filled on success.
  */
 {
-   bool_t	  success = NO;		/* indicates if basis is found */
-   unsigned	  n;			/* counter */
-   basis_values_t bv;			/* basis values */
+   bool_t         success = NO;         /* indicates if basis is found */
+   unsigned       n;                    /* counter */
+   basis_values_t bv;                   /* basis values */
 
    for (n = 0; basis_files [n].filename != NULL; n++)
-      if (streq (basis_files [n].filename, basis_name))	/* basis is stored */
+      if (streq (basis_files [n].filename, basis_name)) /* basis is stored */
       {
-	 unsigned state, edge;
-
-	 (*basis_files [n].function) (&bv); /* initialize local variables */
-	 /*
-	  *  Generate WFA
-	  */
-	 wfa->basis_states = wfa->states = bv.states + 1;
-	 wfa->domain_type[0]             = USE_DOMAIN_MASK;
-	 wfa->final_distribution[0]      = 128;
-	 append_edge (0, 0, 1.0, 0, wfa);
-	 append_edge (0, 0, 1.0, 1, wfa);
-	 for (state = 1; state < wfa->basis_states; state++)
-	 {
-	    wfa->final_distribution [state] = bv.final [state - 1];
-	    wfa->domain_type [state]        = bv.use_domain [state - 1]
-					      ? USE_DOMAIN_MASK
-					      : AUXILIARY_MASK;
-	 }
-	 for (edge = 0; isedge (bv.transitions [edge][0]); edge++)
-	    append_edge (bv.transitions [edge][0], bv.transitions [edge][1],
-			 bv.transitions [edge][2], bv.transitions [edge][3],
-			 wfa);
-
-	 success = YES;
-	 break;
+         unsigned state, edge;
+
+         (*basis_files [n].function) (&bv); /* initialize local variables */
+         /*
+          *  Generate WFA
+          */
+         wfa->basis_states = wfa->states = bv.states + 1;
+         wfa->domain_type[0]             = USE_DOMAIN_MASK;
+         wfa->final_distribution[0]      = 128;
+         append_edge (0, 0, 1.0, 0, wfa);
+         append_edge (0, 0, 1.0, 1, wfa);
+         for (state = 1; state < wfa->basis_states; state++)
+         {
+            wfa->final_distribution [state] = bv.final [state - 1];
+            wfa->domain_type [state]        = bv.use_domain [state - 1]
+                                              ? USE_DOMAIN_MASK
+                                              : AUXILIARY_MASK;
+         }
+         for (edge = 0; isedge (bv.transitions [edge][0]); edge++)
+            append_edge (bv.transitions [edge][0], bv.transitions [edge][1],
+                         bv.transitions [edge][2], bv.transitions [edge][3],
+                         wfa);
+
+         success = YES;
+         break;
       }
 
    if (!success)
       warning ("WFA initial basis '%s' isn't linked with the executable yet."
-	       "\nLoading basis from disk instead.", basis_name);
+               "\nLoading basis from disk instead.", basis_name);
 
    return success;
 }
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 /*****************************************************************************
-				basis "small.wfa"
+                                basis "small.wfa"
 *****************************************************************************/
 
-static unsigned	states_small           = 2;
-static bool_t	use_domain_small[]     = {YES, YES};
-static real_t 	final_small[]          = {64, 64};
-static real_t 	transitions_small[][4] = {{1, 2, 0.5, 0}, {1, 2, 0.5, 1},
-				      	 {1, 0, 0.5, 1}, {2, 1, 1.0, 0},
-				      	 {2, 1, 1.0, 1}, {-1, 0, 0, 0}};
+static unsigned states_small           = 2;
+static bool_t   use_domain_small[]     = {YES, YES};
+static real_t   final_small[]          = {64, 64};
+static real_t   transitions_small[][4] = {{1, 2, 0.5, 0}, {1, 2, 0.5, 1},
+                                         {1, 0, 0.5, 1}, {2, 1, 1.0, 0},
+                                         {2, 1, 1.0, 1}, {-1, 0, 0, 0}};
 static void
 small_init (basis_values_t *bv)
 {
diff --git a/converter/other/fiasco/input/basis.h b/converter/other/fiasco/input/basis.h
index e2242198..d6d2f8b3 100644
--- a/converter/other/fiasco/input/basis.h
+++ b/converter/other/fiasco/input/basis.h
@@ -1,8 +1,8 @@
 /*
  *  basis.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/input/matrices.c b/converter/other/fiasco/input/matrices.c
index d20a27eb..f59b5a30 100644
--- a/converter/other/fiasco/input/matrices.c
+++ b/converter/other/fiasco/input/matrices.c
@@ -1,7 +1,7 @@
 /*
- *  matrices.c:		Input of transition matrices
+ *  matrices.c:         Input of transition matrices
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -28,12 +28,12 @@
 #include "matrices.h"
 
 #if STDC_HEADERS
-#	include <stdlib.h>
+#       include <stdlib.h>
 #endif /* not STDC_HEADERS */
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
@@ -48,7 +48,7 @@ compute_y_state (int state, int y_state, wfa_t *wfa);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -58,16 +58,16 @@ read_matrices (wfa_t *wfa, bitfile_t *input)
  *  Read transitions of WFA given from the stream 'input'.
  *
  *  Return value:
- *	number of edges
+ *      number of edges
  *
  *  Side effects:
- *	'wfa->into' is filled with decoded values
+ *      'wfa->into' is filled with decoded values
  */
 {
-   unsigned total;			/* total number of edges in the WFA */
+   unsigned total;                      /* total number of edges in the WFA */
    unsigned root_state = wfa->wfainfo->color
-			 ? wfa->tree [wfa->tree [wfa->root_state][0]][0]
-			 : wfa->root_state;
+                         ? wfa->tree [wfa->tree [wfa->root_state][0]][0]
+                         : wfa->root_state;
 
    total  = column_0_decoding (wfa, root_state, input);
    total += delta_decoding (wfa, root_state, input);
@@ -79,7 +79,7 @@ read_matrices (wfa_t *wfa, bitfile_t *input)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
@@ -91,34 +91,34 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input)
  *  'last_domain' is the maximum state number used as domain image.
  *
  *  Return value:
- *	number of non-zero matrix elements (WFA edges)
+ *      number of non-zero matrix elements (WFA edges)
  *
  *  Side effects:
- *	'wfa->into' is filled with decoded values
+ *      'wfa->into' is filled with decoded values
  */
 {
-   range_sort_t	 rs;			/* ranges are sorted as in the coder */
-   unsigned	 max_domain;		/* dummy used for recursion */
-   unsigned	 range;
-   unsigned	 count [MAXEDGES + 1];
-   unsigned 	 state, label;
-   unsigned	*n_edges;		/* number of elements per row */
-   unsigned	 total = 0;		/* total number of decoded edges */
+   range_sort_t  rs;                    /* ranges are sorted as in the coder */
+   unsigned      max_domain;            /* dummy used for recursion */
+   unsigned      range;
+   unsigned      count [MAXEDGES + 1];
+   unsigned      state, label;
+   unsigned     *n_edges;               /* number of elements per row */
+   unsigned      total = 0;             /* total number of decoded edges */
 
    /*
     *  Generate a list of range blocks.
     *  The order is the same as in the coder.
     */
    rs.range_state      = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (u_word_t));
+                                 sizeof (u_word_t));
    rs.range_label      = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (byte_t));
+                                 sizeof (byte_t));
    rs.range_max_domain = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (u_word_t));
+                                 sizeof (u_word_t));
    rs.range_subdivided = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (bool_t));
-   rs.range_no	       = 0;
-   max_domain 	       = wfa->basis_states - 1;
+                                 sizeof (bool_t));
+   rs.range_no         = 0;
+   max_domain          = wfa->basis_states - 1;
    sort_ranges (last_domain, &max_domain, &rs, wfa);
 
    /*
@@ -127,42 +127,42 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input)
    {
       arith_t  *decoder;
       model_t  *elements;
-      unsigned 	max_edges = read_rice_code (3, input);
+      unsigned  max_edges = read_rice_code (3, input);
 
       /*
        *  Get the probability array of the number of edges distribution
        *  and allocate the corresponding model.
        */
       {
-	 unsigned edge;
+         unsigned edge;
 
-	 for (edge = 0; edge <= max_edges; edge++)
-	    count [edge] = read_rice_code ((int) log2 (last_domain) - 2,
-					   input);
-	 elements = alloc_model (max_edges + 1, 0, 0, count);
+         for (edge = 0; edge <= max_edges; edge++)
+            count [edge] = read_rice_code ((int) log2 (last_domain) - 2,
+                                           input);
+         elements = alloc_model (max_edges + 1, 0, 0, count);
       }
 
       /*
        *  Get number of elements per matrix row
        */
       {
-	 unsigned row;
-
-	 n_edges = Calloc (wfa->states, sizeof (unsigned));
-	 decoder = alloc_decoder (input);
-	 for (row = range = 0; range < rs.range_no; range++)
-	    if (!rs.range_subdivided [range])
-	    {
-	       state = rs.range_state [range];
-	       label = rs.range_label [range];
-
-	       n_edges [row++]
-		  = decode_symbol (decoder, elements)
-		  - (isedge (wfa->into [state][label][0]) ? 1 : 0);
-	    }
-
-	 free_decoder (decoder);
-	 free_model (elements);
+         unsigned row;
+
+         n_edges = Calloc (wfa->states, sizeof (unsigned));
+         decoder = alloc_decoder (input);
+         for (row = range = 0; range < rs.range_no; range++)
+            if (!rs.range_subdivided [range])
+            {
+               state = rs.range_state [range];
+               label = rs.range_label [range];
+
+               n_edges [row++]
+                  = decode_symbol (decoder, elements)
+                  - (isedge (wfa->into [state][label][0]) ? 1 : 0);
+            }
+
+         free_decoder (decoder);
+         free_model (elements);
       }
    }
 
@@ -175,8 +175,8 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input)
       u_word_t *mapping_coder1     = Calloc (wfa->states, sizeof (word_t));
       u_word_t *mapping2           = Calloc (wfa->states, sizeof (word_t));
       u_word_t *mapping_coder2     = Calloc (wfa->states, sizeof (word_t));
-      bool_t	use_normal_domains = get_bit (input);
-      bool_t	use_delta_domains  = get_bit (input);
+      bool_t    use_normal_domains = get_bit (input);
+      bool_t    use_delta_domains  = get_bit (input);
 
       /*
        *  Generate array of states which are admitted domains.
@@ -187,63 +187,63 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input)
        *             coding the motion compensated prediction error
        */
       {
-	 unsigned n1, n2, state;
-
-	 for (n1 = n2 = state = 0; state < wfa->states; state++)
-	 {
-	    mapping1 [n1] = state;
-	    mapping_coder1 [state] = n1;
-	    if (usedomain (state, wfa)
-		&& (state < wfa->basis_states
-		    || use_delta_domains || !wfa->delta_state [state]))
-	       n1++;
-
-	    mapping2 [n2] = state;
-	    mapping_coder2 [state] = n2;
-	    if (usedomain (state, wfa)
-		&& (state < wfa->basis_states || use_normal_domains
-		    || wfa->delta_state [state]))
-	       n2++;
-	 }
+         unsigned n1, n2, state;
+
+         for (n1 = n2 = state = 0; state < wfa->states; state++)
+         {
+            mapping1 [n1] = state;
+            mapping_coder1 [state] = n1;
+            if (usedomain (state, wfa)
+                && (state < wfa->basis_states
+                    || use_delta_domains || !wfa->delta_state [state]))
+               n1++;
+
+            mapping2 [n2] = state;
+            mapping_coder2 [state] = n2;
+            if (usedomain (state, wfa)
+                && (state < wfa->basis_states || use_normal_domains
+                    || wfa->delta_state [state]))
+               n2++;
+         }
       }
 
       for (row = 0, range = 0; range < rs.range_no; range++)
-	 if (!rs.range_subdivided [range])
-	 {
-	    u_word_t *mapping;
-	    u_word_t *mapping_coder;
-	    unsigned  max_value;
-	    unsigned  edge;
-	    unsigned  state = rs.range_state [range];
-	    unsigned  label = rs.range_label [range];
-	    unsigned  last  = 1;
-
-	    if (wfa->delta_state [state] ||
-		wfa->mv_tree [state][label].type != NONE)
-	    {
-	       mapping 	     = mapping2;
-	       mapping_coder = mapping_coder2;
-	    }
-	    else
-	    {
-	       mapping 	     = mapping1;
-	       mapping_coder = mapping_coder1;
-	    }
-	    max_value = mapping_coder [rs.range_max_domain [range]];
-	    for (edge = n_edges [row]; edge; edge--)
-	    {
-	       unsigned domain;
-
-	       if (max_value - last)
-		  domain = read_bin_code (max_value - last, input) + last;
-	       else
-		  domain = max_value;
-	       append_edge (state, mapping [domain], -1, label, wfa);
-	       last = domain + 1;
-	       total++;
-	    }
-	    row++;
-	 }
+         if (!rs.range_subdivided [range])
+         {
+            u_word_t *mapping;
+            u_word_t *mapping_coder;
+            unsigned  max_value;
+            unsigned  edge;
+            unsigned  state = rs.range_state [range];
+            unsigned  label = rs.range_label [range];
+            unsigned  last  = 1;
+
+            if (wfa->delta_state [state] ||
+                wfa->mv_tree [state][label].type != NONE)
+            {
+               mapping       = mapping2;
+               mapping_coder = mapping_coder2;
+            }
+            else
+            {
+               mapping       = mapping1;
+               mapping_coder = mapping_coder1;
+            }
+            max_value = mapping_coder [rs.range_max_domain [range]];
+            for (edge = n_edges [row]; edge; edge--)
+            {
+               unsigned domain;
+
+               if (max_value - last)
+                  domain = read_bin_code (max_value - last, input) + last;
+               else
+                  domain = max_value;
+               append_edge (state, mapping [domain], -1, label, wfa);
+               last = domain + 1;
+               total++;
+            }
+            row++;
+         }
       Free (mapping1);
       Free (mapping_coder1);
       Free (mapping2);
@@ -267,23 +267,23 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input)
  *  All rows from 'wfa->basis_states' up to 'last_row' are decoded.
  *
  *  Return value:
- *	number of non-zero matrix elements (WFA edges)
+ *      number of non-zero matrix elements (WFA edges)
  *
  *  Side effects:
- *	'wfa->into' is filled with decoded values
+ *      'wfa->into' is filled with decoded values
  */
 {
-   unsigned  row;			/* current matrix row */
-   unsigned  total = 0;			/* total number of edges in col 0 */
-   unsigned *prob_ptr;			/* pointer to current probability */
-   unsigned *last;			/* pointer to minimum probability */
-   unsigned *first;			/* pointer to maximum probability */
-   unsigned *new_prob_ptr;		/* ptr to probability of last domain */
-   unsigned *prob;			/* probability array */
-   u_word_t  high;			/* Start of the current code range */
-   u_word_t  low;			/* End of the current code range */
-   u_word_t  code;			/* The present input code value */
-   word_t   *is_leaf;			/* pointer to the tree structure */
+   unsigned  row;                       /* current matrix row */
+   unsigned  total = 0;                 /* total number of edges in col 0 */
+   unsigned *prob_ptr;                  /* pointer to current probability */
+   unsigned *last;                      /* pointer to minimum probability */
+   unsigned *first;                     /* pointer to maximum probability */
+   unsigned *new_prob_ptr;              /* ptr to probability of last domain */
+   unsigned *prob;                      /* probability array */
+   u_word_t  high;                      /* Start of the current code range */
+   u_word_t  low;                       /* End of the current code range */
+   u_word_t  code;                      /* The present input code value */
+   word_t   *is_leaf;                   /* pointer to the tree structure */
 
    /*
     *  Compute the asymmetric probability array
@@ -292,14 +292,14 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input)
     */
    {
       unsigned n;
-      unsigned index;			/* probability index */
-      unsigned exp;			/* current exponent */
+      unsigned index;                   /* probability index */
+      unsigned exp;                     /* current exponent */
 
       prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned));
 
       for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++)
-	 for (exp = 0; exp < 1U << n; exp++, index++)
-	    prob [index] = n;
+         for (exp = 0; exp < 1U << n; exp++, index++)
+            prob [index] = n;
    }
 
    first = prob_ptr = new_prob_ptr = prob;
@@ -307,8 +307,8 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input)
 
    is_leaf = wfa->tree [wfa->basis_states]; /* use pointer arithmetics ... */
 
-   high = HIGH;				/* 1.0 */
-   low  = LOW;				/* 0.0 */
+   high = HIGH;                         /* 1.0 */
+   low  = LOW;                          /* 0.0 */
    code = get_bits (input, 16);
 
    /*
@@ -324,73 +324,73 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input)
     */
    for (row = wfa->basis_states; row <= last_row; row++)
    {
-      unsigned count;			/* value in the current interval */
+      unsigned count;                   /* value in the current interval */
 
       /*
        *  Read label 0 element
        */
-      if (isrange (*is_leaf++))		/* valid matrix index */
+      if (isrange (*is_leaf++))         /* valid matrix index */
       {
-	 count = high - ((high - low) >> *prob_ptr);
-	 if (code < count)
-	 {
-	    if (prob_ptr < last)	/* model update */
-	       prob_ptr++;
-	    /*
-	     *  Decode the MPS '0'
-	     */
-	    high = count - 1;
-
-	    RESCALE_INPUT_INTERVAL;
-	 }
-	 else
-	 {
-	    prob_ptr = ((prob_ptr - first) >> 1) + first; /* model update */
-	    /*
-	     *  Decode the LPS '1'
-	     */
-	    low = count;
-
-	    RESCALE_INPUT_INTERVAL;
-	    /*
-	     *  Restore the transition (weight = -1)
-	     */
-	    append_edge (row, 0, -1, 0, wfa);
-	    total++;
-	 }
+         count = high - ((high - low) >> *prob_ptr);
+         if (code < count)
+         {
+            if (prob_ptr < last)        /* model update */
+               prob_ptr++;
+            /*
+             *  Decode the MPS '0'
+             */
+            high = count - 1;
+
+            RESCALE_INPUT_INTERVAL;
+         }
+         else
+         {
+            prob_ptr = ((prob_ptr - first) >> 1) + first; /* model update */
+            /*
+             *  Decode the LPS '1'
+             */
+            low = count;
+
+            RESCALE_INPUT_INTERVAL;
+            /*
+             *  Restore the transition (weight = -1)
+             */
+            append_edge (row, 0, -1, 0, wfa);
+            total++;
+         }
       }
       /*
        *  Read label 1 element
        */
       if (isrange (*is_leaf++)) /* valid matrix index */
       {
-	 count = high - ((high - low) >> *prob_ptr);
-	 if (code < count)
-	 {
-	    if (prob_ptr < last)
-	       prob_ptr++;		/* model update */
-	    /*
-	     *  Decode the MPS '0'
-	     */
-	    high = count - 1;
-
-	    RESCALE_INPUT_INTERVAL;
-	 }
-	 else
-	 {
-	    prob_ptr = ((prob_ptr - first) >> 1) + first; /* model update */
-	    /*
-	     *  Decode the LPS '1'
-	     */
-	    low = count;
-
-	    RESCALE_INPUT_INTERVAL;
-	    /*
-	     *  Restore the transition (weight = -1)
-	     */
-	    append_edge (row, 0, -1, 1, wfa);
-	    total++;
-	 }
+         count = high - ((high - low) >> *prob_ptr);
+         if (code < count)
+         {
+            if (prob_ptr < last)
+               prob_ptr++;              /* model update */
+            /*
+             *  Decode the MPS '0'
+             */
+            high = count - 1;
+
+            RESCALE_INPUT_INTERVAL;
+         }
+         else
+         {
+            prob_ptr = ((prob_ptr - first) >> 1) + first; /* model update */
+            /*
+             *  Decode the LPS '1'
+             */
+            low = count;
+
+            RESCALE_INPUT_INTERVAL;
+            /*
+             *  Restore the transition (weight = -1)
+             */
+            append_edge (row, 0, -1, 1, wfa);
+            total++;
+         }
       }
    }
 
@@ -408,24 +408,24 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input)
  *  chroma channels Cb and Cr from stream 'input'.
  *
  *  Return value:
- *	number of non-zero matrix elements (WFA edges)
+ *      number of non-zero matrix elements (WFA edges)
  *
  *  Side effects:
- *	'wfa->into' is filled with decoded values
+ *      'wfa->into' is filled with decoded values
  */
 {
-   unsigned  domain;			/* current domain, counter */
-   unsigned  total = 0;			/* total number of chroma edges */
-   unsigned *prob_ptr;			/* pointer to current probability */
-   unsigned *last;			/* pointer to minimum probability */
-   unsigned *first;			/* pointer to maximum probability */
-   unsigned *new_prob_ptr;		/* ptr to probability of last domain */
-   unsigned *prob;			/* probability array */
-   u_word_t  high;			/* Start of the current code range */
-   u_word_t  low;			/* End of the current code range */
-   u_word_t  code;			/* The present input code value */
-   word_t   *y_domains;			/* domain images corresponding to Y */
-   int	     save_index;		/* YES: store current probability */
+   unsigned  domain;                    /* current domain, counter */
+   unsigned  total = 0;                 /* total number of chroma edges */
+   unsigned *prob_ptr;                  /* pointer to current probability */
+   unsigned *last;                      /* pointer to minimum probability */
+   unsigned *first;                     /* pointer to maximum probability */
+   unsigned *new_prob_ptr;              /* ptr to probability of last domain */
+   unsigned *prob;                      /* probability array */
+   u_word_t  high;                      /* Start of the current code range */
+   u_word_t  low;                       /* End of the current code range */
+   u_word_t  code;                      /* The present input code value */
+   word_t   *y_domains;                 /* domain images corresponding to Y */
+   int       save_index;                /* YES: store current probability */
 
    /*
     *  Compute the asymmetric probability array
@@ -434,26 +434,26 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input)
     */
    {
       unsigned n;
-      unsigned index;			/* probability index */
-      unsigned exp;			/* current exponent */
+      unsigned index;                   /* probability index */
+      unsigned exp;                     /* current exponent */
 
       prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned));
 
       for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++)
-	 for (exp = 0; exp < 1U << n; exp++, index++)
-	    prob [index] = n;
+         for (exp = 0; exp < 1U << n; exp++, index++)
+            prob [index] = n;
    }
 
-   high = HIGH;				/* 1.0 */
-   low  = LOW;				/* 0.0 */
+   high = HIGH;                         /* 1.0 */
+   low  = LOW;                          /* 0.0 */
    code = get_bits (input, 16);
 
    /*
     *  Compute list of admitted domains
     */
    y_domains = compute_hits (wfa->basis_states,
-			     wfa->tree [wfa->tree [wfa->root_state][0]][0],
-			     wfa->wfainfo->chroma_max_states, wfa);
+                             wfa->tree [wfa->tree [wfa->root_state][0]][0],
+                             wfa->wfainfo->chroma_max_states, wfa);
 
    first = prob_ptr = new_prob_ptr = prob;
    last  = first + 1020;
@@ -465,7 +465,7 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input)
     */
    for (domain = 0; y_domains [domain] != -1; domain++)
    {
-      unsigned 	row	= wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1;
+      unsigned  row     = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1;
       word_t   *is_leaf = wfa->tree [row];
 
       prob_ptr   = new_prob_ptr;
@@ -473,87 +473,87 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input)
 
       for (; row < wfa->states; row++)
       {
-	 unsigned count;		/* value in the current interval */
-	 /*
-	  *  Read label 0 element
-	  */
-	 if (isrange (*is_leaf++)) 	/* valid matrix index */
-	 {
-	    count = high - ((high - low) >> *prob_ptr);
-	    if (code < count)
-	    {
-	       if (prob_ptr < last)
-		  prob_ptr++;
-	       /*
-		*  Decode the MPS '0'
-		*/
-	       high = count - 1;
-
-	       RESCALE_INPUT_INTERVAL;
-	    }
-	    else
-	    {
-	       prob_ptr = ((prob_ptr - first) >> 1) + first;
-	       /*
-		*  Decode the LPS '1'
-		*/
-	       low = count;
-
-	       RESCALE_INPUT_INTERVAL;
-	       /*
-		*  Restore the transition (weight = -1)
-		*/
-	       append_edge (row, y_domains [domain], -1, 0, wfa);
-	       total++;
-	    }
-	 }
-	 /*
-	  *  Read label 1 element
-	  */
-	 if (isrange (*is_leaf++)) /* valid matrix index */
-	 {
-	    count = high - ((high - low) >> *prob_ptr);
-	    if (code < count)
-	    {
-	       if (prob_ptr < last)
-		  prob_ptr++;
-	       /*
-		*  Decode the MPS '0'
-		*/
-	       high = count - 1;
-
-	       RESCALE_INPUT_INTERVAL;
-	    }
-	    else
-	    {
-	       prob_ptr = ((prob_ptr - first) >> 1) + first;
-	       /*
-		*  Decode the LPS '1'
-		*/
-	       low = count;
-
-	       RESCALE_INPUT_INTERVAL;
-	       /*
-		*  Restore the transition (weight = -1)
-		*/
-	       append_edge (row, y_domains [domain], -1, 1, wfa);
-	       total++;
-	    }
-	 }
-	 if (save_index)
-	 {
-	    save_index 	 = NO;
-	    new_prob_ptr = prob_ptr;
-	 }
+         unsigned count;                /* value in the current interval */
+         /*
+          *  Read label 0 element
+          */
+         if (isrange (*is_leaf++))      /* valid matrix index */
+         {
+            count = high - ((high - low) >> *prob_ptr);
+            if (code < count)
+            {
+               if (prob_ptr < last)
+                  prob_ptr++;
+               /*
+                *  Decode the MPS '0'
+                */
+               high = count - 1;
+
+               RESCALE_INPUT_INTERVAL;
+            }
+            else
+            {
+               prob_ptr = ((prob_ptr - first) >> 1) + first;
+               /*
+                *  Decode the LPS '1'
+                */
+               low = count;
+
+               RESCALE_INPUT_INTERVAL;
+               /*
+                *  Restore the transition (weight = -1)
+                */
+               append_edge (row, y_domains [domain], -1, 0, wfa);
+               total++;
+            }
+         }
+         /*
+          *  Read label 1 element
+          */
+         if (isrange (*is_leaf++)) /* valid matrix index */
+         {
+            count = high - ((high - low) >> *prob_ptr);
+            if (code < count)
+            {
+               if (prob_ptr < last)
+                  prob_ptr++;
+               /*
+                *  Decode the MPS '0'
+                */
+               high = count - 1;
+
+               RESCALE_INPUT_INTERVAL;
+            }
+            else
+            {
+               prob_ptr = ((prob_ptr - first) >> 1) + first;
+               /*
+                *  Decode the LPS '1'
+                */
+               low = count;
+
+               RESCALE_INPUT_INTERVAL;
+               /*
+                *  Restore the transition (weight = -1)
+                */
+               append_edge (row, y_domains [domain], -1, 1, wfa);
+               total++;
+            }
+         }
+         if (save_index)
+         {
+            save_index   = NO;
+            new_prob_ptr = prob_ptr;
+         }
       }
    }
 
    Free (y_domains);
 
    compute_y_state (wfa->tree [wfa->tree [wfa->root_state][0]][1],
-		    wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa);
+                    wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa);
    compute_y_state (wfa->tree [wfa->tree [wfa->root_state][1]][0],
-		    wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa);
+                    wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa);
 
    first = prob_ptr = new_prob_ptr = prob;
 
@@ -565,44 +565,44 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input)
     *  Again, quasi arithmetic decoding is used for this task.
     */
    {
-      unsigned 	row;
+      unsigned  row;
 
       for (row = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1;
-	   row < wfa->states; row++)
+           row < wfa->states; row++)
       {
-	 int label;			/* current label */
-
-	 for (label = 0; label < MAXLABELS; label++)
-	 {
-	    u_word_t count = high - ((high - low) >> *prob_ptr);
-
-	    if (code < count)
-	    {
-	       if (prob_ptr < last)
-		  prob_ptr++;
-	       /*
-		*  Decode the MPS '0'
-		*/
-	       high = count - 1;
-
-	       RESCALE_INPUT_INTERVAL;
-	    }
-	    else
-	    {
-	       prob_ptr = ((prob_ptr - first) >> 1) + first;
-	       /*
-		*  Decode the LPS '1'
-		*/
-	       low = count;
-
-	       RESCALE_INPUT_INTERVAL;
-	       /*
-		*  Restore the transition (weight = -1)
-		*/
-	       append_edge (row, wfa->y_state [row][label], -1, label, wfa);
-	       total++;
-	    }
-	 }
+         int label;                     /* current label */
+
+         for (label = 0; label < MAXLABELS; label++)
+         {
+            u_word_t count = high - ((high - low) >> *prob_ptr);
+
+            if (code < count)
+            {
+               if (prob_ptr < last)
+                  prob_ptr++;
+               /*
+                *  Decode the MPS '0'
+                */
+               high = count - 1;
+
+               RESCALE_INPUT_INTERVAL;
+            }
+            else
+            {
+               prob_ptr = ((prob_ptr - first) >> 1) + first;
+               /*
+                *  Decode the LPS '1'
+                */
+               low = count;
+
+               RESCALE_INPUT_INTERVAL;
+               /*
+                *  Restore the transition (weight = -1)
+                */
+               append_edge (row, wfa->y_state [row][label], -1, label, wfa);
+               total++;
+            }
+         }
       }
    }
 
@@ -625,20 +625,20 @@ compute_y_state (int state, int y_state, wfa_t *wfa)
  *  No return value.
  *
  *  Side effects:
- *	'wfa->y_state' is filled with the generated tree structure.
+ *      'wfa->y_state' is filled with the generated tree structure.
  */
 {
    unsigned label;
 
    for (label = 0; label < MAXLABELS; label++)
       if (isrange (y_state))
-	 wfa->y_state [state][label] = RANGE;
+         wfa->y_state [state][label] = RANGE;
       else
       {
-	 wfa->y_state [state][label] = wfa->tree [y_state][label];
-	 if (!isrange (wfa->tree [state][label]))
-	    compute_y_state (wfa->tree [state][label],
-			     wfa->y_state [state][label], wfa);
+         wfa->y_state [state][label] = wfa->tree [y_state][label];
+         if (!isrange (wfa->tree [state][label]))
+            compute_y_state (wfa->tree [state][label],
+                             wfa->y_state [state][label], wfa);
       }
 
 }
diff --git a/converter/other/fiasco/input/matrices.h b/converter/other/fiasco/input/matrices.h
index 6d1cef15..193bc6a7 100644
--- a/converter/other/fiasco/input/matrices.h
+++ b/converter/other/fiasco/input/matrices.h
@@ -1,8 +1,8 @@
 /*
  *  matrices.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/input/mc.c b/converter/other/fiasco/input/mc.c
index afc0c1c3..8d93d931 100644
--- a/converter/other/fiasco/input/mc.c
+++ b/converter/other/fiasco/input/mc.c
@@ -1,8 +1,8 @@
 /*
- *  mc.c:	Input of motion compensation
+ *  mc.c:       Input of motion compensation
  *
  *  written by: Michael Unger
- *		Ullrich Hafner
+ *              Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -31,27 +31,27 @@
 
 /*****************************************************************************
 
-			     local variables
+                             local variables
 
 *****************************************************************************/
 
 typedef struct huff_node
 {
-   int		     code_index;	/* leaf if index >= 0 */
-   struct huff_node *left;		/* follow if '0' bit read */
-   struct huff_node *right;		/* follow if '1' bit read */
-   int		     index_set [34];
+   int               code_index;        /* leaf if index >= 0 */
+   struct huff_node *left;              /* follow if '0' bit read */
+   struct huff_node *right;             /* follow if '1' bit read */
+   int               index_set [34];
 } huff_node_t;
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static void
 decode_mc_tree (frame_type_e frame_type, unsigned max_state,
-		wfa_t *wfa, bitfile_t *input);
+                wfa_t *wfa, bitfile_t *input);
 static void
 decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input);
 static int
@@ -63,7 +63,7 @@ create_huff_node (huff_node_t *hn, int bits_processed);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -76,12 +76,12 @@ read_mc (frame_type_e frame_type, wfa_t *wfa, bitfile_t *input)
  *  No return value.
  *
  *  Side effects:
- *	'wfa->mv_tree' is filled with the decoded values.
+ *      'wfa->mv_tree' is filled with the decoded values.
  */
 {
    unsigned max_state = wfa->wfainfo->color
-			? wfa->tree [wfa->tree [wfa->root_state][0]][0]
-			: wfa->states;
+                        ? wfa->tree [wfa->tree [wfa->root_state][0]][0]
+                        : wfa->states;
 
    decode_mc_tree (frame_type, max_state, wfa, input);
    decode_mc_coords (max_state, wfa, input);
@@ -89,13 +89,13 @@ read_mc (frame_type_e frame_type, wfa_t *wfa, bitfile_t *input)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static void
 decode_mc_tree (frame_type_e frame_type, unsigned max_state,
-		wfa_t *wfa, bitfile_t *input)
+                wfa_t *wfa, bitfile_t *input)
 /*
  *  Read tree of motion compensation decisions of the 'input' stream.
  *  Depending on 'frame_type' different decoding methods are used.
@@ -104,13 +104,13 @@ decode_mc_tree (frame_type_e frame_type, unsigned max_state,
  *  No return value.
  *
  *  Side effects:
- *	'wfa->mv_tree' is filled with decoded values.
+ *      'wfa->mv_tree' is filled with decoded values.
  */
 {
-   unsigned  state;			/* current state */
-   unsigned *queue;			/* states in breadth first order */
-   unsigned  last;			/* last node
-					   (update for each new node) */
+   unsigned  state;                     /* current state */
+   unsigned *queue;                     /* states in breadth first order */
+   unsigned  last;                      /* last node
+                                           (update for each new node) */
 
    /*
     *  Traverse tree in breadth first order (starting at level
@@ -120,68 +120,68 @@ decode_mc_tree (frame_type_e frame_type, unsigned max_state,
    queue = Calloc (MAXSTATES, sizeof (unsigned));
    for (last = 0, state = wfa->basis_states; state < max_state; state++)
       if (wfa->level_of_state [state] - 1 == (int) wfa->wfainfo->p_max_level)
-	 queue [last++] = state;	/* init level 'p_max_level' */
+         queue [last++] = state;        /* init level 'p_max_level' */
 
    if (frame_type == P_FRAME)
    {
-      unsigned label;			/* current label */
-      unsigned current;			/* current node to process */
+      unsigned label;                   /* current label */
+      unsigned current;                 /* current node to process */
 
       for (current = 0; current < last; current++)
-	 for (label = 0; label < MAXLABELS; label++)
-	 {
-	    state = queue[current];
-	    if (wfa->x [state][label]	/* process visible states only */
-		+  width_of_level (wfa->level_of_state [state] - 1)
-		<= wfa->wfainfo->width
-		&&
-		wfa->y [state][label]
-		+  height_of_level (wfa->level_of_state [state] - 1)
-		<= wfa->wfainfo->height)
-	    {
-	       wfa->mv_tree [state][label].type
-		  = get_bit (input) ? NONE : FORWARD;
-	    }
-	    else
-	       wfa->mv_tree [state][label].type = NONE;
-	    if (wfa->mv_tree [state][label].type == NONE &&
-		!isrange (wfa->tree [state][label]) &&
-		wfa->level_of_state [state] - 1 >=
-		(int) wfa->wfainfo->p_min_level)
-	       queue [last++] = wfa->tree [state][label]; /* append child  */
-	 }
+         for (label = 0; label < MAXLABELS; label++)
+         {
+            state = queue[current];
+            if (wfa->x [state][label]   /* process visible states only */
+                +  width_of_level (wfa->level_of_state [state] - 1)
+                <= wfa->wfainfo->width
+                &&
+                wfa->y [state][label]
+                +  height_of_level (wfa->level_of_state [state] - 1)
+                <= wfa->wfainfo->height)
+            {
+               wfa->mv_tree [state][label].type
+                  = get_bit (input) ? NONE : FORWARD;
+            }
+            else
+               wfa->mv_tree [state][label].type = NONE;
+            if (wfa->mv_tree [state][label].type == NONE &&
+                !isrange (wfa->tree [state][label]) &&
+                wfa->level_of_state [state] - 1 >=
+                (int) wfa->wfainfo->p_min_level)
+               queue [last++] = wfa->tree [state][label]; /* append child  */
+         }
    }
    else
    {
-      unsigned label;			/* current label */
-      unsigned current;			/* current node to process */
+      unsigned label;                   /* current label */
+      unsigned current;                 /* current node to process */
 
       for (current = 0; current < last; current++)
-	 for (label = 0; label < MAXLABELS; label++)
-	 {
-	    state = queue[current];
-	    if (wfa->x [state][label]	/* process visible states only */
-		+ width_of_level (wfa->level_of_state [state] - 1)
-		> wfa->wfainfo->width
-		||
-		wfa->y [state][label]
-		+ height_of_level (wfa->level_of_state [state] - 1)
-		> wfa->wfainfo->height)
-	       wfa->mv_tree[state][label].type = NONE;
-	    else if (get_bit (input))	/* 1   */
-	       wfa->mv_tree[state][label].type = NONE;
-	    else if (get_bit (input))	/* 01  */
-	       wfa->mv_tree[state][label].type = INTERPOLATED;
-	    else if (get_bit (input))	/* 001 */
-	       wfa->mv_tree[state][label].type = BACKWARD;
-	    else			/* 000 */
-	       wfa->mv_tree[state][label].type = FORWARD;
-	    if (wfa->mv_tree[state][label].type == NONE &&
-		!isrange (wfa->tree[state][label]) &&
-		wfa->level_of_state[state] - 1
-		>= (int) wfa->wfainfo->p_min_level)
-	       queue[last++] = wfa->tree[state][label]; /* append child  */
-	 }
+         for (label = 0; label < MAXLABELS; label++)
+         {
+            state = queue[current];
+            if (wfa->x [state][label]   /* process visible states only */
+                + width_of_level (wfa->level_of_state [state] - 1)
+                > wfa->wfainfo->width
+                ||
+                wfa->y [state][label]
+                + height_of_level (wfa->level_of_state [state] - 1)
+                > wfa->wfainfo->height)
+               wfa->mv_tree[state][label].type = NONE;
+            else if (get_bit (input))   /* 1   */
+               wfa->mv_tree[state][label].type = NONE;
+            else if (get_bit (input))   /* 01  */
+               wfa->mv_tree[state][label].type = INTERPOLATED;
+            else if (get_bit (input))   /* 001 */
+               wfa->mv_tree[state][label].type = BACKWARD;
+            else                        /* 000 */
+               wfa->mv_tree[state][label].type = FORWARD;
+            if (wfa->mv_tree[state][label].type == NONE &&
+                !isrange (wfa->tree[state][label]) &&
+                wfa->level_of_state[state] - 1
+                >= (int) wfa->wfainfo->p_min_level)
+               queue[last++] = wfa->tree[state][label]; /* append child  */
+         }
    }
 
    INPUT_BYTE_ALIGN (input);
@@ -198,12 +198,12 @@ decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input)
  *  No return value.
  *
  *  Side effects:
- *	'wfa->mv_tree' is filled with decoded values.
+ *      'wfa->mv_tree' is filled with decoded values.
  */
 {
-   unsigned	       label;		/* current label */
-   unsigned	       state;		/* current state */
-   mv_t		      *mv;		/* current motion vector */
+   unsigned            label;           /* current label */
+   unsigned            state;           /* current state */
+   mv_t               *mv;              /* current motion vector */
    static huff_node_t *huff_mv_root = NULL; /* root of huffman tree */
 
    if (huff_mv_root == NULL)
@@ -212,26 +212,26 @@ decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input)
    for (state = wfa->basis_states; state < max_state; state++)
       for (label = 0; label < MAXLABELS; label++)
       {
-	 mv = &wfa->mv_tree[state][label];
-	 switch (mv->type)
-	 {
-	    case NONE:
-	       break;
-	    case FORWARD:
-	       mv->fx = get_mv (1, huff_mv_root, input);
-	       mv->fy = get_mv (1, huff_mv_root, input);
-	       break;
-	    case BACKWARD:
-	       mv->bx = get_mv (1, huff_mv_root, input);
-	       mv->by = get_mv (1, huff_mv_root, input);
-	       break;
-	    case INTERPOLATED:
-	       mv->fx = get_mv (1, huff_mv_root, input);
-	       mv->fy = get_mv (1, huff_mv_root, input);
-	       mv->bx = get_mv (1, huff_mv_root, input);
-	       mv->by = get_mv (1, huff_mv_root, input);
-	       break;
-	 }
+         mv = &wfa->mv_tree[state][label];
+         switch (mv->type)
+         {
+            case NONE:
+               break;
+            case FORWARD:
+               mv->fx = get_mv (1, huff_mv_root, input);
+               mv->fy = get_mv (1, huff_mv_root, input);
+               break;
+            case BACKWARD:
+               mv->bx = get_mv (1, huff_mv_root, input);
+               mv->by = get_mv (1, huff_mv_root, input);
+               break;
+            case INTERPOLATED:
+               mv->fx = get_mv (1, huff_mv_root, input);
+               mv->fy = get_mv (1, huff_mv_root, input);
+               mv->bx = get_mv (1, huff_mv_root, input);
+               mv->by = get_mv (1, huff_mv_root, input);
+               break;
+         }
       }
 
    INPUT_BYTE_ALIGN (input);
@@ -249,11 +249,11 @@ get_mv (int f_code, huff_node_t *hn, bitfile_t *input)
    while (hn->code_index < 0)
    {
       if (hn->code_index == -2)
-	 error ("wrong huffman code !");
+         error ("wrong huffman code !");
       if (get_bit (input))
-	 hn = hn->right;
+         hn = hn->right;
       else
-	 hn = hn->left;
+         hn = hn->left;
    }
    vlc_code = hn->code_index - 16;
    if (vlc_code == 0 || f_code == 1)
@@ -275,7 +275,7 @@ create_huff_tree (void)
  *  Construct huffman tree from code table
  */
 {
-   unsigned	i;
+   unsigned     i;
    huff_node_t *huff_root = Calloc (1, sizeof (huff_node_t));
 
    /*
@@ -286,7 +286,7 @@ create_huff_tree (void)
 
    for (i = 0; i < 33; i++)
       huff_root->index_set [i] = i;
-   huff_root->index_set [i] = -1;	/* end marker */
+   huff_root->index_set [i] = -1;       /* end marker */
 
    create_huff_node (huff_root, 0);
 
@@ -299,14 +299,14 @@ create_huff_node (huff_node_t *hn, int bits_processed)
  *  Create one node in the huffman tree
  */
 {
-   int lind = 0;			/* next index of left huff_node */
-   int rind = 0;			/* next index of right huff_node */
+   int lind = 0;                        /* next index of left huff_node */
+   int rind = 0;                        /* next index of right huff_node */
    int code_len, i, ind;
 
    hn->code_index = -1;
-   if (hn->index_set [0] < 0)		/* empty index set ? */
+   if (hn->index_set [0] < 0)           /* empty index set ? */
    {
-      hn->code_index = -2;		/* error */
+      hn->code_index = -2;              /* error */
       return;
    }
    hn->left  = Calloc (1, sizeof (huff_node_t));
@@ -315,19 +315,19 @@ create_huff_node (huff_node_t *hn, int bits_processed)
    for (i = 0; (ind = hn->index_set[i]) >= 0; i++)
    {
       code_len = mv_code_table[ind][1];
-      if (code_len == bits_processed)	/* generate leaf */
+      if (code_len == bits_processed)   /* generate leaf */
       {
-	 hn->code_index = ind;
-	 Free (hn->left);
-	 Free (hn->right);
-	 return;
+         hn->code_index = ind;
+         Free (hn->left);
+         Free (hn->right);
+         return;
       }
       if (mv_code_table[ind][0] & (1 << (code_len - 1 - bits_processed)))
-	 hn->right->index_set[rind++] = ind;
+         hn->right->index_set[rind++] = ind;
       else
-	 hn->left->index_set[lind++] = ind;
+         hn->left->index_set[lind++] = ind;
    }
-   hn->right->index_set[rind] = -1;	/* set end markers */
+   hn->right->index_set[rind] = -1;     /* set end markers */
    hn->left->index_set[lind]  = -1;
    create_huff_node (hn->left, bits_processed + 1);
    create_huff_node (hn->right, bits_processed + 1);
diff --git a/converter/other/fiasco/input/mc.h b/converter/other/fiasco/input/mc.h
index 9d9d714d..a61f7e4a 100644
--- a/converter/other/fiasco/input/mc.h
+++ b/converter/other/fiasco/input/mc.h
@@ -2,8 +2,8 @@
  *  mc.h
  *
  *  written by: Michael Unger
- *		Ullrich Hafner
- 
+ *              Ullrich Hafner
+
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/input/nd.c b/converter/other/fiasco/input/nd.c
index 129a150e..0317073a 100644
--- a/converter/other/fiasco/input/nd.c
+++ b/converter/other/fiasco/input/nd.c
@@ -1,7 +1,7 @@
 /*
- *  nd.c:		Input of prediction tree
+ *  nd.c:               Input of prediction tree
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -30,7 +30,7 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
@@ -41,7 +41,7 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -52,7 +52,7 @@ read_nd (wfa_t *wfa, bitfile_t *input)
  *  ND is used only at levels {'wfa->p_min_level', ... , 'wfa->p_max_level'}.
  *
  *  Side effects:
- *	'wfa->into' and 'wfa->weights' are filled with the decoded values
+ *      'wfa->into' and 'wfa->weights' are filled with the decoded values
  */
 {
    unsigned total = decode_nd_tree (wfa, input);
@@ -63,7 +63,7 @@ read_nd (wfa_t *wfa, bitfile_t *input)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
@@ -75,16 +75,16 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input)
  *  No return value.
  *
  *  Side effects:
- *	'wfa->into' is filled with the decoded values
+ *      'wfa->into' is filled with the decoded values
  */
 {
-   lqueue_t *queue;			/* queue of states */
-   int       next, state;		/* state and its current child */
-   unsigned  total = 0;			/* total number of predicted states */
-   u_word_t  sum0, sum1;		/* Probability model */
-   u_word_t  code;			/* The present input code value */
-   u_word_t  low;			/* Start of the current code range */
-   u_word_t  high;			/* End of the current code range */
+   lqueue_t *queue;                     /* queue of states */
+   int       next, state;               /* state and its current child */
+   unsigned  total = 0;                 /* total number of predicted states */
+   u_word_t  sum0, sum1;                /* Probability model */
+   u_word_t  code;                      /* The present input code value */
+   u_word_t  low;                       /* Start of the current code range */
+   u_word_t  high;                      /* End of the current code range */
 
    /*
     *  Initialize arithmetic decoder
@@ -108,78 +108,78 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input)
 
       if (wfa->level_of_state [next] > wfa->wfainfo->p_max_level + 1)
       {
-	 /*
-	  *  Nondetermismn is not allowed at levels larger than
-	  *  'wfa->wfainfo->p_max_level'.
-	  */
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (ischild (state = wfa->tree [next][label]))
-	       queue_append (queue, &state); /* continue with children */
+         /*
+          *  Nondetermismn is not allowed at levels larger than
+          *  'wfa->wfainfo->p_max_level'.
+          */
+         for (label = 0; label < MAXLABELS; label++)
+            if (ischild (state = wfa->tree [next][label]))
+               queue_append (queue, &state); /* continue with children */
       }
       else if (wfa->level_of_state [next] > wfa->wfainfo->p_min_level)
       {
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (ischild (state = wfa->tree [next][label]))
-	    {
-	       unsigned count;		/* Current interval count */
-	       unsigned range;		/* Current interval range */
-
-	       count = (((code - low) + 1) * sum1 - 1) / ((high - low) + 1);
-	       if (count < sum0)
-	       {
-		  /*
-		   *  Decode a '0' symbol
-		   *  First, the range is expanded to account for the
-		   *  symbol removal.
-		   */
-		  range = (high - low) + 1;
-		  high = low + (u_word_t) ((range * sum0) / sum1 - 1 );
-		  RESCALE_INPUT_INTERVAL;
-		  /*
-		   *  Update the frequency counts
-		   */
-		  sum0++;
-		  sum1++;
-		  if (sum1 > 50) /* scale the symbol frequencies */
-		  {
-		     sum0 >>= 1;
-		     sum1 >>= 1;
-		     if (!sum0)
-			sum0 = 1;
-		     if (sum0 >= sum1)
-			sum1 = sum0 + 1;
-		  }
-		  if (wfa->level_of_state [state] > wfa->wfainfo->p_min_level)
-		     queue_append (queue, &state);
-	       }
-	       else
-	       {
-		  /*
-		   *  Decode a '1' symbol
-		   *  First, the range is expanded to account for the
-		   *  symbol removal.
-		   */
-		  range = (high - low) + 1;
-		  high = low + (u_word_t) ((range * sum1) / sum1 - 1);
-		  low  = low + (u_word_t) ((range * sum0) / sum1);
-		  RESCALE_INPUT_INTERVAL;
-		  /*
-		   *  Update the frequency counts
-		   */
-		  sum1++;
-		  if (sum1 > 50) /* scale the symbol frequencies */
-		  {
-		     sum0 >>= 1;
-		     sum1 >>= 1;
-		     if (!sum0)
-			sum0 = 1;
-		     if (sum0 >= sum1)
-			sum1 = sum0 + 1;
-		  }
-		  append_edge (next, 0, -1, label, wfa);
-		  total++;
-	       }
-	    }
+         for (label = 0; label < MAXLABELS; label++)
+            if (ischild (state = wfa->tree [next][label]))
+            {
+               unsigned count;          /* Current interval count */
+               unsigned range;          /* Current interval range */
+
+               count = (((code - low) + 1) * sum1 - 1) / ((high - low) + 1);
+               if (count < sum0)
+               {
+                  /*
+                   *  Decode a '0' symbol
+                   *  First, the range is expanded to account for the
+                   *  symbol removal.
+                   */
+                  range = (high - low) + 1;
+                  high = low + (u_word_t) ((range * sum0) / sum1 - 1 );
+                  RESCALE_INPUT_INTERVAL;
+                  /*
+                   *  Update the frequency counts
+                   */
+                  sum0++;
+                  sum1++;
+                  if (sum1 > 50) /* scale the symbol frequencies */
+                  {
+                     sum0 >>= 1;
+                     sum1 >>= 1;
+                     if (!sum0)
+                        sum0 = 1;
+                     if (sum0 >= sum1)
+                        sum1 = sum0 + 1;
+                  }
+                  if (wfa->level_of_state [state] > wfa->wfainfo->p_min_level)
+                     queue_append (queue, &state);
+               }
+               else
+               {
+                  /*
+                   *  Decode a '1' symbol
+                   *  First, the range is expanded to account for the
+                   *  symbol removal.
+                   */
+                  range = (high - low) + 1;
+                  high = low + (u_word_t) ((range * sum1) / sum1 - 1);
+                  low  = low + (u_word_t) ((range * sum0) / sum1);
+                  RESCALE_INPUT_INTERVAL;
+                  /*
+                   *  Update the frequency counts
+                   */
+                  sum1++;
+                  if (sum1 > 50) /* scale the symbol frequencies */
+                  {
+                     sum0 >>= 1;
+                     sum1 >>= 1;
+                     if (!sum0)
+                        sum0 = 1;
+                     if (sum0 >= sum1)
+                        sum1 = sum0 + 1;
+                  }
+                  append_edge (next, 0, -1, label, wfa);
+                  total++;
+               }
+            }
       }
    }
    free_queue (queue);
@@ -199,21 +199,21 @@ decode_nd_coefficients (unsigned total, wfa_t *wfa, bitfile_t *input)
  *  No return value.
  *
  *  Side effects:
- *	'wfa->weights' is filled with the decoded values.
+ *      'wfa->weights' is filled with the decoded values.
  */
 {
-   unsigned *coefficients;		/* array of factors to encode */
-   unsigned *ptr;			/* pointer to current factor */
+   unsigned *coefficients;              /* array of factors to encode */
+   unsigned *ptr;                       /* pointer to current factor */
 
    /*
     *  Decode array of coefficients stored with arithmetic coding
     */
    {
-      const int	scaling  = 50;		/* scaling factor of prob. model */
+      const int scaling  = 50;          /* scaling factor of prob. model */
       unsigned  c_symbols = 1 << (wfa->wfainfo->dc_rpf->mantissa_bits + 1);
 
       ptr = coefficients = decode_array (input, NULL, &c_symbols, 1,
-					 total, scaling);
+                                         total, scaling);
    }
 
    /*
@@ -223,15 +223,15 @@ decode_nd_coefficients (unsigned total, wfa_t *wfa, bitfile_t *input)
       unsigned state, label;
 
       for (state = wfa->basis_states; state < wfa->states; state++)
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (ischild (wfa->tree [state][label])
-		&& isedge (wfa->into [state][label][0]))
-	    {
-	       wfa->weight [state][label][0] = btor (*ptr++,
-						     wfa->wfainfo->dc_rpf);
-	       wfa->int_weight [state][label][0]
-		  = wfa->weight [state][label][0] * 512 + 0.5;
-	    }
+         for (label = 0; label < MAXLABELS; label++)
+            if (ischild (wfa->tree [state][label])
+                && isedge (wfa->into [state][label][0]))
+            {
+               wfa->weight [state][label][0] = btor (*ptr++,
+                                                     wfa->wfainfo->dc_rpf);
+               wfa->int_weight [state][label][0]
+                  = wfa->weight [state][label][0] * 512 + 0.5;
+            }
    }
    Free (coefficients);
 }
diff --git a/converter/other/fiasco/input/nd.h b/converter/other/fiasco/input/nd.h
index 0fe06cf1..57f46440 100644
--- a/converter/other/fiasco/input/nd.h
+++ b/converter/other/fiasco/input/nd.h
@@ -1,8 +1,8 @@
 /*
  *  nd.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/input/read.c b/converter/other/fiasco/input/read.c
index c3aa77a8..50e271e5 100644
--- a/converter/other/fiasco/input/read.c
+++ b/converter/other/fiasco/input/read.c
@@ -1,7 +1,7 @@
 /*
- *  read.c:		Input of WFA files
+ *  read.c:             Input of WFA files
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -46,17 +46,17 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static void
 read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height,
-	     unsigned image_level, bitfile_t *input);
+             unsigned image_level, bitfile_t *input);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -66,14 +66,14 @@ open_wfa (const char *filename, wfa_info_t *wi)
  *  Open WFA file 'filename' and read header information.
  *
  *  Return value:
- *	Pointer to input stream (fileposition: first WFA frame)
+ *      Pointer to input stream (fileposition: first WFA frame)
  *
  *  Side effects:
- *	The values of the header of 'filename' are copied to 'wfainfo'.
+ *      The values of the header of 'filename' are copied to 'wfainfo'.
  *
  */
 {
-   bitfile_t *input;			/* pointer to WFA bitfile */
+   bitfile_t *input;                    /* pointer to WFA bitfile */
 
    assert (filename && wi);
 
@@ -83,7 +83,7 @@ open_wfa (const char *filename, wfa_info_t *wi)
     *  Check whether 'filename' is a regular WFA file
     */
    {
-      unsigned 	n;
+      unsigned  n;
       const char     *str;
 
       if (!(input = open_bitfile (filename, "FIASCO_DATA", READ_ACCESS)))
@@ -92,57 +92,57 @@ open_wfa (const char *filename, wfa_info_t *wi)
       for (str = FIASCO_MAGIC, n = strlen (FIASCO_MAGIC); n; n--)
           if (get_bits (input, 8) != (unsigned) *str++)
               error ("Input file %s is not a valid FIASCO file!", filename);
-      get_bits (input, 8);		/* fetch newline */
+      get_bits (input, 8);              /* fetch newline */
    }
 
    /*
     *  Read WFA header information
     */
    {
-      char	      basis_name [MAXSTRLEN]; /* temp. buffer */
-      const unsigned  rice_k = 8; 	/* parameter of Rice Code */
-      char     	     *str    = basis_name;
+      char            basis_name [MAXSTRLEN]; /* temp. buffer */
+      const unsigned  rice_k = 8;       /* parameter of Rice Code */
+      char           *str    = basis_name;
 
       while ((*str++ = get_bits (input, 8)) != 0
-	     && str < basis_name + MAXSTRLEN)
-	 ;
+             && str < basis_name + MAXSTRLEN)
+         ;
       if (str == basis_name + MAXSTRLEN)
-	 error ("Input file %s is not a valid FIASCO file!", filename);
+         error ("Input file %s is not a valid FIASCO file!", filename);
 
       {
-	 wi->release = read_rice_code (rice_k, input);
+         wi->release = read_rice_code (rice_k, input);
 
-	 if (wi->release > FIASCO_BINFILE_RELEASE)
-	    error ("Can't decode FIASCO files of file format release `%d'."
-		   "\nCurrent file format release is `%d'.", wi->release,
-		   FIASCO_BINFILE_RELEASE);
+         if (wi->release > FIASCO_BINFILE_RELEASE)
+            error ("Can't decode FIASCO files of file format release `%d'."
+                   "\nCurrent file format release is `%d'.", wi->release,
+                   FIASCO_BINFILE_RELEASE);
       }
 
       if (wi->release > 1)
       {
-	 header_type_e type;
-
-	 while ((type = read_rice_code (rice_k, input)) != HEADER_END)
-	 {
-	    char     buffer [MAXSTRLEN];
-	    unsigned n = 0;
-
-	    switch (type)
-	    {
-	       case HEADER_TITLE:
-		  while ((buffer [n++] = get_bits (input, 8)))
-		     ;
-		  wi->title = strdup (buffer);
-		  break;
-	       case HEADER_COMMENT:
-		  while ((buffer [n++] = get_bits (input, 8)))
-		     ;
-		  wi->comment = strdup (buffer);
-		  break;
-	       default:			/* should not happen */
-		  break;
-	    }
-	 }
+         header_type_e type;
+
+         while ((type = read_rice_code (rice_k, input)) != HEADER_END)
+         {
+            char     buffer [MAXSTRLEN];
+            unsigned n = 0;
+
+            switch (type)
+            {
+               case HEADER_TITLE:
+                  while ((buffer [n++] = get_bits (input, 8)))
+                     ;
+                  wi->title = strdup (buffer);
+                  break;
+               case HEADER_COMMENT:
+                  while ((buffer [n++] = get_bits (input, 8)))
+                     ;
+                  wi->comment = strdup (buffer);
+                  break;
+               default:                 /* should not happen */
+                  break;
+            }
+         }
       }
 
       wi->basis_name = strdup (basis_name);
@@ -155,65 +155,65 @@ open_wfa (const char *filename, wfa_info_t *wi)
        *  Compute bintree level
        */
       {
-	 unsigned lx = log2 (wi->width - 1) + 1;
-	 unsigned ly = log2 (wi->height - 1) + 1;
+         unsigned lx = log2 (wi->width - 1) + 1;
+         unsigned ly = log2 (wi->height - 1) + 1;
 
-	 wi->level = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0);
+         wi->level = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0);
       }
       wi->chroma_max_states = wi->color ? read_rice_code (rice_k, input) : -1;
       wi->p_min_level       = read_rice_code (rice_k, input);
       wi->p_max_level       = read_rice_code (rice_k, input);
       wi->frames            = read_rice_code (rice_k, input);
-      wi->smoothing	    = read_rice_code (rice_k, input);
+      wi->smoothing         = read_rice_code (rice_k, input);
 
       /*
        *  Read RPF models from disk
        */
       {
-	 unsigned 	    mantissa;
-	 fiasco_rpf_range_e range;
-
-	 mantissa = get_bits (input, 3) + 2;
-	 range    = get_bits (input, 2);
-	 wi->rpf  = alloc_rpf (mantissa, range);
-
-	 if (get_bit (input))		/* different DC model */
-	 {
-	    mantissa   = get_bits (input, 3) + 2;
-	    range      = get_bits (input, 2);
-	    wi->dc_rpf = alloc_rpf (mantissa, range);
-	 }
-	 else				/* use same model for DC coefficients */
-	    wi->dc_rpf = alloc_rpf (wi->rpf->mantissa_bits,
-				    wi->rpf->range_e);
-
-	 if (get_bit (input))		/* different delta model */
-	 {
-	    mantissa  = get_bits (input, 3) + 2;
-	    range     = get_bits (input, 2);
-	    wi->d_rpf = alloc_rpf (mantissa, range);
-	 }
-	 else
-	    wi->d_rpf = alloc_rpf (wi->rpf->mantissa_bits,
-				   wi->rpf->range_e);
-
-	 if (get_bit (input))		/* different DC delta model */
-	 {
-	    mantissa  	 = get_bits (input, 3) + 2;
-	    range     	 = get_bits (input, 2);
-	    wi->d_dc_rpf = alloc_rpf (mantissa, range);
-	 }
-	 else
-	    wi->d_dc_rpf = alloc_rpf (wi->dc_rpf->mantissa_bits,
-				      wi->dc_rpf->range_e);
+         unsigned           mantissa;
+         fiasco_rpf_range_e range;
+
+         mantissa = get_bits (input, 3) + 2;
+         range    = get_bits (input, 2);
+         wi->rpf  = alloc_rpf (mantissa, range);
+
+         if (get_bit (input))           /* different DC model */
+         {
+            mantissa   = get_bits (input, 3) + 2;
+            range      = get_bits (input, 2);
+            wi->dc_rpf = alloc_rpf (mantissa, range);
+         }
+         else                           /* use same model for DC coefficients */
+            wi->dc_rpf = alloc_rpf (wi->rpf->mantissa_bits,
+                                    wi->rpf->range_e);
+
+         if (get_bit (input))           /* different delta model */
+         {
+            mantissa  = get_bits (input, 3) + 2;
+            range     = get_bits (input, 2);
+            wi->d_rpf = alloc_rpf (mantissa, range);
+         }
+         else
+            wi->d_rpf = alloc_rpf (wi->rpf->mantissa_bits,
+                                   wi->rpf->range_e);
+
+         if (get_bit (input))           /* different DC delta model */
+         {
+            mantissa     = get_bits (input, 3) + 2;
+            range        = get_bits (input, 2);
+            wi->d_dc_rpf = alloc_rpf (mantissa, range);
+         }
+         else
+            wi->d_dc_rpf = alloc_rpf (wi->dc_rpf->mantissa_bits,
+                                      wi->dc_rpf->range_e);
       }
 
-      if (wi->frames > 1)		/* motion compensation stuff */
+      if (wi->frames > 1)               /* motion compensation stuff */
       {
-	 wi->fps           = read_rice_code (rice_k, input);
-	 wi->search_range  = read_rice_code (rice_k, input);
-	 wi->half_pixel    = get_bit (input) ? YES : NO;
-	 wi->B_as_past_ref = get_bit (input) ? YES : NO;
+         wi->fps           = read_rice_code (rice_k, input);
+         wi->search_range  = read_rice_code (rice_k, input);
+         wi->half_pixel    = get_bit (input) ? YES : NO;
+         wi->B_as_past_ref = get_bit (input) ? YES : NO;
       }
    }
 
@@ -230,12 +230,12 @@ read_basis (const char *filename, wfa_t *wfa)
  *  No return value.
  *
  *  Side effects:
- *	wfa->into, wfa->weights, wfa->final_distribution, wfa->basis_states
- *	wfa->domain_type wfa->wfainfo->basis_name, are filled with the
- *	values of the WFA basis.
+ *      wfa->into, wfa->weights, wfa->final_distribution, wfa->basis_states
+ *      wfa->domain_type wfa->wfainfo->basis_name, are filled with the
+ *      values of the WFA basis.
  */
 {
-   FILE	*input;				/* ASCII WFA initial basis file */
+   FILE *input;                         /* ASCII WFA initial basis file */
 
    assert (filename && wfa);
 
@@ -243,27 +243,27 @@ read_basis (const char *filename, wfa_t *wfa)
        !streq (wfa->wfainfo->basis_name, filename))
    {
       if (wfa->wfainfo->basis_name)
-	 Free (wfa->wfainfo->basis_name);
+         Free (wfa->wfainfo->basis_name);
       wfa->wfainfo->basis_name = strdup (filename);
    }
 
    if (get_linked_basis (filename, wfa))
-      return;				/* basis is linked with executable */
+      return;                           /* basis is linked with executable */
 
    /*
     *  Check whether 'wfa_name' is a regular ASCII WFA initial basis file
     */
    {
-      char magic [MAXSTRLEN];		/* WFA magic number */
+      char magic [MAXSTRLEN];           /* WFA magic number */
 
       if (!(input = open_file (filename, "FIASCO_DATA", READ_ACCESS)))
-	 file_error(filename);
+         file_error(filename);
 
       if (fscanf (input, MAXSTRLEN_SCANF, magic) != 1)
-	 error ("Format error: ASCII FIASCO initial basis file %s", filename);
+         error ("Format error: ASCII FIASCO initial basis file %s", filename);
       else if (!streq (FIASCO_BASIS_MAGIC, magic))
-	 error ("Input file %s is not an ASCII FIASCO initial basis!",
-		filename);
+         error ("Input file %s is not an ASCII FIASCO initial basis!",
+                filename);
    }
 
    /*
@@ -273,74 +273,74 @@ read_basis (const char *filename, wfa_t *wfa)
     *        Don't define any transitions of state 0 in an initial basis.
     *
     *  Header:
-    *   type		|description
-    *	----------------+-----------
-    *   string		|MAGIC Number "Wfa"
-    *	int		|Number of basis states 'N'
-    *	bool_t-array[N]	|use vector in linear combinations,
-    *			|0: don't use vector (auxiliary state)
-    *			|1: use vector in linear combinations
-    *	float-array[N]	|final distribution of every state
+    *   type            |description
+    *   ----------------+-----------
+    *   string          |MAGIC Number "Wfa"
+    *   int             |Number of basis states 'N'
+    *   bool_t-array[N] |use vector in linear combinations,
+    *                   |0: don't use vector (auxiliary state)
+    *                   |1: use vector in linear combinations
+    *   float-array[N]  |final distribution of every state
     *
     *  Transitions:
     *
-    *      <state 1>			current state
-    *      <label> <into> <weight>	transition 1 of current state
-    *      <label> <into> <weight>	transition 2 of current state
+    *      <state 1>                    current state
+    *      <label> <into> <weight>      transition 1 of current state
+    *      <label> <into> <weight>      transition 2 of current state
     *      ...
-    *      <-1>				last transition marker
+    *      <-1>                         last transition marker
     *      <state 2>
     *      ...
-    *      <-1>				last transition marker
+    *      <-1>                         last transition marker
     *      <state N>
     *      ...
     *
-    *      <-1>				last transition marker
-    *      <-1>				last state marker
+    *      <-1>                         last transition marker
+    *      <-1>                         last state marker
     */
    {
       unsigned state;
 
       if (fscanf (input ,"%u", &wfa->basis_states) != 1)
-	 error ("Format error: ASCII FIASCO initial basis file %s", filename);
+         error ("Format error: ASCII FIASCO initial basis file %s", filename);
 
       /*
        *  State 0 is assumed to be the constant function f(x, y) = 128.
        */
       wfa->domain_type [0]        = USE_DOMAIN_MASK;
       wfa->final_distribution [0] = 128;
-      wfa->states 		  = wfa->basis_states;
+      wfa->states                 = wfa->basis_states;
       wfa->basis_states++;
 
       append_edge (0, 0, 1.0, 0, wfa);
       append_edge (0, 0, 1.0, 1, wfa);
 
       for (state = 1; state < wfa->basis_states; state++)
-	 wfa->domain_type [state]
-	    = read_int (input) ? USE_DOMAIN_MASK : AUXILIARY_MASK;
+         wfa->domain_type [state]
+            = read_int (input) ? USE_DOMAIN_MASK : AUXILIARY_MASK;
 
       for (state = 1; state < wfa->basis_states; state++)
-	 wfa->final_distribution[state] = read_real (input);
+         wfa->final_distribution[state] = read_real (input);
 
       /*
        *  Read transitions
        */
       for (state = 1; state < wfa->basis_states; state++)
       {
-	 unsigned domain;
-	 int      label;
-	 real_t   weight;
-
-	 if (read_int (input) != (int) state)
-	    error ("Format error: ASCII FIASCO initial basis file %s",
-		   filename);
-
-	 while((label = read_int (input)) != -1)
-	 {
-	    domain = read_int (input);
-	    weight = read_real (input);
-	    append_edge (state, domain, weight, label, wfa);
-	 }
+         unsigned domain;
+         int      label;
+         real_t   weight;
+
+         if (read_int (input) != (int) state)
+            error ("Format error: ASCII FIASCO initial basis file %s",
+                   filename);
+
+         while((label = read_int (input)) != -1)
+         {
+            domain = read_int (input);
+            weight = read_real (input);
+            append_edge (state, domain, weight, label, wfa);
+         }
       }
    }
 
@@ -357,13 +357,13 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input)
  *  No return value.
  *
  *  Side effects:
- *	wfa->into, wfa->weights, wfa->final_distribution, wfa->states
- *	wfa->x, wfa->y, wfa->level_of_state, wfa->domain_type
+ *      wfa->into, wfa->weights, wfa->final_distribution, wfa->states
+ *      wfa->x, wfa->y, wfa->level_of_state, wfa->domain_type
  *      mt->type, mt->number are filled with the values of the WFA file.
  */
 {
-   tiling_t tiling;			/* tiling information */
-   unsigned frame_number;		/* current frame number */
+   tiling_t tiling;                     /* tiling information */
+   unsigned frame_number;               /* current frame number */
 
    assert (wfa && input);
 
@@ -371,14 +371,14 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input)
     *  Frame header information
     */
    {
-      const unsigned rice_k = 8;	/* parameter of Rice Code */
+      const unsigned rice_k = 8;        /* parameter of Rice Code */
 
       wfa->states     = read_rice_code (rice_k, input);
       wfa->frame_type = read_rice_code (rice_k, input);
       frame_number    = read_rice_code (rice_k, input);
    }
 
-   if (wfa->wfainfo->release > 1)	/* no alignment in version 1 */
+   if (wfa->wfainfo->release > 1)       /* no alignment in version 1 */
    {
       INPUT_BYTE_ALIGN (input);
    }
@@ -386,9 +386,9 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input)
    /*
     *  Read image tiling info
     */
-   if (get_bit (input))			/* tiling performed ? */
+   if (get_bit (input))                 /* tiling performed ? */
       read_tiling (&tiling, wfa->wfainfo->width, wfa->wfainfo->height,
-		   wfa->wfainfo->level, input);
+                   wfa->wfainfo->level, input);
    else
       tiling.exponent = 0;
 
@@ -404,30 +404,30 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input)
       unsigned state;
 
       for (state = wfa->basis_states; state < wfa->states; state++)
-	 if ((!wfa->wfainfo->color
-	      || (int) state <= wfa->tree [wfa->tree [wfa->root_state][0]][0])
-	     &&
-	     (!tiling.exponent ||
-	      wfa->level_of_state [state] <= (wfa->wfainfo->level
-					      - tiling.exponent))
-	     && ((wfa->x [state][0]
-		 + width_of_level (wfa->level_of_state [state]))
-		 <= wfa->wfainfo->width)
-	     && ((wfa->y [state][0]
-		 + height_of_level (wfa->level_of_state [state]))
-		 <= wfa->wfainfo->height))
-	    wfa->domain_type [state] = USE_DOMAIN_MASK;
-	 else
-	    wfa->domain_type [state] = 0;
+         if ((!wfa->wfainfo->color
+              || (int) state <= wfa->tree [wfa->tree [wfa->root_state][0]][0])
+             &&
+             (!tiling.exponent ||
+              wfa->level_of_state [state] <= (wfa->wfainfo->level
+                                              - tiling.exponent))
+             && ((wfa->x [state][0]
+                 + width_of_level (wfa->level_of_state [state]))
+                 <= wfa->wfainfo->width)
+             && ((wfa->y [state][0]
+                 + height_of_level (wfa->level_of_state [state]))
+                 <= wfa->wfainfo->height))
+            wfa->domain_type [state] = USE_DOMAIN_MASK;
+         else
+            wfa->domain_type [state] = 0;
    }
 
    if (tiling.exponent)
       Free (tiling.vorder);
 
-   if (get_bit (input))			/* nondeterministic prediction used */
+   if (get_bit (input))                 /* nondeterministic prediction used */
       read_nd (wfa, input);
 
-   if (wfa->frame_type != I_FRAME)	/* motion compensation used */
+   if (wfa->frame_type != I_FRAME)      /* motion compensation used */
       read_mc (wfa->frame_type, wfa, input);
 
    locate_delta_images (wfa);
@@ -439,7 +439,7 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input)
       unsigned edges = read_matrices (wfa, input);
 
       if (edges)
-	 read_weights (edges, wfa, input);
+         read_weights (edges, wfa, input);
    }
 
    /*
@@ -449,8 +449,8 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input)
       unsigned state;
 
       for (state = wfa->basis_states; state <= wfa->states; state++)
-	 wfa->final_distribution[state]
-	    = compute_final_distribution (state, wfa);
+         wfa->final_distribution[state]
+            = compute_final_distribution (state, wfa);
    }
 
    return frame_number;
@@ -458,13 +458,13 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static void
 read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height,
-	     unsigned image_level, bitfile_t *input)
+             unsigned image_level, bitfile_t *input)
 /*
  *  Read image tiling information from the given file 'input'
  *  and store parameters in struct 'tiling'.
@@ -472,32 +472,32 @@ read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height,
  *  No return value.
  */
 {
-   const unsigned rice_k = 8;		/* parameter of Rice Code */
+   const unsigned rice_k = 8;           /* parameter of Rice Code */
 
    tiling->exponent = read_rice_code (rice_k, input);
 
-   if (get_bit (input))			/* variance order */
+   if (get_bit (input))                 /* variance order */
    {
-      unsigned tile;			/* current image tile */
-      unsigned x0, y0;			/* NW corner of image tile */
-      unsigned width, height;		/* size of image tile */
+      unsigned tile;                    /* current image tile */
+      unsigned x0, y0;                  /* NW corner of image tile */
+      unsigned width, height;           /* size of image tile */
 
       tiling->vorder = Calloc (1 << tiling->exponent, sizeof (int));
       for (tile = 0; tile <  1U << tiling->exponent; tile++)
       {
-	 locate_subimage (image_level, image_level - tiling->exponent, tile,
-			  &x0, &y0, &width, &height);
-	 if (x0 < image_width && y0 < image_height)
-	    tiling->vorder [tile] = get_bits (input, tiling->exponent);
-	 else
-	    tiling->vorder [tile] = -1;
+         locate_subimage (image_level, image_level - tiling->exponent, tile,
+                          &x0, &y0, &width, &height);
+         if (x0 < image_width && y0 < image_height)
+            tiling->vorder [tile] = get_bits (input, tiling->exponent);
+         else
+            tiling->vorder [tile] = -1;
       }
    }
-   else					/* spiral order */
+   else                                 /* spiral order */
    {
       tiling->vorder = Calloc (1 << tiling->exponent, sizeof (int));
       compute_spiral (tiling->vorder, image_width, image_height,
-		      tiling->exponent, get_bit (input) ? YES : NO);
+                      tiling->exponent, get_bit (input) ? YES : NO);
    }
 }
 
diff --git a/converter/other/fiasco/input/read.h b/converter/other/fiasco/input/read.h
index 1f59f103..f41cb874 100644
--- a/converter/other/fiasco/input/read.h
+++ b/converter/other/fiasco/input/read.h
@@ -1,8 +1,8 @@
 /*
  *  read.h
  *
- *  Written by:		Ullrich Hafner
- *  
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/input/tree.c b/converter/other/fiasco/input/tree.c
index 74ceeb68..8d81ae1b 100644
--- a/converter/other/fiasco/input/tree.c
+++ b/converter/other/fiasco/input/tree.c
@@ -1,7 +1,7 @@
 /*
- *  tree.c:		Input of bintree partitioning
+ *  tree.c:             Input of bintree partitioning
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -30,22 +30,22 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static unsigned
 restore_depth_first_order (unsigned src_state, unsigned level, unsigned x,
-			   unsigned y, unsigned *dst_state,
-			   word_t (*bfo_tree)[MAXLABELS],
-			   wfa_t *wfa, tiling_t *tiling);
+                           unsigned y, unsigned *dst_state,
+                           word_t (*bfo_tree)[MAXLABELS],
+                           wfa_t *wfa, tiling_t *tiling);
 static void
 decode_tree (bitfile_t *input, byte_t *data, unsigned n_data, unsigned scaling,
-	     u_word_t sum0, u_word_t sum1);
+             u_word_t sum0, u_word_t sum1);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -58,12 +58,12 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input)
  *  No return value.
  *
  *  Side effects:
- *	'wfa->tree', 'wfa->x', 'wfa->y', 'wfa->level_of_state'
+ *      'wfa->tree', 'wfa->x', 'wfa->y', 'wfa->level_of_state'
  *      are filled with decoded values.
  */
 {
-   byte_t *bitstring;			/* the encoded data */
-   word_t (*bfo_tree)[MAXLABELS];	/* node numbers in BFO */
+   byte_t *bitstring;                   /* the encoded data */
+   word_t (*bfo_tree)[MAXLABELS];       /* node numbers in BFO */
 
    /*
     *  Read WFA tree stored in breadth first order
@@ -80,15 +80,15 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input)
     *  Generate tree using a breadth first traversal
     */
    {
-      unsigned 	next;			/* next free node number of the tree */
-      unsigned 	state;
-      unsigned 	label;
-      byte_t   *buffer = bitstring;	/* pointer to decoded data */
+      unsigned  next;                   /* next free node number of the tree */
+      unsigned  state;
+      unsigned  label;
+      byte_t   *buffer = bitstring;     /* pointer to decoded data */
 
       bfo_tree = Calloc (wfa->states * MAXLABELS, sizeof (word_t));
       for (state = 0, next = 1; state < next; state++)
-	 for (label = 0; label < MAXLABELS; label++)
-	    bfo_tree [state][label] = *buffer++ ? next++ : RANGE;
+         for (label = 0; label < MAXLABELS; label++)
+            bfo_tree [state][label] = *buffer++ ? next++ : RANGE;
    }
 
    /*
@@ -98,9 +98,9 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input)
       unsigned dst_state = wfa->basis_states;
 
       wfa->root_state
-	 = restore_depth_first_order (0, (wfa->wfainfo->level
-					  + (wfa->wfainfo->color ? 2 : 0)),
-				      0, 0, &dst_state, bfo_tree, wfa, tiling);
+         = restore_depth_first_order (0, (wfa->wfainfo->level
+                                          + (wfa->wfainfo->color ? 2 : 0)),
+                                      0, 0, &dst_state, bfo_tree, wfa, tiling);
    }
 
    Free (bitstring);
@@ -109,15 +109,15 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static unsigned
 restore_depth_first_order (unsigned src_state, unsigned level, unsigned x,
-			   unsigned y, unsigned *dst_state,
-			   word_t (*bfo_tree)[MAXLABELS],
-			   wfa_t *wfa, tiling_t *tiling)
+                           unsigned y, unsigned *dst_state,
+                           word_t (*bfo_tree)[MAXLABELS],
+                           wfa_t *wfa, tiling_t *tiling)
 /*
  *  Map state 'src_state' (breadth first order)
  *  to state '*dst_state' (depth first order)
@@ -127,17 +127,17 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x,
  *  of size 'image_level'. 'tiling' defines the image partitioning.
  *
  *  Return value:
- *	new node number in depth first order
+ *      new node number in depth first order
  *
  *  Side effects:
- *	'wfa->tree', 'wfa->x', 'wfa->y', 'wfa->level_of_state'
+ *      'wfa->tree', 'wfa->x', 'wfa->y', 'wfa->level_of_state'
  *      are filled with decoded values.
  */
 {
-   unsigned newx [MAXLABELS];		/* x coordinate of children */
-   unsigned newy [MAXLABELS];		/* y coordinate of children */
-   unsigned x0, y0;			/* NW corner of image tile */
-   unsigned width, height;		/* size of image tile */
+   unsigned newx [MAXLABELS];           /* x coordinate of children */
+   unsigned newy [MAXLABELS];           /* y coordinate of children */
+   unsigned x0, y0;                     /* NW corner of image tile */
+   unsigned width, height;              /* size of image tile */
 
    /*
     *  If tiling is performed then replace current coordinates
@@ -148,14 +148,14 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x,
 
       for (tile = 0; tile < 1U << tiling->exponent; tile++)
       {
-	 locate_subimage (wfa->wfainfo->level, level, tile,
-			  &x0, &y0, &width, &height);
-	 if (x0 == x && y0 == y) /* matched ! */
-	 {
-	    locate_subimage (wfa->wfainfo->level, level, tiling->vorder[tile],
-			     &x, &y, &width, &height);
-	    break;
-	 }
+         locate_subimage (wfa->wfainfo->level, level, tile,
+                          &x0, &y0, &width, &height);
+         if (x0 == x && y0 == y) /* matched ! */
+         {
+            locate_subimage (wfa->wfainfo->level, level, tiling->vorder[tile],
+                             &x, &y, &width, &height);
+            break;
+         }
       }
    }
    /*
@@ -175,24 +175,24 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x,
     *  Remap node numbers
     */
    {
-      int      child [MAXLABELS];	/* children of current node (state) */
-      int      domain;			/* current domain */
+      int      child [MAXLABELS];       /* children of current node (state) */
+      int      domain;                  /* current domain */
       unsigned label;
 
       for (label = 0; label < MAXLABELS; label++)
-	 if (!isrange (domain = bfo_tree [src_state][label]))
-	    child [label] = restore_depth_first_order (domain, level - 1,
-						       newx [label],
-						       newy [label], dst_state,
-						       bfo_tree, wfa, tiling);
-	 else
-	    child [label] = RANGE;
+         if (!isrange (domain = bfo_tree [src_state][label]))
+            child [label] = restore_depth_first_order (domain, level - 1,
+                                                       newx [label],
+                                                       newy [label], dst_state,
+                                                       bfo_tree, wfa, tiling);
+         else
+            child [label] = RANGE;
 
       for (label = 0; label < MAXLABELS; label++)
       {
-	 wfa->tree [*dst_state][label] = child [label];
-	 wfa->x [*dst_state][label]    = newx [label];
-	 wfa->y [*dst_state][label]    = newy [label];
+         wfa->tree [*dst_state][label] = child [label];
+         wfa->x [*dst_state][label]    = newx [label];
+         wfa->y [*dst_state][label]    = newy [label];
       }
       wfa->level_of_state [*dst_state] = level;
    }
@@ -208,26 +208,26 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x,
 
 static void
 decode_tree (bitfile_t *input, byte_t *data, unsigned n_data, unsigned scaling,
-	     u_word_t sum0, u_word_t sum1)
+             u_word_t sum0, u_word_t sum1)
 /*
  *  Decode bintree partitioning using adaptive binary arithmetic decoding.
- *  'input'	input stream,
- *  'data'	buffer for decoded szmbols,
- *  'n_data'	number of symbols to decode,
- *  'scaling'	rescale probability models if range > 'scaling'
- *  'sum0'	initial totals of symbol '0'
- *  'sum1'	initial totals of symbol '1'
+ *  'input'     input stream,
+ *  'data'      buffer for decoded szmbols,
+ *  'n_data'    number of symbols to decode,
+ *  'scaling'   rescale probability models if range > 'scaling'
+ *  'sum0'      initial totals of symbol '0'
+ *  'sum1'      initial totals of symbol '1'
  *
  *  No return value.
  *
  *  Side effects:
- *	'data []' is filled with the decoded bitstring
+ *      'data []' is filled with the decoded bitstring
  */
 {
-   u_word_t code;			/* The present input code value */
-   u_word_t low;			/* Start of the current code range */
-   u_word_t high;			/* End of the current code range */
-   unsigned n;				/* Data counter */
+   u_word_t code;                       /* The present input code value */
+   u_word_t low;                        /* Start of the current code range */
+   u_word_t high;                       /* End of the current code range */
+   unsigned n;                          /* Data counter */
 
    assert (data);
 
@@ -237,64 +237,64 @@ decode_tree (bitfile_t *input, byte_t *data, unsigned n_data, unsigned scaling,
 
    for (n = n_data; n; n--)
    {
-      unsigned count;			/* Current interval count */
-      unsigned range;			/* Current interval range */
+      unsigned count;                   /* Current interval count */
+      unsigned range;                   /* Current interval range */
 
       count = (((code - low) + 1) * sum1 - 1) / ((high - low) + 1);
       if (count < sum0)
       {
-	 /*
-	  *  Decode a '0' symbol
-	  *  First, the range is expanded to account for the symbol removal.
-	  */
-	 range = (high - low) + 1;
-	 high = low + (u_word_t) ((range * sum0) / sum1 - 1 );
-
-	 RESCALE_INPUT_INTERVAL;
-
-	 *data++ = 0;
-	 /*
-	  *  Update the frequency counts
-	  */
-	 sum0++;
-	 sum1++;
-	 if (sum1 > scaling) /* scale the symbol frequencies */
-	 {
-	    sum0 >>= 1;
-	    sum1 >>= 1;
-	    if (!sum0)
-	       sum0 = 1;
-	    if (sum0 >= sum1)
-	       sum1 = sum0 + 1;
-	 }
+         /*
+          *  Decode a '0' symbol
+          *  First, the range is expanded to account for the symbol removal.
+          */
+         range = (high - low) + 1;
+         high = low + (u_word_t) ((range * sum0) / sum1 - 1 );
+
+         RESCALE_INPUT_INTERVAL;
+
+         *data++ = 0;
+         /*
+          *  Update the frequency counts
+          */
+         sum0++;
+         sum1++;
+         if (sum1 > scaling) /* scale the symbol frequencies */
+         {
+            sum0 >>= 1;
+            sum1 >>= 1;
+            if (!sum0)
+               sum0 = 1;
+            if (sum0 >= sum1)
+               sum1 = sum0 + 1;
+         }
 
       }
       else
       {
-	 /*
-	  *  Decode a '1' symbol
-	  *  First, the range is expanded to account for the symbol removal.
-	  */
-	 range = (high - low) + 1;
-	 high = low + (u_word_t) ((range * sum1) / sum1 - 1);
-	 low  = low + (u_word_t) ((range * sum0) / sum1);
-
-	 RESCALE_INPUT_INTERVAL;
-
-	 *data++ = 1;
-	 /*
-	  *  Update the frequency counts
-	  */
-	 sum1++;
-	 if (sum1 > scaling) /* scale the symbol frequencies */
-	 {
-	    sum0 >>= 1;
-	    sum1 >>= 1;
-	    if (!sum0)
-	       sum0 = 1;
-	    if (sum0 >= sum1)
-	       sum1 = sum0 + 1;
-	 }
+         /*
+          *  Decode a '1' symbol
+          *  First, the range is expanded to account for the symbol removal.
+          */
+         range = (high - low) + 1;
+         high = low + (u_word_t) ((range * sum1) / sum1 - 1);
+         low  = low + (u_word_t) ((range * sum0) / sum1);
+
+         RESCALE_INPUT_INTERVAL;
+
+         *data++ = 1;
+         /*
+          *  Update the frequency counts
+          */
+         sum1++;
+         if (sum1 > scaling) /* scale the symbol frequencies */
+         {
+            sum0 >>= 1;
+            sum1 >>= 1;
+            if (!sum0)
+               sum0 = 1;
+            if (sum0 >= sum1)
+               sum1 = sum0 + 1;
+         }
       }
    }
    INPUT_BYTE_ALIGN (input);
diff --git a/converter/other/fiasco/input/tree.h b/converter/other/fiasco/input/tree.h
index f743ee98..31b73fa5 100644
--- a/converter/other/fiasco/input/tree.h
+++ b/converter/other/fiasco/input/tree.h
@@ -1,8 +1,8 @@
 /*
  *  tree.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/input/weights.c b/converter/other/fiasco/input/weights.c
index 8a1e8899..debf38ad 100644
--- a/converter/other/fiasco/input/weights.c
+++ b/converter/other/fiasco/input/weights.c
@@ -2,7 +2,7 @@
  *  weights.c:          Input of weights
  *
  *  Written by:         Ullrich Hafner
- *              
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -32,7 +32,7 @@
 /*****************************************************************************
 
                                 public code
-  
+
 *****************************************************************************/
 
 void
@@ -55,7 +55,7 @@ read_weights (unsigned total, wfa_t *wfa, bitfile_t *input)
    unsigned         offset1, offset2;   /* prob. model offsets. */
    unsigned         offset3, offset4;   /* prob. model offsets. */
    bool_t           delta_approx = NO;  /* true if delta has been used */
-   
+
    /*
     *  Check whether delta approximation has been used
     */
@@ -65,7 +65,7 @@ read_weights (unsigned total, wfa_t *wfa, bitfile_t *input)
          delta_approx = YES;
          break;
       }
-  
+
    /*
     *  Generate array of corresponding levels (context of probability model)
     */
@@ -82,7 +82,7 @@ read_weights (unsigned total, wfa_t *wfa, bitfile_t *input)
       min_level = d_min_level = MAXLEVEL;
       max_level = d_max_level = 0;
       dc        = d_dc     = NO;
-   
+
       for (state = wfa->basis_states; state < wfa->states; state++)
           for (label = 0; label < MAXLABELS; label++)
               if (isrange (wfa->tree [state][label]))
@@ -156,7 +156,7 @@ read_weights (unsigned total, wfa_t *wfa, bitfile_t *input)
          c_symbols [i] = 1 << (wfa->wfainfo->rpf->mantissa_bits + 1);
       for (; i < offset4; i++)
          c_symbols [i] = 1 << (wfa->wfainfo->d_rpf->mantissa_bits + 1);
-      
+
       weights_array = decode_array (input, level_array, c_symbols,
                                     offset4, total, scale);
       Free (c_symbols);
@@ -198,7 +198,7 @@ read_weights (unsigned total, wfa_t *wfa, bitfile_t *input)
                      = wfa->weight [state][label][edge] * 512 + 0.5;
                }
    }
-   
+
    Free (weights_array);
 }
- 
+
diff --git a/converter/other/fiasco/input/weights.h b/converter/other/fiasco/input/weights.h
index 36cea5c2..4a6bdf0a 100644
--- a/converter/other/fiasco/input/weights.h
+++ b/converter/other/fiasco/input/weights.h
@@ -1,8 +1,8 @@
 /*
  *  weights.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/lib/arith.c b/converter/other/fiasco/lib/arith.c
index e61e753e..7fac0c6d 100644
--- a/converter/other/fiasco/lib/arith.c
+++ b/converter/other/fiasco/lib/arith.c
@@ -1,7 +1,7 @@
 /*
- *  arith.c:		Adaptive arithmetic coding and decoding
+ *  arith.c:            Adaptive arithmetic coding and decoding
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -26,7 +26,7 @@
 
 /******************************************************************************
 
-				public code
+                                public code
 
 ******************************************************************************/
 
@@ -37,7 +37,7 @@ alloc_encoder (bitfile_t *output)
  *  Initialize the arithmetic coder.
  *
  *  Return value:
- *	A pointer to the new coder structure
+ *      A pointer to the new coder structure
  */
 {
    arith_t *arith = Calloc (1, sizeof (arith_t));
@@ -47,7 +47,7 @@ alloc_encoder (bitfile_t *output)
    arith->low       = LOW;
    arith->high      = HIGH;
    arith->underflow = 0;
-   arith->file 	    = output;
+   arith->file      = output;
 
    return arith;
 }
@@ -62,9 +62,9 @@ free_encoder (arith_t *arith)
  *  No return value.
  */
 {
-   u_word_t   low;			/* start of the current code range  */
-   u_word_t   high;			/* end of the current code range    */
-   u_word_t   underflow;		/* number of underflow bits pending */
+   u_word_t   low;                      /* start of the current code range  */
+   u_word_t   high;                     /* end of the current code range    */
+   u_word_t   underflow;                /* number of underflow bits pending */
    bitfile_t *output;
 
    assert (arith);
@@ -94,22 +94,22 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model)
  *  symbol counts are rescaled).
  *
  *  Return value:
- *	information content of the encoded symbol.
+ *      information content of the encoded symbol.
  *
  *  Side effects:
- *	'model' is updated (probability distribution)
- *	'arith' is updated (coder state)
+ *      'model' is updated (probability distribution)
+ *      'arith' is updated (coder state)
  */
 {
-   u_word_t   low_count;		/* lower bound of 'symbol' interval */
-   u_word_t   high_count;		/* upper bound of 'symbol' interval */
-   u_word_t   scale;			/* range of all 'm' symbol intervals */
-   unsigned   range;			/* range of current interval */
-   unsigned   index;			/* index of probability model */
-   u_word_t   low;			/* start of the current code range  */
-   u_word_t   high;			/* end of the current code range    */
-   u_word_t   underflow;		/* number of underflow bits pending */
-   bitfile_t *output;			/* output file */
+   u_word_t   low_count;                /* lower bound of 'symbol' interval */
+   u_word_t   high_count;               /* upper bound of 'symbol' interval */
+   u_word_t   scale;                    /* range of all 'm' symbol intervals */
+   unsigned   range;                    /* range of current interval */
+   unsigned   index;                    /* index of probability model */
+   u_word_t   low;                      /* start of the current code range  */
+   u_word_t   high;                     /* end of the current code range    */
+   u_word_t   underflow;                /* number of underflow bits pending */
+   bitfile_t *output;                   /* output file */
 
    assert (model && arith);
 
@@ -123,28 +123,28 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model)
 
    assert (high > low);
 
-   if (model->order > 0)		/* order-'n' model*/
+   if (model->order > 0)                /* order-'n' model*/
    {
-      unsigned power;			/* multiplicator */
+      unsigned power;                   /* multiplicator */
       unsigned i;
 
       /*
        *  Compute index of the probability model to use.
        *  See init_model() for more details.
        */
-      power = 1;			/* multiplicator */
-      index = 0;			/* address of prob. model */
+      power = 1;                        /* multiplicator */
+      index = 0;                        /* address of prob. model */
 
       for (i = 0; i < model->order; i++) /* generate a M-nary number */
       {
-	 index += model->context [i] * power;
-	 power *= model->symbols;
+         index += model->context [i] * power;
+         power *= model->symbols;
       }
 
-      index *= model->symbols + 1;	/* we need space for M + 1 elements */
+      index *= model->symbols + 1;      /* we need space for M + 1 elements */
 
       for (i = 0; i < model->order - 1; i++)
-	 model->context [i] = model->context [i + 1];
+         model->context [i] = model->context [i + 1];
       model->context [i] = symbol;
    }
    else
@@ -163,7 +163,7 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model)
 
    RESCALE_OUTPUT_INTERVAL;
 
-   if (model->scale > 0)		/* adaptive model */
+   if (model->scale > 0)                /* adaptive model */
    {
       unsigned i;
 
@@ -171,23 +171,23 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model)
        *  Update probability model
        */
       for (i = symbol + 1; i <= model->symbols; i++)
-	 model->totals [index + i]++;
+         model->totals [index + i]++;
       if (model->totals [index + model->symbols] > model->scale) /* scaling */
       {
-	 for (i = 1; i <= model->symbols; i++)
-	 {
-	    model->totals [index + i] >>= 1;
-	    if (model->totals [index + i] <= model->totals [index + i - 1])
-	       model->totals [index + i] = model->totals [index + i - 1] + 1;
-	 }
+         for (i = 1; i <= model->symbols; i++)
+         {
+            model->totals [index + i] >>= 1;
+            if (model->totals [index + i] <= model->totals [index + i - 1])
+               model->totals [index + i] = model->totals [index + i - 1] + 1;
+         }
       }
    }
 
    /*
     *  Store interval values
     */
-   arith->low  	    = low;
-   arith->high 	    = high;
+   arith->low       = low;
+   arith->high      = high;
    arith->underflow = underflow;
 
    return - log2 ((high_count - low_count) / (real_t) scale);
@@ -195,8 +195,8 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model)
 
 void
 encode_array (bitfile_t *output, const unsigned *data, const unsigned *context,
-	      const unsigned *c_symbols, unsigned n_context, unsigned n_data,
-	      unsigned scaling)
+              const unsigned *c_symbols, unsigned n_context, unsigned n_data,
+              unsigned scaling)
 /*
  *  Arithmetic coding of #'n_data' symbols given in the array 'data'.
  *  If 'n_context' > 1 then a number (context [n]) is assigned to every
@@ -207,10 +207,10 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context,
  *  No return value.
  */
 {
-   u_word_t **totals;			/* probability model */
+   u_word_t **totals;                   /* probability model */
 
    if (!n_context)
-      n_context = 1;			/* always use one context */
+      n_context = 1;                    /* always use one context */
 
    assert (output && c_symbols && data);
    assert (n_context == 1 || context);
@@ -224,13 +224,13 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context,
 
       for (c = 0; c < n_context; c++)
       {
-	 unsigned i;
+         unsigned i;
 
-	 totals [c]    = Calloc (c_symbols [c] + 1, sizeof (u_word_t));
-	 totals [c][0] = 0;
+         totals [c]    = Calloc (c_symbols [c] + 1, sizeof (u_word_t));
+         totals [c][0] = 0;
 
-	 for (i = 0; i < c_symbols [c]; i++)
-	    totals [c][i + 1] = totals [c][i] + 1;
+         for (i = 0; i < c_symbols [c]; i++)
+            totals [c][i + 1] = totals [c][i] + 1;
       }
    }
 
@@ -238,52 +238,52 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context,
     *  Encode array elements
     */
    {
-      u_word_t low  	 = 0;		/* Start of the current code range */
-      u_word_t high 	 = 0xffff;	/* End of the current code range */
-      u_word_t underflow = 0;		/* Number of underflow bits pending */
+      u_word_t low       = 0;           /* Start of the current code range */
+      u_word_t high      = 0xffff;      /* End of the current code range */
+      u_word_t underflow = 0;           /* Number of underflow bits pending */
       unsigned n;
 
       for (n = 0; n < n_data; n++)
       {
-	 u_word_t low_count;		/* lower bound of 'symbol' interval */
-	 u_word_t high_count;		/* upper bound of 'symbol' interval */
-	 u_word_t scale;		/* range of all 'm' symbol intervals */
-	 unsigned range;		/* current range */
-	 int	  d;			/* current data symbol */
-	 int	  c;			/* context of current data symbol */
-
-	 d = data [n];
-	 c = n_context > 1 ? context [n] : 0;
-
-	 scale	    = totals [c][c_symbols [c]];
-	 low_count  = totals [c][d];
-	 high_count = totals [c][d + 1];
-
-	 /*
-	  * Rescale high and low for the new symbol.
-	  */
-	 range = (high - low) + 1;
-	 high  = low + (u_word_t) ((range * high_count) / scale - 1);
-	 low   = low + (u_word_t) ((range * low_count) / scale);
-	 RESCALE_OUTPUT_INTERVAL;
-
-	 /*
-	  *  Update probability models
-	  */
-	 {
-	    unsigned i;
-
-	    for (i = d + 1; i < c_symbols [c] + 1; i++)
-	       totals [c][i]++;
-
-	    if (totals [c][c_symbols [c]] > scaling) /* scaling */
-	       for (i = 1; i < c_symbols [c] + 1; i++)
-	       {
-		  totals [c][i] >>= 1;
-		  if (totals [c][i] <= totals [c][i - 1])
-		     totals [c][i] = totals [c][i - 1] + 1;
-	       }
-	 }
+         u_word_t low_count;            /* lower bound of 'symbol' interval */
+         u_word_t high_count;           /* upper bound of 'symbol' interval */
+         u_word_t scale;                /* range of all 'm' symbol intervals */
+         unsigned range;                /* current range */
+         int      d;                    /* current data symbol */
+         int      c;                    /* context of current data symbol */
+
+         d = data [n];
+         c = n_context > 1 ? context [n] : 0;
+
+         scale      = totals [c][c_symbols [c]];
+         low_count  = totals [c][d];
+         high_count = totals [c][d + 1];
+
+         /*
+          * Rescale high and low for the new symbol.
+          */
+         range = (high - low) + 1;
+         high  = low + (u_word_t) ((range * high_count) / scale - 1);
+         low   = low + (u_word_t) ((range * low_count) / scale);
+         RESCALE_OUTPUT_INTERVAL;
+
+         /*
+          *  Update probability models
+          */
+         {
+            unsigned i;
+
+            for (i = d + 1; i < c_symbols [c] + 1; i++)
+               totals [c][i]++;
+
+            if (totals [c][c_symbols [c]] > scaling) /* scaling */
+               for (i = 1; i < c_symbols [c] + 1; i++)
+               {
+                  totals [c][i] >>= 1;
+                  if (totals [c][i] <= totals [c][i - 1])
+                     totals [c][i] = totals [c][i - 1] + 1;
+               }
+         }
       }
       /*
        *  Flush arithmetic encoder
@@ -299,7 +299,7 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context,
    {
       unsigned c;
       for (c = 0; c < n_context; c++)
-	 Free (totals [c]);
+         Free (totals [c]);
       Free (totals);
    }
 }
@@ -312,7 +312,7 @@ alloc_decoder (bitfile_t *input)
  *  16 input bits from the stream 'input'.
  *
  *  Return value:
- *	A pointer to the new decoder structure
+ *      A pointer to the new decoder structure
  */
 
 {
@@ -338,7 +338,7 @@ free_decoder (arith_t *arith)
  *  No return value.
  *
  *  Side effects:
- *	structure 'arith' is discarded.
+ *      structure 'arith' is discarded.
  */
 {
    assert (arith);
@@ -357,22 +357,22 @@ decode_symbol (arith_t *arith, model_t *model)
  *  decoding the symbol (if necessary also rescale the symbol counts).
  *
  *  Return value:
- *	decoded symbol
+ *      decoded symbol
  *
  *  Side effects:
- *	'model' is updated (probability distribution)
- *	'arith' is updated (decoder state)
+ *      'model' is updated (probability distribution)
+ *      'arith' is updated (decoder state)
  */
 {
-   unsigned   range;			/* range of current interval */
-   unsigned   count;			/* value in the current interval */
-   unsigned   index;			/* index of probability model */
-   unsigned   symbol;			/* decoded symbol */
-   u_word_t   scale;			/* range of all 'm' symbol intervals */
-   u_word_t   low;			/* start of the current code range  */
-   u_word_t   high;			/* end of the current code range    */
-   u_word_t   code;			/* the present input code value */
-   bitfile_t *input;			/* input file */
+   unsigned   range;                    /* range of current interval */
+   unsigned   count;                    /* value in the current interval */
+   unsigned   index;                    /* index of probability model */
+   unsigned   symbol;                   /* decoded symbol */
+   u_word_t   scale;                    /* range of all 'm' symbol intervals */
+   u_word_t   low;                      /* start of the current code range  */
+   u_word_t   high;                     /* end of the current code range    */
+   u_word_t   code;                     /* the present input code value */
+   bitfile_t *input;                    /* input file */
 
    assert (arith && model);
 
@@ -386,25 +386,25 @@ decode_symbol (arith_t *arith, model_t *model)
 
    assert (high > low);
 
-   if (model->order > 0)		/* order-'n' model */
+   if (model->order > 0)                /* order-'n' model */
    {
-      unsigned power;			/* multiplicator */
+      unsigned power;                   /* multiplicator */
       unsigned i;
 
       /*
        *  Compute index of the probability model to use.
        *  See init_model() for more details.
        */
-      power = 1;			/* multiplicator */
-      index = 0;			/* address of prob. model */
+      power = 1;                        /* multiplicator */
+      index = 0;                        /* address of prob. model */
 
       for (i = 0; i < model->order; i++) /* generate a m-nary number */
       {
-	 index += model->context[i] * power;
-	 power *= model->symbols;
+         index += model->context[i] * power;
+         power *= model->symbols;
       }
 
-      index *= model->symbols + 1;	/* we need space for m + 1 elements */
+      index *= model->symbols + 1;      /* we need space for m + 1 elements */
    }
    else
       index = 0;
@@ -414,15 +414,15 @@ decode_symbol (arith_t *arith, model_t *model)
    count = ((code - low + 1) * scale - 1) / range;
 
    for (symbol = model->symbols; count < model->totals [index + symbol];
-	symbol--)
+        symbol--)
       ;
 
-   if (model->order > 0)		/* order-'n' model */
+   if (model->order > 0)                /* order-'n' model */
    {
       unsigned i;
 
       for (i = 0; i < model->order - 1; i++)
-	 model->context [i] = model->context [i + 1];
+         model->context [i] = model->context [i + 1];
       model->context [i] = symbol;
    }
 
@@ -430,8 +430,8 @@ decode_symbol (arith_t *arith, model_t *model)
     *  Compute interval boundaries
     */
    {
-      u_word_t low_count;		/* lower bound of 'symbol' interval */
-      u_word_t high_count;		/* upper bound of 'symbol' interval */
+      u_word_t low_count;               /* lower bound of 'symbol' interval */
+      u_word_t high_count;              /* upper bound of 'symbol' interval */
 
       low_count  = model->totals [index + symbol];
       high_count = model->totals [index + symbol + 1];
@@ -441,7 +441,7 @@ decode_symbol (arith_t *arith, model_t *model)
 
    RESCALE_INPUT_INTERVAL;
 
-   if (model->scale > 0)		/* adaptive model */
+   if (model->scale > 0)                /* adaptive model */
    {
       unsigned i;
 
@@ -449,15 +449,15 @@ decode_symbol (arith_t *arith, model_t *model)
        *  Update probability model
        */
       for (i = symbol + 1; i <= model->symbols; i++)
-	 model->totals [index + i]++;
+         model->totals [index + i]++;
       if (model->totals [index + model->symbols] > model->scale) /* scaling */
       {
-	 for (i = 1; i <= model->symbols; i++)
-	 {
-	    model->totals [index + i] >>= 1;
-	    if (model->totals [index + i] <= model->totals [index + i - 1])
-	       model->totals [index + i] = model->totals [index + i - 1] + 1;
-	 }
+         for (i = 1; i <= model->symbols; i++)
+         {
+            model->totals [index + i] >>= 1;
+            if (model->totals [index + i] <= model->totals [index + i - 1])
+               model->totals [index + i] = model->totals [index + i - 1] + 1;
+         }
       }
    }
 
@@ -473,8 +473,8 @@ decode_symbol (arith_t *arith, model_t *model)
 
 unsigned *
 decode_array (bitfile_t *input, const unsigned *context,
-	      const unsigned *c_symbols, unsigned n_context,
-	      unsigned n_data, unsigned scaling)
+              const unsigned *c_symbols, unsigned n_context,
+              unsigned n_data, unsigned scaling)
 /*
  *  Arithmetic decoding of #'n_data' symbols.
  *  If 'n_context' > 1 then a number (context [n]) is assigned to every
@@ -483,14 +483,14 @@ decode_array (bitfile_t *input, const unsigned *context,
  *  Rescale probability models if range > 'scaling'.
  *
  *  Return value:
- *	pointer to array containing the decoded symbols
+ *      pointer to array containing the decoded symbols
  */
 {
-   unsigned  *data;			/* array to store decoded symbols */
-   u_word_t **totals;			/* probability model */
+   unsigned  *data;                     /* array to store decoded symbols */
+   u_word_t **totals;                   /* probability model */
 
    if (n_context < 1)
-      n_context = 1;			/* always use one context */
+      n_context = 1;                    /* always use one context */
    assert (input && c_symbols);
    assert (n_context == 1 || context);
 
@@ -505,13 +505,13 @@ decode_array (bitfile_t *input, const unsigned *context,
 
       for (c = 0; c < n_context; c++)
       {
-	 unsigned i;
+         unsigned i;
 
-	 totals [c]    = Calloc (c_symbols [c] + 1, sizeof (u_word_t));
-	 totals [c][0] = 0;
+         totals [c]    = Calloc (c_symbols [c] + 1, sizeof (u_word_t));
+         totals [c][0] = 0;
 
-	 for (i = 0; i < c_symbols [c]; i++)
-	    totals [c][i + 1] = totals [c][i] + 1;
+         for (i = 0; i < c_symbols [c]; i++)
+            totals [c][i + 1] = totals [c][i] + 1;
       }
    }
 
@@ -520,54 +520,54 @@ decode_array (bitfile_t *input, const unsigned *context,
     */
    {
       u_word_t code = get_bits (input, 16); /* The present input code value */
-      u_word_t low  = 0;		/* Start of the current code range */
-      u_word_t high = 0xffff;		/* End of the current code range */
+      u_word_t low  = 0;                /* Start of the current code range */
+      u_word_t high = 0xffff;           /* End of the current code range */
       unsigned n;
 
       for (n = 0; n < n_data; n++)
       {
-	 u_word_t scale;		/* range of all 'm' symbol intervals */
-	 u_word_t low_count;		/* lower bound of 'symbol' interval */
-	 u_word_t high_count;		/* upper bound of 'symbol' interval */
-	 unsigned count;		/* value in the current interval */
-	 unsigned range;		/* current interval range */
-	 unsigned d;			/* current data symbol */
-	 unsigned c;			/* context of current data symbol */
-
-	 c = n_context > 1 ? context [n] : 0;
-
-	 assert (high > low);
-	 scale = totals [c][c_symbols [c]];
-	 range = (high - low) + 1;
-	 count = (((code - low) + 1 ) * scale - 1) / range;
-
-	 for (d = c_symbols [c]; count < totals [c][d]; d--) /* next symbol */
-	    ;
-	 low_count  = totals [c][d];
-	 high_count = totals [c][d + 1];
-
-	 high = low + (u_word_t) ((range * high_count) / scale - 1 );
-	 low  = low + (u_word_t) ((range * low_count) / scale );
-	 RESCALE_INPUT_INTERVAL;
-
-	 /*
-	  *  Updata probability models
-	  */
-	 {
-	    unsigned i;
-
-	    for (i = d + 1; i < c_symbols [c] + 1; i++)
-	       totals [c][i]++;
-
-	    if (totals [c][c_symbols [c]] > scaling) /* scaling */
-	       for (i = 1; i < c_symbols [c] + 1; i++)
-	       {
-		  totals [c][i] >>= 1;
-		  if (totals [c][i] <= totals [c][i - 1])
-		     totals [c][i] = totals [c][i - 1] + 1;
-	       }
-	 }
-	 data [n] = d;
+         u_word_t scale;                /* range of all 'm' symbol intervals */
+         u_word_t low_count;            /* lower bound of 'symbol' interval */
+         u_word_t high_count;           /* upper bound of 'symbol' interval */
+         unsigned count;                /* value in the current interval */
+         unsigned range;                /* current interval range */
+         unsigned d;                    /* current data symbol */
+         unsigned c;                    /* context of current data symbol */
+
+         c = n_context > 1 ? context [n] : 0;
+
+         assert (high > low);
+         scale = totals [c][c_symbols [c]];
+         range = (high - low) + 1;
+         count = (((code - low) + 1 ) * scale - 1) / range;
+
+         for (d = c_symbols [c]; count < totals [c][d]; d--) /* next symbol */
+            ;
+         low_count  = totals [c][d];
+         high_count = totals [c][d + 1];
+
+         high = low + (u_word_t) ((range * high_count) / scale - 1 );
+         low  = low + (u_word_t) ((range * low_count) / scale );
+         RESCALE_INPUT_INTERVAL;
+
+         /*
+          *  Updata probability models
+          */
+         {
+            unsigned i;
+
+            for (i = d + 1; i < c_symbols [c] + 1; i++)
+               totals [c][i]++;
+
+            if (totals [c][c_symbols [c]] > scaling) /* scaling */
+               for (i = 1; i < c_symbols [c] + 1; i++)
+               {
+                  totals [c][i] >>= 1;
+                  if (totals [c][i] <= totals [c][i - 1])
+                     totals [c][i] = totals [c][i - 1] + 1;
+               }
+         }
+         data [n] = d;
       }
       INPUT_BYTE_ALIGN (input);
    }
@@ -579,7 +579,7 @@ decode_array (bitfile_t *input, const unsigned *context,
       unsigned c;
 
       for (c = 0; c < n_context; c++)
-	 Free (totals [c]);
+         Free (totals [c]);
       Free (totals);
    }
 
@@ -599,17 +599,17 @@ alloc_model (unsigned m, unsigned scale, unsigned n, unsigned *totals)
  *  the initial counts.
  *
  *  Return value:
- *	a pointer to the new probability model structure.
+ *      a pointer to the new probability model structure.
  *
  *  Note: We recommend a small size of the alphabet because no escape codes
  *  are used to encode/decode previously unseen symbols.
  *
  */
 {
-   model_t  *model;			/* new probability model */
-   unsigned  num;			/* number of contexts to allocate */
-   bool_t    cont;			/* continue flag */
-   bool_t    dec;			/* next order flag */
+   model_t  *model;                     /* new probability model */
+   unsigned  num;                       /* number of contexts to allocate */
+   bool_t    cont;                      /* continue flag */
+   bool_t    dec;                       /* next order flag */
    unsigned  i;
 
    /*
@@ -630,56 +630,56 @@ alloc_model (unsigned m, unsigned scale, unsigned n, unsigned *totals)
    model->totals = Calloc (num * (model->symbols + 1), sizeof (unsigned));
 
    for (i = 0; i < model->order; i++)
-      model->context[i] = 0;		/* start with context 0,0, .. ,0 */
+      model->context[i] = 0;            /* start with context 0,0, .. ,0 */
    cont = YES;
-   while (cont)				/* repeat while context != M ... M */
+   while (cont)                         /* repeat while context != M ... M */
    {
-      int	power;			/* multiplicator */
-      int	index;			/* index of probability model */
+      int       power;                  /* multiplicator */
+      int       index;                  /* index of probability model */
       /*
        *  There are m^n different contexts:
        *  Let "context_1 context_2 ... context_n symbol" be the current input
        *  stream then the index of the probability model is given by:
        *  index = context_1 * M^0 + context_2 * M^1 + ... + context_n * M^(n-1)
        */
-      power = 1;			/* multiplicator */
-      index = 0;			/* address of prob. model */
+      power = 1;                        /* multiplicator */
+      index = 0;                        /* address of prob. model */
 
-      for (i = 0; i < model->order; i++)	/* generate a m-nary number */
+      for (i = 0; i < model->order; i++)        /* generate a m-nary number */
       {
-	 index += model->context[i] * power;
-	 power *= model->symbols;
+         index += model->context[i] * power;
+         power *= model->symbols;
       }
 
-      index *= model->symbols + 1;	/* size of each model is m + 1 */
+      index *= model->symbols + 1;      /* size of each model is m + 1 */
 
-      model->totals [index + 0] = 0;	/* always zero */
+      model->totals [index + 0] = 0;    /* always zero */
 
       for (i = 1; i <= model->symbols; i++) /* prob of each symbol is 1/m or
-					       as given in totals */
-	 model->totals[index + i] = model->totals [index + i - 1]
-				    + (totals ? totals [i - 1] : 1);
-
-      if (model->order == 0)		/* order-0 model */
-	 cont = NO;
-      else				/* try next context */
-	 for (i = model->order - 1, dec = YES; dec; i--)
-	 {
-	    dec = NO;
-	    model->context[i]++;
-	    if (model->context[i] >= model->symbols)
-	    {
-	       /* change previous context */
-	       model->context[i] = 0;
-	       if (i > 0)		/* there's still a context remaining */
-		  dec = YES;
-	       else
-		  cont = NO;		/* all context models initialized */
-	    }
-	 }
+                                               as given in totals */
+         model->totals[index + i] = model->totals [index + i - 1]
+                                    + (totals ? totals [i - 1] : 1);
+
+      if (model->order == 0)            /* order-0 model */
+         cont = NO;
+      else                              /* try next context */
+         for (i = model->order - 1, dec = YES; dec; i--)
+         {
+            dec = NO;
+            model->context[i]++;
+            if (model->context[i] >= model->symbols)
+            {
+               /* change previous context */
+               model->context[i] = 0;
+               if (i > 0)               /* there's still a context remaining */
+                  dec = YES;
+               else
+                  cont = NO;            /* all context models initialized */
+            }
+         }
    }
    for (i = 0; i < model->order; i++)
-      model->context[i] = 0;		/* start with context 0,0, .. ,0 */
+      model->context[i] = 0;            /* start with context 0,0, .. ,0 */
 
    return model;
 }
@@ -693,13 +693,13 @@ free_model (model_t *model)
  *  No return value.
  *
  *  Side effects:
- *	struct 'model' is discarded
+ *      struct 'model' is discarded
  */
 {
    if (model != NULL)
    {
       if (model->context != NULL)
-	 Free (model->context);
+         Free (model->context);
       Free (model->totals);
       Free (model);
    }
diff --git a/converter/other/fiasco/lib/arith.h b/converter/other/fiasco/lib/arith.h
index 04297eb5..152dabab 100644
--- a/converter/other/fiasco/lib/arith.h
+++ b/converter/other/fiasco/lib/arith.h
@@ -20,24 +20,24 @@
 
 typedef struct model
 {
-   unsigned  symbols;			/* number of symbols in the alphabet */
-   unsigned  scale;			/* if totals > scale rescale totals */
-   unsigned  order;			/* order of the probability model */
-   unsigned *context;			/* context of the model */
-   unsigned *totals;			/* the totals */
+   unsigned  symbols;                   /* number of symbols in the alphabet */
+   unsigned  scale;                     /* if totals > scale rescale totals */
+   unsigned  order;                     /* order of the probability model */
+   unsigned *context;                   /* context of the model */
+   unsigned *totals;                    /* the totals */
 } model_t;
 
 typedef struct arith
 {
-   u_word_t   low;			/* start of the current code range */
-   u_word_t   high;			/* end of the current code range */
-   u_word_t   underflow;		/* number of underflow bits pending */
-   u_word_t   code;			/* the present input code value */
-   bitfile_t *file;			/* I/O stream */
+   u_word_t   low;                      /* start of the current code range */
+   u_word_t   high;                     /* end of the current code range */
+   u_word_t   underflow;                /* number of underflow bits pending */
+   u_word_t   code;                     /* the present input code value */
+   bitfile_t *file;                     /* I/O stream */
 } arith_t;
 
 enum interval {LOW = 0x0000, FIRST_QUARTER = 0x4000, HALF = 0x8000,
-	       THIRD_QUARTER = 0xc000, HIGH = 0xffff};
+               THIRD_QUARTER = 0xc000, HIGH = 0xffff};
 
 arith_t *
 alloc_encoder (bitfile_t *file);
@@ -47,8 +47,8 @@ real_t
 encode_symbol (unsigned symbol, arith_t *arith, model_t *model);
 void
 encode_array (bitfile_t *output, const unsigned *data, const unsigned *context,
-	      const unsigned *c_symbols, unsigned n_context, unsigned n_data,
-	      unsigned scaling);
+              const unsigned *c_symbols, unsigned n_context, unsigned n_data,
+              unsigned scaling);
 arith_t *
 alloc_decoder (bitfile_t *input);
 void
@@ -57,8 +57,8 @@ unsigned
 decode_symbol (arith_t *arith, model_t *model);
 unsigned *
 decode_array (bitfile_t *input, const unsigned *context,
-	      const unsigned *c_symbols, unsigned n_context,
-	      unsigned n_data, unsigned scaling);
+              const unsigned *c_symbols, unsigned n_context,
+              unsigned n_data, unsigned scaling);
 model_t *
 alloc_model (unsigned m, unsigned scale, unsigned n, unsigned *totals);
 void
@@ -67,7 +67,7 @@ free_model (model_t *model);
 #define RESCALE_INPUT_INTERVAL  for (;;)                                      \
                                    if ((high >= HALF) && (low < HALF) &&      \
                                       ((low & FIRST_QUARTER) != FIRST_QUARTER \
-				       || (high & FIRST_QUARTER) != 0))       \
+                                       || (high & FIRST_QUARTER) != 0))       \
                                    {                                          \
                                       break;                                  \
                                    }                                          \
@@ -88,8 +88,8 @@ free_model (model_t *model);
                                       high  |= HALF + 1;                      \
                                       code <<= 1;                             \
                                       code  += get_bit (input);               \
-                                   }                                          
-        								   
+                                   }
+
 #define RESCALE_OUTPUT_INTERVAL  for (;;)                                     \
                                  {                                            \
                                     if (high < HALF)                          \
@@ -116,7 +116,7 @@ free_model (model_t *model);
                                     high <<= 1;                               \
                                     high  |= 1;                               \
                                     low  <<= 1;                               \
-                                 }                                             
-					 
+                                 }
+
 #endif /* not _ARITH_H */
 
diff --git a/converter/other/fiasco/lib/bit-io.h b/converter/other/fiasco/lib/bit-io.h
index 08029824..6de7e396 100644
--- a/converter/other/fiasco/lib/bit-io.h
+++ b/converter/other/fiasco/lib/bit-io.h
@@ -1,7 +1,7 @@
 /*
  *  bit-io.h
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -27,14 +27,14 @@ typedef enum {READ_ACCESS, WRITE_ACCESS} openmode_e;
 
 typedef struct bitfile
 {
-   FILE	      *file;			/* associated filepointer */
-   char	      *filename;		/* corresponding filename */
-   byte_t     *buffer;			/* stream buffer */
-   byte_t     *ptr;			/* pointer to current buffer pos */
-   unsigned    bytepos;			/* current I/O byte */
-   unsigned    bitpos;			/* current I/O bit */
-   unsigned    bits_processed;		/* number of bits already processed */
-   openmode_e  mode;			/* access mode */
+   FILE       *file;                    /* associated filepointer */
+   char       *filename;                /* corresponding filename */
+   byte_t     *buffer;                  /* stream buffer */
+   byte_t     *ptr;                     /* pointer to current buffer pos */
+   unsigned    bytepos;                 /* current I/O byte */
+   unsigned    bitpos;                  /* current I/O bit */
+   unsigned    bits_processed;          /* number of bits already processed */
+   openmode_e  mode;                    /* access mode */
 } bitfile_t;
 
 FILE *
@@ -47,7 +47,7 @@ void
 put_bits (bitfile_t *bitfile, unsigned value, unsigned bits);
 bool_t
 get_bit (bitfile_t *bitfile);
-unsigned 
+unsigned
 get_bits (bitfile_t *bitfile, unsigned bits);
 void
 close_bitfile (bitfile_t *bitfile);
diff --git a/converter/other/fiasco/lib/dither.c b/converter/other/fiasco/lib/dither.c
index 669bb16c..c394f5ec 100644
--- a/converter/other/fiasco/lib/dither.c
+++ b/converter/other/fiasco/lib/dither.c
@@ -1,8 +1,8 @@
 /*
- *  dither.c:		Various dithering routines 	
+ *  dither.c:           Various dithering routines
+ *
+ *  Adapted by:         Ullrich Hafner
  *
- *  Adapted by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -10,17 +10,17 @@
 /*
  * Copyright (c) 1995 Erik Corry
  * All rights reserved.
- * 
+ *
  * Permission to use, copy, modify, and distribute this software and its
  * documentation for any purpose, without fee, and without written agreement is
  * hereby granted, provided that the above copyright notice and the following
  * two paragraphs appear in all copies of this software.
- * 
+ *
  * IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
  * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
  * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED
  * OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
@@ -52,25 +52,25 @@
 
 /*****************************************************************************
 
-				prototypes
-  
+                                prototypes
+
 *****************************************************************************/
 
-static int 
+static int
 display_16_bit (const struct fiasco_renderer *this, unsigned char *ximage,
-		const fiasco_image_t *fiasco_image);
+                const fiasco_image_t *fiasco_image);
 
-static int 
+static int
 display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage,
-		    const fiasco_image_t *fiasco_image);
+                    const fiasco_image_t *fiasco_image);
 
-static int 
+static int
 display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage,
-		    const fiasco_image_t *fiasco_image);
+                    const fiasco_image_t *fiasco_image);
 
-static int 
+static int
 display_32_bit (const struct fiasco_renderer *this, unsigned char *ximage,
-		const fiasco_image_t *fiasco_image);
+                const fiasco_image_t *fiasco_image);
 
 static int
 free_bits_at_bottom (unsigned long a);
@@ -80,26 +80,26 @@ number_of_bits_set (unsigned long a);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 fiasco_renderer_t *
 fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask,
-		     unsigned long blue_mask, unsigned bpp,
-		     int double_resolution)
+                     unsigned long blue_mask, unsigned bpp,
+                     int double_resolution)
 /*
  *  FIASCO renderer constructor.
  *  Allocate memory for the FIASCO renderer structure and
  *  initialize values.
  *  `red_mask', `green_mask', and `blue_mask' are the corresponding masks
- *  of the X11R6 XImage structure. 
+ *  of the X11R6 XImage structure.
  *  `bpp' gives the depth of the image in bits per pixel (16, 24, or 32).
  *  If `double_resolution' is not 0 the the image width and height is doubled.
  *  (fast pixel doubling, no interpolation!)
  *
  *  Return value:
- *	pointer to the new structure or NULL on error
+ *      pointer to the new structure or NULL on error
  */
 {
    if (bpp != 16 && bpp != 24 && bpp !=32)
@@ -111,30 +111,30 @@ fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask,
    {
       fiasco_renderer_t  *render    = calloc (1, sizeof (fiasco_renderer_t));
       renderer_private_t *private   = calloc (1, sizeof (renderer_private_t));
-      bool_t 	       	  twopixels = (bpp == 16 && double_resolution);
-      int 		  crval, cbval, i; /* counter */
+      bool_t              twopixels = (bpp == 16 && double_resolution);
+      int                 crval, cbval, i; /* counter */
 
       if (!render || !private)
       {
-	 set_error (_("Out of memory."));
-	 return NULL;
+         set_error (_("Out of memory."));
+         return NULL;
       }
       switch (bpp)
       {
-	 case 16:
-	    render->render = display_16_bit;
-	    break;
-	 case 24:
-	    if (red_mask > green_mask)
-	       render->render = display_24_bit_rgb;
-	    else
-	       render->render = display_24_bit_bgr;
-	    break;
-	 case 32:
-	    render->render = display_32_bit;
-	    break;
-	 default:
-	    break;			/* does not happen */
+         case 16:
+            render->render = display_16_bit;
+            break;
+         case 24:
+            if (red_mask > green_mask)
+               render->render = display_24_bit_rgb;
+            else
+               render->render = display_24_bit_bgr;
+            break;
+         case 32:
+            render->render = display_32_bit;
+            break;
+         default:
+            break;                      /* does not happen */
       }
       render->private = private;
       render->delete  = fiasco_renderer_delete;
@@ -146,42 +146,42 @@ fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask,
       private->Cb_b_tab = calloc (256 + 2 * 1024, sizeof (int));
 
       if (!private->Cr_r_tab || !private->Cr_g_tab
-	  || !private->Cb_b_tab || !private->Cb_g_tab)
+          || !private->Cb_b_tab || !private->Cb_g_tab)
       {
-	 set_error (_("Out of memory."));
-	 return NULL;
+         set_error (_("Out of memory."));
+         return NULL;
       }
-      
+
       for (i = 1024; i < 1024 + 256; i++)
       {
-	 cbval = crval  = i - 128 - 1024;
+         cbval = crval  = i - 128 - 1024;
 
-	 private->Cr_r_tab [i] =  1.4022 * crval + 0.5;
-	 private->Cr_g_tab [i] = -0.7145 * crval + 0.5;
-	 private->Cb_g_tab [i] = -0.3456 * cbval + 0.5; 
-	 private->Cb_b_tab [i] =  1.7710 * cbval + 0.5;
+         private->Cr_r_tab [i] =  1.4022 * crval + 0.5;
+         private->Cr_g_tab [i] = -0.7145 * crval + 0.5;
+         private->Cb_g_tab [i] = -0.3456 * cbval + 0.5;
+         private->Cb_b_tab [i] =  1.7710 * cbval + 0.5;
       }
       for (i = 0; i < 1024; i++)
       {
-	 private->Cr_r_tab [i] = private->Cr_r_tab [1024];
-	 private->Cr_g_tab [i] = private->Cr_g_tab [1024];
-	 private->Cb_g_tab [i] = private->Cb_g_tab [1024]; 
-	 private->Cb_b_tab [i] = private->Cb_b_tab [1024];
+         private->Cr_r_tab [i] = private->Cr_r_tab [1024];
+         private->Cr_g_tab [i] = private->Cr_g_tab [1024];
+         private->Cb_g_tab [i] = private->Cb_g_tab [1024];
+         private->Cb_b_tab [i] = private->Cb_b_tab [1024];
       }
       for (i = 1024 + 256; i < 2048 + 256; i++)
       {
-	 private->Cr_r_tab [i] = private->Cr_r_tab [1024 + 255];
-	 private->Cr_g_tab [i] = private->Cr_g_tab [1024 + 255];
-	 private->Cb_g_tab [i] = private->Cb_g_tab [1024 + 255]; 
-	 private->Cb_b_tab [i] = private->Cb_b_tab [1024 + 255];
+         private->Cr_r_tab [i] = private->Cr_r_tab [1024 + 255];
+         private->Cr_g_tab [i] = private->Cr_g_tab [1024 + 255];
+         private->Cb_g_tab [i] = private->Cb_g_tab [1024 + 255];
+         private->Cb_b_tab [i] = private->Cb_b_tab [1024 + 255];
       }
 
       private->Cr_r_tab += 1024 + 128;
       private->Cr_g_tab += 1024 + 128;
       private->Cb_g_tab += 1024 + 128;
       private->Cb_b_tab += 1024 + 128;
-   
-      /* 
+
+      /*
        *  Set up entries 0-255 in rgb-to-pixel value tables.
        */
       private->r_table = calloc (256 + 2 * 1024, sizeof (unsigned int));
@@ -190,38 +190,38 @@ fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask,
       private->y_table = calloc (256 + 2 * 1024, sizeof (unsigned int));
 
       if (!private->r_table || !private->g_table
-	  || !private->b_table || !private->y_table)
+          || !private->b_table || !private->y_table)
       {
-	 set_error (_("Out of memory."));
-	 return NULL;
+         set_error (_("Out of memory."));
+         return NULL;
       }
-      
+
       for (i = 0; i < 256; i++)
       {
-	 private->r_table [i + 1024]
-	    = i >> (8 - number_of_bits_set(red_mask));
-	 private->r_table [i + 1024]
-	    <<= free_bits_at_bottom (red_mask);
-	 private->g_table [i + 1024]
-	    = i >> (8 - number_of_bits_set (green_mask));
-	 private->g_table [i + 1024]
-	    <<= free_bits_at_bottom (green_mask);
-	 private->b_table [i + 1024]
-	    <<= free_bits_at_bottom (blue_mask);
-	 private->b_table [i + 1024]
-	    = i >> (8 - number_of_bits_set (blue_mask));
-	 if (twopixels)
-	 {
-	    private->r_table [i + 1024] = ((private->r_table [i + 1024] << 16)
-					   | private->r_table [i + 1024]);
-	    private->g_table [i + 1024] = ((private->g_table [i + 1024] << 16)
-					   | private->g_table [i + 1024]);
-	    private->b_table [i + 1024] = ((private->b_table [i + 1024] << 16)
-					   | private->b_table [i + 1024]);
-	 }
-	 private->y_table [i + 1024] = (private->r_table [i + 1024]
-					| private->g_table [i + 1024]
-					| private->b_table [i + 1024]);
+         private->r_table [i + 1024]
+            = i >> (8 - number_of_bits_set(red_mask));
+         private->r_table [i + 1024]
+            <<= free_bits_at_bottom (red_mask);
+         private->g_table [i + 1024]
+            = i >> (8 - number_of_bits_set (green_mask));
+         private->g_table [i + 1024]
+            <<= free_bits_at_bottom (green_mask);
+         private->b_table [i + 1024]
+            <<= free_bits_at_bottom (blue_mask);
+         private->b_table [i + 1024]
+            = i >> (8 - number_of_bits_set (blue_mask));
+         if (twopixels)
+         {
+            private->r_table [i + 1024] = ((private->r_table [i + 1024] << 16)
+                                           | private->r_table [i + 1024]);
+            private->g_table [i + 1024] = ((private->g_table [i + 1024] << 16)
+                                           | private->g_table [i + 1024]);
+            private->b_table [i + 1024] = ((private->b_table [i + 1024] << 16)
+                                           | private->b_table [i + 1024]);
+         }
+         private->y_table [i + 1024] = (private->r_table [i + 1024]
+                                        | private->g_table [i + 1024]
+                                        | private->b_table [i + 1024]);
       }
 
       /*
@@ -230,14 +230,14 @@ fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask,
        */
       for (i = 0; i < 1024; i++)
       {
-	 private->r_table [i]              = private->r_table [1024];
-	 private->r_table [i + 1024 + 256] = private->r_table [1024 + 255];
-	 private->g_table [i]              = private->g_table [1024];
-	 private->g_table [i + 1024 + 256] = private->g_table [1024 + 255];
-	 private->b_table [i]              = private->b_table [1024];
-	 private->b_table [i + 1024 + 256] = private->b_table [1024 + 255];
-	 private->y_table [i]              = private->y_table [1024];
-	 private->y_table [i + 1024 + 256] = private->y_table [1024 + 255];
+         private->r_table [i]              = private->r_table [1024];
+         private->r_table [i + 1024 + 256] = private->r_table [1024 + 255];
+         private->g_table [i]              = private->g_table [1024];
+         private->g_table [i + 1024 + 256] = private->g_table [1024 + 255];
+         private->b_table [i]              = private->b_table [1024];
+         private->b_table [i + 1024 + 256] = private->b_table [1024 + 255];
+         private->y_table [i]              = private->y_table [1024];
+         private->y_table [i + 1024 + 256] = private->y_table [1024 + 255];
       }
 
       private->r_table += 1024;
@@ -247,7 +247,7 @@ fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask,
 
       return render;
    }
-   
+
 }
 
 void
@@ -259,7 +259,7 @@ fiasco_renderer_delete (fiasco_renderer_t *renderer)
  *  No return value.
  *
  *  Side effects:
- *	structure 'renderer' is discarded.
+ *      structure 'renderer' is discarded.
  */
 {
    if (!renderer)
@@ -284,8 +284,8 @@ fiasco_renderer_delete (fiasco_renderer_t *renderer)
 
 int
 fiasco_renderer_render (const fiasco_renderer_t *renderer,
-			unsigned char *ximage,
-			const fiasco_image_t *fiasco_image)
+                        unsigned char *ximage,
+                        const fiasco_image_t *fiasco_image)
 {
    if (!renderer)
    {
@@ -298,8 +298,8 @@ fiasco_renderer_render (const fiasco_renderer_t *renderer,
 
 /*****************************************************************************
 
-				private code
-  
+                                private code
+
 *****************************************************************************/
 
 /*
@@ -313,7 +313,7 @@ fiasco_renderer_render (const fiasco_renderer_t *renderer,
  *  mode, since this involves getting down to byte level again. It is
  *  assumed that the bits for each color are contiguous in the
  *  longword.
- * 
+ *
  *  Writing to memory is done in shorts or ints. (Unfortunately, short
  *  is not very fast on Alpha, so there is room for improvement
  *  here). There is no dither time check for overflow - instead the
@@ -357,9 +357,9 @@ free_bits_at_bottom (unsigned long a)
       return 1 + free_bits_at_bottom ( a >> 1);
 }
 
-static int 
+static int
 display_16_bit (const struct fiasco_renderer *this, unsigned char *ximage,
-		const fiasco_image_t *fiasco_image)
+                const fiasco_image_t *fiasco_image)
 /*
  *  Convert 'image' to 16 bit color bitmap.
  *  If 'double_resolution' is true then double image size in both directions.
@@ -367,13 +367,13 @@ display_16_bit (const struct fiasco_renderer *this, unsigned char *ximage,
  *  No return value.
  *
  *  Side effects:
- *	'out[]'	is filled with dithered image
+ *      'out[]' is filled with dithered image
  */
 {
    const image_t      *image;
    renderer_private_t *private;
-   byte_t	      *out;
-   
+   byte_t             *out;
+
    if (!this)
    {
       set_error (_("Parameter `%s' not defined (NULL)."), "this");
@@ -390,21 +390,21 @@ display_16_bit (const struct fiasco_renderer *this, unsigned char *ximage,
       return 0;
    }
 
-   out 	   = (byte_t *) ximage;
+   out     = (byte_t *) ximage;
    image   = cast_image ((fiasco_image_t *) fiasco_image);
    if (!image)
       return 0;
    private = (renderer_private_t *) this->private;
-   
+
    if (image->color)
    {
-      word_t 	   *cbptr, *crptr;	/* pointer to chroma bands */
-      word_t 	   *yptr;		/* pointers to lumincance band */
-      int     	    yval, crval, cbval;	/* pixel value in YCbCr color space */
-      int     	    R, G, B;		/* pixel value in RGB color space */
-      int     	    n;			/* pixel counter */
-      int     	    x, y;		/* pixel coordinates */
-      int 	   *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
+      word_t       *cbptr, *crptr;      /* pointer to chroma bands */
+      word_t       *yptr;               /* pointers to lumincance band */
+      int           yval, crval, cbval; /* pixel value in YCbCr color space */
+      int           R, G, B;            /* pixel value in RGB color space */
+      int           n;                  /* pixel counter */
+      int           x, y;               /* pixel coordinates */
+      int          *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
       unsigned int *r_table, *g_table, *b_table;
 
       Cr_g_tab = private->Cr_g_tab;
@@ -420,245 +420,245 @@ display_16_bit (const struct fiasco_renderer *this, unsigned char *ximage,
 
       if (image->format == FORMAT_4_2_0)
       {
-	 u_word_t *dst, *dst2;		/* pointers to dithered pixels */
-	 word_t	  *yptr2;		/* pointers to lumincance band */
-
-	 if (private->double_resolution)
-	 {
-	    yptr2 = yptr + image->width;
-	    dst   = (u_word_t *) out;
-	    dst2  = dst + 4 * image->width;
-	    for (y = image->height / 2; y; y--)
-	    {
-	       for (x = image->width / 2; x; x--)
-	       {
+         u_word_t *dst, *dst2;          /* pointers to dithered pixels */
+         word_t   *yptr2;               /* pointers to lumincance band */
+
+         if (private->double_resolution)
+         {
+            yptr2 = yptr + image->width;
+            dst   = (u_word_t *) out;
+            dst2  = dst + 4 * image->width;
+            for (y = image->height / 2; y; y--)
+            {
+               for (x = image->width / 2; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  crval = *crptr++ >> 4;
-		  cbval = *cbptr++ >> 4;
-		  yval  = (*yptr++ >> 4) + 128;
+                  crval = *crptr++ >> 4;
+                  cbval = *cbptr++ >> 4;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  crval = *crptr++ / 16;
-		  cbval = *cbptr++ / 16;
-		  yval  = *yptr++  / 16 + 128;
+                  crval = *crptr++ / 16;
+                  cbval = *cbptr++ / 16;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-	       
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr++ >> 4) + 128;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr++  / 16 + 128;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-	       }
-	       memcpy (dst, dst - 2 * image->width,
-		       2 * image->width * sizeof (u_word_t));
-	       memcpy (dst2, dst2 - 2 * image->width,
-		       2 * image->width * sizeof (u_word_t));
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	       dst   += 3 * image->width * 2;
-	       dst2  += 3 * image->width * 2;
-	    }
-	 }
-	 else
-	 {
-	    yptr2 = yptr + image->width;
-	    dst  = (u_word_t *) out;
-	    dst2 = dst + image->width;
-	    
-	    for (y = image->height / 2; y; y--)
-	    {
-	       for (x = image->width / 2; x; x--)
-	       {
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+               }
+               memcpy (dst, dst - 2 * image->width,
+                       2 * image->width * sizeof (u_word_t));
+               memcpy (dst2, dst2 - 2 * image->width,
+                       2 * image->width * sizeof (u_word_t));
+               yptr  += image->width;
+               yptr2 += image->width;
+               dst   += 3 * image->width * 2;
+               dst2  += 3 * image->width * 2;
+            }
+         }
+         else
+         {
+            yptr2 = yptr + image->width;
+            dst  = (u_word_t *) out;
+            dst2 = dst + image->width;
+
+            for (y = image->height / 2; y; y--)
+            {
+               for (x = image->width / 2; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  crval = *crptr++ >> 4;
-		  cbval = *cbptr++ >> 4;
-		  yval  = (*yptr++ >> 4) + 128;
+                  crval = *crptr++ >> 4;
+                  cbval = *cbptr++ >> 4;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  crval = *crptr++ / 16;
-		  cbval = *cbptr++ / 16;
-		  yval  = *yptr++  / 16 + 128;
+                  crval = *crptr++ / 16;
+                  cbval = *cbptr++ / 16;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-	       
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr++ >> 4) + 128;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr++  / 16 + 128;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-	       }
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	       dst   += image->width;
-	       dst2  += image->width;
-	    }
-	 }
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+               }
+               yptr  += image->width;
+               yptr2 += image->width;
+               dst   += image->width;
+               dst2  += image->width;
+            }
+         }
       }
-      else				/* 4:4:4 format */
+      else                              /* 4:4:4 format */
       {
-	 if (private->double_resolution)
-	 {
-	    unsigned int *dst;		/* pointer to dithered pixels */
-	    
-	    dst  = (unsigned int *) out;
-	    
-	    for (y = image->height; y; y--)
-	    {
-	       for (x = image->width; x; x--)
-	       {
+         if (private->double_resolution)
+         {
+            unsigned int *dst;          /* pointer to dithered pixels */
+
+            dst  = (unsigned int *) out;
+
+            for (y = image->height; y; y--)
+            {
+               for (x = image->width; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  crval = *crptr++ >> 4;
-		  cbval = *cbptr++ >> 4;
-		  yval  = (*yptr++ >> 4) + 128;
+                  crval = *crptr++ >> 4;
+                  cbval = *cbptr++ >> 4;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  crval = *crptr++ / 16;
-		  cbval = *cbptr++ / 16;
-		  yval  = *yptr++  / 16 + 128;
+                  crval = *crptr++ / 16;
+                  cbval = *cbptr++ / 16;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-	       }
-	       memcpy (dst, dst - image->width,
-		       image->width * sizeof (unsigned int));
-	       dst += image->width;
-	    }
-	 }
-	 else
-	 {
-	    u_word_t *dst;		/* pointer to dithered pixels */
-
-	    dst  = (u_word_t *) out;
-	    
-	    for (n = image->width * image->height; n; n--)
-	    {
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+               }
+               memcpy (dst, dst - image->width,
+                       image->width * sizeof (unsigned int));
+               dst += image->width;
+            }
+         }
+         else
+         {
+            u_word_t *dst;              /* pointer to dithered pixels */
+
+            dst  = (u_word_t *) out;
+
+            for (n = image->width * image->height; n; n--)
+            {
 #ifdef HAVE_SIGNED_SHIFT
-	       crval = *crptr++ >> 4;
-	       cbval = *cbptr++ >> 4;
-	       yval  = (*yptr++ >> 4) + 128;
+               crval = *crptr++ >> 4;
+               cbval = *cbptr++ >> 4;
+               yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-	       crval = *crptr++ / 16;
-	       cbval = *cbptr++ / 16;
-	       yval  = *yptr++  / 16 + 128;
+               crval = *crptr++ / 16;
+               cbval = *cbptr++ / 16;
+               yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-	       R = yval + Cr_r_tab [crval];
-	       G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-	       B = yval + Cb_b_tab [cbval];
+               R = yval + Cr_r_tab [crval];
+               G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+               B = yval + Cb_b_tab [cbval];
 
-	       *dst++ = r_table [R] | g_table [G] | b_table [B];
-	    }
-	 }
+               *dst++ = r_table [R] | g_table [G] | b_table [B];
+            }
+         }
       }
    }
    else
    {
-      unsigned int *dst;		/* pointer to dithered pixels */
-      word_t	   *src;		/* current pixel of frame */
+      unsigned int *dst;                /* pointer to dithered pixels */
+      word_t       *src;                /* current pixel of frame */
       unsigned int *y_table;
 
       y_table = private->y_table;
       dst     = (unsigned int *) out;
       src     = image->pixels [GRAY];
-      
+
       if (private->double_resolution)
       {
-	 int x, y;			/* pixel coordinates */
-  	    
-	 for (y = image->height; y; y--)
-	 {
-	    for (x = image->width; x; x--)
-	    {
-	       int value;
-	       
+         int x, y;                      /* pixel coordinates */
+
+         for (y = image->height; y; y--)
+         {
+            for (x = image->width; x; x--)
+            {
+               int value;
+
 #ifdef HAVE_SIGNED_SHIFT
-	       value = y_table [*src++ >> 4];
+               value = y_table [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	       value = y_table [*src++ / 16];
+               value = y_table [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
-	       *dst++ = (value << 16) | value;
-	    }
-	    
-	    memcpy (dst, dst - image->width,
-		    image->width * sizeof (unsigned int));
-	    dst += image->width;
-	 }
+               *dst++ = (value << 16) | value;
+            }
+
+            memcpy (dst, dst - image->width,
+                    image->width * sizeof (unsigned int));
+            dst += image->width;
+         }
       }
       else
       {
-	 int n;				/* pixel counter */
-	 
-	 for (n = image->width * image->height / 2; n; n--, src += 2)
+         int n;                         /* pixel counter */
+
+         for (n = image->width * image->height / 2; n; n--, src += 2)
 #ifdef HAVE_SIGNED_SHIFT
-#	if BYTE_ORDER == LITTLE_ENDIAN
-	    *dst++ = (y_table [src [1] >> 4] << 16) | y_table [src [0] >> 4];
-#	else
-	    *dst++ = (y_table [src [0] >> 4] << 16) | y_table [src [1] >> 4];
-#	endif
+#       if BYTE_ORDER == LITTLE_ENDIAN
+            *dst++ = (y_table [src [1] >> 4] << 16) | y_table [src [0] >> 4];
+#       else
+            *dst++ = (y_table [src [0] >> 4] << 16) | y_table [src [1] >> 4];
+#       endif
 #else /* not HAVE_SIGNED_SHIFT */
-#	if BYTE_ORDER == LITTLE_ENDIAN
-	    *dst++ = (y_table [src [1] / 16] << 16) | y_table [src [0] / 16];
-#	else
-	    *dst++ = (y_table [src [0] / 16] << 16) | y_table [src [1] / 16];
-#	endif
+#       if BYTE_ORDER == LITTLE_ENDIAN
+            *dst++ = (y_table [src [1] / 16] << 16) | y_table [src [0] / 16];
+#       else
+            *dst++ = (y_table [src [0] / 16] << 16) | y_table [src [1] / 16];
+#       endif
 #endif /* not HAVE_SIGNED_SHIFT */
       }
    }
@@ -666,9 +666,9 @@ display_16_bit (const struct fiasco_renderer *this, unsigned char *ximage,
    return 1;
 }
 
-static int 
+static int
 display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage,
-		    const fiasco_image_t *fiasco_image)
+                    const fiasco_image_t *fiasco_image)
 /*
  *  Convert 'image' to 16 bit color bitmap.
  *  If 'double_resolution' is true then double image size in both directions.
@@ -676,13 +676,13 @@ display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage,
  *  No return value.
  *
  *  Side effects:
- *	'out[]'	is filled with dithered image
+ *      'out[]' is filled with dithered image
  */
 {
-   unsigned 	      *gray_clip = init_clipping ();
+   unsigned           *gray_clip = init_clipping ();
    const image_t      *image;
    renderer_private_t *private;
-   byte_t	      *out;
+   byte_t             *out;
 
    if (!gray_clip)
       return 0;
@@ -702,17 +702,17 @@ display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage,
       return 0;
    }
 
-   out 	   = (byte_t *) ximage;
+   out     = (byte_t *) ximage;
    image   = cast_image ((fiasco_image_t *) fiasco_image);
    if (!image)
       return 0;
    private = (renderer_private_t *) this->private;
-   
+
    if (image->color)
    {
-      word_t 	   *cbptr, *crptr;	/* pointer to chroma bands */
-      word_t 	   *yptr;		/* pointers to lumincance band */
-      int 	   *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
+      word_t       *cbptr, *crptr;      /* pointer to chroma bands */
+      word_t       *yptr;               /* pointers to lumincance band */
+      int          *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
 
       Cr_g_tab = private->Cr_g_tab;
       Cr_r_tab = private->Cr_r_tab;
@@ -724,396 +724,396 @@ display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage,
 
       if (image->format == FORMAT_4_2_0)
       {
-	 if (private->double_resolution)
-	 {
-	    int		  yval1;	/* lumincance pixel */
-	    int 	  crval1, cbval1; /* chroma pixels */
-	    int		  yval2;	/* pixel in YCbCr color space */
-	    unsigned int  R1, G1, B1;	/* pixel in RGB color space */
-	    unsigned int  R2, G2, B2;	/* pixel in RGB color space */
-	    int		  x, y;		/* pixel counter */
-	    unsigned int *dst;		/* pointer to dithered pixels */
-	    unsigned int *dst2;		/* pointers to dithered pixels */
-	    word_t	 *yptr2;	/* pointers to lumincance band */
-	    
-	    dst   = (unsigned int *) out;
-	    dst2  = dst + (image->width >> 1) * 3 * 2;
-	    yptr2 = yptr + image->width;
-	    
-	    for (y = image->height >> 1; y; y--)
-	    {
-	       for (x = image->width >> 1; x; x--)
-	       {
+         if (private->double_resolution)
+         {
+            int           yval1;        /* lumincance pixel */
+            int           crval1, cbval1; /* chroma pixels */
+            int           yval2;        /* pixel in YCbCr color space */
+            unsigned int  R1, G1, B1;   /* pixel in RGB color space */
+            unsigned int  R2, G2, B2;   /* pixel in RGB color space */
+            int           x, y;         /* pixel counter */
+            unsigned int *dst;          /* pointer to dithered pixels */
+            unsigned int *dst2;         /* pointers to dithered pixels */
+            word_t       *yptr2;        /* pointers to lumincance band */
+
+            dst   = (unsigned int *) out;
+            dst2  = dst + (image->width >> 1) * 3 * 2;
+            yptr2 = yptr + image->width;
+
+            for (y = image->height >> 1; y; y--)
+            {
+               for (x = image->width >> 1; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
 
-		  *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B1 << 24);
-		  *dst++ = G1 | (R1 << 8) | (B2 << 16) | (G2 << 24);
-		  *dst++ = R2 | (B2 << 8) | (G2 << 16) | (R2 << 24);
+                  *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B1 << 24);
+                  *dst++ = G1 | (R1 << 8) | (B2 << 16) | (G2 << 24);
+                  *dst++ = R2 | (B2 << 8) | (G2 << 16) | (R2 << 24);
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr2++ >> 4) + 128;
-		  yval2  = (*yptr2++ >> 4) + 128;
+                  yval1  = (*yptr2++ >> 4) + 128;
+                  yval2  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr2++  / 16 + 128;
-		  yval2  = *yptr2++  / 16 + 128;
+                  yval1  = *yptr2++  / 16 + 128;
+                  yval2  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
-
-		  *dst2++ = B1 | (G1 << 8) | (R1 << 16) | (B1 << 24);
-		  *dst2++ = G1 | (R1 << 8) | (B2 << 16) | (G2 << 24);
-		  *dst2++ = R2 | (B2 << 8) | (G2 << 16) | (R2 << 24);
-	       }
-	       memcpy (dst, dst - (image->width >> 1) * 3,
-		       (image->width >> 1) * 3 * sizeof (unsigned int));
-	       memcpy (dst2, dst2 - (image->width >> 1) * 3, 
-		       (image->width >> 1) * 3 * sizeof (unsigned int));
-	       dst   += (image->width >> 1) * 3 * 3;
-	       dst2  += (image->width >> 1) * 3 * 3;
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	    }
-	 }
-	 else
-	 {
-	    int		  yval1;	/* lumincance pixel */
-	    int 	  crval1, cbval1; /* chroma pixels */
-	    int		  yval2;	/* pixel in YCbCr color space */
-	    unsigned int  R1, G1, B1;	/* pixel in RGB color space */
-	    unsigned int  R2, G2, B2;	/* pixel in RGB color space */
-	    int		  x, y;		/* pixel counter */
-	    unsigned int *dst;		/* pointer to dithered pixels */
-	    unsigned int *dst2;		/* pointers to dithered pixels */
-	    word_t	 *yptr2;	/* pointers to lumincance band */
-	    
-	    dst   = (unsigned int *) out;
-	    dst2  = dst + (image->width >> 2) * 3;
-	    yptr2 = yptr + image->width;
-	    
-	    for (y = image->height >> 1; y; y--)
-	    {
-	       for (x = image->width >> 2; x; x--)
-	       {
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+
+                  *dst2++ = B1 | (G1 << 8) | (R1 << 16) | (B1 << 24);
+                  *dst2++ = G1 | (R1 << 8) | (B2 << 16) | (G2 << 24);
+                  *dst2++ = R2 | (B2 << 8) | (G2 << 16) | (R2 << 24);
+               }
+               memcpy (dst, dst - (image->width >> 1) * 3,
+                       (image->width >> 1) * 3 * sizeof (unsigned int));
+               memcpy (dst2, dst2 - (image->width >> 1) * 3,
+                       (image->width >> 1) * 3 * sizeof (unsigned int));
+               dst   += (image->width >> 1) * 3 * 3;
+               dst2  += (image->width >> 1) * 3 * 3;
+               yptr  += image->width;
+               yptr2 += image->width;
+            }
+         }
+         else
+         {
+            int           yval1;        /* lumincance pixel */
+            int           crval1, cbval1; /* chroma pixels */
+            int           yval2;        /* pixel in YCbCr color space */
+            unsigned int  R1, G1, B1;   /* pixel in RGB color space */
+            unsigned int  R2, G2, B2;   /* pixel in RGB color space */
+            int           x, y;         /* pixel counter */
+            unsigned int *dst;          /* pointer to dithered pixels */
+            unsigned int *dst2;         /* pointers to dithered pixels */
+            word_t       *yptr2;        /* pointers to lumincance band */
+
+            dst   = (unsigned int *) out;
+            dst2  = dst + (image->width >> 2) * 3;
+            yptr2 = yptr + image->width;
+
+            for (y = image->height >> 1; y; y--)
+            {
+               for (x = image->width >> 2; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
 
-		  *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B2 << 24);
-		  *dst   = G2 | (R2 << 8);
+                  *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B2 << 24);
+                  *dst   = G2 | (R2 << 8);
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr2++ >> 4) + 128;
-		  yval2  = (*yptr2++ >> 4) + 128;
+                  yval1  = (*yptr2++ >> 4) + 128;
+                  yval2  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr2++  / 16 + 128;
-		  yval2  = *yptr2++  / 16 + 128;
+                  yval1  = *yptr2++  / 16 + 128;
+                  yval2  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
-
-		  *dst2++ = B1 | (G1 << 8) | (R1 << 16) | (B2 << 24);
-		  *dst2   = G2 | (R2 << 8);
-	       
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+
+                  *dst2++ = B1 | (G1 << 8) | (R1 << 16) | (B2 << 24);
+                  *dst2   = G2 | (R2 << 8);
+
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  crval2 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
-		  cbval2 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  crval2 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
+                  cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
 
-		  *dst++ |= (B1 << 16) | (G1 << 24);
-		  *dst++ = R1 | (B2 << 8) | (G2 << 16) | (R2 << 24);
+                  *dst++ |= (B1 << 16) | (G1 << 24);
+                  *dst++ = R1 | (B2 << 8) | (G2 << 16) | (R2 << 24);
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr2++ >> 4) + 128;
-		  yval2  = (*yptr2++ >> 4) + 128;
+                  yval1  = (*yptr2++ >> 4) + 128;
+                  yval2  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr2++  / 16 + 128;
-		  yval2  = *yptr2++  / 16 + 128;
+                  yval1  = *yptr2++  / 16 + 128;
+                  yval2  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
-
-		  *dst2++ |= (B1 << 16) | (G1 << 24);
-		  *dst2++ = R1 | (B2 << 8) | (G2 << 16) | (R2 << 24);
-	       }
-	       dst   += (image->width >> 2) * 3;
-	       dst2  += (image->width >> 2) * 3;
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	    }
-	 }
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+
+                  *dst2++ |= (B1 << 16) | (G1 << 24);
+                  *dst2++ = R1 | (B2 << 8) | (G2 << 16) | (R2 << 24);
+               }
+               dst   += (image->width >> 2) * 3;
+               dst2  += (image->width >> 2) * 3;
+               yptr  += image->width;
+               yptr2 += image->width;
+            }
+         }
       }
-      else				/* 4:4:4 format */
+      else                              /* 4:4:4 format */
       {
-	 if (private->double_resolution)
-	 {
-	    unsigned int R1, G1, B1;		/* pixel1 in RGB color space */
-	    unsigned int R2, G2, B2;		/* pixel2 in RGB color space */
-	    int		 yval1, crval1, cbval1;	/* pixel1 in YCbCr space */
-	    int		 yval2, crval2, cbval2;	/* pixel2 in YCbCr space */
-	    int		 x, y;			/* pixel counter */
-	    unsigned int *dst;		        /* dithered pixel pointer */
-	    
-	    dst = (unsigned int *) out;
-	    
-	    for (y = image->height; y; y--)
-	    {
-	       for (x = image->width >> 1; x; x--)
-	       {
+         if (private->double_resolution)
+         {
+            unsigned int R1, G1, B1;            /* pixel1 in RGB color space */
+            unsigned int R2, G2, B2;            /* pixel2 in RGB color space */
+            int          yval1, crval1, cbval1; /* pixel1 in YCbCr space */
+            int          yval2, crval2, cbval2; /* pixel2 in YCbCr space */
+            int          x, y;                  /* pixel counter */
+            unsigned int *dst;                  /* dithered pixel pointer */
+
+            dst = (unsigned int *) out;
+
+            for (y = image->height; y; y--)
+            {
+               for (x = image->width >> 1; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  crval2 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
-		  cbval2 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  crval2 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
+                  cbval2 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  crval2 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
-		  cbval2 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  crval2 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
+                  cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				 + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval2]
-				 + Cb_g_tab [cbval2]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
-
-		  *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B1 << 24);
-		  *dst++ = G1 | (R1 << 8) | (B2 << 16) | (G2 << 24);
-		  *dst++ = R2 | (B2 << 8) | (G2 << 16) | (R2 << 24);
-	       }
-	       memcpy (dst, dst - 3 * (image->width >> 1),
-		       3 * (image->width >> 1) * sizeof (unsigned int));
-	       dst += 3 * (image->width >> 1);
-	    }
-	 }
-	 else
-	 {
-	    unsigned int R1, G1, B1;		/* pixel in RGB color space */
-	    unsigned int R2, G2, B2;		/* pixel in RGB color space */
-	    int		 yval1, crval1, cbval1;	/* pixel1 in YCbCr space */
-	    int		 yval2, crval2, cbval2;	/* pixel2 in YCbCr space */
-	    int		 n;			/* pixel counter */
-	    unsigned int *dst;		        /* dithered pixel pointer */
-	    
-	    dst = (unsigned int *) out;
-	    
-	    for (n = (image->width * image->height) >> 2; n; n--)
-	    {
+
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                 + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval2]
+                                 + Cb_g_tab [cbval2]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
+
+                  *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B1 << 24);
+                  *dst++ = G1 | (R1 << 8) | (B2 << 16) | (G2 << 24);
+                  *dst++ = R2 | (B2 << 8) | (G2 << 16) | (R2 << 24);
+               }
+               memcpy (dst, dst - 3 * (image->width >> 1),
+                       3 * (image->width >> 1) * sizeof (unsigned int));
+               dst += 3 * (image->width >> 1);
+            }
+         }
+         else
+         {
+            unsigned int R1, G1, B1;            /* pixel in RGB color space */
+            unsigned int R2, G2, B2;            /* pixel in RGB color space */
+            int          yval1, crval1, cbval1; /* pixel1 in YCbCr space */
+            int          yval2, crval2, cbval2; /* pixel2 in YCbCr space */
+            int          n;                     /* pixel counter */
+            unsigned int *dst;                  /* dithered pixel pointer */
+
+            dst = (unsigned int *) out;
+
+            for (n = (image->width * image->height) >> 2; n; n--)
+            {
 #ifdef HAVE_SIGNED_SHIFT
-	       yval1  = (*yptr++ >> 4) + 128;
-	       yval2  = (*yptr++ >> 4) + 128;
-	       crval1 = *crptr++ >> 4;
-	       crval2 = *crptr++ >> 4;
-	       cbval1 = *cbptr++ >> 4;
-	       cbval2 = *cbptr++ >> 4;
+               yval1  = (*yptr++ >> 4) + 128;
+               yval2  = (*yptr++ >> 4) + 128;
+               crval1 = *crptr++ >> 4;
+               crval2 = *crptr++ >> 4;
+               cbval1 = *cbptr++ >> 4;
+               cbval2 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-	       yval1  = *yptr++  / 16 + 128;
-	       yval2  = *yptr++  / 16 + 128;
-	       crval1 = *crptr++ / 16;
-	       crval2 = *crptr++ / 16;
-	       cbval1 = *cbptr++ / 16;
-	       cbval2 = *cbptr++ / 16;
+               yval1  = *yptr++  / 16 + 128;
+               yval2  = *yptr++  / 16 + 128;
+               crval1 = *crptr++ / 16;
+               crval2 = *crptr++ / 16;
+               cbval1 = *cbptr++ / 16;
+               cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-	       G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
-	       B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-	       R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
-	       G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
-	       B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
+               R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+               G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
+               B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+               R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
+               G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
+               B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
 
-	       *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B2 << 24);
-	       *dst   = G2 | (R2 << 8);
+               *dst++ = B1 | (G1 << 8) | (R1 << 16) | (B2 << 24);
+               *dst   = G2 | (R2 << 8);
 
 #ifdef HAVE_SIGNED_SHIFT
-	       yval1  = (*yptr++ >> 4) + 128;
-	       yval2  = (*yptr++ >> 4) + 128;
-	       crval1 = *crptr++ >> 4;
-	       crval2 = *crptr++ >> 4;
-	       cbval1 = *cbptr++ >> 4;
-	       cbval2 = *cbptr++ >> 4;
+               yval1  = (*yptr++ >> 4) + 128;
+               yval2  = (*yptr++ >> 4) + 128;
+               crval1 = *crptr++ >> 4;
+               crval2 = *crptr++ >> 4;
+               cbval1 = *cbptr++ >> 4;
+               cbval2 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-	       yval1  = *yptr++  / 16 + 128;
-	       yval2  = *yptr++  / 16 + 128;
-	       crval1 = *crptr++ / 16;
-	       crval2 = *crptr++ / 16;
-	       cbval1 = *cbptr++ / 16;
-	       cbval2 = *cbptr++ / 16;
+               yval1  = *yptr++  / 16 + 128;
+               yval2  = *yptr++  / 16 + 128;
+               crval1 = *crptr++ / 16;
+               crval2 = *crptr++ / 16;
+               cbval1 = *cbptr++ / 16;
+               cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-	       G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
-	       B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-	       R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
-	       G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
-	       B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
-
-	       *dst++ |= (B1 << 16) | (G1 << 24);
-	       *dst++ = R1 | (B2 << 8) | (G2 << 16) | (R2 << 24);
-	    }
-	 }
+               R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+               G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
+               B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+               R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
+               G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
+               B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
+
+               *dst++ |= (B1 << 16) | (G1 << 24);
+               *dst++ = R1 | (B2 << 8) | (G2 << 16) | (R2 << 24);
+            }
+         }
       }
    }
    else
    {
-      unsigned int *dst;		/* pointer to dithered pixels */
-      word_t	   *src;		/* current pixel of frame */
+      unsigned int *dst;                /* pointer to dithered pixels */
+      word_t       *src;                /* current pixel of frame */
 
       dst     = (unsigned int *) out;
       src     = image->pixels [GRAY];
 
       if (private->double_resolution)
       {
-	 int	   x, y;		/* pixel counter */
-	 unsigned *shift_clipping = gray_clip + 128;
-
-	 for (y = image->height; y; y--)
-	 {
-	    for (x = image->width >> 1; x; x--)
-	    {
-	       unsigned int val1, val2;
+         int       x, y;                /* pixel counter */
+         unsigned *shift_clipping = gray_clip + 128;
+
+         for (y = image->height; y; y--)
+         {
+            for (x = image->width >> 1; x; x--)
+            {
+               unsigned int val1, val2;
 #ifdef HAVE_SIGNED_SHIFT
-	       val1 = shift_clipping [*src++ >> 4];
-	       val2 = shift_clipping [*src++ >> 4];
+               val1 = shift_clipping [*src++ >> 4];
+               val2 = shift_clipping [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	       val1 = shift_clipping [*src++ / 16];
-	       val2 = shift_clipping [*src++ / 16];
+               val1 = shift_clipping [*src++ / 16];
+               val2 = shift_clipping [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       *dst++ = val1 | (val1 << 8) | (val1 << 16) | (val1 << 24);
-	       *dst++ = val1 | (val1 << 8) | (val2 << 16) | (val2 << 24); 
-	       *dst++ = val2 | (val2 << 8) | (val2 << 16) | (val2 << 24);
-	    }
+               *dst++ = val1 | (val1 << 8) | (val1 << 16) | (val1 << 24);
+               *dst++ = val1 | (val1 << 8) | (val2 << 16) | (val2 << 24);
+               *dst++ = val2 | (val2 << 8) | (val2 << 16) | (val2 << 24);
+            }
 
-	    memcpy (dst, dst - 3 * (image->width >> 1),
-		    3 * (image->width >> 1) * sizeof (unsigned int));
-	    dst += 3 * (image->width >> 1);
-	 }
+            memcpy (dst, dst - 3 * (image->width >> 1),
+                    3 * (image->width >> 1) * sizeof (unsigned int));
+            dst += 3 * (image->width >> 1);
+         }
       }
       else
       {
-	 int	   n;			/* pixel counter */
-	 unsigned *shift_clipping = gray_clip + 128;
+         int       n;                   /* pixel counter */
+         unsigned *shift_clipping = gray_clip + 128;
 
-	 for (n = (image->width * image->height) >> 2; n; n--)
-	 {
-	    unsigned int val1, val2;
+         for (n = (image->width * image->height) >> 2; n; n--)
+         {
+            unsigned int val1, val2;
 
 #ifdef HAVE_SIGNED_SHIFT
-	    val1 = shift_clipping [*src++ >> 4];
-	    val2 = shift_clipping [*src++ >> 4];
+            val1 = shift_clipping [*src++ >> 4];
+            val2 = shift_clipping [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	    val1 = shift_clipping [*src++ / 16];
-	    val2 = shift_clipping [*src++ / 16];
+            val1 = shift_clipping [*src++ / 16];
+            val2 = shift_clipping [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	    *dst++ = val1 | (val1 << 8)
-		     | (val1 << 16) | (val2 << 24);  /* RGBR */
-	    *dst   = val2 | (val2 << 8);             /* GB-- */
+            *dst++ = val1 | (val1 << 8)
+                     | (val1 << 16) | (val2 << 24);  /* RGBR */
+            *dst   = val2 | (val2 << 8);             /* GB-- */
 
 #ifdef HAVE_SIGNED_SHIFT
-	    val1 = shift_clipping [*src++ >> 4];
-	    val2 = shift_clipping [*src++ >> 4];
+            val1 = shift_clipping [*src++ >> 4];
+            val2 = shift_clipping [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	    val1 = shift_clipping [*src++ / 16];
-	    val2 = shift_clipping [*src++ / 16];
+            val1 = shift_clipping [*src++ / 16];
+            val2 = shift_clipping [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
-	    
-	    *dst++ |= (val1 << 16) | (val1 << 24);   /* --RG */
-	    *dst++  = val1 | (val2 << 8)
-		      | (val2 << 16) | (val2 << 24); /* BRGB */
-	 }
+
+            *dst++ |= (val1 << 16) | (val1 << 24);   /* --RG */
+            *dst++  = val1 | (val2 << 8)
+                      | (val2 << 16) | (val2 << 24); /* BRGB */
+         }
       }
    }
-   
+
    return 1;
 }
 
-static int 
+static int
 display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage,
-		    const fiasco_image_t *fiasco_image)
+                    const fiasco_image_t *fiasco_image)
 /*
  *  Convert 'image' to 16 bit color bitmap.
  *  If 'double_resolution' is true then double image size in both directions.
@@ -1121,13 +1121,13 @@ display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage,
  *  No return value.
  *
  *  Side effects:
- *	'out[]'	is filled with dithered image
+ *      'out[]' is filled with dithered image
  */
 {
-   unsigned 	      *gray_clip = init_clipping ();
+   unsigned           *gray_clip = init_clipping ();
    const image_t      *image;
    renderer_private_t *private;
-   byte_t	      *out;
+   byte_t             *out;
 
    if (!gray_clip)
       return 0;
@@ -1147,17 +1147,17 @@ display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage,
       return 0;
    }
 
-   out 	   = (byte_t *) ximage;
+   out     = (byte_t *) ximage;
    image   = cast_image ((fiasco_image_t *) fiasco_image);
    if (!image)
       return 0;
    private = (renderer_private_t *) this->private;
-   
+
    if (image->color)
    {
-      word_t 	   *cbptr, *crptr;	/* pointer to chroma bands */
-      word_t 	   *yptr;		/* pointers to lumincance band */
-      int 	   *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
+      word_t       *cbptr, *crptr;      /* pointer to chroma bands */
+      word_t       *yptr;               /* pointers to lumincance band */
+      int          *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
 
       Cr_g_tab = private->Cr_g_tab;
       Cr_r_tab = private->Cr_r_tab;
@@ -1169,396 +1169,396 @@ display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage,
 
       if (image->format == FORMAT_4_2_0)
       {
-	 if (private->double_resolution)
-	 {
-	    int		  yval1;	/* lumincance pixel */
-	    int 	  crval1, cbval1; /* chroma pixels */
-	    int		  yval2;	/* pixel in YCbCr color space */
-	    unsigned int  R1, G1, B1;	/* pixel in RGB color space */
-	    unsigned int  R2, G2, B2;	/* pixel in RGB color space */
-	    int		  x, y;		/* pixel counter */
-	    unsigned int *dst;		/* pointer to dithered pixels */
-	    unsigned int *dst2;		/* pointers to dithered pixels */
-	    word_t	 *yptr2;	/* pointers to lumincance band */
-	    
-	    dst   = (unsigned int *) out;
-	    dst2  = dst + (image->width >> 1) * 3 * 2;
-	    yptr2 = yptr + image->width;
-	    
-	    for (y = image->height >> 1; y; y--)
-	    {
-	       for (x = image->width >> 1; x; x--)
-	       {
+         if (private->double_resolution)
+         {
+            int           yval1;        /* lumincance pixel */
+            int           crval1, cbval1; /* chroma pixels */
+            int           yval2;        /* pixel in YCbCr color space */
+            unsigned int  R1, G1, B1;   /* pixel in RGB color space */
+            unsigned int  R2, G2, B2;   /* pixel in RGB color space */
+            int           x, y;         /* pixel counter */
+            unsigned int *dst;          /* pointer to dithered pixels */
+            unsigned int *dst2;         /* pointers to dithered pixels */
+            word_t       *yptr2;        /* pointers to lumincance band */
+
+            dst   = (unsigned int *) out;
+            dst2  = dst + (image->width >> 1) * 3 * 2;
+            yptr2 = yptr + image->width;
+
+            for (y = image->height >> 1; y; y--)
+            {
+               for (x = image->width >> 1; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
 
-		  *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R1 << 24);
-		  *dst++ = G1 | (B1 << 8) | (R2 << 16) | (G2 << 24);
-		  *dst++ = B2 | (R2 << 8) | (G2 << 16) | (B2 << 24);
+                  *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R1 << 24);
+                  *dst++ = G1 | (B1 << 8) | (R2 << 16) | (G2 << 24);
+                  *dst++ = B2 | (R2 << 8) | (G2 << 16) | (B2 << 24);
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr2++ >> 4) + 128;
-		  yval2  = (*yptr2++ >> 4) + 128;
+                  yval1  = (*yptr2++ >> 4) + 128;
+                  yval2  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr2++  / 16 + 128;
-		  yval2  = *yptr2++  / 16 + 128;
+                  yval1  = *yptr2++  / 16 + 128;
+                  yval2  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
-
-		  *dst2++ = R1 | (G1 << 8) | (B1 << 16) | (R1 << 24);
-		  *dst2++ = G1 | (B1 << 8) | (R2 << 16) | (G2 << 24);
-		  *dst2++ = B2 | (R2 << 8) | (G2 << 16) | (B2 << 24);
-	       }
-	       memcpy (dst, dst - (image->width >> 1) * 3,
-		       (image->width >> 1) * 3 * sizeof (unsigned int));
-	       memcpy (dst2, dst2 - (image->width >> 1) * 3, 
-		       (image->width >> 1) * 3 * sizeof (unsigned int));
-	       dst   += (image->width >> 1) * 3 * 3;
-	       dst2  += (image->width >> 1) * 3 * 3;
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	    }
-	 }
-	 else
-	 {
-	    int		  yval1;	/* lumincance pixel */
-	    int 	  crval1, cbval1; /* chroma pixels */
-	    int		  yval2;	/* pixel in YCbCr color space */
-	    unsigned int  R1, G1, B1;	/* pixel in RGB color space */
-	    unsigned int  R2, G2, B2;	/* pixel in RGB color space */
-	    int		  x, y;		/* pixel counter */
-	    unsigned int *dst;		/* pointer to dithered pixels */
-	    unsigned int *dst2;		/* pointers to dithered pixels */
-	    word_t	 *yptr2;	/* pointers to lumincance band */
-	    
-	    dst   = (unsigned int *) out;
-	    dst2  = dst + (image->width >> 2) * 3;
-	    yptr2 = yptr + image->width;
-	    
-	    for (y = image->height >> 1; y; y--)
-	    {
-	       for (x = image->width >> 2; x; x--)
-	       {
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+
+                  *dst2++ = R1 | (G1 << 8) | (B1 << 16) | (R1 << 24);
+                  *dst2++ = G1 | (B1 << 8) | (R2 << 16) | (G2 << 24);
+                  *dst2++ = B2 | (R2 << 8) | (G2 << 16) | (B2 << 24);
+               }
+               memcpy (dst, dst - (image->width >> 1) * 3,
+                       (image->width >> 1) * 3 * sizeof (unsigned int));
+               memcpy (dst2, dst2 - (image->width >> 1) * 3,
+                       (image->width >> 1) * 3 * sizeof (unsigned int));
+               dst   += (image->width >> 1) * 3 * 3;
+               dst2  += (image->width >> 1) * 3 * 3;
+               yptr  += image->width;
+               yptr2 += image->width;
+            }
+         }
+         else
+         {
+            int           yval1;        /* lumincance pixel */
+            int           crval1, cbval1; /* chroma pixels */
+            int           yval2;        /* pixel in YCbCr color space */
+            unsigned int  R1, G1, B1;   /* pixel in RGB color space */
+            unsigned int  R2, G2, B2;   /* pixel in RGB color space */
+            int           x, y;         /* pixel counter */
+            unsigned int *dst;          /* pointer to dithered pixels */
+            unsigned int *dst2;         /* pointers to dithered pixels */
+            word_t       *yptr2;        /* pointers to lumincance band */
+
+            dst   = (unsigned int *) out;
+            dst2  = dst + (image->width >> 2) * 3;
+            yptr2 = yptr + image->width;
+
+            for (y = image->height >> 1; y; y--)
+            {
+               for (x = image->width >> 2; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
 
-		  *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R2 << 24);
-		  *dst   = G2 | (B2 << 8);
+                  *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R2 << 24);
+                  *dst   = G2 | (B2 << 8);
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr2++ >> 4) + 128;
-		  yval2  = (*yptr2++ >> 4) + 128;
+                  yval1  = (*yptr2++ >> 4) + 128;
+                  yval2  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr2++  / 16 + 128;
-		  yval2  = *yptr2++  / 16 + 128;
+                  yval1  = *yptr2++  / 16 + 128;
+                  yval2  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
-
-		  *dst2++ = R1 | (G1 << 8) | (B1 << 16) | (R2 << 24);
-		  *dst2   = G2 | (B2 << 8);
-	       
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+
+                  *dst2++ = R1 | (G1 << 8) | (B1 << 16) | (R2 << 24);
+                  *dst2   = G2 | (B2 << 8);
+
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  crval2 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
-		  cbval2 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  crval2 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
+                  cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
 
-		  *dst++ |= (R1 << 16) | (G1 << 24);
-		  *dst++ = B1 | (R2 << 8) | (G2 << 16) | (B2 << 24);
+                  *dst++ |= (R1 << 16) | (G1 << 24);
+                  *dst++ = B1 | (R2 << 8) | (G2 << 16) | (B2 << 24);
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr2++ >> 4) + 128;
-		  yval2  = (*yptr2++ >> 4) + 128;
+                  yval1  = (*yptr2++ >> 4) + 128;
+                  yval2  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr2++  / 16 + 128;
-		  yval2  = *yptr2++  / 16 + 128;
+                  yval1  = *yptr2++  / 16 + 128;
+                  yval2  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
-
-		  *dst2++ |= (R1 << 16) | (G1 << 24);
-		  *dst2++ = B1 | (R2 << 8) | (G2 << 16) | (B2 << 24);
-	       }
-	       dst   += (image->width >> 2) * 3;
-	       dst2  += (image->width >> 2) * 3;
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	    }
-	 }
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval1]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval1]];
+
+                  *dst2++ |= (R1 << 16) | (G1 << 24);
+                  *dst2++ = B1 | (R2 << 8) | (G2 << 16) | (B2 << 24);
+               }
+               dst   += (image->width >> 2) * 3;
+               dst2  += (image->width >> 2) * 3;
+               yptr  += image->width;
+               yptr2 += image->width;
+            }
+         }
       }
-      else				/* 4:4:4 format */
+      else                              /* 4:4:4 format */
       {
-	 if (private->double_resolution)
-	 {
-	    unsigned int R1, G1, B1;		/* pixel1 in RGB color space */
-	    unsigned int R2, G2, B2;		/* pixel2 in RGB color space */
-	    int		 yval1, crval1, cbval1;	/* pixel1 in YCbCr space */
-	    int		 yval2, crval2, cbval2;	/* pixel2 in YCbCr space */
-	    int		 x, y;			/* pixel counter */
-	    unsigned int *dst;		        /* dithered pixel pointer */
-	    
-	    dst = (unsigned int *) out;
-	    
-	    for (y = image->height; y; y--)
-	    {
-	       for (x = image->width >> 1; x; x--)
-	       {
+         if (private->double_resolution)
+         {
+            unsigned int R1, G1, B1;            /* pixel1 in RGB color space */
+            unsigned int R2, G2, B2;            /* pixel2 in RGB color space */
+            int          yval1, crval1, cbval1; /* pixel1 in YCbCr space */
+            int          yval2, crval2, cbval2; /* pixel2 in YCbCr space */
+            int          x, y;                  /* pixel counter */
+            unsigned int *dst;                  /* dithered pixel pointer */
+
+            dst = (unsigned int *) out;
+
+            for (y = image->height; y; y--)
+            {
+               for (x = image->width >> 1; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  yval1  = (*yptr++ >> 4) + 128;
-		  yval2  = (*yptr++ >> 4) + 128;
-		  crval1 = *crptr++ >> 4;
-		  crval2 = *crptr++ >> 4;
-		  cbval1 = *cbptr++ >> 4;
-		  cbval2 = *cbptr++ >> 4;
+                  yval1  = (*yptr++ >> 4) + 128;
+                  yval2  = (*yptr++ >> 4) + 128;
+                  crval1 = *crptr++ >> 4;
+                  crval2 = *crptr++ >> 4;
+                  cbval1 = *cbptr++ >> 4;
+                  cbval2 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval1  = *yptr++  / 16 + 128;
-		  yval2  = *yptr++  / 16 + 128;
-		  crval1 = *crptr++ / 16;
-		  crval2 = *crptr++ / 16;
-		  cbval1 = *cbptr++ / 16;
-		  cbval2 = *cbptr++ / 16;
+                  yval1  = *yptr++  / 16 + 128;
+                  yval2  = *yptr++  / 16 + 128;
+                  crval1 = *crptr++ / 16;
+                  crval2 = *crptr++ / 16;
+                  cbval1 = *cbptr++ / 16;
+                  cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  
-		  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-		  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
-				  + Cb_g_tab [cbval1]];
-		  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-		  R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
-		  G2 = gray_clip [yval2 + Cr_g_tab [crval2]
-				  + Cb_g_tab [cbval2]];
-		  B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
-
-		  *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R1 << 24);
-		  *dst++ = G1 | (B1 << 8) | (R2 << 16) | (G2 << 24);
-		  *dst++ = B2 | (R2 << 8) | (G2 << 16) | (B2 << 24);
-	       }
-	       memcpy (dst, dst - 3 * (image->width >> 1),
-		       3 * (image->width >> 1) * sizeof (unsigned int));
-	       dst += 3 * (image->width >> 1);
-	    }
-	 }
-	 else
-	 {
-	    unsigned int R1, G1, B1;		/* pixel in RGB color space */
-	    unsigned int R2, G2, B2;		/* pixel in RGB color space */
-	    int		 yval1, crval1, cbval1;	/* pixel1 in YCbCr space */
-	    int		 yval2, crval2, cbval2;	/* pixel2 in YCbCr space */
-	    int		 n;			/* pixel counter */
-	    unsigned int *dst;		        /* dithered pixel pointer */
-	    
-	    dst = (unsigned int *) out;
-	    
-	    for (n = (image->width * image->height) >> 2; n; n--)
-	    {
+
+                  R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+                  G1 = gray_clip [yval1 + Cr_g_tab [crval1]
+                                  + Cb_g_tab [cbval1]];
+                  B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+                  R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
+                  G2 = gray_clip [yval2 + Cr_g_tab [crval2]
+                                  + Cb_g_tab [cbval2]];
+                  B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
+
+                  *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R1 << 24);
+                  *dst++ = G1 | (B1 << 8) | (R2 << 16) | (G2 << 24);
+                  *dst++ = B2 | (R2 << 8) | (G2 << 16) | (B2 << 24);
+               }
+               memcpy (dst, dst - 3 * (image->width >> 1),
+                       3 * (image->width >> 1) * sizeof (unsigned int));
+               dst += 3 * (image->width >> 1);
+            }
+         }
+         else
+         {
+            unsigned int R1, G1, B1;            /* pixel in RGB color space */
+            unsigned int R2, G2, B2;            /* pixel in RGB color space */
+            int          yval1, crval1, cbval1; /* pixel1 in YCbCr space */
+            int          yval2, crval2, cbval2; /* pixel2 in YCbCr space */
+            int          n;                     /* pixel counter */
+            unsigned int *dst;                  /* dithered pixel pointer */
+
+            dst = (unsigned int *) out;
+
+            for (n = (image->width * image->height) >> 2; n; n--)
+            {
 #ifdef HAVE_SIGNED_SHIFT
-	       yval1  = (*yptr++ >> 4) + 128;
-	       yval2  = (*yptr++ >> 4) + 128;
-	       crval1 = *crptr++ >> 4;
-	       crval2 = *crptr++ >> 4;
-	       cbval1 = *cbptr++ >> 4;
-	       cbval2 = *cbptr++ >> 4;
+               yval1  = (*yptr++ >> 4) + 128;
+               yval2  = (*yptr++ >> 4) + 128;
+               crval1 = *crptr++ >> 4;
+               crval2 = *crptr++ >> 4;
+               cbval1 = *cbptr++ >> 4;
+               cbval2 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-	       yval1  = *yptr++  / 16 + 128;
-	       yval2  = *yptr++  / 16 + 128;
-	       crval1 = *crptr++ / 16;
-	       crval2 = *crptr++ / 16;
-	       cbval1 = *cbptr++ / 16;
-	       cbval2 = *cbptr++ / 16;
+               yval1  = *yptr++  / 16 + 128;
+               yval2  = *yptr++  / 16 + 128;
+               crval1 = *crptr++ / 16;
+               crval2 = *crptr++ / 16;
+               cbval1 = *cbptr++ / 16;
+               cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-	       G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
-	       B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-	       R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
-	       G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
-	       B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
+               R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+               G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
+               B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+               R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
+               G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
+               B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
 
-	       *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R2 << 24);
-	       *dst   = G2 | (B2 << 8);
+               *dst++ = R1 | (G1 << 8) | (B1 << 16) | (R2 << 24);
+               *dst   = G2 | (B2 << 8);
 
 #ifdef HAVE_SIGNED_SHIFT
-	       yval1  = (*yptr++ >> 4) + 128;
-	       yval2  = (*yptr++ >> 4) + 128;
-	       crval1 = *crptr++ >> 4;
-	       crval2 = *crptr++ >> 4;
-	       cbval1 = *cbptr++ >> 4;
-	       cbval2 = *cbptr++ >> 4;
+               yval1  = (*yptr++ >> 4) + 128;
+               yval2  = (*yptr++ >> 4) + 128;
+               crval1 = *crptr++ >> 4;
+               crval2 = *crptr++ >> 4;
+               cbval1 = *cbptr++ >> 4;
+               cbval2 = *cbptr++ >> 4;
 #else /* not HAVE_SIGNED_SHIFT */
-	       yval1  = *yptr++  / 16 + 128;
-	       yval2  = *yptr++  / 16 + 128;
-	       crval1 = *crptr++ / 16;
-	       crval2 = *crptr++ / 16;
-	       cbval1 = *cbptr++ / 16;
-	       cbval2 = *cbptr++ / 16;
+               yval1  = *yptr++  / 16 + 128;
+               yval2  = *yptr++  / 16 + 128;
+               crval1 = *crptr++ / 16;
+               crval2 = *crptr++ / 16;
+               cbval1 = *cbptr++ / 16;
+               cbval2 = *cbptr++ / 16;
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
-	       G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
-	       B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
-	       R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
-	       G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
-	       B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
-
-	       *dst++ |= (R1 << 16) | (G1 << 24);
-	       *dst++ = B1 | (R2 << 8) | (G2 << 16) | (B2 << 24);
-	    }
-	 }
+               R1 = gray_clip [yval1 + Cr_r_tab [crval1]];
+               G1 = gray_clip [yval1 + Cr_g_tab [crval1] + Cb_g_tab [cbval1]];
+               B1 = gray_clip [yval1 + Cb_b_tab [cbval1]];
+               R2 = gray_clip [yval2 + Cr_r_tab [crval2]];
+               G2 = gray_clip [yval2 + Cr_g_tab [crval2] + Cb_g_tab [cbval2]];
+               B2 = gray_clip [yval2 + Cb_b_tab [cbval2]];
+
+               *dst++ |= (R1 << 16) | (G1 << 24);
+               *dst++ = B1 | (R2 << 8) | (G2 << 16) | (B2 << 24);
+            }
+         }
       }
    }
    else
    {
-      unsigned int *dst;		/* pointer to dithered pixels */
-      word_t	   *src;		/* current pixel of frame */
+      unsigned int *dst;                /* pointer to dithered pixels */
+      word_t       *src;                /* current pixel of frame */
 
       dst     = (unsigned int *) out;
       src     = image->pixels [GRAY];
 
       if (private->double_resolution)
       {
-	 int	   x, y;		/* pixel counter */
-	 unsigned *shift_clipping = gray_clip + 128;
-
-	 for (y = image->height; y; y--)
-	 {
-	    for (x = image->width >> 1; x; x--)
-	    {
-	       unsigned int val1, val2;
+         int       x, y;                /* pixel counter */
+         unsigned *shift_clipping = gray_clip + 128;
+
+         for (y = image->height; y; y--)
+         {
+            for (x = image->width >> 1; x; x--)
+            {
+               unsigned int val1, val2;
 #ifdef HAVE_SIGNED_SHIFT
-	       val1 = shift_clipping [*src++ >> 4];
-	       val2 = shift_clipping [*src++ >> 4];
+               val1 = shift_clipping [*src++ >> 4];
+               val2 = shift_clipping [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	       val1 = shift_clipping [*src++ / 16];
-	       val2 = shift_clipping [*src++ / 16];
+               val1 = shift_clipping [*src++ / 16];
+               val2 = shift_clipping [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	       *dst++ = val1 | (val1 << 8) | (val1 << 16) | (val1 << 24);
-	       *dst++ = val1 | (val1 << 8) | (val2 << 16) | (val2 << 24); 
-	       *dst++ = val2 | (val2 << 8) | (val2 << 16) | (val2 << 24);
-	    }
+               *dst++ = val1 | (val1 << 8) | (val1 << 16) | (val1 << 24);
+               *dst++ = val1 | (val1 << 8) | (val2 << 16) | (val2 << 24);
+               *dst++ = val2 | (val2 << 8) | (val2 << 16) | (val2 << 24);
+            }
 
-	    memcpy (dst, dst - 3 * (image->width >> 1),
-		    3 * (image->width >> 1) * sizeof (unsigned int));
-	    dst += 3 * (image->width >> 1);
-	 }
+            memcpy (dst, dst - 3 * (image->width >> 1),
+                    3 * (image->width >> 1) * sizeof (unsigned int));
+            dst += 3 * (image->width >> 1);
+         }
       }
       else
       {
-	 int	   n;			/* pixel counter */
-	 unsigned *shift_clipping = gray_clip + 128;
+         int       n;                   /* pixel counter */
+         unsigned *shift_clipping = gray_clip + 128;
 
-	 for (n = (image->width * image->height) >> 2; n; n--)
-	 {
-	    unsigned int val1, val2;
+         for (n = (image->width * image->height) >> 2; n; n--)
+         {
+            unsigned int val1, val2;
 
 #ifdef HAVE_SIGNED_SHIFT
-	    val1 = shift_clipping [*src++ >> 4];
-	    val2 = shift_clipping [*src++ >> 4];
+            val1 = shift_clipping [*src++ >> 4];
+            val2 = shift_clipping [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	    val1 = shift_clipping [*src++ / 16];
-	    val2 = shift_clipping [*src++ / 16];
+            val1 = shift_clipping [*src++ / 16];
+            val2 = shift_clipping [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
 
-	    *dst++ = val1 | (val1 << 8)
-		     | (val1 << 16) | (val2 << 24);  /* RGBR */
-	    *dst   = val2 | (val2 << 8);             /* GB-- */
+            *dst++ = val1 | (val1 << 8)
+                     | (val1 << 16) | (val2 << 24);  /* RGBR */
+            *dst   = val2 | (val2 << 8);             /* GB-- */
 
 #ifdef HAVE_SIGNED_SHIFT
-	    val1 = shift_clipping [*src++ >> 4];
-	    val2 = shift_clipping [*src++ >> 4];
+            val1 = shift_clipping [*src++ >> 4];
+            val2 = shift_clipping [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	    val1 = shift_clipping [*src++ / 16];
-	    val2 = shift_clipping [*src++ / 16];
+            val1 = shift_clipping [*src++ / 16];
+            val2 = shift_clipping [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
-	    
-	    *dst++ |= (val1 << 16) | (val1 << 24);   /* --RG */
-	    *dst++  = val1 | (val2 << 8)
-		      | (val2 << 16) | (val2 << 24); /* BRGB */
-	 }
+
+            *dst++ |= (val1 << 16) | (val1 << 24);   /* --RG */
+            *dst++  = val1 | (val2 << 8)
+                      | (val2 << 16) | (val2 << 24); /* BRGB */
+         }
       }
    }
-   
+
    return 1;
 }
 
-static int 
+static int
 display_32_bit (const struct fiasco_renderer *this, unsigned char *ximage,
-		const fiasco_image_t *fiasco_image)
+                const fiasco_image_t *fiasco_image)
 /*
  *  Convert 'image' to 16 bit color bitmap.
  *  If 'double_resolution' is true then double image size in both directions.
@@ -1566,13 +1566,13 @@ display_32_bit (const struct fiasco_renderer *this, unsigned char *ximage,
  *  No return value.
  *
  *  Side effects:
- *	'out[]'	is filled with dithered image
+ *      'out[]' is filled with dithered image
  */
 {
    const image_t      *image;
    renderer_private_t *private;
-   byte_t	      *out;
-   
+   byte_t             *out;
+
    if (!this)
    {
       set_error (_("Parameter `%s' not defined (NULL)."), "this");
@@ -1589,21 +1589,21 @@ display_32_bit (const struct fiasco_renderer *this, unsigned char *ximage,
       return 0;
    }
 
-   out 	   = (byte_t *) ximage;
+   out     = (byte_t *) ximage;
    private = (renderer_private_t *) this->private;
    image   = cast_image ((fiasco_image_t *) fiasco_image);
    if (!image)
       return 0;
-   
+
    if (image->color)
    {
-      word_t 	   *cbptr, *crptr;	/* pointer to chroma bands */
-      word_t 	   *yptr;		/* pointers to lumincance band */
-      int     	    yval, crval, cbval;	/* pixel value in YCbCr color space */
-      int     	    R, G, B;		/* pixel value in RGB color space */
-      int     	    n;			/* pixel counter */
-      int     	    x, y;		/* pixel coordinates */
-      int 	   *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
+      word_t       *cbptr, *crptr;      /* pointer to chroma bands */
+      word_t       *yptr;               /* pointers to lumincance band */
+      int           yval, crval, cbval; /* pixel value in YCbCr color space */
+      int           R, G, B;            /* pixel value in RGB color space */
+      int           n;                  /* pixel counter */
+      int           x, y;               /* pixel coordinates */
+      int          *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
       unsigned int *r_table, *g_table, *b_table;
 
       Cr_g_tab = private->Cr_g_tab;
@@ -1619,245 +1619,245 @@ display_32_bit (const struct fiasco_renderer *this, unsigned char *ximage,
 
       if (image->format == FORMAT_4_2_0)
       {
-	 unsigned int	*dst, *dst2;	/* pointers to dithered pixels */
-	 word_t		*yptr2;		/* pointers to lumincance band */
-
-	 if (private->double_resolution)
-	 {
-	    yptr2 = yptr + image->width;
-	    dst  = (unsigned int *) out;
-	    dst2 = dst + 4 * image->width;
-	    for (y = image->height / 2; y; y--)
-	    {
-	       for (x = image->width / 2; x; x--)
-	       {
+         unsigned int   *dst, *dst2;    /* pointers to dithered pixels */
+         word_t         *yptr2;         /* pointers to lumincance band */
+
+         if (private->double_resolution)
+         {
+            yptr2 = yptr + image->width;
+            dst  = (unsigned int *) out;
+            dst2 = dst + 4 * image->width;
+            for (y = image->height / 2; y; y--)
+            {
+               for (x = image->width / 2; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  crval = *crptr++ >> 4;
-		  cbval = *cbptr++ >> 4;
-		  yval  = (*yptr++ >> 4) + 128;
+                  crval = *crptr++ >> 4;
+                  cbval = *cbptr++ >> 4;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  crval = *crptr++ / 16;
-		  cbval = *cbptr++ / 16;
-		  yval  = *yptr++  / 16 + 128;
+                  crval = *crptr++ / 16;
+                  cbval = *cbptr++ / 16;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-	       
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr++ >> 4) + 128;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr++  / 16 + 128;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-	       }
-	       memcpy (dst, dst - 2 * image->width,
-		       2 * image->width * sizeof (unsigned int));
-	       memcpy (dst2, dst2 - 2 * image->width,
-		       2 * image->width * sizeof (unsigned int));
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	       dst   += 3 * image->width * 2;
-	       dst2  += 3 * image->width * 2;
-	    }
-	 }
-	 else
-	 {
-	    yptr2 = yptr + image->width;
-	    dst   = (unsigned int *) out;
-	    dst2  = dst + image->width;
-	    
-	    for (y = image->height / 2; y; y--)
-	    {
-	       for (x = image->width / 2; x; x--)
-	       {
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+               }
+               memcpy (dst, dst - 2 * image->width,
+                       2 * image->width * sizeof (unsigned int));
+               memcpy (dst2, dst2 - 2 * image->width,
+                       2 * image->width * sizeof (unsigned int));
+               yptr  += image->width;
+               yptr2 += image->width;
+               dst   += 3 * image->width * 2;
+               dst2  += 3 * image->width * 2;
+            }
+         }
+         else
+         {
+            yptr2 = yptr + image->width;
+            dst   = (unsigned int *) out;
+            dst2  = dst + image->width;
+
+            for (y = image->height / 2; y; y--)
+            {
+               for (x = image->width / 2; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  crval = *crptr++ >> 4;
-		  cbval = *cbptr++ >> 4;
-		  yval  = (*yptr++ >> 4) + 128;
+                  crval = *crptr++ >> 4;
+                  cbval = *cbptr++ >> 4;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  crval = *crptr++ / 16;
-		  cbval = *cbptr++ / 16;
-		  yval  = *yptr++  / 16 + 128;
+                  crval = *crptr++ / 16;
+                  cbval = *cbptr++ / 16;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-	       
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr++ >> 4) + 128;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr++  / 16 + 128;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
 
 #ifdef HAVE_SIGNED_SHIFT
-		  yval  = (*yptr2++ >> 4) + 128;
+                  yval  = (*yptr2++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  yval  = *yptr2++  / 16 + 128;
+                  yval  = *yptr2++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  *dst2++ = r_table [R] | g_table [G] | b_table [B];
-	       }
-	       yptr  += image->width;
-	       yptr2 += image->width;
-	       dst   += image->width;
-	       dst2  += image->width;
-	    }
-	 }
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+                  *dst2++ = r_table [R] | g_table [G] | b_table [B];
+               }
+               yptr  += image->width;
+               yptr2 += image->width;
+               dst   += image->width;
+               dst2  += image->width;
+            }
+         }
       }
-      else				/* 4:4:4 format */
+      else                              /* 4:4:4 format */
       {
-	 if (private->double_resolution)
-	 {
-	    unsigned int *dst;		/* pointer to dithered pixels */
-	    
-	    dst = (unsigned int *) out;
-	    
-	    for (y = image->height; y; y--)
-	    {
-	       for (x = image->width; x; x--)
-	       {
+         if (private->double_resolution)
+         {
+            unsigned int *dst;          /* pointer to dithered pixels */
+
+            dst = (unsigned int *) out;
+
+            for (y = image->height; y; y--)
+            {
+               for (x = image->width; x; x--)
+               {
 #ifdef HAVE_SIGNED_SHIFT
-		  crval = *crptr++ >> 4;
-		  cbval = *cbptr++ >> 4;
-		  yval  = (*yptr++ >> 4) + 128;
+                  crval = *crptr++ >> 4;
+                  cbval = *cbptr++ >> 4;
+                  yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-		  crval = *crptr++ / 16;
-		  cbval = *cbptr++ / 16;
-		  yval  = *yptr++  / 16 + 128;
+                  crval = *crptr++ / 16;
+                  cbval = *cbptr++ / 16;
+                  yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-		  R = yval + Cr_r_tab [crval];
-		  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-		  B = yval + Cb_b_tab [cbval];
-		  
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-		  *dst++ = r_table [R] | g_table [G] | b_table [B];
-	       }
-	       memcpy (dst, dst - 2 * image->width,
-		       2 * image->width * sizeof (unsigned int));
-	       dst += image->width * 2;
-	    }
-	 }
-	 else
-	 {
-	    unsigned int *dst;		/* pointer to dithered pixels */
-
-	    dst  = (unsigned int *) out;
-	    
-	    for (n = image->width * image->height; n; n--)
-	    {
+                  R = yval + Cr_r_tab [crval];
+                  G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+                  B = yval + Cb_b_tab [cbval];
+
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+                  *dst++ = r_table [R] | g_table [G] | b_table [B];
+               }
+               memcpy (dst, dst - 2 * image->width,
+                       2 * image->width * sizeof (unsigned int));
+               dst += image->width * 2;
+            }
+         }
+         else
+         {
+            unsigned int *dst;          /* pointer to dithered pixels */
+
+            dst  = (unsigned int *) out;
+
+            for (n = image->width * image->height; n; n--)
+            {
 #ifdef HAVE_SIGNED_SHIFT
-	       crval = *crptr++ >> 4;
-	       cbval = *cbptr++ >> 4;
-	       yval  = (*yptr++ >> 4) + 128;
+               crval = *crptr++ >> 4;
+               cbval = *cbptr++ >> 4;
+               yval  = (*yptr++ >> 4) + 128;
 #else /* not HAVE_SIGNED_SHIFT */
-	       crval = *crptr++ / 16;
-	       cbval = *cbptr++ / 16;
-	       yval  = *yptr++  / 16 + 128;
+               crval = *crptr++ / 16;
+               cbval = *cbptr++ / 16;
+               yval  = *yptr++  / 16 + 128;
 #endif /* not HAVE_SIGNED_SHIFT */
-	       R = yval + Cr_r_tab [crval];
-	       G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
-	       B = yval + Cb_b_tab [cbval];
+               R = yval + Cr_r_tab [crval];
+               G = yval + Cr_g_tab [crval] + Cb_g_tab [cbval];
+               B = yval + Cb_b_tab [cbval];
 
-	       *dst++ = r_table [R] | g_table [G] | b_table [B];
-	    }
-	 }
+               *dst++ = r_table [R] | g_table [G] | b_table [B];
+            }
+         }
       }
    }
    else
    {
-      unsigned int *dst;		/* pointer to dithered pixels */
-      word_t	   *src;		/* current pixel of frame */
+      unsigned int *dst;                /* pointer to dithered pixels */
+      word_t       *src;                /* current pixel of frame */
       unsigned int *y_table;
 
       y_table = private->y_table;
       dst     = (unsigned int *) out;
       src     = image->pixels [GRAY];
-      
+
       if (private->double_resolution)
       {
-	 int x, y;			/* pixel coordinates */
-	 
-	 for (y = image->height; y; y--)
-	 {
-	    for (x = image->width; x; x--)
-	    {
-	       int value;
+         int x, y;                      /* pixel coordinates */
+
+         for (y = image->height; y; y--)
+         {
+            for (x = image->width; x; x--)
+            {
+               int value;
 
 #ifdef HAVE_SIGNED_SHIFT
-	       value = y_table [*src++ >> 4];
+               value = y_table [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	       value = y_table [*src++ / 16];
+               value = y_table [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
-	       *dst++ = value;
-	       *dst++ = value;
-	    }
-
-	    memcpy (dst, dst - 2 * image->width,
-		    2 * image->width * sizeof (unsigned int));
-	    dst += 2 * image->width;
-	 }
+               *dst++ = value;
+               *dst++ = value;
+            }
+
+            memcpy (dst, dst - 2 * image->width,
+                    2 * image->width * sizeof (unsigned int));
+            dst += 2 * image->width;
+         }
       }
       else
       {
-	 int n;				/* pixel counter */
-	 
-	 for (n = image->width * image->height; n; n--)
+         int n;                         /* pixel counter */
+
+         for (n = image->width * image->height; n; n--)
 #ifdef HAVE_SIGNED_SHIFT
-	    *dst++ = y_table [*src++ >> 4];
+            *dst++ = y_table [*src++ >> 4];
 #else /* not HAVE_SIGNED_SHIFT */
-	    *dst++ = y_table [*src++ / 16];
+            *dst++ = y_table [*src++ / 16];
 #endif /* not HAVE_SIGNED_SHIFT */
       }
    }
-   
+
    return 1;
 }
 
 
- 
+
diff --git a/converter/other/fiasco/lib/dither.h b/converter/other/fiasco/lib/dither.h
index 767bca28..e786af1f 100644
--- a/converter/other/fiasco/lib/dither.h
+++ b/converter/other/fiasco/lib/dither.h
@@ -1,8 +1,8 @@
 /*
  *  dither.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -19,9 +19,9 @@
 
 typedef struct renderer_private
 {
-   int 	       	*Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
+   int          *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
    unsigned int *r_table, *g_table, *b_table, *y_table;
-   bool_t	double_resolution;
+   bool_t       double_resolution;
 } renderer_private_t;
 
 #endif /* _DITHER_H */
diff --git a/converter/other/fiasco/lib/error.c b/converter/other/fiasco/lib/error.c
index 394f896f..30d0cf97 100644
--- a/converter/other/fiasco/lib/error.c
+++ b/converter/other/fiasco/lib/error.c
@@ -1,11 +1,11 @@
 /*
- *  error.c:		Error handling
+ *  error.c:            Error handling
  *
- *  Written by:		Stefan Frank
- *			Ullrich Hafner
+ *  Written by:         Stefan Frank
+ *                      Ullrich Hafner
  *
- *  Credits:	Modelled after variable argument routines from Jef
- *		Poskanzer's pbmplus package.
+ *  Credits:    Modelled after variable argument routines from Jef
+ *              Poskanzer's pbmplus package.
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #if HAVE_SETJMP_H
-#	include <setjmp.h>
+#       include <setjmp.h>
 #endif /* HAVE_SETJMP_H */
 
 #include "types.h"
@@ -36,12 +36,12 @@
 
 /*****************************************************************************
 
-			     local variables
+                             local variables
 
 *****************************************************************************/
 
 static fiasco_verbosity_e  verboselevel  = FIASCO_SOME_VERBOSITY;
-static char 	      	  *error_message = NULL;
+static char               *error_message = NULL;
 
 #if HAVE_SETJMP_H
 jmp_buf env;
@@ -49,7 +49,7 @@ jmp_buf env;
 
 /*****************************************************************************
 
-			       public code
+                               public code
 
 *****************************************************************************/
 
@@ -195,7 +195,7 @@ warning(const char * const format, ...) {
 /*----------------------------------------------------------------------------
   Issue a warning.
 -----------------------------------------------------------------------------*/
-    va_list	args;
+    va_list     args;
 
     VA_START (args, format);
 
diff --git a/converter/other/fiasco/lib/error.h b/converter/other/fiasco/lib/error.h
index 4159ccd2..dd6a049f 100644
--- a/converter/other/fiasco/lib/error.h
+++ b/converter/other/fiasco/lib/error.h
@@ -1,6 +1,6 @@
 /*
  *  error.h
- *  
+ *
  *  Written by:     Stefan Frank
  *          Ullrich Hafner
  *
@@ -19,11 +19,11 @@ void
 file_error (const char *filename);
 void
 message (const char *format, ...);
-void 
+void
 debug_message (const char *format, ...);
 void
 warning (const char *format, ...);
-void 
+void
 info (const char *format, ...);
 const char *
 get_system_error (void);
diff --git a/converter/other/fiasco/lib/image.h b/converter/other/fiasco/lib/image.h
index c3c5f0df..d6a3c6c0 100644
--- a/converter/other/fiasco/lib/image.h
+++ b/converter/other/fiasco/lib/image.h
@@ -1,8 +1,8 @@
 /*
  *  image.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -31,11 +31,11 @@ typedef struct image
 {
    char      id [8];         /* NUL-terminated "IFIASCO" */
    unsigned  reference_count;
-   unsigned  width;			/* Width of the image */
-   unsigned  height;			/* Height of the image */
-   bool_t    color;			/* Color or grayscale image */
-   format_e  format;			/* Pixel format 4:4:4 or 4:2:0 */
-   word_t   *pixels [3];		/* Pixels in short format */
+   unsigned  width;                     /* Width of the image */
+   unsigned  height;                    /* Height of the image */
+   bool_t    color;                     /* Color or grayscale image */
+   format_e  format;                    /* Pixel format 4:4:4 or 4:2:0 */
+   word_t   *pixels [3];                /* Pixels in short format */
 } image_t;
 
 image_t *
@@ -48,7 +48,7 @@ void
 free_image (image_t *image);
 FILE *
 read_pnmheader (const char *image_name, unsigned *width, unsigned *height,
-		bool_t *color);
+                bool_t *color);
 
 image_t *
 read_image_stream(FILE *       const ifP,
diff --git a/converter/other/fiasco/lib/list.c b/converter/other/fiasco/lib/list.c
index b67ff4b8..24ba4985 100644
--- a/converter/other/fiasco/lib/list.c
+++ b/converter/other/fiasco/lib/list.c
@@ -1,8 +1,8 @@
 /*
- *  list.c:		List operations	
+ *  list.c:             List operations
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -27,8 +27,8 @@
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 list_t *
@@ -39,15 +39,15 @@ alloc_list (size_t size_of_element)
  *  Size of list element values is given by 'size_of_element'.
  *
  *  Return value:
- *	pointer to an empty list
+ *      pointer to an empty list
  */
 {
    list_t *new_list = Calloc (1, sizeof (list_t));
 
    assert (size_of_element > 0);
 
-   new_list->head 	     = NULL;
-   new_list->tail 	     = NULL;
+   new_list->head            = NULL;
+   new_list->tail            = NULL;
    new_list->size_of_element = size_of_element;
 
    return new_list;
@@ -62,11 +62,11 @@ free_list (list_t *list)
  *  No return value.
  *
  *  Side effects:
- *	struct 'list' is discarded
+ *      struct 'list' is discarded
  */
 {
    assert (list);
-   
+
    while (list_remove (list, HEAD, NULL))
       ;
    Free (list);
@@ -76,7 +76,7 @@ void
 list_insert (list_t *list, pos_e pos, const void *data)
 /*
  *  Insert a new 'list' element at head ('pos' = HEAD) or
- *  tail ('pos' = TAIL) of 'list'. 
+ *  tail ('pos' = TAIL) of 'list'.
  *  'data' is a pointer to a memory segment of size
  *  'list'->size_of_element containing the value to store.
  *  The value is directly copied - no references are stored.
@@ -84,14 +84,14 @@ list_insert (list_t *list, pos_e pos, const void *data)
  *  No return value.
  *
  *  Side effects:
- *	lists current tail or head is replaced by the new element
+ *      lists current tail or head is replaced by the new element
  */
 {
    node_t *element;
 
    assert (list && data);
 
-   element 	  = Calloc (1, sizeof (node_t));
+   element        = Calloc (1, sizeof (node_t));
    element->value = Calloc (1, list->size_of_element);
    memcpy (element->value, data, list->size_of_element);
 
@@ -100,20 +100,20 @@ list_insert (list_t *list, pos_e pos, const void *data)
       element->next = NULL;
       element->prev = list->tail;
       if (list->tail)
-	 list->tail->next = element;
+         list->tail->next = element;
       list->tail = element;
       if (!list->head)
-	 list->head = element;
+         list->head = element;
    }
-   else					/* pos == HEAD */
+   else                                 /* pos == HEAD */
    {
       element->prev = NULL;
       element->next = list->head;
       if (list->head)
-	 list->head->prev = element;
+         list->head->prev = element;
       list->head = element;
       if (!list->tail)
-	 list->tail = element;
+         list->tail = element;
    }
 }
 
@@ -123,57 +123,57 @@ list_remove (list_t *list, pos_e pos, void *data)
  *  Remove 'list' element from head or tail of 'list'.
  *
  *  Return value:
- *	TRUE on success,
- *	FALSE if list is empty or
- *	      if list value data is NULL
+ *      TRUE on success,
+ *      FALSE if list is empty or
+ *            if list value data is NULL
  *
  *  Side effects:
- *	lists current head or tail is removed
- *	value of the removed list element (if not NULL) is copied to
+ *      lists current head or tail is removed
+ *      value of the removed list element (if not NULL) is copied to
  *      'data' (if 'data' is not NULL)
  */
 {
    node_t *element;
-   void	  *valueptr;
+   void   *valueptr;
 
    assert (list);
-   
+
    if (pos == TAIL)
    {
       element = list->tail;
       if (element)
       {
-	 list->tail = element->prev;
-	 valueptr   = element->value;
-	 Free (element);
+         list->tail = element->prev;
+         valueptr   = element->value;
+         Free (element);
       }
       else
-	 valueptr = NULL;
-      if (!list->tail)			/* 'element' was last node */
-	 list->head = NULL;
+         valueptr = NULL;
+      if (!list->tail)                  /* 'element' was last node */
+         list->head = NULL;
    }
-   else					/* pos == HEAD */
+   else                                 /* pos == HEAD */
    {
       element = list->head;
       if (element)
       {
-	 list->head = element->next;
-	 valueptr   = element->value;
-	 Free (element);
+         list->head = element->next;
+         valueptr   = element->value;
+         Free (element);
       }
       else
-	 valueptr = NULL;
-      if (!list->head)			/* 'element' was last node */
-	 list->tail = NULL;
+         valueptr = NULL;
+      if (!list->head)                  /* 'element' was last node */
+         list->tail = NULL;
    }
 
-   if (valueptr)			/* copy value of node */
+   if (valueptr)                        /* copy value of node */
    {
-      if (data)				
-	 memcpy (data, valueptr, list->size_of_element);
+      if (data)
+         memcpy (data, valueptr, list->size_of_element);
       Free (valueptr);
    }
-   
+
    return valueptr ? TRUE : FALSE;
 }
 
@@ -184,27 +184,27 @@ list_element_n (const list_t *list, pos_e pos, unsigned n, void *data)
  *  (First element is list head if 'pos' == HEAD
  *                 or list tail if 'pos' == TAIL.
  *   Accordingly, traverse the list in ascending or descending order).
- *  
+ *
  *  Return value:
- *	TRUE on success, FALSE if there is no element 'n'
+ *      TRUE on success, FALSE if there is no element 'n'
  *
  *  Side effects:
- *	value of list element 'n' is copied to 'data' 
+ *      value of list element 'n' is copied to 'data'
  */
 {
    node_t *element;
 
    assert (list && data);
-   
+
    if (pos == HEAD)
       for (element = list->head; element != NULL && n;
-	   element = element->next, n--)
-	 ;
+           element = element->next, n--)
+         ;
    else
       for (element = list->tail; element != NULL && n;
-	   element = element->prev, n--)
-	 ;
-      
+           element = element->prev, n--)
+         ;
+
    if (element)
    {
       memcpy (data, element->value, list->size_of_element);
@@ -220,14 +220,14 @@ list_sizeof (const list_t *list)
  *  Count number of 'list' elements.
  *
  *  Return value:
- *	number of 'list' elements.
+ *      number of 'list' elements.
  */
 {
    node_t   *element;
    unsigned  n = 0;
 
    assert (list);
-   
+
    for (element = list->head; element != NULL; element = element->next)
       n++;
 
@@ -247,7 +247,7 @@ list_foreach (const list_t *list, void (*function)(void *, void *), void *data)
    node_t *element;
 
    assert (list && function && data);
-   
+
    for (element = list->head; element; element = element->next)
       function (element->value, data);
 }
diff --git a/converter/other/fiasco/lib/list.h b/converter/other/fiasco/lib/list.h
index 68577dfd..3ba860c0 100644
--- a/converter/other/fiasco/lib/list.h
+++ b/converter/other/fiasco/lib/list.h
@@ -1,8 +1,8 @@
 /*
  *  list.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -22,16 +22,16 @@
 
 typedef struct node
 {
-   struct node *prev;			/* pointer to prev list element */
-   struct node *next;			/* pointer to next list element */
-   void	       *value;			/* pointer to value of node */
+   struct node *prev;                   /* pointer to prev list element */
+   struct node *next;                   /* pointer to next list element */
+   void        *value;                  /* pointer to value of node */
 } node_t;
 
 typedef struct list
 {
    node_t *head;
    node_t *tail;
-   size_t  size_of_element;		/* number of bytes to store value */
+   size_t  size_of_element;             /* number of bytes to store value */
 } list_t;
 
 typedef enum {TAIL, HEAD} pos_e;
@@ -41,26 +41,26 @@ typedef enum {TAIL, HEAD} pos_e;
  */
 
 typedef list_t lqueue_t ;
-#define alloc_queue		alloc_list
-#define free_queue		free_list		
-#define queue_append(q, d)	(list_insert ((q), TAIL, (d)))
-#define queue_remove(q, d)	(list_remove ((q), HEAD, (d)))
+#define alloc_queue             alloc_list
+#define free_queue              free_list
+#define queue_append(q, d)      (list_insert ((q), TAIL, (d)))
+#define queue_remove(q, d)      (list_remove ((q), HEAD, (d)))
 
 typedef list_t lstack_t ;
-#define alloc_stack		alloc_list
-#define free_stack		free_list
-#define stack_push(q, d)	(list_insert ((q), TAIL, (d)))
-#define stack_pop(q, d)		(list_remove ((q), TAIL, (d)))
+#define alloc_stack             alloc_list
+#define free_stack              free_list
+#define stack_push(q, d)        (list_insert ((q), TAIL, (d)))
+#define stack_pop(q, d)         (list_remove ((q), TAIL, (d)))
 
 list_t *
 alloc_list (size_t size_of_element);
-void 
+void
 free_list (list_t *list);
 bool_t
 list_element_n (const list_t *list, pos_e pos, unsigned n, void *data);
 void
 list_foreach (const list_t *list, void (*function)(void *, void *),
-	      void *data);
+              void *data);
 void
 list_insert (list_t *list, pos_e pos, const void *data);
 bool_t
diff --git a/converter/other/fiasco/lib/macros.h b/converter/other/fiasco/lib/macros.h
index 2f404a74..aafea45b 100644
--- a/converter/other/fiasco/lib/macros.h
+++ b/converter/other/fiasco/lib/macros.h
@@ -1,8 +1,8 @@
 /*
  *  macros.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -20,34 +20,34 @@
 #include <string.h>
 /*******************************************************************************
 
-			  System configuration section
-  
+                          System configuration section
+
 *******************************************************************************/
 
 #ifndef SEEK_CUR
-#   define SEEK_CUR	1
+#   define SEEK_CUR     1
 #endif /* not SEEK_CUR */
 
 /*****************************************************************************
 
-				Various macros
-  
+                                Various macros
+
 *****************************************************************************/
 
-#define square(x)		((x) * (x))
-#define first_band(color)	((unsigned) ((color) ? Y  : GRAY))
+#define square(x)               ((x) * (x))
+#define first_band(color)       ((unsigned) ((color) ? Y  : GRAY))
 #define last_band(color)        ((unsigned) ((color) ? Cr : GRAY))
-#define width_of_level(l)	((unsigned) (1 << ((l) >> 1)))
-#define height_of_level(l)	((unsigned) (1 << (((l) + 1) >> 1)))
-#define size_of_level(l)	((unsigned) (1 << (l)))
-#define address_of_level(l)	((unsigned) (size_of_level (l) - 1))
-#define size_of_tree(l)		((unsigned) (address_of_level ((l) + 1)))
-#define is_odd(n)		(abs (n) % 2)
-#define _(x) (x) 
+#define width_of_level(l)       ((unsigned) (1 << ((l) >> 1)))
+#define height_of_level(l)      ((unsigned) (1 << (((l) + 1) >> 1)))
+#define size_of_level(l)        ((unsigned) (1 << (l)))
+#define address_of_level(l)     ((unsigned) (size_of_level (l) - 1))
+#define size_of_tree(l)         ((unsigned) (address_of_level ((l) + 1)))
+#define is_odd(n)               (abs (n) % 2)
+#define _(x) (x)
 
 
-#define	MAXSTRLEN 1024
-#define	MAXSTRLEN_SCANF "%1024s"
+#define MAXSTRLEN 1024
+#define MAXSTRLEN_SCANF "%1024s"
 
 typedef enum color {GRAY = 0, Y = 0, Cb = 1, Cr = 2} color_e;
 
diff --git a/converter/other/fiasco/lib/misc.c b/converter/other/fiasco/lib/misc.c
index c5629c5c..d02511de 100644
--- a/converter/other/fiasco/lib/misc.c
+++ b/converter/other/fiasco/lib/misc.c
@@ -1,11 +1,11 @@
 /*
- *  misc.c:		Some useful functions, that don't fit in one of 
- *			the other files and that are needed by at least
- *			two modules. 
+ *  misc.c:             Some useful functions, that don't fit in one of
+ *                      the other files and that are needed by at least
+ *                      two modules.
+ *
+ *  Written by:         Stefan Frank
+ *                      Ullrich Hafner
  *
- *  Written by:		Stefan Frank
- *			Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -23,14 +23,14 @@
 #include <ctype.h>
 
 #ifdef TIME_WITH_SYS_TIME
-#	include <sys/time.h>
-#	include <time.h>
+#       include <sys/time.h>
+#       include <time.h>
 #else  /* not TIME_WITH_SYS_TIME */
-#	if HAVE_SYS_TIME_H
-#		include <sys/time.h>
-#	else /* not HAVE_SYS_TIME_H */
-#		include <time.h>
-#	endif /* not HAVE_SYS_TIME_H */
+#       if HAVE_SYS_TIME_H
+#               include <sys/time.h>
+#       else /* not HAVE_SYS_TIME_H */
+#               include <time.h>
+#       endif /* not HAVE_SYS_TIME_H */
 #endif /* not TIME_WITH_SYS_TIME */
 
 #include <stdlib.h>
@@ -47,8 +47,8 @@
 
 /*****************************************************************************
 
-				prototypes
-  
+                                prototypes
+
 *****************************************************************************/
 
 static void
@@ -56,8 +56,8 @@ remove_comments (FILE *file);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 void *
@@ -66,14 +66,14 @@ Calloc (size_t n, size_t size)
  *  Allocate memory like calloc ().
  *
  *  Return value: Pointer to the new block of memory on success,
- *		  otherwise the program is terminated.
+ *                otherwise the program is terminated.
  */
 {
-   void	*ptr;				/* pointer to the new memory block */
+   void *ptr;                           /* pointer to the new memory block */
 
    if (n <= 0 || size <= 0)
       error ("Can't allocate memory for %d items of size %d",
-	     (int) n, (int) size);
+             (int) n, (int) size);
 
    ptr = calloc (n, size);
    if (!ptr)
@@ -100,20 +100,20 @@ unsigned
 prg_timer (clock_t *last_timer, enum action_e action)
 /*
  *  If 'action' == START then store current value of system timer.
- *  If 'action' == STOP	 then compute number of elapsed micro seconds since
- *			 the last time 'prg_timer' was called
- *			 with 'action' == START.
+ *  If 'action' == STOP  then compute number of elapsed micro seconds since
+ *                       the last time 'prg_timer' was called
+ *                       with 'action' == START.
  *
  *  Return value:
- *	Number of elapsed micro seconds if 'action' == STOP
- *	0				if 'action' == START
+ *      Number of elapsed micro seconds if 'action' == STOP
+ *      0                               if 'action' == START
  *
  *  Side effects:
- *	last_timer is set to current timer if action == START
+ *      last_timer is set to current timer if action == START
  */
 {
    assert (last_timer);
-   
+
    if (action == START)
    {
       *last_timer = clock ();
@@ -123,19 +123,19 @@ prg_timer (clock_t *last_timer, enum action_e action)
       return (clock () - *last_timer) / (CLOCKS_PER_SEC / 1000.0);
 }
 
-real_t 
+real_t
 read_real (FILE *infile)
-/* 
+/*
  *  Read one real value from the given input stream 'infile'.
- *  
+ *
  *  Return value:
- *	real value on success
+ *      real value on success
  */
 {
    float input;
 
    assert (infile);
-   
+
    remove_comments (infile);
    if (fscanf(infile, "%f", &input) != 1)
       error("Can't read float value!");
@@ -143,26 +143,26 @@ read_real (FILE *infile)
    return (real_t) input;
 }
 
-int 
+int
 read_int (FILE *infile)
-/* 
+/*
  *  Read one integer value from the given input stream 'infile'.
  *
  *  Return value:
- *	integer value on success
+ *      integer value on success
  */
 {
-   int input;				/* integer */
+   int input;                           /* integer */
 
    assert (infile);
-   
+
    remove_comments (infile);
    if (fscanf(infile, "%d", &input) != 1)
       error("Can't read integer value!");
 
    return input;
 }
-   
+
 static void
 remove_comments (FILE *file)
 /*
@@ -171,27 +171,27 @@ remove_comments (FILE *file)
  *  No return value.
  */
 {
-   int c;				/* current character */
-   
+   int c;                               /* current character */
+
    assert (file);
-   
+
    do
    {
       while (isspace(c = getc (file)))
-	 ;
+         ;
       if (c == EOF)
-	 error ("EOF reached, input seems to be truncated!");
+         error ("EOF reached, input seems to be truncated!");
       if (c == '#')
       {
-	 int dummy;
-	 
-	 while (((dummy = getc (file)) != '\n') && dummy != EOF)
-	    ;
-	 if (dummy == EOF)
-	    error ("EOF reached, input seems to be truncated!");
+         int dummy;
+
+         while (((dummy = getc (file)) != '\n') && dummy != EOF)
+            ;
+         if (dummy == EOF)
+            error ("EOF reached, input seems to be truncated!");
       }
-      else 
-	 ungetc (c, file);
+      else
+         ungetc (c, file);
    } while (c == '#');
 }
 
@@ -203,10 +203,10 @@ write_rice_code (unsigned value, unsigned rice_k, bitfile_t *output)
  *  No return value.
  */
 {
-   unsigned unary;			/* unary part of Rice Code */
+   unsigned unary;                      /* unary part of Rice Code */
 
    assert (output);
-   
+
    for (unary = value >> rice_k; unary; unary--)
       put_bit (output, 1);
    put_bit (output, 0);
@@ -219,13 +219,13 @@ read_rice_code (unsigned rice_k, bitfile_t *input)
  *  Read a Rice encoded integer (base 'rice_k') from the stream 'input'.
  *
  *  Return value:
- *	decoded integer
+ *      decoded integer
  */
 {
-   unsigned unary;			/* unary part of Rice code */
-   
+   unsigned unary;                      /* unary part of Rice code */
+
    assert (input);
-   
+
    for (unary = 0; get_bit (input); unary++) /* unary part */
       ;
 
@@ -243,15 +243,15 @@ write_bin_code (unsigned value, unsigned maxval, bitfile_t *output)
 {
    unsigned k;
    unsigned r;
-   
+
    assert (output && maxval && value <= maxval);
 
    k = log2 (maxval + 1);
    r = (maxval + 1) % (1 << k);
 
-   if (value < maxval + 1 - 2 * r)	/* 0, ... , maxval - 2r */
+   if (value < maxval + 1 - 2 * r)      /* 0, ... , maxval - 2r */
       put_bits (output, value, k);
-   else					/* maxval - 2r + 1, ..., maxval */
+   else                                 /* maxval - 2r + 1, ..., maxval */
       put_bits (output, value + maxval + 1 - 2 * r, k + 1);
 }
 
@@ -261,13 +261,13 @@ read_bin_code (unsigned maxval, bitfile_t *input)
  *  Read a bincode encoded integer from the stream 'input'.
  *
  *  Return value:
- *	decoded integer
+ *      decoded integer
  */
 {
    unsigned k;
    unsigned r;
    unsigned value;
-   
+
    assert (input);
 
    k = log2 (maxval + 1);
@@ -280,7 +280,7 @@ read_bin_code (unsigned maxval, bitfile_t *input)
    {
       value <<= 1;
       if (get_bit (input))
-	 value++;
+         value++;
       return value - maxval - 1 + 2 * r;
    }
 }
@@ -292,12 +292,12 @@ bits_rice_code (unsigned value, unsigned rice_k)
  *  with given Rice code 'rice_k'.
  *
  *  Return value:
- *	number of bits
+ *      number of bits
  */
 {
    unsigned unary;
    unsigned bits = 0;
-   
+
    for (unary = value >> rice_k; unary; unary--)
       bits++;
    bits += rice_k + 1;
@@ -312,7 +312,7 @@ bits_bin_code (unsigned value, unsigned maxval)
  *  with adjusted binary code of given maximum value 'maxval'.
  *
  *  Return value:
- *	number of bits
+ *      number of bits
  */
 {
    unsigned k;
@@ -332,30 +332,30 @@ init_clipping (void)
  *  Initialize the clipping tables
  *
  *  Return value:
- *	pointer to clipping table
+ *      pointer to clipping table
  */
 {
-   static unsigned *gray_clip = NULL;	/* clipping array */
+   static unsigned *gray_clip = NULL;   /* clipping array */
 
-   if (gray_clip == NULL)		/* initialize clipping table */
+   if (gray_clip == NULL)               /* initialize clipping table */
    {
-      int i;				/* counter */
+      int i;                            /* counter */
 
       gray_clip  = calloc (256 * 3, sizeof (unsigned));
       if (!gray_clip)
       {
-	 set_error (_("Out of memory."));
-	 return NULL;
+         set_error (_("Out of memory."));
+         return NULL;
       }
       gray_clip += 256;
 
       for (i = -256; i < 512; i++)
-	 if (i < 0)
-	    gray_clip [i] = 0;
-	 else if (i > 255)
-	    gray_clip [i] = 255;
-	 else
-	    gray_clip [i] = i;
+         if (i < 0)
+            gray_clip [i] = 0;
+         else if (i > 255)
+            gray_clip [i] = 255;
+         else
+            gray_clip [i] = i;
    }
 
    return gray_clip;
@@ -369,29 +369,29 @@ memmove (void *v_dst, const void *v_src, size_t n)
  *  The memory areas may overlap.
  *
  *  Return value:
- *	pointer 'dest'
+ *      pointer 'dest'
  */
 {
-   byte_t	*to, *dst = (byte_t *) v_dst;
-   const byte_t	*from, *src = (byte_t *) v_src;
-   
+   byte_t       *to, *dst = (byte_t *) v_dst;
+   const byte_t *from, *src = (byte_t *) v_src;
+
    assert (v_dst && v_src);
-   
+
    if (dst <= src)
    {
       from = src;
       to   = dst;
       for (; n; n--)
-	 *to++ = *from++;
+         *to++ = *from++;
    }
    else
-   { 
+   {
       from = src + (n - 1);
       to   = dst + (n - 1);
       for (; n; n--)
-	 *to-- = *from--;
+         *to-- = *from--;
    }
-   
+
    return v_dst;
 }
 #endif /* not HAVE_MEMMOVE */
@@ -405,7 +405,7 @@ double
 Log2 (double x)
 /*
  *  Return value:
- *	base-2 logarithm of 'x'
+ *      base-2 logarithm of 'x'
  */
 {
    return log (x) / 0.69314718;
@@ -413,32 +413,32 @@ Log2 (double x)
 
 real_t
 variance (const word_t *pixels, unsigned x0, unsigned y0,
-	  unsigned width, unsigned height, unsigned cols)
+          unsigned width, unsigned height, unsigned cols)
 /*
- *  Compute variance of subimage ('x0', y0', 'width', 'height') of 
+ *  Compute variance of subimage ('x0', y0', 'width', 'height') of
  *  the image data given by 'pixels' ('cols' is the number of pixels
  *  in one row of the image).
  *
  *  Return value:
- *	variance
+ *      variance
  */
 {
-   real_t   average;			/* average of pixel values */
-   real_t   variance;			/* variance of pixel values */
-   unsigned x, y;			/* pixel counter */
-   unsigned n;				/* number of pixels */
+   real_t   average;                    /* average of pixel values */
+   real_t   variance;                   /* variance of pixel values */
+   unsigned x, y;                       /* pixel counter */
+   unsigned n;                          /* number of pixels */
 
    assert (pixels);
-   
+
    for (average = 0, n = 0, y = y0; y < y0 + height; y++)
       for (x = x0; x < MIN(x0 + width, cols); x++, n++)
-	 average += pixels [y * cols + x] / 16;
+         average += pixels [y * cols + x] / 16;
 
    average /= n;
 
    for (variance = 0, y = y0; y < y0 + height; y++)
       for (x = x0; x < MIN(x0 + width, cols); x++)
-	 variance += square ((pixels [y * cols + x] / 16) - average);
+         variance += square ((pixels [y * cols + x] / 16) - average);
 
    return variance;
 }
@@ -482,7 +482,7 @@ sort_asc_pair (const void *value1, const void *value2)
 {
    word_t v1 = ((pair_t *) value1)->key;
    word_t v2 = ((pair_t *) value2)->key;
-   
+
    if (v1 < v2)
       return -1;
    else if (v1 > v2)
diff --git a/converter/other/fiasco/lib/misc.h b/converter/other/fiasco/lib/misc.h
index 6f643b7a..48f8bdaa 100644
--- a/converter/other/fiasco/lib/misc.h
+++ b/converter/other/fiasco/lib/misc.h
@@ -1,9 +1,9 @@
 /*
  *  misc.h
  *
- *  Written by:		Stefan Frank
- *			Ullrich Hafner
- *		
+ *  Written by:         Stefan Frank
+ *                      Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -21,14 +21,14 @@
 #include "config.h"
 
 #if TIME_WITH_SYS_TIME
-#	include <sys/time.h>
-#	include <time.h>
+#       include <sys/time.h>
+#       include <time.h>
 #else  /* not TIME_WITH_SYS_TIME */
-#	if HAVE_SYS_TIME_H
-#		include <sys/time.h>
-#	else /* not HAVE_SYS_TIME_H */
-#		include <time.h>
-#	endif /* not HAVE_SYS_TIME_H */
+#       if HAVE_SYS_TIME_H
+#               include <sys/time.h>
+#       else /* not HAVE_SYS_TIME_H */
+#               include <time.h>
+#       endif /* not HAVE_SYS_TIME_H */
 #endif /* not TIME_WITH_SYS_TIME */
 
 #include <stdio.h>
@@ -43,9 +43,9 @@ void
 Free (void *memory);
 unsigned
 prg_timer (clock_t *ptimer, enum action_e action);
-int 
+int
 read_int(FILE *infile);
-real_t 
+real_t
 read_real(FILE *infile);
 unsigned
 read_rice_code (unsigned rice_k, bitfile_t *input);
@@ -63,7 +63,7 @@ unsigned *
 init_clipping (void);
 real_t
 variance (const word_t *pixels, unsigned x0, unsigned y0,
-	  unsigned width, unsigned height, unsigned cols);
+          unsigned width, unsigned height, unsigned cols);
 
 #ifndef HAVE_MEMMOVE
 void *
diff --git a/converter/other/fiasco/lib/mvcode.c b/converter/other/fiasco/lib/mvcode.c
index d9ce91e2..0e6b6626 100644
--- a/converter/other/fiasco/lib/mvcode.c
+++ b/converter/other/fiasco/lib/mvcode.c
@@ -8,7 +8,7 @@ unsigned mv_code_table [33][2] =
    {0x19, 11}, {0x1b, 11}, {0x1d, 11}, {0x1f, 11}, {0x21, 11}, {0x23, 11},
    {0x13, 10}, {0x15, 10}, {0x17, 10}, {0x7, 8}, {0x9, 8}, {0xb, 8}, {0x7, 7},
    {0x3, 5}, {0x3, 4}, {0x3, 3}, {0x1, 1}, {0x2, 3}, {0x2, 4}, {0x2, 5},
-   {0x6, 7}, {0xa, 8}, {0x8, 8}, {0x6, 8}, {0x16, 10}, {0x14, 10}, {0x12, 10}, 
+   {0x6, 7}, {0xa, 8}, {0x8, 8}, {0x6, 8}, {0x16, 10}, {0x14, 10}, {0x12, 10},
    {0x22, 11}, {0x20, 11}, {0x1e, 11}, {0x1c, 11}, {0x1a, 11}, {0x18, 11}
 };
 
diff --git a/converter/other/fiasco/lib/rpf.c b/converter/other/fiasco/lib/rpf.c
index e6ff6e09..61e2f953 100644
--- a/converter/other/fiasco/lib/rpf.c
+++ b/converter/other/fiasco/lib/rpf.c
@@ -4,7 +4,7 @@
  *  Written by:     Stefan Frank
  *          Richard Krampfl
  *          Ullrich Hafner
- *      
+ *
  *  This file is part of FIASCO («F»ractal «I»mage «A»nd «S»equence «CO»dec)
  *  Copyright (C) 1994-2000 Ullrich Hafner <hafner@bigfoot.de>
  */
@@ -32,7 +32,7 @@ int const RPF_ZERO = -1;
 /*****************************************************************************
 
                    private code
-  
+
 *****************************************************************************/
 
 
@@ -62,25 +62,25 @@ rtob (real_t        const f,
  *  Convert real number 'f' into fixed point format.
  *  The real number in [-'range'; +'range'] is scaled to [-1 ; +1].
  *  Sign and the first 'precision' - 1 bits of the mantissa are
- *  packed into one integer.  
+ *  packed into one integer.
  *
  *  Return value:
  *  real value in reduced precision format
  */
-{  
+{
     /*
      *  Extract mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit)
      */
 
     double const normalized = f / rpfP->range;
-        /* 'f' scaled to [-1,+1] */    
+        /* 'f' scaled to [-1,+1] */
     FracExp const fracExp = fracExpFromDouble(normalized);
     unsigned int const signedMantissa =
         (unsigned int) (fracExp.fraction * (1<<23));
 
     unsigned int mantissa;
     unsigned int sign;  /* 0 for positive; 1 for negative */
-    
+
     if (signedMantissa < 0) {
         mantissa = -signedMantissa;
         sign = 1;
@@ -92,16 +92,16 @@ rtob (real_t        const f,
     /*
      *  Generate reduced precision mantissa.
      */
-    if (fracExp.exponent > 0) 
+    if (fracExp.exponent > 0)
         mantissa <<= fracExp.exponent;
     else
-        mantissa >>= -fracExp.exponent;  
-    
+        mantissa >>= -fracExp.exponent;
+
     mantissa >>= (23 - rpfP->mantissa_bits - 1);
 
     mantissa +=  1;          /* Round last bit. */
     mantissa >>= 1;
-   
+
     if (mantissa == 0)           /* close to zero */
         return RPF_ZERO;
     else if (mantissa >= (1U << rpfP->mantissa_bits)) /* overflow */
@@ -126,7 +126,7 @@ btor (int           const binary,
     unsigned int mantissa;
     float sign;
     float f;
- 
+
     if (binary == RPF_ZERO)
         return 0;
 
@@ -137,16 +137,16 @@ btor (int           const binary,
      *  Restore IEEE float format:
      *  mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit)
      */
-   
+
     sign       = (binary & 0x1) == 0 ? 1.0 : -1.0;
-    mantissa   = (binary & ((0x1 << (rpfP->mantissa_bits + 1)) - 1)) >> 1; 
+    mantissa   = (binary & ((0x1 << (rpfP->mantissa_bits + 1)) - 1)) >> 1;
     mantissa <<= (23 - rpfP->mantissa_bits);
 
-    if (mantissa == 0) 
+    if (mantissa == 0)
         f = sign;
     else
         f =  sign * (float) mantissa / 8388608;
-   
+
     return f * rpfP->range;       /* expand [ -1 ; +1 ] to
                                      [ -range ; +range ] */
 }
@@ -163,7 +163,7 @@ alloc_rpf (unsigned           const mantissa,
  *  Number of mantissa bits is given by `mantissa'.
  *  The range of the real values is in the interval [-`range', +`range'].
  *  In case of invalid parameters, a structure with default values is
- *  returned. 
+ *  returned.
  *
  *  Return value
  *  pointer to the new rpf structure
@@ -172,7 +172,7 @@ alloc_rpf (unsigned           const mantissa,
     rpf_t * rpfP;
 
     MALLOCVAR(rpfP);
-   
+
     if (mantissa < 2) {
         warning (_("Size of RPF mantissa has to be in the interval [2,8]. "
                    "Using minimum value 2.\n"));
diff --git a/converter/other/fiasco/lib/rpf.h b/converter/other/fiasco/lib/rpf.h
index e543f855..19e330fb 100644
--- a/converter/other/fiasco/lib/rpf.h
+++ b/converter/other/fiasco/lib/rpf.h
@@ -1,10 +1,10 @@
 /*
  *  rpf.h
  *
- *  Written by:		Stefan Frank
- *			Richard Krampfl
- *			Ullrich Hafner
- *		
+ *  Written by:         Stefan Frank
+ *                      Richard Krampfl
+ *                      Ullrich Hafner
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -24,14 +24,14 @@
 
 typedef struct rpf
 {
-   unsigned    	      mantissa_bits;	/* number of bits used for mantissa */
-   real_t      	      range;		/* scale value to [-range, +range] */
+   unsigned           mantissa_bits;    /* number of bits used for mantissa */
+   real_t             range;            /* scale value to [-range, +range] */
    fiasco_rpf_range_e range_e;
 } rpf_t;
 
 int
 rtob (real_t real, const rpf_t *rpf);
-real_t 
+real_t
 btor (int b, const rpf_t *rpf);
 rpf_t *
 alloc_rpf (unsigned mantissa, fiasco_rpf_range_e range);
diff --git a/converter/other/fiasco/lib/types.h b/converter/other/fiasco/lib/types.h
index 02e40a90..ce216ce5 100644
--- a/converter/other/fiasco/lib/types.h
+++ b/converter/other/fiasco/lib/types.h
@@ -2,7 +2,7 @@
  *  types.h
  *
  *  Written by:     Ullrich Hafner
- *      
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/output/matrices.c b/converter/other/fiasco/output/matrices.c
index 7dc0e6d9..32289dec 100644
--- a/converter/other/fiasco/output/matrices.c
+++ b/converter/other/fiasco/output/matrices.c
@@ -1,8 +1,8 @@
 /*
- *  matrices.c:		Output of transitions matrices
+ *  matrices.c:         Output of transitions matrices
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -38,13 +38,13 @@
 
 /*****************************************************************************
 
-				prototypes
-  
+                                prototypes
+
 *****************************************************************************/
 
 static unsigned
 delta_encoding (bool_t use_normal_domains, bool_t use_delta_domains,
-		const wfa_t *wfa, unsigned last_domain, bitfile_t *output);
+                const wfa_t *wfa, unsigned last_domain, bitfile_t *output);
 static unsigned
 column_0_encoding (const wfa_t *wfa, unsigned last_row, bitfile_t *output);
 static unsigned
@@ -52,75 +52,75 @@ chroma_encoding (const wfa_t *wfa, bitfile_t *output);
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 unsigned
 write_matrices (bool_t use_normal_domains, bool_t use_delta_domains,
-		const wfa_t *wfa, bitfile_t *output)
+                const wfa_t *wfa, bitfile_t *output)
 /*
  *  Write transition matrices of 'wfa' to stream 'output'.
  *
  *  Return value:
- *	number of transitions encoded
+ *      number of transitions encoded
  */
 {
-   unsigned root_state;			/* root of luminance */
-   unsigned total = 0;			/* number of transitions */
-   
+   unsigned root_state;                 /* root of luminance */
+   unsigned total = 0;                  /* number of transitions */
+
    root_state = wfa->wfainfo->color
-		? wfa->tree [wfa->tree [wfa->root_state][0]][0]
-		: wfa->root_state;
-   
+                ? wfa->tree [wfa->tree [wfa->root_state][0]][0]
+                : wfa->root_state;
+
    total  = column_0_encoding (wfa, root_state, output);
 
    total += delta_encoding (use_normal_domains, use_delta_domains,
-			    wfa, root_state, output);
-   
+                            wfa, root_state, output);
+
    if (wfa->wfainfo->color)
       total += chroma_encoding (wfa, output);
-   
+
    return total;
 }
 
 /*****************************************************************************
 
-				private code
-  
+                                private code
+
 *****************************************************************************/
 
 static unsigned
 delta_encoding (bool_t use_normal_domains, bool_t use_delta_domains,
-		const wfa_t *wfa, unsigned last_domain, bitfile_t *output)
+                const wfa_t *wfa, unsigned last_domain, bitfile_t *output)
 /*
  *  Write transition matrices with delta coding to stream 'input'.
  *  'last_domain' is the maximum state number used as domain image.
  *
  *  Return value:
- *	number of non-zero matrix elements (WFA edges)
+ *      number of non-zero matrix elements (WFA edges)
  */
 {
-   range_sort_t	rs;			/* ranges are sorted as in the coder */
-   unsigned	max_domain;		/* dummy used for recursion */
-   unsigned	total = 0;
-      
+   range_sort_t rs;                     /* ranges are sorted as in the coder */
+   unsigned     max_domain;             /* dummy used for recursion */
+   unsigned     total = 0;
+
    /*
     *  Generate a list of range blocks.
     *  The order is the same as in the coder.
     */
    rs.range_state      = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (u_word_t));
+                                 sizeof (u_word_t));
    rs.range_label      = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (byte_t));
+                                 sizeof (byte_t));
    rs.range_max_domain = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (u_word_t));
+                                 sizeof (u_word_t));
    rs.range_subdivided = Calloc ((last_domain + 1) * MAXLABELS,
-				 sizeof (bool_t));
-   rs.range_no	       = 0;
-   max_domain 	       = wfa->basis_states - 1;
+                                 sizeof (bool_t));
+   rs.range_no         = 0;
+   max_domain          = wfa->basis_states - 1;
    sort_ranges (last_domain, &max_domain, &rs, wfa);
-   
+
    /*
     *  Compute and write distribution of #edges
     */
@@ -132,138 +132,138 @@ delta_encoding (bool_t use_normal_domains, bool_t use_delta_domains,
       unsigned edges = 0;
       unsigned M     = 0;
       unsigned bits  = bits_processed (output);
-      
+
       for (n = 0; n < MAXEDGES + 1; n++)
-	 count [n] = 0;
-      
+         count [n] = 0;
+
       for (state = wfa->basis_states; state <= last_domain; state++)
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (isrange (wfa->tree [state][label]))
-	    {
-	       for (edge = 0; isedge (wfa->into [state][label][edge]); edge++)
-		  ;
-	       count [edge]++;
-	       edges++;
-	       M = MAX(edge, M);
-	    }
+         for (label = 0; label < MAXLABELS; label++)
+            if (isrange (wfa->tree [state][label]))
+            {
+               for (edge = 0; isedge (wfa->into [state][label][edge]); edge++)
+                  ;
+               count [edge]++;
+               edges++;
+               M = MAX(edge, M);
+            }
       write_rice_code (M, 3, output);
       for (n = 0; n <= M; n++)
 /* NETPBM: The following causes a crash when last_domain < 4, because
    it requests writing of a negative number of bits.  And we have seen
-   last_domain = 3.  But we have no clue what last_domain means, or 
+   last_domain = 3.  But we have no clue what last_domain means, or
    even what a rice code is, so we don't know where the error lies.
-   -Bryan 2001.02.09 
+   -Bryan 2001.02.09
 */
-	 write_rice_code (count [n], (int) log2 (last_domain) - 2, output);
+         write_rice_code (count [n], (int) log2 (last_domain) - 2, output);
 
       /*
        * Arithmetic coding of values */
       {
-	 unsigned  range;
-	 model_t  *elements = alloc_model (M + 1, 0, 0, count);
-	 arith_t  *encoder  = alloc_encoder (output);
-	       
-	 for (range = 0; range < rs.range_no; range++)
-	    if (!rs.range_subdivided [range])
-	    {
-	       state = rs.range_state [range];
-	       label = rs.range_label [range];
-	       for (edge = 0; isedge (wfa->into [state][label][edge]); edge++)
-		  ;
-	       
-	       encode_symbol (edge, encoder, elements);
-	    }
-	 free_encoder (encoder);
-	 free_model (elements);
+         unsigned  range;
+         model_t  *elements = alloc_model (M + 1, 0, 0, count);
+         arith_t  *encoder  = alloc_encoder (output);
+
+         for (range = 0; range < rs.range_no; range++)
+            if (!rs.range_subdivided [range])
+            {
+               state = rs.range_state [range];
+               label = rs.range_label [range];
+               for (edge = 0; isedge (wfa->into [state][label][edge]); edge++)
+                  ;
+
+               encode_symbol (edge, encoder, elements);
+            }
+         free_encoder (encoder);
+         free_model (elements);
       }
       debug_message ("delta-#edges: %5d bits. (%5d symbols => %5.2f bps)",
-		     bits_processed (output) - bits, edges,
-		     edges > 0 ? ((bits_processed (output) - bits) /
-				  (double) edges) : 0);
+                     bits_processed (output) - bits, edges,
+                     edges > 0 ? ((bits_processed (output) - bits) /
+                                  (double) edges) : 0);
    }
 
    /*
     *  Write matrix elements
     */
    {
-      unsigned	bits  	 = bits_processed (output);
+      unsigned  bits     = bits_processed (output);
       u_word_t *mapping1 = Calloc (wfa->states, sizeof (u_word_t));
       u_word_t *mapping2 = Calloc (wfa->states, sizeof (u_word_t));
-      unsigned	range;
+      unsigned  range;
 
       put_bit (output, use_normal_domains);
       put_bit (output, use_delta_domains);
-      
+
       /*
        *  Generate array of states which are admitted domains.
        *  When coding intra frames 'mapping1' == 'mapping2' otherwise
-       *  'mapping1' is a list of 'normal' domains which are admitted for 
+       *  'mapping1' is a list of 'normal' domains which are admitted for
        *             coding intra blocks
        *  'mapping2' is a list of 'delta' domains which are admitted for
-       *             coding the motion compensated prediction error 
+       *             coding the motion compensated prediction error
        */
       {
-	 unsigned n1, n2, state;
-	 
-	 for (n1 = n2 = state = 0; state < wfa->states; state++)
-	 {
-	    mapping1 [state] = n1;
-	    if (usedomain (state, wfa)
-		&& (state < wfa->basis_states || use_delta_domains
-		    || !wfa->delta_state [state]))
-	       n1++;
-	    
-	    mapping2 [state] = n2;
-	    if (usedomain (state, wfa)
-		&& (state < wfa->basis_states || use_normal_domains
-		    || wfa->delta_state [state]))
-	       n2++;
-	 }
-	 debug_message ("# normal states = %d, # delta states = %d,"
-			" # WFA states = %d", n1, n2, wfa->states);
+         unsigned n1, n2, state;
+
+         for (n1 = n2 = state = 0; state < wfa->states; state++)
+         {
+            mapping1 [state] = n1;
+            if (usedomain (state, wfa)
+                && (state < wfa->basis_states || use_delta_domains
+                    || !wfa->delta_state [state]))
+               n1++;
+
+            mapping2 [state] = n2;
+            if (usedomain (state, wfa)
+                && (state < wfa->basis_states || use_normal_domains
+                    || wfa->delta_state [state]))
+               n2++;
+         }
+         debug_message ("# normal states = %d, # delta states = %d,"
+                        " # WFA states = %d", n1, n2, wfa->states);
       }
-      
+
       for (range = 0; range < rs.range_no; range++)
-	 if (!rs.range_subdivided [range])
-	 {
-	    unsigned  state = rs.range_state [range];
-	    unsigned  label = rs.range_label [range];
-	    unsigned  last  = 1;
-	    u_word_t *mapping;
-	    unsigned  max_value;
-	    unsigned  edge;
-	    word_t    domain;
-
-	    if (wfa->delta_state [state] ||
-		wfa->mv_tree [state][label].type != NONE)
-	       mapping = mapping2;
-	    else
-	       mapping = mapping1;
-	    
-	    max_value = mapping [rs.range_max_domain [range]];
-	    
-	    for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
-		 edge++)
-	       if (domain > 0)
-	       {
-		  total++;
-		  if (max_value - last)
-		  {
-		     write_bin_code (mapping [domain] - last,
-				     max_value - last, output);
-		     last = mapping [domain] + 1;
-		  }
-	       }
-	 }
+         if (!rs.range_subdivided [range])
+         {
+            unsigned  state = rs.range_state [range];
+            unsigned  label = rs.range_label [range];
+            unsigned  last  = 1;
+            u_word_t *mapping;
+            unsigned  max_value;
+            unsigned  edge;
+            word_t    domain;
+
+            if (wfa->delta_state [state] ||
+                wfa->mv_tree [state][label].type != NONE)
+               mapping = mapping2;
+            else
+               mapping = mapping1;
+
+            max_value = mapping [rs.range_max_domain [range]];
+
+            for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
+                 edge++)
+               if (domain > 0)
+               {
+                  total++;
+                  if (max_value - last)
+                  {
+                     write_bin_code (mapping [domain] - last,
+                                     max_value - last, output);
+                     last = mapping [domain] + 1;
+                  }
+               }
+         }
 
       debug_message ("delta-index:  %5d bits. (%5d symbols => %5.2f bps)",
-		     bits_processed (output) - bits, total,
-		     total > 0 ? ((bits_processed (output) - bits) /
-				  (double) total) : 0);
+                     bits_processed (output) - bits, total,
+                     total > 0 ? ((bits_processed (output) - bits) /
+                                  (double) total) : 0);
       Free (mapping1);
       Free (mapping2);
    }
-   
+
    Free (rs.range_state);
    Free (rs.range_label);
    Free (rs.range_max_domain);
@@ -280,17 +280,17 @@ column_0_encoding (const wfa_t *wfa, unsigned last_row, bitfile_t *output)
  *  All rows from 'wfa->basis_states' up to 'last_row' are decoded.
  *
  *  Return value:
- *	number of non-zero matrix elements (WFA edges)
+ *      number of non-zero matrix elements (WFA edges)
  */
 {
-   u_word_t  high;			/* Start of the current code range */
-   u_word_t  low;			/* End of the current code range */
-   unsigned *prob;			/* probability array */
-   unsigned  row;			/* current matrix row */
-   unsigned  label;			/* current matrix label */
-   unsigned  underflow;			/* Underflow bits */
-   unsigned  index;			/* probability index */
-   unsigned  total = 0;			/* Number of '1' elements */
+   u_word_t  high;                      /* Start of the current code range */
+   u_word_t  low;                       /* End of the current code range */
+   unsigned *prob;                      /* probability array */
+   unsigned  row;                       /* current matrix row */
+   unsigned  label;                     /* current matrix label */
+   unsigned  underflow;                 /* Underflow bits */
+   unsigned  index;                     /* probability index */
+   unsigned  total = 0;                 /* Number of '1' elements */
    unsigned  bits  = bits_processed (output);
 
    /*
@@ -300,18 +300,18 @@ column_0_encoding (const wfa_t *wfa, unsigned last_row, bitfile_t *output)
     */
    {
       unsigned n;
-      unsigned exp;			/* current exponent */
-      
+      unsigned exp;                     /* current exponent */
+
       prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned));
-   
+
       for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++)
-	 for (exp = 0; exp < 1U << n; exp++, index++)
-	    prob [index] = n;
+         for (exp = 0; exp < 1U << n; exp++, index++)
+            prob [index] = n;
    }
-   
-   high      = HIGH;			/* 1.0 */
-   low       = LOW;			/* 0.0 */
-   underflow = 0;			/* no underflow bits */
+
+   high      = HIGH;                    /* 1.0 */
+   low       = LOW;                     /* 0.0 */
+   underflow = 0;                       /* no underflow bits */
 
    index = 0;
 
@@ -325,50 +325,50 @@ column_0_encoding (const wfa_t *wfa, unsigned last_row, bitfile_t *output)
     */
    for (row = wfa->basis_states; row <= last_row; row++)
       for (label = 0; label < MAXLABELS; label++)
-	 if (isrange (wfa->tree [row][label]))
-	 {
-	    if (wfa->into [row][label][0] != 0)
-	    {
-	       /*
-		*  encode the MPS '0'
-		*/
-	       high = high - ((high - low) >> prob [index]) - 1;
-	       RESCALE_OUTPUT_INTERVAL;
-	       
-	       if (index < 1020)
-		  index++;
-	    }
-	    else
-	    {
-	       /*
-		*  encode the LPS '1'
-		*/
-	       low = high - ((high - low) >> prob [index]);
-
-	       RESCALE_OUTPUT_INTERVAL;
-	       
-	       total++;
-	       index >>= 1;
-	    }
-	 }
+         if (isrange (wfa->tree [row][label]))
+         {
+            if (wfa->into [row][label][0] != 0)
+            {
+               /*
+                *  encode the MPS '0'
+                */
+               high = high - ((high - low) >> prob [index]) - 1;
+               RESCALE_OUTPUT_INTERVAL;
+
+               if (index < 1020)
+                  index++;
+            }
+            else
+            {
+               /*
+                *  encode the LPS '1'
+                */
+               low = high - ((high - low) >> prob [index]);
+
+               RESCALE_OUTPUT_INTERVAL;
+
+               total++;
+               index >>= 1;
+            }
+         }
    /*
     *  Flush the quasi-arithmetic encoder
     */
    low = high;
 
    RESCALE_OUTPUT_INTERVAL;
-   
+
    OUTPUT_BYTE_ALIGN (output);
 
    Free (prob);
 
    debug_message ("delta-state0: %5d bits. (%5d symbols => %5.2f bps)",
-		  bits_processed (output) - bits, total,
-		  total > 0 ? ((bits_processed (output) - bits) /
-			       (double) total) : 0);
+                  bits_processed (output) - bits, total,
+                  total > 0 ? ((bits_processed (output) - bits) /
+                               (double) total) : 0);
 
    return total;
-}   
+}
 
 static unsigned
 chroma_encoding (const wfa_t *wfa, bitfile_t *output)
@@ -377,24 +377,24 @@ chroma_encoding (const wfa_t *wfa, bitfile_t *output)
  *  chroma channels Cb and Cr to stream 'output'.
  *
  *  Return value:
- *	number of non-zero matrix elements (WFA edges)
+ *      number of non-zero matrix elements (WFA edges)
  */
 {
 
-   unsigned  domain;			/* current domain, counter */
-   unsigned  label;			/* current label */
-   unsigned  total = 0;			/* number of '1' elements */
-   u_word_t  high;			/* Start of the current code range */
-   u_word_t  low;			/* End of the current code range */
-   unsigned  underflow;			/* underflow bits */
-   unsigned *prob;			/* probability array */
-   unsigned  index;			/* probability index, counter */
-   unsigned  next_index;		/* probability of last domain */
-   unsigned  row;			/* current matrix row */
+   unsigned  domain;                    /* current domain, counter */
+   unsigned  label;                     /* current label */
+   unsigned  total = 0;                 /* number of '1' elements */
+   u_word_t  high;                      /* Start of the current code range */
+   u_word_t  low;                       /* End of the current code range */
+   unsigned  underflow;                 /* underflow bits */
+   unsigned *prob;                      /* probability array */
+   unsigned  index;                     /* probability index, counter */
+   unsigned  next_index;                /* probability of last domain */
+   unsigned  row;                       /* current matrix row */
    word_t   *y_domains;
-   unsigned  count = 0;			/* number of transitions for part 1 */
+   unsigned  count = 0;                 /* number of transitions for part 1 */
    unsigned  bits  = bits_processed (output);
-   
+
    /*
     *  Compute the asymmetric probability array
     *  prob[] = { 1/2, 1/2, 1/4, 1/4, 1/4, 1/4,
@@ -402,24 +402,24 @@ chroma_encoding (const wfa_t *wfa, bitfile_t *output)
     */
    {
       unsigned n;
-      unsigned exp;			/* current exponent */
-      
+      unsigned exp;                     /* current exponent */
+
       prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned));
-   
+
       for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++)
-	 for (exp = 0; exp < 1U << n; exp++, index++)
-	    prob [index] = n;
+         for (exp = 0; exp < 1U << n; exp++, index++)
+            prob [index] = n;
    }
-   
-   high      = HIGH;			/* 1.0 */
-   low       = LOW;			/* 0.0 */
-   underflow = 0;			/* no underflow bits */
+
+   high      = HIGH;                    /* 1.0 */
+   low       = LOW;                     /* 0.0 */
+   underflow = 0;                       /* no underflow bits */
 
    next_index = index = 0;
 
    y_domains = compute_hits (wfa->basis_states,
-			     wfa->tree [wfa->tree [wfa->root_state][0]][0],
-			     wfa->wfainfo->chroma_max_states, wfa);
+                             wfa->tree [wfa->tree [wfa->root_state][0]][0],
+                             wfa->wfainfo->chroma_max_states, wfa);
 
    /*
     *  First of all, read all matrix columns given in the list 'y_domains'
@@ -428,67 +428,67 @@ chroma_encoding (const wfa_t *wfa, bitfile_t *output)
     */
    for (domain = 0; y_domains [domain] != -1; domain++)
    {
-      bool_t save_index = YES;		/* YES: store current prob. index */
-      
+      bool_t save_index = YES;          /* YES: store current prob. index */
+
       row   = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1;
       index = next_index;
-	 
+
       for (; row < wfa->states; row++)
       {
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (isrange (wfa->tree [row][label]))
-	    {
-	       unsigned	edge;
-	       int	into;
-	       bool_t    match;		/* approx with current domain found */
-	       
-	       for (match = NO, edge = 0;
-		    isedge (into = wfa->into [row][label][edge])
-			    && (unsigned) into < row;
-		    edge++)
-		  if (into == y_domains [domain]
-		      && into != wfa->y_state [row][label])
-		     match = YES;
-	       if (!match)
-	       {
-		  /*
-		   *  encode the MPS '0'
-		   */
-		  high = high - ((high - low) >> prob [index]) - 1;
-
-		  RESCALE_OUTPUT_INTERVAL;
-		     
-		  if (index < 1020)
-		     index++;
-	       }
-	       else
-	       {
-		  /*
-		   *  encode the LPS '1'
-		   */
-		  low = high - ((high - low) >> prob [index]);
-
-		  RESCALE_OUTPUT_INTERVAL;
-		     
-		  total++;
-		  index >>= 1;
-	       }
-	    }
-	 if (save_index)
-	 {
-	    next_index = index;
-	    save_index = NO;
-	 }
+         for (label = 0; label < MAXLABELS; label++)
+            if (isrange (wfa->tree [row][label]))
+            {
+               unsigned edge;
+               int      into;
+               bool_t    match;         /* approx with current domain found */
+
+               for (match = NO, edge = 0;
+                    isedge (into = wfa->into [row][label][edge])
+                            && (unsigned) into < row;
+                    edge++)
+                  if (into == y_domains [domain]
+                      && into != wfa->y_state [row][label])
+                     match = YES;
+               if (!match)
+               {
+                  /*
+                   *  encode the MPS '0'
+                   */
+                  high = high - ((high - low) >> prob [index]) - 1;
+
+                  RESCALE_OUTPUT_INTERVAL;
+
+                  if (index < 1020)
+                     index++;
+               }
+               else
+               {
+                  /*
+                   *  encode the LPS '1'
+                   */
+                  low = high - ((high - low) >> prob [index]);
+
+                  RESCALE_OUTPUT_INTERVAL;
+
+                  total++;
+                  index >>= 1;
+               }
+            }
+         if (save_index)
+         {
+            next_index = index;
+            save_index = NO;
+         }
       }
    }
 
    debug_message ("CbCr_matrix:  %5d bits. (%5d symbols => %5.2f bps)",
-		  bits_processed (output) - bits, total,
-		  total > 0 ? ((bits_processed (output) - bits) /
-			       (double) total) : 0);
+                  bits_processed (output) - bits, total,
+                  total > 0 ? ((bits_processed (output) - bits) /
+                               (double) total) : 0);
    count = total;
    bits  = bits_processed (output);
-   
+
    /*
     *  Encode the additional column which indicates whether there
     *  are transitions to a state with same spatial coordinates
@@ -500,32 +500,32 @@ chroma_encoding (const wfa_t *wfa, bitfile_t *output)
    next_index = index = 0;
 
    for (row = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1;
-	row < wfa->states; row++)
+        row < wfa->states; row++)
       for (label = 0; label < MAXLABELS; label++)
-	 if (!wfa->y_column [row][label])
-	 {
-	    /*
-	     *  encode the MPS '0'
-	     */
-	    high = high - ((high - low) >> prob [index]) - 1;
-
-	    RESCALE_OUTPUT_INTERVAL;
-	    
-	    if (index < 1020)
-	       index++;
-	 }
-	 else
-	 {
-	    /*
-	     *  encode the LPS '1'
-	     */
-	    low = high - ((high - low) >> prob [index]);
-
-	    RESCALE_OUTPUT_INTERVAL;
-
-	    index >>= 1;
-	    total++;
-	 }
+         if (!wfa->y_column [row][label])
+         {
+            /*
+             *  encode the MPS '0'
+             */
+            high = high - ((high - low) >> prob [index]) - 1;
+
+            RESCALE_OUTPUT_INTERVAL;
+
+            if (index < 1020)
+               index++;
+         }
+         else
+         {
+            /*
+             *  encode the LPS '1'
+             */
+            low = high - ((high - low) >> prob [index]);
+
+            RESCALE_OUTPUT_INTERVAL;
+
+            index >>= 1;
+            total++;
+         }
 
    /*
     *  Flush the quasi-arithmetic encoder
@@ -536,12 +536,12 @@ chroma_encoding (const wfa_t *wfa, bitfile_t *output)
    OUTPUT_BYTE_ALIGN (output);
 
    debug_message ("Yreferences:  %5d bits. (%5d symbols => %5.2f bps)",
-		  bits_processed (output) - bits, total - count,
-		  total - count > 0 ? ((bits_processed (output) - bits) /
-				       (double) (total - count)) : 0);
+                  bits_processed (output) - bits, total - count,
+                  total - count > 0 ? ((bits_processed (output) - bits) /
+                                       (double) (total - count)) : 0);
 
    Free (prob);
    Free (y_domains);
-   
+
    return total;
 }
diff --git a/converter/other/fiasco/output/matrices.h b/converter/other/fiasco/output/matrices.h
index 44671496..6e6ec8a5 100644
--- a/converter/other/fiasco/output/matrices.h
+++ b/converter/other/fiasco/output/matrices.h
@@ -1,8 +1,8 @@
 /*
  *  matrices.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -22,7 +22,7 @@
 
 unsigned
 write_matrices (bool_t use_normal_domains, bool_t use_delta_domains,
-		const wfa_t *wfa, bitfile_t *output);
+                const wfa_t *wfa, bitfile_t *output);
 
 #endif /* _MATRICES_H */
 
diff --git a/converter/other/fiasco/output/mc.c b/converter/other/fiasco/output/mc.c
index 170a2648..06ed0524 100644
--- a/converter/other/fiasco/output/mc.c
+++ b/converter/other/fiasco/output/mc.c
@@ -1,8 +1,8 @@
 /*
- *  mc.c:		Output of motion compensation
+ *  mc.c:               Output of motion compensation
  *
- *  Written by:		Michael Unger
- *			Ullrich Hafner
+ *  Written by:         Michael Unger
+ *                      Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -29,7 +29,7 @@
 
 /*****************************************************************************
 
-			     local variables
+                             local variables
 
 *****************************************************************************/
 
@@ -55,19 +55,19 @@ enum vlc_e {CODE = 0, BITS = 1};
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static void
 encode_mc_tree (unsigned max_state, frame_type_e frame_type, const wfa_t *wfa,
-	       bitfile_t *output);
+               bitfile_t *output);
 static void
 encode_mc_coords (unsigned max_state, const wfa_t *wfa, bitfile_t *output);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -75,8 +75,8 @@ void
 write_mc (frame_type_e frame_type, const wfa_t *wfa, bitfile_t *output)
 {
    unsigned max_state = wfa->wfainfo->color
-			? wfa->tree[wfa->tree[wfa->root_state][0]][0]
-			: wfa->states;
+                        ? wfa->tree[wfa->tree[wfa->root_state][0]][0]
+                        : wfa->states;
 
    encode_mc_tree (max_state, frame_type, wfa, output);
    encode_mc_coords (max_state, wfa, output);
@@ -84,13 +84,13 @@ write_mc (frame_type_e frame_type, const wfa_t *wfa, bitfile_t *output)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static void
 encode_mc_tree (unsigned max_state, frame_type_e frame_type, const wfa_t *wfa,
-		bitfile_t *output)
+                bitfile_t *output)
 /*
  *  Write tree of motion compensation decisions to the 'output' stream.
  *  Depending on 'frame_type' different decoding methods are used.
@@ -99,20 +99,20 @@ encode_mc_tree (unsigned max_state, frame_type_e frame_type, const wfa_t *wfa,
  *  No return value.
  */
 {
-   unsigned  label;			/* current label */
-   unsigned  state;			/* current state */
-   unsigned  total = 0;			/* number of motion tree decisions */
-   unsigned  queue [MAXSTATES];		/* state numbers in BFO */
-   unsigned  current;			/* current node to process */
-   unsigned  last;			/* last node (update every new node) */
-   mc_type_e type;			/* type of motion compensation */
-   unsigned	     (*mc_tree_codes)[2]; /* pointer to VLC table */
+   unsigned  label;                     /* current label */
+   unsigned  state;                     /* current state */
+   unsigned  total = 0;                 /* number of motion tree decisions */
+   unsigned  queue [MAXSTATES];         /* state numbers in BFO */
+   unsigned  current;                   /* current node to process */
+   unsigned  last;                      /* last node (update every new node) */
+   mc_type_e type;                      /* type of motion compensation */
+   unsigned          (*mc_tree_codes)[2]; /* pointer to VLC table */
    unsigned  bits  = bits_processed (output); /* number of bits used */
 
    if (frame_type == P_FRAME)
-      mc_tree_codes = p_frame_codes;	/* binary code */
+      mc_tree_codes = p_frame_codes;    /* binary code */
    else
-      mc_tree_codes = b_frame_codes;	/* variable length code */
+      mc_tree_codes = b_frame_codes;    /* variable length code */
 
    /*
     *  Traverse tree in breadth first order (starting at
@@ -122,37 +122,37 @@ encode_mc_tree (unsigned max_state, frame_type_e frame_type, const wfa_t *wfa,
 
    for (last = 0, state = wfa->basis_states; state < max_state; state++)
       if (wfa->level_of_state [state] - 1 == (int) wfa->wfainfo->p_max_level)
-	 queue [last++] = state;	/* init level = 'mc_max_level' */
+         queue [last++] = state;        /* init level = 'mc_max_level' */
 
    for (current = 0; current < last; current++)
       for (label = 0; label < MAXLABELS; label++)
       {
-	 state = queue [current];
-	 type  = wfa->mv_tree [state][label].type;
-	 if (wfa->x [state][label]
-	     + width_of_level (wfa->level_of_state [state] - 1)
-	     <= wfa->wfainfo->width
-	     &&
-	     wfa->y [state][label]
-	     + height_of_level (wfa->level_of_state [state] - 1)
-	     <= wfa->wfainfo->height)
-	 {
-	    put_bits (output, mc_tree_codes [type][CODE],
-		      mc_tree_codes [type][BITS]);
-	    total++;
-	 }
-	 if (type == NONE && !isrange (wfa->tree [state][label]) &&
-	     wfa->level_of_state [state] - 1 >=
-	     (int) wfa->wfainfo->p_min_level)
-	    queue [last++] = wfa->tree [state][label]; /* append child */
+         state = queue [current];
+         type  = wfa->mv_tree [state][label].type;
+         if (wfa->x [state][label]
+             + width_of_level (wfa->level_of_state [state] - 1)
+             <= wfa->wfainfo->width
+             &&
+             wfa->y [state][label]
+             + height_of_level (wfa->level_of_state [state] - 1)
+             <= wfa->wfainfo->height)
+         {
+            put_bits (output, mc_tree_codes [type][CODE],
+                      mc_tree_codes [type][BITS]);
+            total++;
+         }
+         if (type == NONE && !isrange (wfa->tree [state][label]) &&
+             wfa->level_of_state [state] - 1 >=
+             (int) wfa->wfainfo->p_min_level)
+            queue [last++] = wfa->tree [state][label]; /* append child */
 
       }
 
    OUTPUT_BYTE_ALIGN (output);
    debug_message ("mc-tree:      %5d bits. (%5d symbols => %5.2f bps)",
-		  bits_processed (output) - bits, total,
-		  total > 0 ? ((bits_processed (output) - bits) /
-			       (double) total) : 0);
+                  bits_processed (output) - bits, total,
+                  total > 0 ? ((bits_processed (output) - bits) /
+                               (double) total) : 0);
 }
 
 static void
@@ -165,85 +165,85 @@ encode_mc_coords (unsigned max_state, const wfa_t *wfa, bitfile_t *output)
  *  No return value.
  */
 {
-   unsigned  state;			/* current state */
-   unsigned  label;			/* current label */
-   unsigned  level_count [MAXLEVEL];	/* number of mv per level */
-   unsigned  level;			/* counter */
-   unsigned  ftotal = 0;		/* #forward motion tree decisions */
-   unsigned  btotal = 0;		/* #backward decisions */
-   unsigned  itotal = 0;		/* #interpolated decisions */
+   unsigned  state;                     /* current state */
+   unsigned  label;                     /* current label */
+   unsigned  level_count [MAXLEVEL];    /* number of mv per level */
+   unsigned  level;                     /* counter */
+   unsigned  ftotal = 0;                /* #forward motion tree decisions */
+   unsigned  btotal = 0;                /* #backward decisions */
+   unsigned  itotal = 0;                /* #interpolated decisions */
    unsigned  bits   = bits_processed (output); /* number of bits used */
    unsigned  sr     = wfa->wfainfo->search_range; /* search range */
 
    for (level = wfa->wfainfo->p_max_level;
-	level >= wfa->wfainfo->p_min_level; level--)
+        level >= wfa->wfainfo->p_min_level; level--)
       level_count [level] = 0;
 
    for (state = wfa->basis_states; state < max_state; state++)
       for (label = 0; label < MAXLABELS; label++)
       {
-	 mv_t *mv = &wfa->mv_tree[state][label]; /* motion vector info */
-
-	 if (mv->type != NONE)
-	 {
-	    level_count [wfa->level_of_state [state] - 1]++;
-	    switch (mv->type)
-	    {
-	       case FORWARD:
-		  put_bits (output,
-			    mv_code_table[(mv->fx + sr)][CODE],
-			    mv_code_table[(mv->fx + sr)][BITS]);
-		  put_bits (output,
-			    mv_code_table[(mv->fy + sr)][CODE],
-			    mv_code_table[(mv->fy + sr)][BITS]);
-		  ftotal++;
-		  break;
-	       case BACKWARD:
-		  put_bits (output,
-			    mv_code_table[(mv->bx + sr)][CODE],
-			    mv_code_table[(mv->bx + sr)][BITS]);
-		  put_bits (output,
-			    mv_code_table[(mv->by + sr)][CODE],
-			    mv_code_table[(mv->by + sr)][BITS]);
-		  btotal++;
-		  break;
-	       case INTERPOLATED:
-		  put_bits (output,
-			    mv_code_table[(mv->fx + sr)][CODE],
-			    mv_code_table[(mv->fx + sr)][BITS]);
-		  put_bits (output,
-			    mv_code_table[(mv->fy + sr)][CODE],
-			    mv_code_table[(mv->fy + sr)][BITS]);
-		  put_bits (output,
-			    mv_code_table[(mv->bx + sr)][CODE],
-			    mv_code_table[(mv->bx + sr)][BITS]);
-		  put_bits (output,
-			    mv_code_table[(mv->by + sr)][CODE],
-			    mv_code_table[(mv->by + sr)][BITS]);
-		  itotal++;
-		  break;
-	       default:
-		  break;
-	    }
-	 }
+         mv_t *mv = &wfa->mv_tree[state][label]; /* motion vector info */
+
+         if (mv->type != NONE)
+         {
+            level_count [wfa->level_of_state [state] - 1]++;
+            switch (mv->type)
+            {
+               case FORWARD:
+                  put_bits (output,
+                            mv_code_table[(mv->fx + sr)][CODE],
+                            mv_code_table[(mv->fx + sr)][BITS]);
+                  put_bits (output,
+                            mv_code_table[(mv->fy + sr)][CODE],
+                            mv_code_table[(mv->fy + sr)][BITS]);
+                  ftotal++;
+                  break;
+               case BACKWARD:
+                  put_bits (output,
+                            mv_code_table[(mv->bx + sr)][CODE],
+                            mv_code_table[(mv->bx + sr)][BITS]);
+                  put_bits (output,
+                            mv_code_table[(mv->by + sr)][CODE],
+                            mv_code_table[(mv->by + sr)][BITS]);
+                  btotal++;
+                  break;
+               case INTERPOLATED:
+                  put_bits (output,
+                            mv_code_table[(mv->fx + sr)][CODE],
+                            mv_code_table[(mv->fx + sr)][BITS]);
+                  put_bits (output,
+                            mv_code_table[(mv->fy + sr)][CODE],
+                            mv_code_table[(mv->fy + sr)][BITS]);
+                  put_bits (output,
+                            mv_code_table[(mv->bx + sr)][CODE],
+                            mv_code_table[(mv->bx + sr)][BITS]);
+                  put_bits (output,
+                            mv_code_table[(mv->by + sr)][CODE],
+                            mv_code_table[(mv->by + sr)][BITS]);
+                  itotal++;
+                  break;
+               default:
+                  break;
+            }
+         }
       }
 
    OUTPUT_BYTE_ALIGN (output);
 
    debug_message ("Motion compensation: %d forward, %d backward, "
-		  "%d interpolated", ftotal, btotal, itotal);
+                  "%d interpolated", ftotal, btotal, itotal);
 
    for (level = wfa->wfainfo->p_max_level;
-	level >= wfa->wfainfo->p_min_level; level--)
+        level >= wfa->wfainfo->p_min_level; level--)
       debug_message ("Level %d: %d motion vectors", level, level_count[level]);
 
    {
       unsigned  total = ftotal * 2 + btotal * 2 + itotal * 4;
 
       debug_message ("mv-coord:     %5d bits. (%5d symbols => %5.2f bps)",
-		     bits_processed (output) - bits, total,
-		     total > 0 ? ((bits_processed (output) - bits) /
-				  (double) total) : 0);
+                     bits_processed (output) - bits, total,
+                     total > 0 ? ((bits_processed (output) - bits) /
+                                  (double) total) : 0);
    }
 
    return;
diff --git a/converter/other/fiasco/output/mc.h b/converter/other/fiasco/output/mc.h
index cacddfe7..9e15ae3d 100644
--- a/converter/other/fiasco/output/mc.h
+++ b/converter/other/fiasco/output/mc.h
@@ -1,9 +1,9 @@
 /*
  *  mc.h
  *
- *  Written by:		Michael Unger
- *			Ullrich Hafner
- *		
+ *  Written by:         Michael Unger
+ *                      Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/output/nd.c b/converter/other/fiasco/output/nd.c
index b1dd6746..67b8b106 100644
--- a/converter/other/fiasco/output/nd.c
+++ b/converter/other/fiasco/output/nd.c
@@ -1,7 +1,7 @@
 /*
- *  nd.c:		Output of prediction tree
+ *  nd.c:               Output of prediction tree
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -31,7 +31,7 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
@@ -42,7 +42,7 @@ encode_nd_coefficients (unsigned total, const wfa_t *wfa, bitfile_t *output);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -63,7 +63,7 @@ write_nd (const wfa_t *wfa, bitfile_t *output)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
@@ -75,13 +75,13 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output)
  *  No return value.
  */
 {
-   lqueue_t *queue;			/* queue of states */
-   int	     state, next;		/* state and its current child */
-   unsigned  used, not_used;		/* counter ND used/not used */
-   u_word_t  low;			/* Start of the current code range */
-   u_word_t  high;			/* End of the current code range */
-   u_word_t  underflow;			/* Number of underflow bits pending */
-   u_word_t  sum0, sum1;		/* Probability model */
+   lqueue_t *queue;                     /* queue of states */
+   int       state, next;               /* state and its current child */
+   unsigned  used, not_used;            /* counter ND used/not used */
+   u_word_t  low;                       /* Start of the current code range */
+   u_word_t  high;                      /* End of the current code range */
+   u_word_t  underflow;                 /* Number of underflow bits pending */
+   u_word_t  sum0, sum1;                /* Probability model */
    unsigned  bits = bits_processed (output);
 
    used = not_used = 0;
@@ -108,60 +108,60 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output)
 
       if (wfa->level_of_state [next] > wfa->wfainfo->p_max_level + 1)
       {
-	 /*
-	  *  Nondetermismn is not allowed at levels larger than
-	  *  'wfa->wfainfo->p_max_level'.
-	  */
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (ischild (state = wfa->tree [next][label]))
-	       queue_append (queue, &state); /* continue with children */
+         /*
+          *  Nondetermismn is not allowed at levels larger than
+          *  'wfa->wfainfo->p_max_level'.
+          */
+         for (label = 0; label < MAXLABELS; label++)
+            if (ischild (state = wfa->tree [next][label]))
+               queue_append (queue, &state); /* continue with children */
       }
       else if (wfa->level_of_state [next] > wfa->wfainfo->p_min_level)
       {
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (ischild (state = wfa->tree [next][label]))
-	    {
-	       unsigned range;		/* Current interval range */
-
-	       if (isedge (wfa->into [next][label][0])) /* prediction used */
-	       {
-		  used++;
-
-		  /*
-		   *  Encode a '1' symbol
-		   */
-		  range =  (high - low) + 1;
-		  low   = low + (u_word_t) ((range * sum0) / sum1);
-		  RESCALE_OUTPUT_INTERVAL;
-	       }
-	       else			/* no predict., continue with children */
-	       {
-		  not_used++;
-		  if (wfa->level_of_state [state] > wfa->wfainfo->p_min_level)
-		     queue_append (queue, &state);
-
-		  /*
-		   *  Encode a '0' symbol
-		   */
-		  range =  (high - low) + 1;
-		  high  = low + (u_word_t) ((range * sum0) / sum1 - 1);
-		  RESCALE_OUTPUT_INTERVAL;
-		  sum0++;
-	       }
-	       /*
-		*  Update the frequency counts
-		*/
-	       sum1++;
-	       if (sum1 > 50)		/* Scale the symbol frequencies */
-	       {
-		  sum0 >>= 1;
-		  sum1 >>= 1;
-		  if (!sum0)
-		     sum0 = 1;
-		  if (sum0 >= sum1)
-		     sum1 = sum0 + 1;
-	       }
-	    }
+         for (label = 0; label < MAXLABELS; label++)
+            if (ischild (state = wfa->tree [next][label]))
+            {
+               unsigned range;          /* Current interval range */
+
+               if (isedge (wfa->into [next][label][0])) /* prediction used */
+               {
+                  used++;
+
+                  /*
+                   *  Encode a '1' symbol
+                   */
+                  range =  (high - low) + 1;
+                  low   = low + (u_word_t) ((range * sum0) / sum1);
+                  RESCALE_OUTPUT_INTERVAL;
+               }
+               else                     /* no predict., continue with children */
+               {
+                  not_used++;
+                  if (wfa->level_of_state [state] > wfa->wfainfo->p_min_level)
+                     queue_append (queue, &state);
+
+                  /*
+                   *  Encode a '0' symbol
+                   */
+                  range =  (high - low) + 1;
+                  high  = low + (u_word_t) ((range * sum0) / sum1 - 1);
+                  RESCALE_OUTPUT_INTERVAL;
+                  sum0++;
+               }
+               /*
+                *  Update the frequency counts
+                */
+               sum1++;
+               if (sum1 > 50)           /* Scale the symbol frequencies */
+               {
+                  sum0 >>= 1;
+                  sum1 >>= 1;
+                  if (!sum0)
+                     sum0 = 1;
+                  if (sum0 >= sum1)
+                     sum1 = sum0 + 1;
+               }
+            }
 
       }
    }
@@ -175,14 +175,14 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output)
    OUTPUT_BYTE_ALIGN (output);
 
    debug_message ("%d nd fields: %d used nd, %d used not nd", used + not_used,
-		  used, not_used);
+                  used, not_used);
    {
       unsigned total = used + not_used;
 
       debug_message ("nd-tree:      %5d bits. (%5d symbols => %5.2f bps)",
-		     bits_processed (output) - bits, total,
-		     total > 0 ? ((bits_processed (output) - bits) /
-				  (double) total) : 0);
+                     bits_processed (output) - bits, total,
+                     total > 0 ? ((bits_processed (output) - bits) /
+                                  (double) total) : 0);
    }
 
    return used;
@@ -201,42 +201,42 @@ encode_nd_coefficients (unsigned total, const wfa_t *wfa, bitfile_t *output)
    unsigned bits = bits_processed (output);
 
    {
-      unsigned *coefficients;		/* array of factors to encode */
-      unsigned *ptr;			/* pointer to current factor */
-      unsigned	state, label, edge;
-      word_t	domain;
+      unsigned *coefficients;           /* array of factors to encode */
+      unsigned *ptr;                    /* pointer to current factor */
+      unsigned  state, label, edge;
+      word_t    domain;
 
       ptr = coefficients  = Calloc (total, sizeof (unsigned));
 
       for (state = wfa->basis_states; state < wfa->states; state++)
-	 for (label = 0; label < MAXLABELS; label++)
-	    if (ischild (wfa->tree [state][label])
-		&& isedge (wfa->into [state][label][0]))
-	       for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
-		    edge++)
-	       {
-		  if (ptr - coefficients >= (int) total)
-		     error ("Can't write more than %d coefficients.", total);
-
-		  *ptr++ = rtob (wfa->weight [state][label][edge],
-				 wfa->wfainfo->dc_rpf);
-	       }
+         for (label = 0; label < MAXLABELS; label++)
+            if (ischild (wfa->tree [state][label])
+                && isedge (wfa->into [state][label][0]))
+               for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
+                    edge++)
+               {
+                  if (ptr - coefficients >= (int) total)
+                     error ("Can't write more than %d coefficients.", total);
+
+                  *ptr++ = rtob (wfa->weight [state][label][edge],
+                                 wfa->wfainfo->dc_rpf);
+               }
 
       /*
        *  Encode array of coefficients with arithmetic coding
        */
       {
-	 const int scaling = 50;	/* scaling factor of prob. model */
-	 unsigned  c_symbols = 1 << (wfa->wfainfo->dc_rpf->mantissa_bits + 1);
+         const int scaling = 50;        /* scaling factor of prob. model */
+         unsigned  c_symbols = 1 << (wfa->wfainfo->dc_rpf->mantissa_bits + 1);
 
-	 encode_array (output, coefficients, NULL, &c_symbols, 1,
-		       total, scaling);
+         encode_array (output, coefficients, NULL, &c_symbols, 1,
+                       total, scaling);
       }
 
       debug_message ("nd-factors:   %5d bits. (%5d symbols => %5.2f bps)",
-		     bits_processed (output) - bits, total,
-		     total ? ((bits_processed (output) - bits)
-			      / (double) total) : 0);
+                     bits_processed (output) - bits, total,
+                     total ? ((bits_processed (output) - bits)
+                              / (double) total) : 0);
       Free (coefficients);
    }
 }
diff --git a/converter/other/fiasco/output/nd.h b/converter/other/fiasco/output/nd.h
index 01a37838..7b8ea9fe 100644
--- a/converter/other/fiasco/output/nd.h
+++ b/converter/other/fiasco/output/nd.h
@@ -1,8 +1,8 @@
 /*
  *  nd.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/output/tree.c b/converter/other/fiasco/output/tree.c
index 55080a51..02afec50 100644
--- a/converter/other/fiasco/output/tree.c
+++ b/converter/other/fiasco/output/tree.c
@@ -1,7 +1,7 @@
 /*
- *  tree.c:		Output of bintree partitioning
+ *  tree.c:             Output of bintree partitioning
  *
- *  Written by:		Ullrich Hafner
+ *  Written by:         Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -29,17 +29,17 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
 static void
 encode_tree (bitfile_t *output, const byte_t *data, unsigned n_data,
-	     unsigned scaling, u_word_t sum0, u_word_t sum1);
+             unsigned scaling, u_word_t sum0, u_word_t sum1);
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -53,13 +53,13 @@ write_tree (const wfa_t *wfa, bitfile_t *output)
  *  No return value.
  */
 {
-   unsigned  queue [MAXSTATES];		/* state numbers in BFO */
-   unsigned  current;			/* current node to process */
-   unsigned  last;			/* last node (update every new node) */
-   unsigned  label;			/* current label */
-   int	     into;			/* next child */
-   byte_t   *tree_string;		/* bitstring to encode */
-   unsigned  total = 0;			/* number of ranges */
+   unsigned  queue [MAXSTATES];         /* state numbers in BFO */
+   unsigned  current;                   /* current node to process */
+   unsigned  last;                      /* last node (update every new node) */
+   unsigned  label;                     /* current label */
+   int       into;                      /* next child */
+   byte_t   *tree_string;               /* bitstring to encode */
+   unsigned  total = 0;                 /* number of ranges */
    unsigned  bits  = bits_processed (output); /* number of bits */
 
    /*
@@ -72,17 +72,17 @@ write_tree (const wfa_t *wfa, bitfile_t *output)
    queue [0] = wfa->root_state;
    for (last = 1, current = 0; current < last; current++)
       for (label = 0; label < MAXLABELS; label++)
-	 if (!isrange (into = wfa->tree [queue[current]][label])) /* child ? */
-	 {
-	    queue [last++]        = into;
-	    tree_string [total++] = 1;
-	 }
-	 else				/* or range ? */
-	    tree_string [total++] = 0;
+         if (!isrange (into = wfa->tree [queue[current]][label])) /* child ? */
+         {
+            queue [last++]        = into;
+            tree_string [total++] = 1;
+         }
+         else                           /* or range ? */
+            tree_string [total++] = 0;
 
    if (total != (wfa->states - wfa->basis_states) * MAXLABELS)
       error ("total [%d] != (states - basis_states) * 2 [%d]", total,
-	     (wfa->states - wfa->basis_states) * MAXLABELS);
+             (wfa->states - wfa->basis_states) * MAXLABELS);
 
    {
       unsigned scale = total / 20 ;
@@ -93,20 +93,20 @@ write_tree (const wfa_t *wfa, bitfile_t *output)
    Free (tree_string);
 
    debug_message ("tree:         %5d bits. (%5d symbols => %5.2f bps)",
-		  bits_processed (output) - bits, total,
-		  total > 0 ? ((bits_processed (output) - bits)
-			       / (double) total) : 0);
+                  bits_processed (output) - bits, total,
+                  total > 0 ? ((bits_processed (output) - bits)
+                               / (double) total) : 0);
 }
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
 static void
 encode_tree (bitfile_t *output, const byte_t *data, unsigned n_data,
-	     unsigned scaling, u_word_t sum0, u_word_t sum1)
+             unsigned scaling, u_word_t sum0, u_word_t sum1)
 /*
  *  Encode bintree data with adaptive binary arithmetic coding.
  *  Write 'n_data' output symbols stored in 'data' to stream 'output'.
@@ -116,10 +116,10 @@ encode_tree (bitfile_t *output, const byte_t *data, unsigned n_data,
  *  No return value.
  */
 {
-   u_word_t low;			/* Start of the current code range */
-   u_word_t high;			/* End of the current code range */
-   u_word_t underflow;			/* Number of underflow bits pending */
-   unsigned n;				/* Data counter */
+   u_word_t low;                        /* Start of the current code range */
+   u_word_t high;                       /* End of the current code range */
+   u_word_t underflow;                  /* Number of underflow bits pending */
+   unsigned n;                          /* Data counter */
 
    low       = 0;
    high      = 0xffff;
@@ -127,29 +127,29 @@ encode_tree (bitfile_t *output, const byte_t *data, unsigned n_data,
 
    for (n = n_data; n; n--)
    {
-      unsigned range;			/* Current interval range */
+      unsigned range;                   /* Current interval range */
 
       if (!*data++)
       {
-	 /*
-	  *  encode a '0'
-	  */
-	 range =  (high - low) + 1;
-	 high  = low + (u_word_t) ((range * sum0) / sum1 - 1);
+         /*
+          *  encode a '0'
+          */
+         range =  (high - low) + 1;
+         high  = low + (u_word_t) ((range * sum0) / sum1 - 1);
 
-	 RESCALE_OUTPUT_INTERVAL;
+         RESCALE_OUTPUT_INTERVAL;
 
-	 sum0++;
+         sum0++;
       }
       else
       {
-	 /*
-	  *  encode a '1'
-	  */
-	 range =  (high - low) + 1;
-	 low   = low + (u_word_t) ((range * sum0) / sum1);
+         /*
+          *  encode a '1'
+          */
+         range =  (high - low) + 1;
+         low   = low + (u_word_t) ((range * sum0) / sum1);
 
-	 RESCALE_OUTPUT_INTERVAL;
+         RESCALE_OUTPUT_INTERVAL;
       }
       /*
        *  Update the frequency counts
@@ -157,12 +157,12 @@ encode_tree (bitfile_t *output, const byte_t *data, unsigned n_data,
       sum1++;
       if (sum1 > scaling) /* Scale the symbol frequencies */
       {
-	 sum0 >>= 1;
-	 sum1 >>= 1;
-	 if (!sum0)
-	    sum0 = 1;
-	 if (sum0 >= sum1)
-	    sum1 = sum0 + 1;
+         sum0 >>= 1;
+         sum1 >>= 1;
+         if (!sum0)
+            sum0 = 1;
+         if (sum0 >= sum1)
+            sum1 = sum0 + 1;
       }
    }
    /*
diff --git a/converter/other/fiasco/output/tree.h b/converter/other/fiasco/output/tree.h
index 50fe2279..bcf50ec1 100644
--- a/converter/other/fiasco/output/tree.h
+++ b/converter/other/fiasco/output/tree.h
@@ -1,8 +1,8 @@
 /*
  *  tree.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/output/weights.c b/converter/other/fiasco/output/weights.c
index 0203fef0..4eb068ac 100644
--- a/converter/other/fiasco/output/weights.c
+++ b/converter/other/fiasco/output/weights.c
@@ -1,8 +1,8 @@
 /*
- *  weights.c:		Output of weights
+ *  weights.c:          Output of weights
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -32,8 +32,8 @@
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 void
@@ -45,20 +45,20 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
  *  No return value.
  */
 {
-    unsigned  state, label;		/* current label */
-    unsigned  offset1, offset2;		/* model offsets. */
-    unsigned  offset3, offset4;		/* model offsets. */
-    unsigned *weights_array;		/* array of weights to encode */
-    unsigned *wptr;			/* pointer to current weight */
-    unsigned *level_array;		/* array of corresponding levels */
-    unsigned *lptr;			/* pointer to current corr. level */
-    int	     min_level, max_level;	/* min and max range level */
-    int	     d_min_level, d_max_level; 	/* min and max delta range level */
-    bool_t    dc, d_dc;			/* true if dc or delta dc are used */
-    bool_t    delta_approx = NO;		/* true if delta has been used */
-    unsigned  delta_count  = 0;		/* number of delta ranges */
-    unsigned  bits 	  = bits_processed (output);
-   
+    unsigned  state, label;             /* current label */
+    unsigned  offset1, offset2;         /* model offsets. */
+    unsigned  offset3, offset4;         /* model offsets. */
+    unsigned *weights_array;            /* array of weights to encode */
+    unsigned *wptr;                     /* pointer to current weight */
+    unsigned *level_array;              /* array of corresponding levels */
+    unsigned *lptr;                     /* pointer to current corr. level */
+    int      min_level, max_level;      /* min and max range level */
+    int      d_min_level, d_max_level;  /* min and max delta range level */
+    bool_t    dc, d_dc;                 /* true if dc or delta dc are used */
+    bool_t    delta_approx = NO;                /* true if delta has been used */
+    unsigned  delta_count  = 0;         /* number of delta ranges */
+    unsigned  bits        = bits_processed (output);
+
     /*
      *  Check whether delta approximation has been used
      */
@@ -68,14 +68,14 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
             delta_approx = YES;
             break;
         }
-   
+
     /*
      *  Generate array of corresponding levels (context of probability model)
      */
     min_level = d_min_level = MAXLEVEL;
     max_level = d_max_level = 0;
-    dc 	     = d_dc	   = NO;
-   
+    dc       = d_dc        = NO;
+
     for (state = wfa->basis_states; state < wfa->states; state++)
         for (label = 0; label < MAXLABELS; label++)
             if (isrange (wfa->tree [state][label]))
@@ -95,24 +95,24 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
                         dc = YES;
                 }
             }
-    if (min_level > max_level)		/* no lc found */
+    if (min_level > max_level)          /* no lc found */
         max_level = min_level - 1;
     if (d_min_level > d_max_level)
         d_max_level = d_min_level - 1;
 
     /*
      *  Context model:
-     *		0		DC weight
-     *		1		Delta DC weight
-     *		2-k		normal weights per level
-     *		k+1 - m		Delta weights per level
+     *          0               DC weight
+     *          1               Delta DC weight
+     *          2-k             normal weights per level
+     *          k+1 - m         Delta weights per level
      */
 
     offset1 = dc ? 1 : 0;
     offset2 = offset1 + (d_dc ? 1 : 0);
     offset3 = offset2 + (max_level - min_level + 1);
     offset4 = offset3 + (d_max_level - d_min_level + 1);
-   
+
     /*
      *  Weights are encoded as follows:
      *  all weights of state n
@@ -127,15 +127,15 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
         for (label = 0; label < MAXLABELS; label++)
             if (isrange (wfa->tree [state][label]))
             {
-                int	edge;			/* current edge */
-                int	domain;			/* current domain (context of model) */
-	    
+                int     edge;                   /* current edge */
+                int     domain;                 /* current domain (context of model) */
+
                 for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
                      edge++)
                 {
                     if (wptr - weights_array >= (int) total)
                         error ("Can't write more than %d weights.", total);
-                    if (domain)		/* not DC component */
+                    if (domain)         /* not DC component */
                     {
                         if (delta_approx && wfa->delta_state [state]) /* delta */
                         {
@@ -153,7 +153,7 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
                                 + wfa->level_of_state [state] - 1 - min_level;
                         }
                     }
-                    else			/* DC component */
+                    else                        /* DC component */
                     {
                         if (delta_approx && wfa->delta_state [state]) /* delta */
                         {
@@ -172,9 +172,9 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
             }
 
     {
-        unsigned	 i;
-        unsigned	*c_symbols = Calloc (offset4, sizeof (int));
-        const int	 scale 	   = 500;	/* scaling of probability model */
+        unsigned         i;
+        unsigned        *c_symbols = Calloc (offset4, sizeof (int));
+        const int        scale     = 500;       /* scaling of probability model */
 
         c_symbols [0] = 1 << (wfa->wfainfo->dc_rpf->mantissa_bits + 1);
         if (offset1 != offset2)
@@ -184,12 +184,12 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
             c_symbols [i] = 1 << (wfa->wfainfo->rpf->mantissa_bits + 1);
         for (; i < offset4; i++)
             c_symbols [i] = 1 << (wfa->wfainfo->d_rpf->mantissa_bits + 1);
-      
+
         encode_array (output, weights_array, level_array, c_symbols, offset4,
                       total, scale);
         Free (c_symbols);
     }
-   
+
     debug_message ("%d delta weights out of %d.", delta_count, total);
     debug_message ("weights:      %5d bits. (%5d symbols => %5.2f bps)",
                    bits_processed (output) - bits, total,
diff --git a/converter/other/fiasco/output/weights.h b/converter/other/fiasco/output/weights.h
index f22bd9f8..505918ad 100644
--- a/converter/other/fiasco/output/weights.h
+++ b/converter/other/fiasco/output/weights.h
@@ -1,8 +1,8 @@
 /*
  *  weights.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/output/write.c b/converter/other/fiasco/output/write.c
index d6faee26..8c825a12 100644
--- a/converter/other/fiasco/output/write.c
+++ b/converter/other/fiasco/output/write.c
@@ -2,7 +2,7 @@
  *  write.c:        Output of WFA files
  *
  *  Written by:     Ullrich Hafner
- *      
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -32,11 +32,11 @@
 #include "mc.h"
 #include "nd.h"
 #include "write.h"
- 
+
 /*****************************************************************************
 
                 prototypes
-  
+
 *****************************************************************************/
 
 static void
@@ -46,7 +46,7 @@ write_tiling (const tiling_t *tiling, bitfile_t *output);
 
                 public code
 
-                
+
 *****************************************************************************/
 
 
@@ -61,26 +61,26 @@ write_next_wfa (const wfa_t *wfa, const coding_t *c, bitfile_t *output)
 {
    unsigned edges = 0;          /* number of transitions */
    unsigned bits;
-   
+
    debug_message ("--------------------------------------"
           "--------------------------------------");
 
    if (c->mt->number == 0)              /* first WFA */
       write_header (wfa->wfainfo, output);
-  
+
    bits = bits_processed (output);
-   
+
    /*
     *  Frame header information
     */
    {
       const int rice_k = 8;     /* parameter of Rice Code */
 
-      write_rice_code (wfa->states, rice_k, output);      
-      write_rice_code (c->mt->frame_type, rice_k, output); 
-      write_rice_code (c->mt->number, rice_k, output);     
+      write_rice_code (wfa->states, rice_k, output);
+      write_rice_code (c->mt->frame_type, rice_k, output);
+      write_rice_code (c->mt->number, rice_k, output);
    }
-   
+
    OUTPUT_BYTE_ALIGN (output);
 
    debug_message ("frame-header: %5d bits.", bits_processed (output) - bits);
@@ -99,7 +99,7 @@ write_next_wfa (const wfa_t *wfa, const coding_t *c, bitfile_t *output)
 
    if (c->options.prediction)       /* write nondeterministic approx. */
    {
-      put_bit (output, 1); 
+      put_bit (output, 1);
       write_nd (wfa, output);
    }
    else
@@ -107,7 +107,7 @@ write_next_wfa (const wfa_t *wfa, const coding_t *c, bitfile_t *output)
 
    if (c->mt->frame_type != I_FRAME)    /* write motion compensation info */
       write_mc (c->mt->frame_type, wfa, output);
-   
+
    edges = write_matrices (c->options.normal_domains,
                c->options.delta_domains, wfa, output);
 
@@ -140,7 +140,7 @@ write_header (const wfa_info_t *wi, bitfile_t *output)
    for (text = wi->basis_name; *text; text++)
       put_bits (output, *text, 8);
    put_bits (output, *text, 8);
-   
+
    write_rice_code (FIASCO_BINFILE_RELEASE, rice_k, output);
 
    write_rice_code (HEADER_TITLE, rice_k, output);
@@ -149,24 +149,24 @@ write_header (const wfa_info_t *wi, bitfile_t *output)
     text++)
       put_bits (output, *text, 8);
    put_bits (output, 0, 8);
-   
+
    write_rice_code (HEADER_COMMENT, rice_k, output);
    for (text = wi->comment;
     text && *text && text - wi->comment < MAXSTRLEN - 2;
     text++)
       put_bits (output, *text, 8);
    put_bits (output, 0, 8);
-   
+
    write_rice_code (HEADER_END, rice_k, output);
-   
-   write_rice_code (wi->max_states, rice_k, output); 
-   put_bit (output, wi->color ? 1 : 0); 
+
+   write_rice_code (wi->max_states, rice_k, output);
+   put_bit (output, wi->color ? 1 : 0);
    write_rice_code (wi->width, rice_k, output);
    write_rice_code (wi->height, rice_k, output);
    if (wi->color)
-      write_rice_code (wi->chroma_max_states, rice_k, output); 
-   write_rice_code (wi->p_min_level, rice_k, output); 
-   write_rice_code (wi->p_max_level, rice_k, output); 
+      write_rice_code (wi->chroma_max_states, rice_k, output);
+   write_rice_code (wi->p_min_level, rice_k, output);
+   write_rice_code (wi->p_max_level, rice_k, output);
    write_rice_code (wi->frames, rice_k, output);
    write_rice_code (wi->smoothing, rice_k, output);
 
@@ -202,9 +202,9 @@ write_header (const wfa_info_t *wi, bitfile_t *output)
 
    if (wi->frames > 1)          /* motion compensation stuff */
    {
-      write_rice_code (wi->fps, rice_k, output); 
-      write_rice_code (wi->search_range, rice_k, output); 
-      put_bit (output, wi->half_pixel ? 1 : 0); 
+      write_rice_code (wi->fps, rice_k, output);
+      write_rice_code (wi->search_range, rice_k, output);
+      put_bit (output, wi->half_pixel ? 1 : 0);
       put_bit (output, wi->B_as_past_ref ? 1 : 0);
    }
 
@@ -215,7 +215,7 @@ write_header (const wfa_info_t *wi, bitfile_t *output)
 /*****************************************************************************
 
                 private code
-  
+
 *****************************************************************************/
 
 static void
@@ -228,21 +228,21 @@ write_tiling (const tiling_t *tiling, bitfile_t *output)
 {
    const unsigned rice_k = 8;       /* parameter of Rice Code */
    unsigned       bits   = bits_processed (output);
-   
+
    write_rice_code (tiling->exponent, rice_k, output);
    if (tiling->method == FIASCO_TILING_VARIANCE_ASC
        || tiling->method == FIASCO_TILING_VARIANCE_DSC)
    {
       unsigned tile;            /* current image tile */
 
-      put_bit (output, 1);      
+      put_bit (output, 1);
       for (tile = 0; tile < 1U << tiling->exponent; tile++)
      if (tiling->vorder [tile] != -1) /* image tile is visible */
         put_bits (output, tiling->vorder [tile], tiling->exponent);
    }
    else
    {
-      put_bit (output, 0);      
+      put_bit (output, 0);
       put_bit (output, tiling->method == FIASCO_TILING_SPIRAL_ASC);
    }
 
diff --git a/converter/other/fiasco/output/write.h b/converter/other/fiasco/output/write.h
index 6bdc2f1b..1fb3393c 100644
--- a/converter/other/fiasco/output/write.h
+++ b/converter/other/fiasco/output/write.h
@@ -1,8 +1,8 @@
 /*
  *  write.h
  *
- *  Written by:		Ullrich Hafner
- *		
+ *  Written by:         Ullrich Hafner
+ *              
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
diff --git a/converter/other/fiasco/params.c b/converter/other/fiasco/params.c
index 29f52afc..32145fc3 100644
--- a/converter/other/fiasco/params.c
+++ b/converter/other/fiasco/params.c
@@ -1,8 +1,8 @@
 /*
- *  params.c:		Parameter file and command line parsing
+ *  params.c:           Parameter file and command line parsing
  *
- *  Written by:		Stefan Frank
- *			Ullrich Hafner
+ *  Written by:         Stefan Frank
+ *                      Ullrich Hafner
  *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
@@ -24,12 +24,12 @@
 
 #include <stdio.h>
 #include <ctype.h>
-#include <math.h>			/* strtod() on SUN sparc */
+#include <math.h>                       /* strtod() on SUN sparc */
 
 #include <stdlib.h>
 #include <string.h>
 
-#include <getopt.h>			/* system or ../lib */
+#include <getopt.h>                     /* system or ../lib */
 
 #include "pm_c_util.h"
 #include "nstring.h"
@@ -46,7 +46,7 @@
 
 /*****************************************************************************
 
-				prototypes
+                                prototypes
 
 *****************************************************************************/
 
@@ -64,7 +64,7 @@ usage (const param_t *params, const char *progname, const char *synopsis,
 
 /*****************************************************************************
 
-				public code
+                                public code
 
 *****************************************************************************/
 
@@ -84,29 +84,29 @@ parseargs (param_t *usr_params,
  *  'synopsis' contains a brief description of the program and
  *  'comment' may contain some additional advice.
  *  Initialization order of parameters:
- *	1.) Default values given by the param_t struct
- *	2.) System parameter-file ('path'/'sys_file_name')
- *	3.) User parameter-file ($HOME/'usr_file_name')
- *	4.) Command line parameters
- *	5.) Parameter-file forced by option -f (--config-file)
+ *      1.) Default values given by the param_t struct
+ *      2.) System parameter-file ('path'/'sys_file_name')
+ *      3.) User parameter-file ($HOME/'usr_file_name')
+ *      4.) Command line parameters
+ *      5.) Parameter-file forced by option -f (--config-file)
  *
  *  Return value:
- *	index in ARGV of the first ARGV-element that is not an option.
+ *      index in ARGV of the first ARGV-element that is not an option.
  *
  *  Side effects:
- *	the elements of ARGV are permuted
+ *      the elements of ARGV are permuted
  *      usr_params [].value is modified
  */
 {
-   extern int optind;			/* index in ARGV of the 1st element
-					   that is not an option */
-   bool_t     detailed_help = NO;	/* NO if all parameters can be modified
-					   with short options too */
-   unsigned   n1;			/* number of user parameters */
-   unsigned   n2;			/* number of system parameters */
-   bool_t     read_config_file = NO;	/* will override command line */
-   param_t    *params;			/* array of user and system params */
-   param_t    *sys_params;		/* array of system parameters */
+   extern int optind;                   /* index in ARGV of the 1st element
+                                           that is not an option */
+   bool_t     detailed_help = NO;       /* NO if all parameters can be modified
+                                           with short options too */
+   unsigned   n1;                       /* number of user parameters */
+   unsigned   n2;                       /* number of system parameters */
+   bool_t     read_config_file = NO;    /* will override command line */
+   param_t    *params;                  /* array of user and system params */
+   param_t    *sys_params;              /* array of system parameters */
    param_t    detailed_sys_params [] =  /* detailed system parameters */
    {
       {"version", NULL, 'v', PFLAG, {0}, NULL,
@@ -121,7 +121,7 @@ parseargs (param_t *usr_params,
        "Print detailed help, then exit."},
       {NULL, NULL, 0, PSTR, {0}, NULL, NULL }
    };
-   param_t    short_sys_params [] =	/* short system parameters */
+   param_t    short_sys_params [] =     /* short system parameters */
    {
       {"version", NULL, 'v', PFLAG, {0}, NULL,
        "Print program version number, then exit."},
@@ -133,10 +133,10 @@ parseargs (param_t *usr_params,
        "Print this help, then exit."},
       {NULL, NULL, 0, PSTR, {0}, NULL, NULL }
    };
-   char *sys_path;			/* path to system config file */
+   char *sys_path;                      /* path to system config file */
 
    sys_path = calloc (strlen (path) + strlen (sys_file_name) + 2,
-		      sizeof (char));
+                      sizeof (char));
    if (!sys_path)
       error ("Out of memory.");
    sprintf (sys_path, "%s/%s", path, sys_file_name);
@@ -179,12 +179,12 @@ parseargs (param_t *usr_params,
       FILE *parameter_file = open_file (sys_path, NULL, READ_ACCESS);
       if (parameter_file == NULL)
 /*
-	 warning ("No system resource file found.");
+         warning ("No system resource file found.");
 */ {}
       else
       {
-	 read_parameter_file (params, parameter_file);
-	 fclose (parameter_file);
+         read_parameter_file (params, parameter_file);
+         fclose (parameter_file);
       }
    }
    /*
@@ -194,138 +194,138 @@ parseargs (param_t *usr_params,
       FILE *parameter_file = open_file (usr_file_name, "HOME", READ_ACCESS);
       if (parameter_file != NULL)
       {
-	 read_parameter_file (params, parameter_file);
-	 fclose (parameter_file);
+         read_parameter_file (params, parameter_file);
+         fclose (parameter_file);
       }
    }
    /*
     *  Parse command line options
     */
    {
-      extern char   *optarg;		/* argument of current option */
-      struct option *long_options;	/* array of long options */
-      int	     option_index = 0;
-      char	     optstr [MAXSTRLEN]; /* string containing the legitimate
-					    option characters */
-      int	     optchar;		/* found option character */
+      extern char   *optarg;            /* argument of current option */
+      struct option *long_options;      /* array of long options */
+      int            option_index = 0;
+      char           optstr [MAXSTRLEN]; /* string containing the legitimate
+                                            option characters */
+      int            optchar;           /* found option character */
 
       /*
        *  Build short option string for getopt_long ().
        */
       {
-	 param_t *p;			/* counter */
-	 char	 *ptr_optstr;		/* pointer to position in string */
-
-	 ptr_optstr = optstr;
-	 for (p = params; p->name != NULL; p++)
-	    if (p->optchar != '\0')
-	    {
-	       *ptr_optstr++ = p->optchar;
-	       if (p->type == POSTR)
-	       {
-		  *ptr_optstr++ = ':';
-		  *ptr_optstr++ = ':';
-	       }
-	       else if (p->type != PFLAG)
-		  *ptr_optstr++ = ':';
-	    }
-	 *ptr_optstr = '\0';
+         param_t *p;                    /* counter */
+         char    *ptr_optstr;           /* pointer to position in string */
+
+         ptr_optstr = optstr;
+         for (p = params; p->name != NULL; p++)
+            if (p->optchar != '\0')
+            {
+               *ptr_optstr++ = p->optchar;
+               if (p->type == POSTR)
+               {
+                  *ptr_optstr++ = ':';
+                  *ptr_optstr++ = ':';
+               }
+               else if (p->type != PFLAG)
+                  *ptr_optstr++ = ':';
+            }
+         *ptr_optstr = '\0';
       }
 
       /*
        *  Build long option string for getopt_long ().
        */
       {
-	 int i;
-
-	 long_options = calloc (n1 + n2 + 1, sizeof (struct option));
-	 if (!long_options)
-	    error ("Out of memory.");
-	 for (i = 0; params [i].name != NULL; i++)
-	 {
-	    long_options [i].name    = params [i].name;
-	    switch (params [i].type)
-	    {
-	       case PFLAG:
-		  long_options [i].has_arg = 0;
-		  break;
-	       case POSTR:
-		  long_options [i].has_arg = 2;
-		  break;
-	       case PINT:
-	       case PSTR:
-	       case PFLOAT:
-	       default:
-		  long_options [i].has_arg = 1;
-		  break;
-	    }
-	    long_options [i].has_arg = params [i].type != PFLAG;
-	    long_options [i].flag    = NULL;
-	    long_options [i].val     = 0;
-	 }
+         int i;
+
+         long_options = calloc (n1 + n2 + 1, sizeof (struct option));
+         if (!long_options)
+            error ("Out of memory.");
+         for (i = 0; params [i].name != NULL; i++)
+         {
+            long_options [i].name    = params [i].name;
+            switch (params [i].type)
+            {
+               case PFLAG:
+                  long_options [i].has_arg = 0;
+                  break;
+               case POSTR:
+                  long_options [i].has_arg = 2;
+                  break;
+               case PINT:
+               case PSTR:
+               case PFLOAT:
+               default:
+                  long_options [i].has_arg = 1;
+                  break;
+            }
+            long_options [i].has_arg = params [i].type != PFLAG;
+            long_options [i].flag    = NULL;
+            long_options [i].val     = 0;
+         }
       }
 
       /*
        *  Parse command line
        */
       while ((optchar = getopt_long (argc, argv, optstr, long_options,
-				     &option_index)) != EOF)
+                                     &option_index)) != EOF)
       {
-	 int param_index = -1;
-
-	 switch (optchar)
-	 {
-	    case 0:
-	       param_index = option_index;
-	       break;
-	    case ':':
-	       if (detailed_help)
-		  fprintf (stderr,
-			   "Try `%s -h' or `%s --help' for "
-			   "more information.\n",
-			   argv [0], argv [0]);
-	       else
-		  fprintf (stderr, "Try `%s --help' for more information.\n",
-			   argv [0]);
-	       exit (2);
-	       break;
-	    case '?':
-	       if (detailed_help)
-		  fprintf (stderr,
-			   "Try `%s -h' or `%s --help' "
-			   "for more information.\n",
-			   argv [0], argv [0]);
-	       else
-		  fprintf (stderr, "Try `%s --help' for more information.\n",
-			   argv [0]);
-	       exit (2);
-	       break;
-	    default:
-	       {
-		  int i;
-
-		  for (i = 0; params [i].name != NULL; i++)
-		     if (params [i].optchar == optchar)
-		     {
-			param_index = i;
-			break;
-		     }
-	       }
-	 }
-	 /*
-	  *  Check for system options
-	  */
-	 if (param_index >= 0)
-	 {
-	    set_parameter (params + param_index, optarg ? optarg : "");
-	    if (streq (params [param_index].name, "help"))
-	       usage (params, argv [0], synopsis, comment, non_opt_string,
-		      YES, sys_path, usr_file_name);
-	    else if (streq (params [param_index].name, "info"))
-	       usage (params, argv [0], synopsis, comment, non_opt_string,
-		      NO, sys_path, usr_file_name);
-	    else if (streq (params [param_index].name, "version"))
-	    {
+         int param_index = -1;
+
+         switch (optchar)
+         {
+            case 0:
+               param_index = option_index;
+               break;
+            case ':':
+               if (detailed_help)
+                  fprintf (stderr,
+                           "Try `%s -h' or `%s --help' for "
+                           "more information.\n",
+                           argv [0], argv [0]);
+               else
+                  fprintf (stderr, "Try `%s --help' for more information.\n",
+                           argv [0]);
+               exit (2);
+               break;
+            case '?':
+               if (detailed_help)
+                  fprintf (stderr,
+                           "Try `%s -h' or `%s --help' "
+                           "for more information.\n",
+                           argv [0], argv [0]);
+               else
+                  fprintf (stderr, "Try `%s --help' for more information.\n",
+                           argv [0]);
+               exit (2);
+               break;
+            default:
+               {
+                  int i;
+
+                  for (i = 0; params [i].name != NULL; i++)
+                     if (params [i].optchar == optchar)
+                     {
+                        param_index = i;
+                        break;
+                     }
+               }
+         }
+         /*
+          *  Check for system options
+          */
+         if (param_index >= 0)
+         {
+            set_parameter (params + param_index, optarg ? optarg : "");
+            if (streq (params [param_index].name, "help"))
+               usage (params, argv [0], synopsis, comment, non_opt_string,
+                      YES, sys_path, usr_file_name);
+            else if (streq (params [param_index].name, "info"))
+               usage (params, argv [0], synopsis, comment, non_opt_string,
+                      NO, sys_path, usr_file_name);
+            else if (streq (params [param_index].name, "version"))
+            {
            fprintf (stderr, "%s " VERSION "\n", argv [0]);
            {
               /* Kludge for standard Netpbm version announcement */
@@ -337,15 +337,15 @@ parseargs (param_t *usr_params,
               pm_proginit(&argc, (const char **) modified_argv);
            }
            exit (2);
-	    }
-	    else if (streq (params [param_index].name, "verbose"))
-	       fiasco_set_verbosity (
+            }
+            else if (streq (params [param_index].name, "verbose"))
+               fiasco_set_verbosity (
                * (fiasco_verbosity_e *) parameter_value (params,
                                                          "verbose"));
-	    else if (streq (params [param_index].name, "config"))
-	       read_config_file = YES;
-	    param_index = -1;		/* clear index flag */
-	 }
+            else if (streq (params [param_index].name, "config"))
+               read_config_file = YES;
+            param_index = -1;           /* clear index flag */
+         }
       }
 
       free (long_options);
@@ -360,21 +360,21 @@ parseargs (param_t *usr_params,
 
       if ((filename = (char *) parameter_value (params, "config")) != NULL)
       {
-	 FILE *parameter_file;		/* input file */
-
-	 warning ("Options set in file `%s' will override"
-		  " command line options.", filename);
-	 parameter_file = open_file (filename, NULL, READ_ACCESS);
-	 if (parameter_file != NULL)
-	 {
-	    read_parameter_file (params, parameter_file);
-	    fclose (parameter_file);
-	 }
-	 else
-	    file_error (filename);
+         FILE *parameter_file;          /* input file */
+
+         warning ("Options set in file `%s' will override"
+                  " command line options.", filename);
+         parameter_file = open_file (filename, NULL, READ_ACCESS);
+         if (parameter_file != NULL)
+         {
+            read_parameter_file (params, parameter_file);
+            fclose (parameter_file);
+         }
+         else
+            file_error (filename);
       }
       else
-	 error ("Invalid config filename.");
+         error ("Invalid config filename.");
    }
 
    memcpy (usr_params, params, n1 * sizeof (param_t)); /* fill user struct */
@@ -389,7 +389,7 @@ parameter_value (const param_t *params, const char *name)
  *  Extract value of parameter 'name.' of the given parameters 'params'.
  *
  *  Return value:
- *	value of given parameter
+ *      value of given parameter
  */
 {
    int pind = get_parameter_index (params, name);
@@ -412,7 +412,7 @@ ask_and_set (param_t *params, const char *name, const char *msg)
  *  No return value.
  *
  *  Side effects:
- *	'params ['name'].value' is changed
+ *      'params ['name'].value' is changed
  */
 {
    char answer [MAXSTRLEN];
@@ -426,18 +426,18 @@ ask_and_set (param_t *params, const char *name, const char *msg)
 
    switch (params [index].type)
    {
-      case PFLAG:			/* Unusual, at least. */
-	 warning ("Flags should be initialized and set on demand, "
-		  "not request");
+      case PFLAG:                       /* Unusual, at least. */
+         warning ("Flags should be initialized and set on demand, "
+                  "not request");
       case PINT:
       case PSTR:
       case POSTR:
       case PFLOAT:
-	 scanf (MAXSTRLEN_SCANF, answer);
-	 set_parameter (&params [index], answer);
-	 break;
+         scanf (MAXSTRLEN_SCANF, answer);
+         set_parameter (&params [index], answer);
+         break;
       default:
-	 error ("Invalid parameter type for %s", name);
+         error ("Invalid parameter type for %s", name);
    }
 }
 
@@ -459,22 +459,22 @@ write_parameters (const param_t *params, FILE *output)
       fprintf (output, "# %s = ", params [pind].name);
       switch (params [pind].type)
       {
-	 case PFLAG:
-	    fprintf (output, "%s\n", params [pind].value.b ? "TRUE" : "FALSE");
-	    break;
-	 case PINT:
-	    fprintf (output, "%d\n", params [pind].value.i);
-	    break;
-	 case PFLOAT:
-	    fprintf (output, "%.4f\n", (double) params [pind].value.f);
-	    break;
-	 case PSTR:
-	 case POSTR:
-	    fprintf (output, "%s\n", params [pind].value.s);
-	    break;
-	 default:
-	    error ("Invalid type %d for parameter %s",
-		   params [pind].type, params [pind].name);
+         case PFLAG:
+            fprintf (output, "%s\n", params [pind].value.b ? "TRUE" : "FALSE");
+            break;
+         case PINT:
+            fprintf (output, "%d\n", params [pind].value.i);
+            break;
+         case PFLOAT:
+            fprintf (output, "%.4f\n", (double) params [pind].value.f);
+            break;
+         case PSTR:
+         case POSTR:
+            fprintf (output, "%s\n", params [pind].value.s);
+            break;
+         default:
+            error ("Invalid type %d for parameter %s",
+                   params [pind].type, params [pind].name);
       }
    }
    fputc ('\n', output);
@@ -482,7 +482,7 @@ write_parameters (const param_t *params, FILE *output)
 
 /*****************************************************************************
 
-				private code
+                                private code
 
 *****************************************************************************/
 
@@ -494,7 +494,7 @@ set_parameter (param_t *parameter, const char *value)
  *  No return value.
  *
  *  Side effects:
- *	'parameter.value' is changed accordingly
+ *      'parameter.value' is changed accordingly
  */
 {
    assert (parameter);
@@ -502,61 +502,61 @@ set_parameter (param_t *parameter, const char *value)
    switch (parameter->type)
    {
       case PFLAG:
-	 if (value != NULL && *value != '\0')
-	 {
-	    if (strcaseeq (value, "TRUE"))
-	       parameter->value.b = YES;
-	    else if (strcaseeq (value, "FALSE"))
-	       parameter->value.b = NO;
-	    else if (strcaseeq (value, "YES"))
-	       parameter->value.b = YES;
-	    else if (strcaseeq (value, "NO"))
-	       parameter->value.b = NO;
-	    else
-	    {
-	       long int	data;
-	       char	*endptr;
-
-	       data = strtol (value, &endptr, 0);
-	       if (*endptr != '\0' || endptr == value)
-		  warning ("Invalid value `%s' converted to %d",
-			   value, (int) data);
-	       parameter->value.b = data ? YES : NO;
-	    }
-	 }
-	 else
-	    parameter->value.b = !parameter->value.b;
-	 break;
+         if (value != NULL && *value != '\0')
+         {
+            if (strcaseeq (value, "TRUE"))
+               parameter->value.b = YES;
+            else if (strcaseeq (value, "FALSE"))
+               parameter->value.b = NO;
+            else if (strcaseeq (value, "YES"))
+               parameter->value.b = YES;
+            else if (strcaseeq (value, "NO"))
+               parameter->value.b = NO;
+            else
+            {
+               long int data;
+               char     *endptr;
+
+               data = strtol (value, &endptr, 0);
+               if (*endptr != '\0' || endptr == value)
+                  warning ("Invalid value `%s' converted to %d",
+                           value, (int) data);
+               parameter->value.b = data ? YES : NO;
+            }
+         }
+         else
+            parameter->value.b = !parameter->value.b;
+         break;
       case PINT:
-	 {
-	    long int  data;
-	    char     *endptr;
-
-	    data = strtol (value, &endptr, 0);
-	    if (*endptr != '\0' || endptr == value)
-	       warning ("Invalid value `%s' converted to %d",
-			value, (int) data);
-	    parameter->value.i = data;
-	 }
-	 break;
+         {
+            long int  data;
+            char     *endptr;
+
+            data = strtol (value, &endptr, 0);
+            if (*endptr != '\0' || endptr == value)
+               warning ("Invalid value `%s' converted to %d",
+                        value, (int) data);
+            parameter->value.i = data;
+         }
+         break;
       case PFLOAT:
-	 {
-	    double	data;
-	    char	*endptr;
-
-	    data = strtod (value, &endptr);
-	    if (*endptr != '\0' || endptr == value)
-	       warning ("Invalid value `%s' converted to %f",
-			value, (double) data);
-	    parameter->value.f = data;
-	 }
-	 break;
+         {
+            double      data;
+            char        *endptr;
+
+            data = strtod (value, &endptr);
+            if (*endptr != '\0' || endptr == value)
+               warning ("Invalid value `%s' converted to %f",
+                        value, (double) data);
+            parameter->value.f = data;
+         }
+         break;
       case PSTR:
       case POSTR:
-	 parameter->value.s = value ? strdup (value) : NULL;
-	 break;
+         parameter->value.s = value ? strdup (value) : NULL;
+         break;
       default:
-	 error ("Invalid parameter type for %s", parameter->name);
+         error ("Invalid parameter type for %s", parameter->name);
    }
 }
 
@@ -566,7 +566,7 @@ get_parameter_index (const param_t *params, const char *search_string)
  *  Search for parameter with name 'search_string' in parameter struct.
  *
  *  Return value:
- *	index of parameter or -1 if no matching parameter has been found
+ *      index of parameter or -1 if no matching parameter has been found
  */
 {
    int n;
@@ -577,8 +577,8 @@ get_parameter_index (const param_t *params, const char *search_string)
    for (n = 0; params [n].name != NULL; n++)
       if (strcaseeq (params [n].name, search_string))
       {
-	 index = n;
-	 break;
+         index = n;
+         break;
       }
 
    return index;
@@ -592,7 +592,7 @@ read_parameter_file (param_t *params, FILE *file)
  *  No return value.
  *
  *  Side effects:
- *	'params [].value' are changed if specified in 'file'
+ *      'params [].value' are changed if specified in 'file'
  */
 {
    char buffer [MAXSTRLEN];
@@ -602,41 +602,41 @@ read_parameter_file (param_t *params, FILE *file)
 
    while (fgets (buffer, MAXSTRLEN, file) != NULL)
    {
-      char *b;				/* temporary variable */
-      char *name;			/* parameter name */
-      char *value;			/* parameter value */
-      int   pind;			/* current argument number */
+      char *b;                          /* temporary variable */
+      char *name;                       /* parameter name */
+      char *value;                      /* parameter value */
+      int   pind;                       /* current argument number */
 
       b = strchr (buffer, '#');
-      if (b != NULL)			/* Strip comments. */
-	 *b = '\0';
+      if (b != NULL)                    /* Strip comments. */
+         *b = '\0';
 
       b = strchr (buffer, '=');
-      if (b == NULL)			/* Strip lines that contain no '=' */
-	 continue;
-      *b = '\0';			/* Replace '=' by string terminator */
+      if (b == NULL)                    /* Strip lines that contain no '=' */
+         continue;
+      *b = '\0';                        /* Replace '=' by string terminator */
 
       /*
        *  Extract value of parameter
        */
       for (value = b + 1; ISSPACE (*value); value++)
-	 ;				/* Delete leading spaces */
+         ;                              /* Delete leading spaces */
 
       for (b = value + strlen (value) - 1; b >= value && ISSPACE (*b); b--)
-	 *b = '\0';			/* Delete trailing spaces. */
+         *b = '\0';                     /* Delete trailing spaces. */
 
       /*
        *  Extract parameter name
        */
       for (name = buffer; ISSPACE (*name); name++)
-	 ;				/* Delete leading spaces */
+         ;                              /* Delete leading spaces */
 
       for (b = name + strlen (name) - 1; b >= name && ISSPACE (*b); b--)
-	 *b = '\0';			/* Delete trailing spaces. */
+         *b = '\0';                     /* Delete trailing spaces. */
 
       pind = get_parameter_index (params, name);
       if (pind >= 0)
-	 set_parameter (&params [pind], value);
+         set_parameter (&params [pind], value);
 
       n++;
    }
@@ -660,7 +660,7 @@ usage (const param_t *params, const char *progname, const char *synopsis,
  *  No return value.
  */
 {
-    int	  i;
+    int   i;
     size_t width = 0;
 
     fprintf (stderr, "Usage: %s [OPTION]...%s\n", progname,
diff --git a/converter/other/fiasco/params.h b/converter/other/fiasco/params.h
index a1164cf7..dd79d43d 100644
--- a/converter/other/fiasco/params.h
+++ b/converter/other/fiasco/params.h
@@ -3,7 +3,7 @@
  *
  *  Written by:     Stefan Frank
  *          Ullrich Hafner
- *      
+ *
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -43,13 +43,13 @@ typedef struct param_t
 } param_t;
 
 int
-parseargs (param_t *usr_params, 
-           int argc, char **argv, 
+parseargs (param_t *usr_params,
+           int argc, char **argv,
            const char *synopsis,
-           const char *comment, 
-           const char *non_opt_string, 
+           const char *comment,
+           const char *non_opt_string,
            const char *path,
-           const char *sys_file_name, 
+           const char *sys_file_name,
            const char *usr_file_name);
 void
 write_parameters (const param_t *params, FILE *output);
diff --git a/converter/other/jbig/libjbig/include/jbig.h b/converter/other/jbig/libjbig/include/jbig.h
index 67994107..3c991b08 100644
--- a/converter/other/jbig/libjbig/include/jbig.h
+++ b/converter/other/jbig/libjbig/include/jbig.h
@@ -39,7 +39,7 @@ struct jbg_buf {
   int len;                             /* length of the data in this block */
   struct jbg_buf *next;                           /* pointer to next block */
   struct jbg_buf *previous;                   /* pointer to previous block *
-					       * (unused in freelist)      */
+                                               * (unused in freelist)      */
   struct jbg_buf *last;     /* only used in list head: final block of list */
   struct jbg_buf **free_list;   /* pointer to pointer to head of free list */
 };
@@ -70,12 +70,12 @@ struct jbg_buf {
 /* encoding options that will not be indicated in the header */
 
 #define JBG_DELAY_AT   0x100  /* Delay ATMOVE until the first line of the next
-			       * stripe. Option available for compatibility
-			       * with conformance test example in clause 7.2. */
+                               * stripe. Option available for compatibility
+                               * with conformance test example in clause 7.2. */
 
 #define JBG_SDRST      0x200  /* Use SDRST instead of SDNORM. This option is
-			       * there for anyone who needs to generate
-			       * test data that covers the SDRST cases. */
+                               * there for anyone who needs to generate
+                               * test data that covers the SDRST cases. */
 
 /*
  * Possible error code return values
@@ -115,7 +115,7 @@ struct jbg_enc_state {
   char *dppriv;         /* optional private deterministic prediction table */
   char *res_tab;           /* table for the resolution reduction algorithm */
   struct jbg_buf ****sde;      /* array [stripe][layer][plane] pointers to *
-				* buffers for stored SDEs                  */
+                                * buffers for stored SDEs                  */
   struct jbg_arenc_state *s;  /* array [planes] for arithm. encoder status */
   struct jbg_buf *free_list; /* list of currently unused SDE block buffers */
   void (*data_out)(unsigned char *start, size_t len, void *file);
@@ -140,7 +140,7 @@ struct jbg_dec_state {
   unsigned long xd, yd;     /* size of the full image (resolution layer d) */
   int planes;                         /* number of different bitmap planes */
   unsigned long l0;                /* number of lines per stripe at lowest *
-				    * resolution layer 0                   */
+                                    * resolution layer 0                   */
   unsigned long stripes;    /* number of stripes required  (determ. by l0) */
   int order;                                    /* SDE ordering parameters */
   int options;                                      /* encoding parameters */
@@ -152,34 +152,34 @@ struct jbg_dec_state {
 
   /*
    * Pointers to array [planes] of lower/higher resolution images.
-   * lhp[d & 1] contains image of layer d. 
+   * lhp[d & 1] contains image of layer d.
    */
   unsigned char **lhp[2];
 
   /* status information */
   int **tx, **ty;   /* array [plane][layer-dl] with x,y-offset of AT pixel */
   struct jbg_ardec_state **s;    /* array [plane][layer-dl] for arithmetic *
-				  * decoder status */
+                                  * decoder status */
   int **reset;     /* array [plane][layer-dl] remembers if previous stripe *
-		    * in that plane/resolution ended with SDRST.           */
+                    * in that plane/resolution ended with SDRST.           */
   unsigned long bie_len;                    /* number of bytes read so far */
   unsigned char buffer[20]; /* used to store BIH or marker segments fragm. */
   int buf_len;                                /* number of bytes in buffer */
   unsigned long comment_skip;      /* remaining bytes of a COMMENT segment */
   unsigned long x;              /* x position of next pixel in current SDE */
-  unsigned long i; /* line in current SDE (first line of each stripe is 0) */ 
+  unsigned long i; /* line in current SDE (first line of each stripe is 0) */
   int at_moves;                /* number of AT moves in the current stripe */
   unsigned long at_line[JBG_ATMOVES_MAX];           /* lines at which an   *
-					             * AT move will happen */
+                                                     * AT move will happen */
   int at_tx[JBG_ATMOVES_MAX], at_ty[JBG_ATMOVES_MAX]; /* ATMOVE offsets in *
-						       * current stripe    */
+                                                       * current stripe    */
   unsigned long line_h1, line_h2, line_h3;     /* variables of decode_pscd */
   unsigned long line_l1, line_l2, line_l3;
   int pseudo;         /* flag for TPBON/TPDON:  next pixel is pseudo pixel */
   int **lntp;        /* flag [plane][layer-dl] for TP: line is not typical */
 
   unsigned long xmax, ymax;         /* if possible abort before image gets *
-				     * larger than this size */
+                                     * larger than this size */
   int dmax;                                      /* abort after this layer */
 };
 
@@ -192,31 +192,31 @@ struct jbg_dec_state {
 /* function prototypes */
 
 void jbg_enc_init(struct jbg_enc_state *s, unsigned long x, unsigned long y,
-		  int planes, unsigned char **p,
-		  void (*data_out)(unsigned char *start, size_t len,
-				   void *file),
-		  void *file);
+                  int planes, unsigned char **p,
+                  void (*data_out)(unsigned char *start, size_t len,
+                                   void *file),
+                  void *file);
 int jbg_enc_lrlmax(struct jbg_enc_state *s, unsigned long mwidth,
-		   unsigned long mheight);
+                   unsigned long mheight);
 void jbg_enc_layers(struct jbg_enc_state *s, int d);
 int  jbg_enc_lrange(struct jbg_enc_state *s, int dl, int dh);
 void jbg_enc_options(struct jbg_enc_state *s, int order, int options,
-		     unsigned long l0, int mx, int my);
+                     unsigned long l0, int mx, int my);
 void jbg_enc_out(struct jbg_enc_state *s);
 void jbg_enc_free(struct jbg_enc_state *s);
 
 void jbg_dec_init(struct jbg_dec_state *s);
 void jbg_dec_maxsize(struct jbg_dec_state *s, unsigned long xmax,
-		     unsigned long ymax);
+                     unsigned long ymax);
 int  jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
-		size_t *cnt);
+                size_t *cnt);
 unsigned long jbg_dec_getwidth(const struct jbg_dec_state *s);
 unsigned long jbg_dec_getheight(const struct jbg_dec_state *s);
 unsigned char *jbg_dec_getimage(const struct jbg_dec_state *s, int plane);
 unsigned long jbg_dec_getsize(const struct jbg_dec_state *s);
 void jbg_dec_merge_planes(const struct jbg_dec_state *s, int use_graycode,
-			  void (*data_out)(unsigned char *start, size_t len,
-					   void *file), void *file);
+                          void (*data_out)(unsigned char *start, size_t len,
+                                           void *file), void *file);
 unsigned long jbg_dec_getsize_merged(const struct jbg_dec_state *s);
 void jbg_dec_free(struct jbg_dec_state *s);
 
@@ -225,9 +225,9 @@ void jbg_int2dppriv(unsigned char *dptable, const char *internal);
 void jbg_dppriv2int(char *internal, const unsigned char *dptable);
 unsigned long jbg_ceil_half(unsigned long x, int n);
 void jbg_split_planes(unsigned long x, unsigned long y, int has_planes,
-		      int encode_planes,
-		      const unsigned char *src, unsigned char **dest,
-		      int use_graycode);
+                      int encode_planes,
+                      const unsigned char *src, unsigned char **dest,
+                      int use_graycode);
 int jbg_newlen(unsigned char *bie, size_t len);
 
 #endif /* JBG_H */
diff --git a/converter/other/jbig/libjbig/include/jbig_ar.h b/converter/other/jbig/libjbig/include/jbig_ar.h
index ed5f2f86..e3366aed 100644
--- a/converter/other/jbig/libjbig/include/jbig_ar.h
+++ b/converter/other/jbig/libjbig/include/jbig_ar.h
@@ -39,9 +39,9 @@ struct jbg_ardec_state {
               * special value -1 signals that zero-padding has started     */
   int startup;          /* boolean flag that controls initial fill of s->c */
   int nopadding;        /* boolean flag that triggers return -2 between
-			 * reaching PSCD end and decoding the first symbol
-			 * that might never have been encoded in the first
-			 * place */
+                         * reaching PSCD end and decoding the first symbol
+                         * that might never have been encoded in the first
+                         * place */
 };
 
 void arith_encode_init(struct jbg_arenc_state *s, int reuse_st);
diff --git a/converter/other/jbig/libjbig/jbig.c b/converter/other/jbig/libjbig/jbig.c
index cf24a93b..42932ca7 100644
--- a/converter/other/jbig/libjbig/jbig.c
+++ b/converter/other/jbig/libjbig/jbig.c
@@ -143,7 +143,7 @@ static void *checked_malloc(size_t nmemb, size_t size)
 
 #if 0
   fprintf(stderr, "%p = malloc(%lu * %lu)\n", p,
-	  (unsigned long) nmemb, (unsigned long) size);
+          (unsigned long) nmemb, (unsigned long) size);
 #endif
 
   return p;
@@ -169,7 +169,7 @@ static void *checked_realloc(void *ptr, size_t nmemb, size_t size)
 
 #if 0
   fprintf(stderr, "%p = realloc(%p, %lu * %lu)\n", p, ptr,
-	  (unsigned long) nmemb, (unsigned long) size);
+          (unsigned long) nmemb, (unsigned long) size);
 #endif
 
   return p;
@@ -334,9 +334,9 @@ static void jbg_buf_prefix(struct jbg_buf *new_prefix, struct jbg_buf **start)
  * After the call, *head == NULL.
  */
 static void jbg_buf_output(struct jbg_buf **head,
-			void (*data_out)(unsigned char *start,
-					 size_t len, void *file),
-			void *file)
+                        void (*data_out)(unsigned char *start,
+                                         size_t len, void *file),
+                        void *file)
 {
   struct jbg_buf *tmp;
 
@@ -388,7 +388,7 @@ static void jbg_set_default_l0(struct jbg_enc_state *s)
  * Calculate the number of stripes, as defined in clause 6.2.3 of T.82.
  */
 static unsigned long jbg_stripes(unsigned long l0, unsigned long yd,
-			  unsigned long d)
+                          unsigned long d)
 {
   unsigned long y0 = jbg_ceil_half(yd, d);
 
@@ -767,8 +767,8 @@ static char jbg_dptable[256 + 512 + 2048 + 4096] = {
 void jbg_enc_init(struct jbg_enc_state *s, unsigned long x, unsigned long y,
                   int planes, unsigned char **p,
                   void (*data_out)(unsigned char *start, size_t len,
-				   void *file),
-		  void *file)
+                                   void *file),
+                  void *file)
 {
   unsigned long l, lx;
   int i;
@@ -831,7 +831,7 @@ void jbg_enc_init(struct jbg_enc_state *s, unsigned long x, unsigned long y,
  * is returned.
  */
 int jbg_enc_lrlmax(struct jbg_enc_state *s, unsigned long x,
-		   unsigned long y)
+                   unsigned long y)
 {
   for (s->d = 0; s->d < 6; s->d++)
     if (jbg_ceil_half(s->xd, s->d) <= x && jbg_ceil_half(s->yd, s->d) <= y)
@@ -882,7 +882,7 @@ int jbg_enc_lrange(struct jbg_enc_state *s, int dl, int dh)
  * number of layer 0 lines per stripes.
  */
 void jbg_enc_options(struct jbg_enc_state *s, int order, int options,
-		     unsigned long l0, int mx, int my)
+                     unsigned long l0, int mx, int my)
 {
   if (order >= 0 && order <= 0x0f) s->order = order;
   if (options >= 0) s->options = options;
@@ -900,7 +900,7 @@ void jbg_enc_options(struct jbg_enc_state *s, int order, int options,
  * for later output in the correct order.
  */
 static void encode_sde(struct jbg_enc_state *s,
-		       long stripe, int layer, int plane)
+                       long stripe, int layer, int plane)
 {
   unsigned char *hp, *lp1, *lp2, *p0, *p1, *q1, *q2;
   unsigned long hl, ll, hx, hy, lx, ly, hbpl, lbpl;
@@ -933,7 +933,7 @@ static void encode_sde(struct jbg_enc_state *s,
   if (stripe == 0)
     tp_lines = tp_exceptions = tp_pixels = dp_pixels = encoded_pixels = 0;
   fprintf(stderr, "encode_sde: s/d/p = %2ld/%2d/%2d\n",
-	  stripe, layer, plane);
+          stripe, layer, plane);
 #endif
 
   /* number of lines per stripe in highres image */
@@ -1001,59 +1001,59 @@ static void encode_sde(struct jbg_enc_state *s,
 
       /* check whether it is worth to perform an ATMOVE */
       if (!at_determined && c_all > 2048) {
-	cmin = clmin = 0xffffffffL;
-	cmax = clmax = 0;
-	tmax = 0;
-	for (t = (s->options & JBG_LRLTWO) ? 5 : 3; t <= s->mx; t++) {
-	  if (c[t] > cmax) cmax = c[t];
-	  if (c[t] < cmin) cmin = c[t];
-	  if (c[t] > c[tmax]) tmax = t;
-	}
-	clmin = (c[0] < cmin) ? c[0] : cmin;
-	clmax = (c[0] > cmax) ? c[0] : cmax;
-	if (c_all - cmax < (c_all >> 3) &&
-	    cmax - c[s->tx[plane]] > c_all - cmax &&
-	    cmax - c[s->tx[plane]] > (c_all >> 4) &&
-	    /*                     ^ T.82 said < here, fixed in Cor.1/25 */
-	    cmax - (c_all - c[s->tx[plane]]) > c_all - cmax &&
-	    cmax - (c_all - c[s->tx[plane]]) > (c_all >> 4) &&
-	    cmax - cmin > (c_all >> 2) &&
-	    (s->tx[plane] || clmax - clmin > (c_all >> 3))) {
-	  /* we have decided to perform an ATMOVE */
-	  new_tx = tmax;
-	  if (!(s->options & JBG_DELAY_AT)) {
-	    new_tx_line = i;
-	    s->tx[plane] = new_tx;
-	  }
+        cmin = clmin = 0xffffffffL;
+        cmax = clmax = 0;
+        tmax = 0;
+        for (t = (s->options & JBG_LRLTWO) ? 5 : 3; t <= s->mx; t++) {
+          if (c[t] > cmax) cmax = c[t];
+          if (c[t] < cmin) cmin = c[t];
+          if (c[t] > c[tmax]) tmax = t;
+        }
+        clmin = (c[0] < cmin) ? c[0] : cmin;
+        clmax = (c[0] > cmax) ? c[0] : cmax;
+        if (c_all - cmax < (c_all >> 3) &&
+            cmax - c[s->tx[plane]] > c_all - cmax &&
+            cmax - c[s->tx[plane]] > (c_all >> 4) &&
+            /*                     ^ T.82 said < here, fixed in Cor.1/25 */
+            cmax - (c_all - c[s->tx[plane]]) > c_all - cmax &&
+            cmax - (c_all - c[s->tx[plane]]) > (c_all >> 4) &&
+            cmax - cmin > (c_all >> 2) &&
+            (s->tx[plane] || clmax - clmin > (c_all >> 3))) {
+          /* we have decided to perform an ATMOVE */
+          new_tx = tmax;
+          if (!(s->options & JBG_DELAY_AT)) {
+            new_tx_line = i;
+            s->tx[plane] = new_tx;
+          }
 #ifdef DEBUG
-	  fprintf(stderr, "ATMOVE: line=%ld, tx=%d, c_all=%ld\n",
-		  i, new_tx, c_all);
+          fprintf(stderr, "ATMOVE: line=%ld, tx=%d, c_all=%ld\n",
+                  i, new_tx, c_all);
 #endif
-	}
-	at_determined = 1;
+        }
+        at_determined = 1;
       }
       assert(s->tx[plane] >= 0); /* i.e., tx can safely be cast to unsigned */
 
       /* typical prediction */
       if (s->options & JBG_TPBON) {
-	ltp = 1;
-	p1 = hp;
-	if (i > 0 || !reset) {
-	  q1 = hp - hbpl;
-	  while (q1 < hp && (ltp = (*p1++ == *q1++)) != 0) ;
-	} else
-	  while (p1 < hp + hbpl && (ltp = (*p1++ == 0)) != 0) ;
-	arith_encode(se, (s->options & JBG_LRLTWO) ? TPB2CX : TPB3CX,
-		     ltp == ltp_old);
+        ltp = 1;
+        p1 = hp;
+        if (i > 0 || !reset) {
+          q1 = hp - hbpl;
+          while (q1 < hp && (ltp = (*p1++ == *q1++)) != 0) ;
+        } else
+          while (p1 < hp + hbpl && (ltp = (*p1++ == 0)) != 0) ;
+        arith_encode(se, (s->options & JBG_LRLTWO) ? TPB2CX : TPB3CX,
+                     ltp == ltp_old);
 #ifdef DEBUG
-	tp_lines += ltp;
+        tp_lines += ltp;
 #endif
-	ltp_old = ltp;
-	if (ltp) {
-	  /* skip next line */
-	  hp += hbpl;
-	  continue;
-	}
+        ltp_old = ltp;
+        if (ltp) {
+          /* skip next line */
+          hp += hbpl;
+          continue;
+        }
       }
 
       /*
@@ -1071,102 +1071,102 @@ static void encode_sde(struct jbg_enc_state *s,
 
       /* encode line */
       for (j = 0; j < hx; hp++) {
-	line_h1 |= *hp;
-	if (j < hbpl * 8 - 8 && (i > 0 || !reset)) {
-	  line_h2 |= *(hp - hbpl + 1);
-	  if (i > 1 || !reset)
-	    line_h3 |= *(hp - hbpl - hbpl + 1);
-	}
-	if (s->options & JBG_LRLTWO) {
-	  /* two line template */
-	  do {
-	    line_h1 <<= 1;  line_h2 <<= 1;  line_h3 <<= 1;
-	    if (s->tx[plane]) {
-	      if ((unsigned) s->tx[plane] > j)
-		a = 0;
-	      else {
-		o = (j - s->tx[plane]) - (j & ~7L);
-		a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
-		a <<= 4;
-	      }
-	      assert(s->tx[plane] > 23 ||
-		     a == ((line_h1 >> (4 + s->tx[plane])) & 0x010));
-	      arith_encode(se, (((line_h2 >> 10) & 0x3e0) | a |
-				((line_h1 >>  9) & 0x00f)),
-			   (line_h1 >> 8) & 1);
-	    }
-	    else
-	      arith_encode(se, (((line_h2 >> 10) & 0x3f0) |
-				((line_h1 >>  9) & 0x00f)),
-			   (line_h1 >> 8) & 1);
+        line_h1 |= *hp;
+        if (j < hbpl * 8 - 8 && (i > 0 || !reset)) {
+          line_h2 |= *(hp - hbpl + 1);
+          if (i > 1 || !reset)
+            line_h3 |= *(hp - hbpl - hbpl + 1);
+        }
+        if (s->options & JBG_LRLTWO) {
+          /* two line template */
+          do {
+            line_h1 <<= 1;  line_h2 <<= 1;  line_h3 <<= 1;
+            if (s->tx[plane]) {
+              if ((unsigned) s->tx[plane] > j)
+                a = 0;
+              else {
+                o = (j - s->tx[plane]) - (j & ~7L);
+                a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
+                a <<= 4;
+              }
+              assert(s->tx[plane] > 23 ||
+                     a == ((line_h1 >> (4 + s->tx[plane])) & 0x010));
+              arith_encode(se, (((line_h2 >> 10) & 0x3e0) | a |
+                                ((line_h1 >>  9) & 0x00f)),
+                           (line_h1 >> 8) & 1);
+            }
+            else
+              arith_encode(se, (((line_h2 >> 10) & 0x3f0) |
+                                ((line_h1 >>  9) & 0x00f)),
+                           (line_h1 >> 8) & 1);
 #ifdef DEBUG
-	    encoded_pixels++;
+            encoded_pixels++;
 #endif
-	    /* statistics for adaptive template changes */
-	    if (!at_determined && j >= s->mx && j < hx-2) {
-	      p = (line_h1 & 0x100) != 0; /* current pixel value */
-	      c[0] += ((line_h2 & 0x4000) != 0) == p; /* default position */
-	      assert((!(((line_h2 >> 6) ^ line_h1) & 0x100)) ==
-		     (((line_h2 & 0x4000) != 0) == p));
-	      for (t = 5; t <= s->mx && t <= j; t++) {
-		o = (j - t) - (j & ~7L);
-		a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
-		assert(t > 23 ||
-		       (a == p) == !(((line_h1 >> t) ^ line_h1) & 0x100));
-		c[t] += a == p;
-	      }
-	      for (; t <= s->mx; t++) {
-		c[t] += 0 == p;
-	      }
-	      ++c_all;
-	    }
-	  } while (++j & 7 && j < hx);
-	} else {
-	  /* three line template */
-	  do {
-	    line_h1 <<= 1;  line_h2 <<= 1;  line_h3 <<= 1;
-	    if (s->tx[plane]) {
-	      if ((unsigned) s->tx[plane] > j)
-		a = 0;
-	      else {
-		o = (j - s->tx[plane]) - (j & ~7L);
-		a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
-		a <<= 2;
-	      }
-	      assert(s->tx[plane] > 23 ||
-		     a == ((line_h1 >> (6 + s->tx[plane])) & 0x004));
-	      arith_encode(se, (((line_h3 >>  8) & 0x380) |
-				((line_h2 >> 12) & 0x078) | a |
-				((line_h1 >>  9) & 0x003)),
-			   (line_h1 >> 8) & 1);
-	    } else
-	      arith_encode(se, (((line_h3 >>  8) & 0x380) |
-				((line_h2 >> 12) & 0x07c) |
-				((line_h1 >>  9) & 0x003)),
-			   (line_h1 >> 8) & 1);
+            /* statistics for adaptive template changes */
+            if (!at_determined && j >= s->mx && j < hx-2) {
+              p = (line_h1 & 0x100) != 0; /* current pixel value */
+              c[0] += ((line_h2 & 0x4000) != 0) == p; /* default position */
+              assert((!(((line_h2 >> 6) ^ line_h1) & 0x100)) ==
+                     (((line_h2 & 0x4000) != 0) == p));
+              for (t = 5; t <= s->mx && t <= j; t++) {
+                o = (j - t) - (j & ~7L);
+                a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
+                assert(t > 23 ||
+                       (a == p) == !(((line_h1 >> t) ^ line_h1) & 0x100));
+                c[t] += a == p;
+              }
+              for (; t <= s->mx; t++) {
+                c[t] += 0 == p;
+              }
+              ++c_all;
+            }
+          } while (++j & 7 && j < hx);
+        } else {
+          /* three line template */
+          do {
+            line_h1 <<= 1;  line_h2 <<= 1;  line_h3 <<= 1;
+            if (s->tx[plane]) {
+              if ((unsigned) s->tx[plane] > j)
+                a = 0;
+              else {
+                o = (j - s->tx[plane]) - (j & ~7L);
+                a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
+                a <<= 2;
+              }
+              assert(s->tx[plane] > 23 ||
+                     a == ((line_h1 >> (6 + s->tx[plane])) & 0x004));
+              arith_encode(se, (((line_h3 >>  8) & 0x380) |
+                                ((line_h2 >> 12) & 0x078) | a |
+                                ((line_h1 >>  9) & 0x003)),
+                           (line_h1 >> 8) & 1);
+            } else
+              arith_encode(se, (((line_h3 >>  8) & 0x380) |
+                                ((line_h2 >> 12) & 0x07c) |
+                                ((line_h1 >>  9) & 0x003)),
+                           (line_h1 >> 8) & 1);
 #ifdef DEBUG
-	    encoded_pixels++;
+            encoded_pixels++;
 #endif
-	    /* statistics for adaptive template changes */
-	    if (!at_determined && j >= s->mx && j < hx-2) {
-	      p = (line_h1 & 0x100) != 0; /* current pixel value */
-	      c[0] += ((line_h2 & 0x4000) != 0) == p; /* default position */
-	      assert((!(((line_h2 >> 6) ^ line_h1) & 0x100)) ==
-		     (((line_h2 & 0x4000) != 0) == p));
-	      for (t = 3; t <= s->mx && t <= j; t++) {
-		o = (j - t) - (j & ~7L);
-		a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
-		assert(t > 23 ||
-		       (a == p) == !(((line_h1 >> t) ^ line_h1) & 0x100));
-		c[t] += a == p;
-	      }
-	      for (; t <= s->mx; t++) {
-		c[t] += 0 == p;
-	      }
-	      ++c_all;
-	    }
-	  } while (++j & 7 && j < hx);
-	} /* if (s->options & JBG_LRLTWO) */
+            /* statistics for adaptive template changes */
+            if (!at_determined && j >= s->mx && j < hx-2) {
+              p = (line_h1 & 0x100) != 0; /* current pixel value */
+              c[0] += ((line_h2 & 0x4000) != 0) == p; /* default position */
+              assert((!(((line_h2 >> 6) ^ line_h1) & 0x100)) ==
+                     (((line_h2 & 0x4000) != 0) == p));
+              for (t = 3; t <= s->mx && t <= j; t++) {
+                o = (j - t) - (j & ~7L);
+                a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
+                assert(t > 23 ||
+                       (a == p) == !(((line_h1 >> t) ^ line_h1) & 0x100));
+                c[t] += a == p;
+              }
+              for (; t <= s->mx; t++) {
+                c[t] += 0 == p;
+              }
+              ++c_all;
+            }
+          } while (++j & 7 && j < hx);
+        } /* if (s->options & JBG_LRLTWO) */
       } /* for (j = ...) */
     } /* for (i = ...) */
 
@@ -1180,101 +1180,101 @@ static void encode_sde(struct jbg_enc_state *s,
 
       /* check whether it is worth to perform an ATMOVE */
       if (!at_determined && c_all > 2048) {
-	cmin = clmin = 0xffffffffL;
-	cmax = clmax = 0;
-	tmax = 0;
-	for (t = 3; t <= s->mx; t++) {
-	  if (c[t] > cmax) cmax = c[t];
-	  if (c[t] < cmin) cmin = c[t];
-	  if (c[t] > c[tmax]) tmax = t;
-	}
-	clmin = (c[0] < cmin) ? c[0] : cmin;
-	clmax = (c[0] > cmax) ? c[0] : cmax;
-	if (c_all - cmax < (c_all >> 3) &&
-	    cmax - c[s->tx[plane]] > c_all - cmax &&
-	    cmax - c[s->tx[plane]] > (c_all >> 4) &&
-	    /*                     ^ T.82 said < here, fixed in Cor.1/25 */
-	    cmax - (c_all - c[s->tx[plane]]) > c_all - cmax &&
-	    cmax - (c_all - c[s->tx[plane]]) > (c_all >> 4) &&
-	    cmax - cmin > (c_all >> 2) &&
-	    (s->tx[plane] || clmax - clmin > (c_all >> 3))) {
-	  /* we have decided to perform an ATMOVE */
-	  new_tx = tmax;
-	  if (!(s->options & JBG_DELAY_AT)) {
-	    new_tx_line = i;
-	    s->tx[plane] = new_tx;
-	  }
+        cmin = clmin = 0xffffffffL;
+        cmax = clmax = 0;
+        tmax = 0;
+        for (t = 3; t <= s->mx; t++) {
+          if (c[t] > cmax) cmax = c[t];
+          if (c[t] < cmin) cmin = c[t];
+          if (c[t] > c[tmax]) tmax = t;
+        }
+        clmin = (c[0] < cmin) ? c[0] : cmin;
+        clmax = (c[0] > cmax) ? c[0] : cmax;
+        if (c_all - cmax < (c_all >> 3) &&
+            cmax - c[s->tx[plane]] > c_all - cmax &&
+            cmax - c[s->tx[plane]] > (c_all >> 4) &&
+            /*                     ^ T.82 said < here, fixed in Cor.1/25 */
+            cmax - (c_all - c[s->tx[plane]]) > c_all - cmax &&
+            cmax - (c_all - c[s->tx[plane]]) > (c_all >> 4) &&
+            cmax - cmin > (c_all >> 2) &&
+            (s->tx[plane] || clmax - clmin > (c_all >> 3))) {
+          /* we have decided to perform an ATMOVE */
+          new_tx = tmax;
+          if (!(s->options & JBG_DELAY_AT)) {
+            new_tx_line = i;
+            s->tx[plane] = new_tx;
+          }
 #ifdef DEBUG
-	  fprintf(stderr, "ATMOVE: line=%ld, tx=%d, c_all=%ld\n",
-		  i, new_tx, c_all);
+          fprintf(stderr, "ATMOVE: line=%ld, tx=%d, c_all=%ld\n",
+                  i, new_tx, c_all);
 #endif
-	}
-	at_determined = 1;
+        }
+        at_determined = 1;
       }
 
       if ((i >> 1) >= ll - 1 || (y >> 1) >= ly - 1)
-	lp1 = lp2;
+        lp1 = lp2;
 
       /* typical prediction */
       if (s->options & JBG_TPDON && (i & 1) == 0) {
-	q1 = lp1; q2 = lp2;
-	p0 = p1 = hp;
-	if (i < hl - 1 && y < hy - 1)
-	  p0 = hp + hbpl;
-	if (i > 1 || !reset)
-	  line_l3 = (long)*(q2 - lbpl) << 8;
-	else
-	  line_l3 = 0;
-	line_l2 = (long)*q2 << 8;
-	line_l1 = (long)*q1 << 8;
-	ltp = 1;
-	for (j = 0; j < lx && ltp; q1++, q2++) {
-	  if (j < lbpl * 8 - 8) {
-	    if (i > 1 || !reset)
-	      line_l3 |= *(q2 - lbpl + 1);
-	    line_l2 |= *(q2 + 1);
-	    line_l1 |= *(q1 + 1);
-	  }
-	  do {
-	    if ((j >> 2) < hbpl) {
-	      line_h1 = *(p1++);
-	      line_h0 = *(p0++);
-	    }
-	    do {
-	      line_l3 <<= 1;
-	      line_l2 <<= 1;
-	      line_l1 <<= 1;
-	      line_h1 <<= 2;
-	      line_h0 <<= 2;
-	      cx = (((line_l3 >> 15) & 0x007) |
-		    ((line_l2 >> 12) & 0x038) |
-		    ((line_l1 >> 9)  & 0x1c0));
-	      if (cx == 0x000)
-		if ((line_h1 & 0x300) == 0 && (line_h0 & 0x300) == 0)
-		  s->tp[j] = 0;
-		else {
-		  ltp = 0;
+        q1 = lp1; q2 = lp2;
+        p0 = p1 = hp;
+        if (i < hl - 1 && y < hy - 1)
+          p0 = hp + hbpl;
+        if (i > 1 || !reset)
+          line_l3 = (long)*(q2 - lbpl) << 8;
+        else
+          line_l3 = 0;
+        line_l2 = (long)*q2 << 8;
+        line_l1 = (long)*q1 << 8;
+        ltp = 1;
+        for (j = 0; j < lx && ltp; q1++, q2++) {
+          if (j < lbpl * 8 - 8) {
+            if (i > 1 || !reset)
+              line_l3 |= *(q2 - lbpl + 1);
+            line_l2 |= *(q2 + 1);
+            line_l1 |= *(q1 + 1);
+          }
+          do {
+            if ((j >> 2) < hbpl) {
+              line_h1 = *(p1++);
+              line_h0 = *(p0++);
+            }
+            do {
+              line_l3 <<= 1;
+              line_l2 <<= 1;
+              line_l1 <<= 1;
+              line_h1 <<= 2;
+              line_h0 <<= 2;
+              cx = (((line_l3 >> 15) & 0x007) |
+                    ((line_l2 >> 12) & 0x038) |
+                    ((line_l1 >> 9)  & 0x1c0));
+              if (cx == 0x000)
+                if ((line_h1 & 0x300) == 0 && (line_h0 & 0x300) == 0)
+                  s->tp[j] = 0;
+                else {
+                  ltp = 0;
 #ifdef DEBUG
-		  tp_exceptions++;
+                  tp_exceptions++;
 #endif
-		}
-	      else if (cx == 0x1ff)
-		if ((line_h1 & 0x300) == 0x300 && (line_h0 & 0x300) == 0x300)
-		  s->tp[j] = 1;
-		else {
-		  ltp = 0;
+                }
+              else if (cx == 0x1ff)
+                if ((line_h1 & 0x300) == 0x300 && (line_h0 & 0x300) == 0x300)
+                  s->tp[j] = 1;
+                else {
+                  ltp = 0;
 #ifdef DEBUG
-		  tp_exceptions++;
+                  tp_exceptions++;
 #endif
-		}
-	      else
-		s->tp[j] = 2;
-	    } while (++j & 3 && j < lx);
-	  } while (j & 7 && j < lx);
-	} /* for (j = ...) */
-	arith_encode(se, TPDCX, !ltp);
+                }
+              else
+                s->tp[j] = 2;
+            } while (++j & 3 && j < lx);
+          } while (j & 7 && j < lx);
+        } /* for (j = ...) */
+        arith_encode(se, TPDCX, !ltp);
 #ifdef DEBUG
-	tp_lines += ltp;
+        tp_lines += ltp;
 #endif
       }
 
@@ -1302,158 +1302,158 @@ static void encode_sde(struct jbg_enc_state *s,
       line_h1 = line_h2 = line_h3 = line_l1 = line_l2 = line_l3 = 0;
       if (i > 0 || !reset) line_h2 = (long)*(hp - hbpl) << 8;
       if (i > 1 || !reset) {
-	line_h3 = (long)*(hp - hbpl - hbpl) << 8;
-	line_l3 = (long)*(lp2 - lbpl) << 8;
+        line_h3 = (long)*(hp - hbpl - hbpl) << 8;
+        line_l3 = (long)*(lp2 - lbpl) << 8;
       }
       line_l2 = (long)*lp2 << 8;
       line_l1 = (long)*lp1 << 8;
 
       /* encode line */
       for (j = 0; j < hx; lp1++, lp2++) {
-	if ((j >> 1) < lbpl * 8 - 8) {
-	  if (i > 1 || !reset)
-	    line_l3 |= *(lp2 - lbpl + 1);
-	  line_l2 |= *(lp2 + 1);
-	  line_l1 |= *(lp1 + 1);
-	}
-	do { /* ... while (j & 15 && j < hx) */
-
-	  assert(hp - (s->lhp[s->highres[plane]][plane] +
-		       (stripe * hl + i) * hbpl)
-		 == (ptrdiff_t) j >> 3);
-
-	  assert(lp2 - (s->lhp[1-s->highres[plane]][plane] +
-			(stripe * ll + (i>>1)) * lbpl)
-		 == (ptrdiff_t) j >> 4);
-
-	  line_h1 |= *hp;
-	  if (j < hbpl * 8 - 8) {
-	    if (i > 0 || !reset) {
-	      line_h2 |= *(hp - hbpl + 1);
-	      if (i > 1 || !reset)
-		line_h3 |= *(hp - hbpl - hbpl + 1);
-	    }
-	  }
-	  do { /* ... while (j & 7 && j < hx) */
-	    line_l1 <<= 1;  line_l2 <<= 1;  line_l3 <<= 1;
-	    if (ltp && s->tp[j >> 1] < 2) {
-	      /* pixel are typical and have not to be encoded */
-	      line_h1 <<= 2;  line_h2 <<= 2;  line_h3 <<= 2;
+        if ((j >> 1) < lbpl * 8 - 8) {
+          if (i > 1 || !reset)
+            line_l3 |= *(lp2 - lbpl + 1);
+          line_l2 |= *(lp2 + 1);
+          line_l1 |= *(lp1 + 1);
+        }
+        do { /* ... while (j & 15 && j < hx) */
+
+          assert(hp - (s->lhp[s->highres[plane]][plane] +
+                       (stripe * hl + i) * hbpl)
+                 == (ptrdiff_t) j >> 3);
+
+          assert(lp2 - (s->lhp[1-s->highres[plane]][plane] +
+                        (stripe * ll + (i>>1)) * lbpl)
+                 == (ptrdiff_t) j >> 4);
+
+          line_h1 |= *hp;
+          if (j < hbpl * 8 - 8) {
+            if (i > 0 || !reset) {
+              line_h2 |= *(hp - hbpl + 1);
+              if (i > 1 || !reset)
+                line_h3 |= *(hp - hbpl - hbpl + 1);
+            }
+          }
+          do { /* ... while (j & 7 && j < hx) */
+            line_l1 <<= 1;  line_l2 <<= 1;  line_l3 <<= 1;
+            if (ltp && s->tp[j >> 1] < 2) {
+              /* pixel are typical and have not to be encoded */
+              line_h1 <<= 2;  line_h2 <<= 2;  line_h3 <<= 2;
 #ifdef DEBUG
-	      do {
-		++tp_pixels;
-	      } while (++j & 1 && j < hx);
+              do {
+                ++tp_pixels;
+              } while (++j & 1 && j < hx);
 #else
-	      j += 2;
+              j += 2;
 #endif
-	    } else
-	      do { /* ... while (++j & 1 && j < hx) */
-		line_h1 <<= 1;  line_h2 <<= 1;  line_h3 <<= 1;
-
-		/* deterministic prediction */
-		if (s->options & JBG_DPON) {
-		  if ((y & 1) == 0) {
-		    if ((j & 1) == 0) {
-		      /* phase 0 */
-		      if (s->dppriv[((line_l3 >> 16) & 0x003) |
-				    ((line_l2 >> 14) & 0x00c) |
-				    ((line_h1 >> 5)  & 0x010) |
-				    ((line_h2 >> 10) & 0x0e0)] < 2) {
+            } else
+              do { /* ... while (++j & 1 && j < hx) */
+                line_h1 <<= 1;  line_h2 <<= 1;  line_h3 <<= 1;
+
+                /* deterministic prediction */
+                if (s->options & JBG_DPON) {
+                  if ((y & 1) == 0) {
+                    if ((j & 1) == 0) {
+                      /* phase 0 */
+                      if (s->dppriv[((line_l3 >> 16) & 0x003) |
+                                    ((line_l2 >> 14) & 0x00c) |
+                                    ((line_h1 >> 5)  & 0x010) |
+                                    ((line_h2 >> 10) & 0x0e0)] < 2) {
 #ifdef DEBUG
-			++dp_pixels;
+                        ++dp_pixels;
 #endif
-			continue;
-		      }
-		    } else {
-		      /* phase 1 */
-		      if (s->dppriv[(((line_l3 >> 16) & 0x003) |
-				     ((line_l2 >> 14) & 0x00c) |
-				     ((line_h1 >> 5)  & 0x030) |
-				     ((line_h2 >> 10) & 0x1c0)) + 256] < 2) {
+                        continue;
+                      }
+                    } else {
+                      /* phase 1 */
+                      if (s->dppriv[(((line_l3 >> 16) & 0x003) |
+                                     ((line_l2 >> 14) & 0x00c) |
+                                     ((line_h1 >> 5)  & 0x030) |
+                                     ((line_h2 >> 10) & 0x1c0)) + 256] < 2) {
 #ifdef DEBUG
-			++dp_pixels;
+                        ++dp_pixels;
 #endif
-			continue;
-		      }
-		    }
-		  } else {
-		    if ((j & 1) == 0) {
-		      /* phase 2 */
-		      if (s->dppriv[(((line_l3 >> 16) & 0x003) |
-				     ((line_l2 >> 14) & 0x00c) |
-				     ((line_h1 >> 5)  & 0x010) |
-				     ((line_h2 >> 10) & 0x0e0) |
-				     ((line_h3 >> 7) & 0x700)) + 768] < 2) {
+                        continue;
+                      }
+                    }
+                  } else {
+                    if ((j & 1) == 0) {
+                      /* phase 2 */
+                      if (s->dppriv[(((line_l3 >> 16) & 0x003) |
+                                     ((line_l2 >> 14) & 0x00c) |
+                                     ((line_h1 >> 5)  & 0x010) |
+                                     ((line_h2 >> 10) & 0x0e0) |
+                                     ((line_h3 >> 7) & 0x700)) + 768] < 2) {
 #ifdef DEBUG
-			++dp_pixels;
+                        ++dp_pixels;
 #endif
-			continue;
-		      }
-		    } else {
-		      /* phase 3 */
-		      if (s->dppriv[(((line_l3 >> 16) & 0x003) |
-				     ((line_l2 >> 14) & 0x00c) |
-				     ((line_h1 >> 5)  & 0x030) |
-				     ((line_h2 >> 10) & 0x1c0) |
-				     ((line_h3 >> 7)  & 0xe00)) + 2816] < 2) {
+                        continue;
+                      }
+                    } else {
+                      /* phase 3 */
+                      if (s->dppriv[(((line_l3 >> 16) & 0x003) |
+                                     ((line_l2 >> 14) & 0x00c) |
+                                     ((line_h1 >> 5)  & 0x030) |
+                                     ((line_h2 >> 10) & 0x1c0) |
+                                     ((line_h3 >> 7)  & 0xe00)) + 2816] < 2) {
 #ifdef DEBUG
-			++dp_pixels;
+                        ++dp_pixels;
 #endif
-			continue;
-		      }
-		    }
-		  }
-		}
-
-		/* determine context */
-		if (s->tx[plane]) {
-		  if ((unsigned) s->tx[plane] > j)
-		    a = 0;
-		  else {
-		    o = (j - s->tx[plane]) - (j & ~7L);
-		    a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
-		    a <<= 4;
-		  }
-		  assert(s->tx[plane] > 23 ||
-			 a == ((line_h1 >> (4 + s->tx[plane])) & 0x010));
-		  cx = (((line_h1 >> 9)  & 0x003) | a |
-			((line_h2 >> 13) & 0x00c) |
-			((line_h3 >> 11) & 0x020));
-		} else
-		  cx = (((line_h1 >> 9)  & 0x003) |
-			((line_h2 >> 13) & 0x01c) |
-			((line_h3 >> 11) & 0x020));
-		if (j & 1)
-		  cx |= (((line_l2 >> 9)  & 0x0c0) |
-			 ((line_l1 >> 7)  & 0x300)) | (1UL << 10);
-		else
-		  cx |= (((line_l2 >> 10) & 0x0c0) |
-			 ((line_l1 >> 8)  & 0x300));
-		cx |= (y & 1) << 11;
-
-		arith_encode(se, cx, (line_h1 >> 8) & 1);
+                        continue;
+                      }
+                    }
+                  }
+                }
+
+                /* determine context */
+                if (s->tx[plane]) {
+                  if ((unsigned) s->tx[plane] > j)
+                    a = 0;
+                  else {
+                    o = (j - s->tx[plane]) - (j & ~7L);
+                    a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
+                    a <<= 4;
+                  }
+                  assert(s->tx[plane] > 23 ||
+                         a == ((line_h1 >> (4 + s->tx[plane])) & 0x010));
+                  cx = (((line_h1 >> 9)  & 0x003) | a |
+                        ((line_h2 >> 13) & 0x00c) |
+                        ((line_h3 >> 11) & 0x020));
+                } else
+                  cx = (((line_h1 >> 9)  & 0x003) |
+                        ((line_h2 >> 13) & 0x01c) |
+                        ((line_h3 >> 11) & 0x020));
+                if (j & 1)
+                  cx |= (((line_l2 >> 9)  & 0x0c0) |
+                         ((line_l1 >> 7)  & 0x300)) | (1UL << 10);
+                else
+                  cx |= (((line_l2 >> 10) & 0x0c0) |
+                         ((line_l1 >> 8)  & 0x300));
+                cx |= (y & 1) << 11;
+
+                arith_encode(se, cx, (line_h1 >> 8) & 1);
 #ifdef DEBUG
-		encoded_pixels++;
+                encoded_pixels++;
 #endif
 
-		/* statistics for adaptive template changes */
-		if (!at_determined && j >= s->mx) {
-		  c[0] += !(((line_h2 >> 6) ^ line_h1) & 0x100);
-		  for (t = 3; t <= s->mx; t++)
-		    c[t] += !(((line_h1 >> t) ^ line_h1) & 0x100);
-		  ++c_all;
-		}
-
-	      } while (++j & 1 && j < hx);
-	  } while (j & 7 && j < hx);
-	  hp++;
-	} while (j & 15 && j < hx);
+                /* statistics for adaptive template changes */
+                if (!at_determined && j >= s->mx) {
+                  c[0] += !(((line_h2 >> 6) ^ line_h1) & 0x100);
+                  for (t = 3; t <= s->mx; t++)
+                    c[t] += !(((line_h1 >> t) ^ line_h1) & 0x100);
+                  ++c_all;
+                }
+
+              } while (++j & 1 && j < hx);
+          } while (j & 7 && j < hx);
+          hp++;
+        } while (j & 15 && j < hx);
       } /* for (j = ...) */
 
       /* low resolution pixels are used twice */
       if ((i & 1) == 0) {
-	lp1 -= lbpl;
-	lp2 -= lbpl;
+        lp1 -= lbpl;
+        lp2 -= lbpl;
       }
 
     } /* for (i = ...) */
@@ -1463,7 +1463,7 @@ static void encode_sde(struct jbg_enc_state *s,
   jbg_buf_remove_zeros(s->sde[stripe][layer][plane]);
   jbg_buf_write(MARKER_ESC, s->sde[stripe][layer][plane]);
   jbg_buf_write((s->options & JBG_SDRST) ? MARKER_SDRST : MARKER_SDNORM,
-		s->sde[stripe][layer][plane]);
+                s->sde[stripe][layer][plane]);
   if (s->options & JBG_SDRST)
     s->tx[plane] = 0;
 
@@ -1499,8 +1499,8 @@ static void encode_sde(struct jbg_enc_state *s,
 #if 0
   if (stripe == s->stripes - 1)
     fprintf(stderr, "tp_lines = %ld, tp_exceptions = %ld, tp_pixels = %ld, "
-	    "dp_pixels = %ld, encoded_pixels = %ld\n",
-	    tp_lines, tp_exceptions, tp_pixels, dp_pixels, encoded_pixels);
+            "dp_pixels = %ld, encoded_pixels = %ld\n",
+            tp_lines, tp_exceptions, tp_pixels, dp_pixels, encoded_pixels);
 #endif
 
   return;
@@ -1511,7 +1511,7 @@ static void encode_sde(struct jbg_enc_state *s,
  * Create the next lower resolution version of an image
  */
 static void resolution_reduction(struct jbg_enc_state *s, int plane,
-				 int higher_layer)
+                                 int higher_layer)
 {
   unsigned long hl, ll, hx, hy, lx, ly, hbpl, lbpl;
   unsigned char *hp1, *hp2, *hp3, *lp;
@@ -1542,7 +1542,7 @@ static void resolution_reduction(struct jbg_enc_state *s, int plane,
 
 #ifdef DEBUG
   fprintf(stderr, "resolution_reduction: plane = %d, higher_layer = %d\n",
-	  plane, higher_layer);
+          plane, higher_layer);
 #endif
 
   /*
@@ -1566,34 +1566,34 @@ static void resolution_reduction(struct jbg_enc_state *s, int plane,
   for (y = 0; y < ly;) {
     for (i = 0; i < ll && y < ly; i++, y++) {
       if (2*y + 1 >= hy)
-	hp1 = hp2;
+        hp1 = hp2;
       pix = 0;
       line_h1 = line_h2 = line_h3 = line_l2 = 0;
       for (j = 0; j < lbpl * 8; j += 8) {
-	*lp = 0;
-	if (i > 0 || (y > 0 && !(s->options & JBG_SDRST)))
-	  line_l2 |= *(lp-lbpl);
-	for (k = 0; k < 8 && j + k < lx; k += 4) {
-	  if (((j + k) >> 2) < hbpl) {
-	    if (i > 0 || (y > 0 && !(s->options & JBG_SDRST)))
-	      line_h3 |= *hp3;
-	    ++hp3;
-	    line_h2 |= *(hp2++);
-	    line_h1 |= *(hp1++);
-	  }
-	  for (l = 0; l < 4 && j + k + l < lx; l++) {
-	    line_h3 <<= 2;
-	    line_h2 <<= 2;
-	    line_h1 <<= 2;
-	    line_l2 <<= 1;
-	    pix = s->res_tab[((line_h1 >> 8) & 0x007) |
-			     ((line_h2 >> 5) & 0x038) |
-			     ((line_h3 >> 2) & 0x1c0) |
-			     (pix << 9) | ((line_l2 << 2) & 0xc00)];
-	    *lp = (*lp << 1) | pix;
-	  }
-	}
-	++lp;
+        *lp = 0;
+        if (i > 0 || (y > 0 && !(s->options & JBG_SDRST)))
+          line_l2 |= *(lp-lbpl);
+        for (k = 0; k < 8 && j + k < lx; k += 4) {
+          if (((j + k) >> 2) < hbpl) {
+            if (i > 0 || (y > 0 && !(s->options & JBG_SDRST)))
+              line_h3 |= *hp3;
+            ++hp3;
+            line_h2 |= *(hp2++);
+            line_h1 |= *(hp1++);
+          }
+          for (l = 0; l < 4 && j + k + l < lx; l++) {
+            line_h3 <<= 2;
+            line_h2 <<= 2;
+            line_h1 <<= 2;
+            line_l2 <<= 1;
+            pix = s->res_tab[((line_h1 >> 8) & 0x007) |
+                             ((line_h2 >> 5) & 0x038) |
+                             ((line_h3 >> 2) & 0x1c0) |
+                             (pix << 9) | ((line_l2 << 2) & 0xc00)];
+            *lp = (*lp << 1) | pix;
+          }
+        }
+        ++lp;
       }
       *(lp - 1) <<= lbpl * 8 - lx;
       hp1 += hbpl;
@@ -1635,7 +1635,7 @@ static void resolution_reduction(struct jbg_enc_state *s, int plane,
  * of doing it, but it minimizes the amount of temporary memory used.
  */
 static void output_sde(struct jbg_enc_state *s,
-		       unsigned long stripe, int layer, int plane)
+                       unsigned long stripe, int layer, int plane)
 {
   int lfcl;     /* lowest fully coded layer */
   long i;
@@ -1646,7 +1646,7 @@ static void output_sde(struct jbg_enc_state *s,
   if (s->sde[stripe][layer][plane] != SDE_TODO) {
 #ifdef DEBUG
     fprintf(stderr, "writing SDE: s/d/p = %2lu/%2d/%2d\n",
-	    stripe, layer, plane);
+            stripe, layer, plane);
 #endif
     jbg_buf_output(&s->sde[stripe][layer][plane], s->data_out, s->file);
     s->sde[stripe][layer][plane] = SDE_DONE;
@@ -1822,7 +1822,7 @@ void jbg_enc_out(struct jbg_enc_state *s)
     bpl = jbg_ceil_half(s->xd, 3);     /* bytes per line */
     for (plane = 0; plane < s->planes; plane++)
       for (y = 0; y < s->yd; y++)
-	s->lhp[0][plane][y * bpl + bpl - 1] &= ~((1 << (8 - (s->xd & 7))) - 1);
+        s->lhp[0][plane][y * bpl + bpl - 1] &= ~((1 << (8 - (s->xd & 7))) - 1);
   }
 
   /* prepare BIH */
@@ -1864,12 +1864,12 @@ void jbg_enc_out(struct jbg_enc_state *s)
       checked_malloc(s->stripes, sizeof(struct jbg_buf ***));
     for (stripe = 0; stripe < s->stripes; stripe++) {
       s->sde[stripe] = (struct jbg_buf ***)
-	checked_malloc(s->d + 1, sizeof(struct jbg_buf **));
+        checked_malloc(s->d + 1, sizeof(struct jbg_buf **));
       for (layer = 0; layer < s->d + 1; layer++) {
-	s->sde[stripe][layer] = (struct jbg_buf **)
-	  checked_malloc(s->planes, sizeof(struct jbg_buf *));
-	for (plane = 0; plane < s->planes; plane++)
-	  s->sde[stripe][layer][plane] = SDE_TODO;
+        s->sde[stripe][layer] = (struct jbg_buf **)
+          checked_malloc(s->planes, sizeof(struct jbg_buf *));
+        for (plane = 0; plane < s->planes; plane++)
+          s->sde[stripe][layer][plane] = SDE_TODO;
       }
     }
   }
@@ -1892,9 +1892,9 @@ void jbg_enc_out(struct jbg_enc_state *s)
   for (layer = s->dh; layer >= s->dl; layer--) {
     for (plane = 0; plane < s->planes; plane++) {
       if (layer > 0)
-	resolution_reduction(s, plane, layer);
+        resolution_reduction(s, plane, layer);
       for (stripe = 0; stripe < s->stripes; stripe++)
-	encode_sde(s, stripe, layer, plane);
+        encode_sde(s, stripe, layer, plane);
       s->highres[plane] ^= 1;
     }
   }
@@ -1917,55 +1917,55 @@ void jbg_enc_out(struct jbg_enc_state *s)
     for (ii[1] = is[1]; ii[1] <= ie[1]; ii[1]++)
       for (ii[2] = is[2]; ii[2] <= ie[2]; ii[2]++) {
 
-	stripe = ii[iindex[order][STRIPE]];
-	if (s->order & JBG_HITOLO)
-	  layer = s->dh - (ii[iindex[order][LAYER]] - s->dl);
-	else
-	  layer = ii[iindex[order][LAYER]];
-	plane = ii[iindex[order][PLANE]];
-
-	/* output comment marker segment if there is any pending */
-	if (s->comment) {
-	  buf[0] = MARKER_ESC;
-	  buf[1] = MARKER_COMMENT;
-	  buf[2] = s->comment_len >> 24;
-	  buf[3] = (s->comment_len >> 16) & 0xff;
-	  buf[4] = (s->comment_len >> 8) & 0xff;
-	  buf[5] = s->comment_len & 0xff;
-	  s->data_out(buf, 6, s->file);
-	  s->data_out(s->comment, s->comment_len, s->file);
-	  s->comment = NULL;
-	}
-
-	output_sde(s, stripe, layer, plane);
-
-	/*
-	 * When we generate a NEWLEN test case (s->yd1 > s->yd), output
-	 * NEWLEN after last stripe if we have only a single
-	 * resolution layer or plane (see ITU-T T.85 profile), otherwise
-	 * output NEWLEN before last stripe.
-	 */
-	if (s->yd1 > s->yd &&
-	    (stripe == s->stripes - 1 ||
-	     (stripe == s->stripes - 2 &&
-	      (s->dl != s->dh || s->planes > 1)))) {
-	  s->yd1 = s->yd;
-	  yd = jbg_ceil_half(s->yd, s->d - s->dh);
-	  buf[0] = MARKER_ESC;
-	  buf[1] = MARKER_NEWLEN;
-	  buf[2] = yd >> 24;
-	  buf[3] = (yd >> 16) & 0xff;
-	  buf[4] = (yd >> 8) & 0xff;
-	  buf[5] = yd & 0xff;
-	  s->data_out(buf, 6, s->file);
+        stripe = ii[iindex[order][STRIPE]];
+        if (s->order & JBG_HITOLO)
+          layer = s->dh - (ii[iindex[order][LAYER]] - s->dl);
+        else
+          layer = ii[iindex[order][LAYER]];
+        plane = ii[iindex[order][PLANE]];
+
+        /* output comment marker segment if there is any pending */
+        if (s->comment) {
+          buf[0] = MARKER_ESC;
+          buf[1] = MARKER_COMMENT;
+          buf[2] = s->comment_len >> 24;
+          buf[3] = (s->comment_len >> 16) & 0xff;
+          buf[4] = (s->comment_len >> 8) & 0xff;
+          buf[5] = s->comment_len & 0xff;
+          s->data_out(buf, 6, s->file);
+          s->data_out(s->comment, s->comment_len, s->file);
+          s->comment = NULL;
+        }
+
+        output_sde(s, stripe, layer, plane);
+
+        /*
+         * When we generate a NEWLEN test case (s->yd1 > s->yd), output
+         * NEWLEN after last stripe if we have only a single
+         * resolution layer or plane (see ITU-T T.85 profile), otherwise
+         * output NEWLEN before last stripe.
+         */
+        if (s->yd1 > s->yd &&
+            (stripe == s->stripes - 1 ||
+             (stripe == s->stripes - 2 &&
+              (s->dl != s->dh || s->planes > 1)))) {
+          s->yd1 = s->yd;
+          yd = jbg_ceil_half(s->yd, s->d - s->dh);
+          buf[0] = MARKER_ESC;
+          buf[1] = MARKER_NEWLEN;
+          buf[2] = yd >> 24;
+          buf[3] = (yd >> 16) & 0xff;
+          buf[4] = (yd >> 8) & 0xff;
+          buf[5] = yd & 0xff;
+          s->data_out(buf, 6, s->file);
 #ifdef DEBUG
-	  fprintf(stderr, "NEWLEN: yd=%lu\n", yd);
+          fprintf(stderr, "NEWLEN: yd=%lu\n", yd);
 #endif
-	  if (stripe == s->stripes - 1) {
-	    buf[1] = MARKER_SDNORM;
-	    s->data_out(buf, 2, s->file);
-	  }
-	}
+          if (stripe == s->stripes - 1) {
+            buf[1] = MARKER_SDNORM;
+            s->data_out(buf, 2, s->file);
+          }
+        }
 
       }
 
@@ -1986,11 +1986,11 @@ void jbg_enc_free(struct jbg_enc_state *s)
   if (s->sde) {
     for (stripe = 0; stripe < s->stripes; stripe++) {
       for (layer = 0; layer < s->d + 1; layer++) {
-	for (plane = 0; plane < s->planes; plane++)
-	  if (s->sde[stripe][layer][plane] != SDE_DONE &&
-	      s->sde[stripe][layer][plane] != SDE_TODO)
-	    jbg_buf_free(&s->sde[stripe][layer][plane]);
-	checked_free(s->sde[stripe][layer]);
+        for (plane = 0; plane < s->planes; plane++)
+          if (s->sde[stripe][layer][plane] != SDE_DONE &&
+              s->sde[stripe][layer][plane] != SDE_TODO)
+            jbg_buf_free(&s->sde[stripe][layer][plane]);
+        checked_free(s->sde[stripe][layer]);
       }
       checked_free(s->sde[stripe]);
     }
@@ -2063,7 +2063,7 @@ void jbg_dec_init(struct jbg_dec_state *s)
  * ymax.
  */
 void jbg_dec_maxsize(struct jbg_dec_state *s, unsigned long xmax,
-		     unsigned long ymax)
+                     unsigned long ymax)
 {
   if (xmax > 0) s->xmax = xmax;
   if (ymax > 0) s->ymax = ymax;
@@ -2080,7 +2080,7 @@ void jbg_dec_maxsize(struct jbg_dec_state *s, unsigned long xmax,
  * this code cannot determine whether we have a marker segment).
  */
 static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
-			  size_t len)
+                          size_t len)
 {
   unsigned long stripe;
   unsigned int layer, plane;
@@ -2139,7 +2139,7 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
 #ifdef DEBUG
   if (s->x == 0 && s->i == 0 && s->pseudo)
     fprintf(stderr, "decode_pscd(%p, %p, %ld): s/d/p = %2lu/%2u/%2u\n",
-	    (void *) s, (void *) data, (long) len, stripe, layer, plane);
+            (void *) s, (void *) data, (long) len, stripe, layer, plane);
 #endif
 
   if (s->x == 0 && s->i == 0 &&
@@ -2158,38 +2158,38 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
 
       /* adaptive template changes */
       if (x == 0 && s->pseudo)
-	for (n = 0; n < s->at_moves; n++)
-	  if (s->at_line[n] == s->i) {
-	    s->tx[plane][layer - s->dl] = s->at_tx[n];
-	    s->ty[plane][layer - s->dl] = s->at_ty[n];
+        for (n = 0; n < s->at_moves; n++)
+          if (s->at_line[n] == s->i) {
+            s->tx[plane][layer - s->dl] = s->at_tx[n];
+            s->ty[plane][layer - s->dl] = s->at_ty[n];
 #ifdef DEBUG
-	    fprintf(stderr, "ATMOVE: line=%lu, tx=%d, ty=%d.\n", s->i,
-		    s->tx[plane][layer - s->dl], s->ty[plane][layer - s->dl]);
+            fprintf(stderr, "ATMOVE: line=%lu, tx=%d, ty=%d.\n", s->i,
+                    s->tx[plane][layer - s->dl], s->ty[plane][layer - s->dl]);
 #endif
-	  }
+          }
       tx = s->tx[plane][layer - s->dl];
       assert(tx >= 0); /* i.e., tx can safely be cast to unsigned */
 
       /* typical prediction */
       if (s->options & JBG_TPBON && s->pseudo) {
-	slntp = arith_decode(se, (s->options & JBG_LRLTWO) ? TPB2CX : TPB3CX);
-	if (slntp < 0)
-	  goto leave;
-	s->lntp[plane][layer - s->dl] =
-	  !(slntp ^ s->lntp[plane][layer - s->dl]);
-	if (!s->lntp[plane][layer - s->dl]) {
-	  /* this line is 'typical' (i.e. identical to the previous one) */
-	  p1 = hp;
-	  if (s->i == 0 && (stripe == 0 || s->reset[plane][layer - s->dl]))
-	    while (p1 < hp + hbpl) *p1++ = 0;
-	  else {
-	    q1 = hp - hbpl;
-	    while (q1 < hp) *p1++ = *q1++;
-	  }
-	  hp += hbpl;
-	  continue;
-	}
-	/* this line is 'not typical' and has to be coded completely */
+        slntp = arith_decode(se, (s->options & JBG_LRLTWO) ? TPB2CX : TPB3CX);
+        if (slntp < 0)
+          goto leave;
+        s->lntp[plane][layer - s->dl] =
+          !(slntp ^ s->lntp[plane][layer - s->dl]);
+        if (!s->lntp[plane][layer - s->dl]) {
+          /* this line is 'typical' (i.e. identical to the previous one) */
+          p1 = hp;
+          if (s->i == 0 && (stripe == 0 || s->reset[plane][layer - s->dl]))
+            while (p1 < hp + hbpl) *p1++ = 0;
+          else {
+            q1 = hp - hbpl;
+            while (q1 < hp) *p1++ = *q1++;
+          }
+          hp += hbpl;
+          continue;
+        }
+        /* this line is 'not typical' and has to be coded completely */
       }
       s->pseudo = 0;
 
@@ -2203,11 +2203,11 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
        */
 
       if (x == 0) {
-	line_h1 = line_h2 = line_h3 = 0;
-	if (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl]))
-	  line_h2 = (long)*(hp - hbpl) << 8;
-	if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
-	  line_h3 = (long)*(hp - hbpl - hbpl) << 8;
+        line_h1 = line_h2 = line_h3 = 0;
+        if (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl]))
+          line_h2 = (long)*(hp - hbpl) << 8;
+        if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
+          line_h3 = (long)*(hp - hbpl - hbpl) << 8;
       }
 
       /*
@@ -2256,70 +2256,70 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
 
       /* decode line */
       while (x < hx) {
-	if ((x & 7) == 0) {
-	  if (x < hbpl * 8 - 8 &&
-	      (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl]))) {
-	    line_h2 |= *(hp - hbpl + 1);
-	    if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
-	      line_h3 |= *(hp - hbpl - hbpl + 1);
-	  }
-	}
-	if (s->options & JBG_LRLTWO) {
-	  /* two line template */
-	  do {
-	    if (tx) {
-	      if ((unsigned) tx > x)
-		a = 0;
-	      else if (tx < 8)
-		a = ((line_h1 >> (tx - 5)) & 0x010);
-	      else {
-		o = (x - tx) - (x & ~7L);
-		a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
-		a <<= 4;
-	      }
-	      assert(tx > 31 ||
-		     a == ((line_h1 >> (tx - 5)) & 0x010));
-	      pix = arith_decode(se, (((line_h2 >> 9) & 0x3e0) | a |
-				      (line_h1 & 0x00f)));
-	    } else
-	      pix = arith_decode(se, (((line_h2 >> 9) & 0x3f0) |
-				      (line_h1 & 0x00f)));
-	    if (pix < 0)
-	      goto leave;
-	    line_h1 = (line_h1 << 1) | pix;
-	    line_h2 <<= 1;
-	  } while ((++x & 7) && x < hx);
-	} else {
-	  /* three line template */
-	  do {
-	    if (tx) {
-	      if ((unsigned) tx > x)
-		a = 0;
-	      else if (tx < 8)
-		a = ((line_h1 >> (tx - 3)) & 0x004);
-	      else {
-		o = (x - tx) - (x & ~7L);
-		a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
-		a <<= 2;
-	      }
-	      assert(tx > 31 ||
-		     a == ((line_h1 >> (tx - 3)) & 0x004));
-	      pix = arith_decode(se, (((line_h3 >>  7) & 0x380) |
-				      ((line_h2 >> 11) & 0x078) | a |
-				      (line_h1 & 0x003)));
-	    } else
-	      pix = arith_decode(se, (((line_h3 >>  7) & 0x380) |
-				      ((line_h2 >> 11) & 0x07c) |
-				      (line_h1 & 0x003)));
-	    if (pix < 0)
-	      goto leave;
-
-	    line_h1 = (line_h1 << 1) | pix;
-	    line_h2 <<= 1;
-	    line_h3 <<= 1;
-	  } while ((++x & 7) && x < hx);
-	} /* if (s->options & JBG_LRLTWO) */
-	*hp++ = line_h1;
+        if ((x & 7) == 0) {
+          if (x < hbpl * 8 - 8 &&
+              (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl]))) {
+            line_h2 |= *(hp - hbpl + 1);
+            if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
+              line_h3 |= *(hp - hbpl - hbpl + 1);
+          }
+        }
+        if (s->options & JBG_LRLTWO) {
+          /* two line template */
+          do {
+            if (tx) {
+              if ((unsigned) tx > x)
+                a = 0;
+              else if (tx < 8)
+                a = ((line_h1 >> (tx - 5)) & 0x010);
+              else {
+                o = (x - tx) - (x & ~7L);
+                a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
+                a <<= 4;
+              }
+              assert(tx > 31 ||
+                     a == ((line_h1 >> (tx - 5)) & 0x010));
+              pix = arith_decode(se, (((line_h2 >> 9) & 0x3e0) | a |
+                                      (line_h1 & 0x00f)));
+            } else
+              pix = arith_decode(se, (((line_h2 >> 9) & 0x3f0) |
+                                      (line_h1 & 0x00f)));
+            if (pix < 0)
+              goto leave;
+            line_h1 = (line_h1 << 1) | pix;
+            line_h2 <<= 1;
+          } while ((++x & 7) && x < hx);
+        } else {
+          /* three line template */
+          do {
+            if (tx) {
+              if ((unsigned) tx > x)
+                a = 0;
+              else if (tx < 8)
+                a = ((line_h1 >> (tx - 3)) & 0x004);
+              else {
+                o = (x - tx) - (x & ~7L);
+                a = (hp[o >> 3] >> (7 - (o & 7))) & 1;
+                a <<= 2;
+              }
+              assert(tx > 31 ||
+                     a == ((line_h1 >> (tx - 3)) & 0x004));
+              pix = arith_decode(se, (((line_h3 >>  7) & 0x380) |
+                                      ((line_h2 >> 11) & 0x078) | a |
+                                      (line_h1 & 0x003)));
+            } else
+              pix = arith_decode(se, (((line_h3 >>  7) & 0x380) |
+                                      ((line_h2 >> 11) & 0x07c) |
+                                      (line_h1 & 0x003)));
+            if (pix < 0)
+              goto leave;
+
+            line_h1 = (line_h1 << 1) | pix;
+            line_h2 <<= 1;
+            line_h3 <<= 1;
+          } while ((++x & 7) && x < hx);
+        } /* if (s->options & JBG_LRLTWO) */
+        *hp++ = line_h1;
       } /* while */
       *(hp - 1) <<= hbpl * 8 - hx;
       x = 0;
@@ -2336,25 +2336,25 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
 
       /* adaptive template changes */
       if (x == 0)
-	for (n = 0; n < s->at_moves; n++)
-	  if (s->at_line[n] == s->i) {
-	    s->tx[plane][layer - s->dl] = s->at_tx[n];
-	    s->ty[plane][layer - s->dl] = s->at_ty[n];
+        for (n = 0; n < s->at_moves; n++)
+          if (s->at_line[n] == s->i) {
+            s->tx[plane][layer - s->dl] = s->at_tx[n];
+            s->ty[plane][layer - s->dl] = s->at_ty[n];
 #ifdef DEBUG
-	    fprintf(stderr, "ATMOVE: line=%lu, tx=%d, ty=%d.\n", s->i,
-		    s->tx[plane][layer - s->dl], s->ty[plane][layer - s->dl]);
+            fprintf(stderr, "ATMOVE: line=%lu, tx=%d, ty=%d.\n", s->i,
+                    s->tx[plane][layer - s->dl], s->ty[plane][layer - s->dl]);
 #endif
-	  }
+          }
       tx = s->tx[plane][layer - s->dl];
 
       /* handle lower border of low-resolution image */
       if ((s->i >> 1) >= ll - 1 || (y >> 1) >= ly - 1)
-	lp1 = lp2;
+        lp1 = lp2;
 
       /* typical prediction */
       if ((s->options & JBG_TPDON) && s->pseudo) {
-	if ((s->lntp[plane][layer - s->dl] = arith_decode(se, TPDCX)) < 0)
-	  goto leave;
+        if ((s->lntp[plane][layer - s->dl] = arith_decode(se, TPDCX)) < 0)
+          goto leave;
       }
       s->pseudo = 0;
 
@@ -2379,135 +2379,135 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
 
 
       if (x == 0) {
-	line_h1 = line_h2 = line_h3 = line_l1 = line_l2 = line_l3 = 0;
-	if (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl])) {
-	  line_h2 = (long)*(hp - hbpl) << 8;
-	  if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
-	    line_h3 = (long)*(hp - hbpl - hbpl) << 8;
-	}
-	if (s->i > 1 || (y > 1 && !s->reset[plane][layer-s->dl]))
-	  line_l3 = (long)*(lp2 - lbpl) << 8;
-	line_l2 = (long)*lp2 << 8;
-	line_l1 = (long)*lp1 << 8;
+        line_h1 = line_h2 = line_h3 = line_l1 = line_l2 = line_l3 = 0;
+        if (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl])) {
+          line_h2 = (long)*(hp - hbpl) << 8;
+          if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
+            line_h3 = (long)*(hp - hbpl - hbpl) << 8;
+        }
+        if (s->i > 1 || (y > 1 && !s->reset[plane][layer-s->dl]))
+          line_l3 = (long)*(lp2 - lbpl) << 8;
+        line_l2 = (long)*lp2 << 8;
+        line_l1 = (long)*lp1 << 8;
       }
 
       /* decode line */
       while (x < hx) {
-	if ((x & 15) == 0)
-	  if ((x >> 1) < lbpl * 8 - 8) {
-	    line_l1 |= *(lp1 + 1);
-	    line_l2 |= *(lp2 + 1);
-	    if (s->i > 1 ||
-		(y > 1 && !s->reset[plane][layer - s->dl]))
-	      line_l3 |= *(lp2 - lbpl + 1);
-	  }
-	do {
-
-	  assert(hp  - (s->lhp[ layer     &1][plane] + (stripe * hl + s->i)
-			* hbpl) == (ptrdiff_t) x >> 3);
-	  assert(lp2 - (s->lhp[(layer-1) &1][plane] + (stripe * ll + (s->i>>1))
-			* lbpl) == (ptrdiff_t) x >> 4);
-
-	  if ((x & 7) == 0)
-	    if (x < hbpl * 8 - 8) {
-	      if (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl])) {
-		line_h2 |= *(hp + 1 - hbpl);
-		if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
-		  line_h3 |= *(hp + 1 - hbpl - hbpl);
-	      }
-	    }
-	  do {
-	    if (!s->lntp[plane][layer - s->dl])
+        if ((x & 15) == 0)
+          if ((x >> 1) < lbpl * 8 - 8) {
+            line_l1 |= *(lp1 + 1);
+            line_l2 |= *(lp2 + 1);
+            if (s->i > 1 ||
+                (y > 1 && !s->reset[plane][layer - s->dl]))
+              line_l3 |= *(lp2 - lbpl + 1);
+          }
+        do {
+
+          assert(hp  - (s->lhp[ layer     &1][plane] + (stripe * hl + s->i)
+                        * hbpl) == (ptrdiff_t) x >> 3);
+          assert(lp2 - (s->lhp[(layer-1) &1][plane] + (stripe * ll + (s->i>>1))
+                        * lbpl) == (ptrdiff_t) x >> 4);
+
+          if ((x & 7) == 0)
+            if (x < hbpl * 8 - 8) {
+              if (s->i > 0 || (y > 0 && !s->reset[plane][layer - s->dl])) {
+                line_h2 |= *(hp + 1 - hbpl);
+                if (s->i > 1 || (y > 1 && !s->reset[plane][layer - s->dl]))
+                  line_h3 |= *(hp + 1 - hbpl - hbpl);
+              }
+            }
+          do {
+            if (!s->lntp[plane][layer - s->dl])
               cx = (((line_l3 >> 14) & 0x007) |
                     ((line_l2 >> 11) & 0x038) |
                     ((line_l1 >> 8)  & 0x1c0));
-	    if (!s->lntp[plane][layer - s->dl] &&
-		(cx == 0x000 || cx == 0x1ff)) {
-	      /* pixels are typical and have not to be decoded */
-	      do {
-		line_h1 = (line_h1 << 1) | (cx & 1);
-	      } while ((++x & 1) && x < hx);
-	      line_h2 <<= 2;  line_h3 <<= 2;
-	    } else
-	      do {
-
-		/* deterministic prediction */
-		if (s->options & JBG_DPON)
-		  if ((y & 1) == 0)
-		    if ((x & 1) == 0)
-		      /* phase 0 */
-		      pix = s->dppriv[((line_l3 >> 15) & 0x003) |
-				      ((line_l2 >> 13) & 0x00c) |
-				      ((line_h1 <<  4) & 0x010) |
-				      ((line_h2 >>  9) & 0x0e0)];
-		    else
-		      /* phase 1 */
-		      pix = s->dppriv[(((line_l3 >> 15) & 0x003) |
-				       ((line_l2 >> 13) & 0x00c) |
-				       ((line_h1 <<  4) & 0x030) |
-				       ((line_h2 >>  9) & 0x1c0)) + 256];
-		  else
-		    if ((x & 1) == 0)
-		      /* phase 2 */
-		      pix = s->dppriv[(((line_l3 >> 15) & 0x003) |
-				       ((line_l2 >> 13) & 0x00c) |
-				       ((line_h1 <<  4) & 0x010) |
-				       ((line_h2 >>  9) & 0x0e0) |
-				       ((line_h3 >>  6) & 0x700)) + 768];
-		    else
-		      /* phase 3 */
-		      pix = s->dppriv[(((line_l3 >> 15) & 0x003) |
-				       ((line_l2 >> 13) & 0x00c) |
-				       ((line_h1 <<  4) & 0x030) |
-				       ((line_h2 >>  9) & 0x1c0) |
-				       ((line_h3 >>  6) & 0xe00)) + 2816];
-		else
-		  pix = 2;
-
-		if (pix & 2) {
-		  if (tx)
-		    cx = ((line_h1         & 0x003) |
-			  (((line_h1 << 2) >> (tx - 3)) & 0x010) |
-			  ((line_h2 >> 12) & 0x00c) |
-			  ((line_h3 >> 10) & 0x020));
-		  else
-		    cx = ((line_h1         & 0x003) |
-			  ((line_h2 >> 12) & 0x01c) |
-			  ((line_h3 >> 10) & 0x020));
-		  if (x & 1)
-		    cx |= (((line_l2 >> 8) & 0x0c0) |
-			   ((line_l1 >> 6) & 0x300)) | (1UL << 10);
-		  else
-		    cx |= (((line_l2 >> 9) & 0x0c0) |
-			   ((line_l1 >> 7) & 0x300));
-		  cx |= (y & 1) << 11;
-
-		  pix = arith_decode(se, cx);
-		  if (pix < 0)
-		    goto leave;
-		}
-
-		line_h1 = (line_h1 << 1) | pix;
-		line_h2 <<= 1;
-		line_h3 <<= 1;
-
-	      } while ((++x & 1) && x < hx);
-	    line_l1 <<= 1; line_l2 <<= 1;  line_l3 <<= 1;
-	  } while ((x & 7) && x < hx);
-	  *hp++ = line_h1;
-	} while ((x & 15) && x < hx);
-	++lp1;
-	++lp2;
+            if (!s->lntp[plane][layer - s->dl] &&
+                (cx == 0x000 || cx == 0x1ff)) {
+              /* pixels are typical and have not to be decoded */
+              do {
+                line_h1 = (line_h1 << 1) | (cx & 1);
+              } while ((++x & 1) && x < hx);
+              line_h2 <<= 2;  line_h3 <<= 2;
+            } else
+              do {
+
+                /* deterministic prediction */
+                if (s->options & JBG_DPON)
+                  if ((y & 1) == 0)
+                    if ((x & 1) == 0)
+                      /* phase 0 */
+                      pix = s->dppriv[((line_l3 >> 15) & 0x003) |
+                                      ((line_l2 >> 13) & 0x00c) |
+                                      ((line_h1 <<  4) & 0x010) |
+                                      ((line_h2 >>  9) & 0x0e0)];
+                    else
+                      /* phase 1 */
+                      pix = s->dppriv[(((line_l3 >> 15) & 0x003) |
+                                       ((line_l2 >> 13) & 0x00c) |
+                                       ((line_h1 <<  4) & 0x030) |
+                                       ((line_h2 >>  9) & 0x1c0)) + 256];
+                  else
+                    if ((x & 1) == 0)
+                      /* phase 2 */
+                      pix = s->dppriv[(((line_l3 >> 15) & 0x003) |
+                                       ((line_l2 >> 13) & 0x00c) |
+                                       ((line_h1 <<  4) & 0x010) |
+                                       ((line_h2 >>  9) & 0x0e0) |
+                                       ((line_h3 >>  6) & 0x700)) + 768];
+                    else
+                      /* phase 3 */
+                      pix = s->dppriv[(((line_l3 >> 15) & 0x003) |
+                                       ((line_l2 >> 13) & 0x00c) |
+                                       ((line_h1 <<  4) & 0x030) |
+                                       ((line_h2 >>  9) & 0x1c0) |
+                                       ((line_h3 >>  6) & 0xe00)) + 2816];
+                else
+                  pix = 2;
+
+                if (pix & 2) {
+                  if (tx)
+                    cx = ((line_h1         & 0x003) |
+                          (((line_h1 << 2) >> (tx - 3)) & 0x010) |
+                          ((line_h2 >> 12) & 0x00c) |
+                          ((line_h3 >> 10) & 0x020));
+                  else
+                    cx = ((line_h1         & 0x003) |
+                          ((line_h2 >> 12) & 0x01c) |
+                          ((line_h3 >> 10) & 0x020));
+                  if (x & 1)
+                    cx |= (((line_l2 >> 8) & 0x0c0) |
+                           ((line_l1 >> 6) & 0x300)) | (1UL << 10);
+                  else
+                    cx |= (((line_l2 >> 9) & 0x0c0) |
+                           ((line_l1 >> 7) & 0x300));
+                  cx |= (y & 1) << 11;
+
+                  pix = arith_decode(se, cx);
+                  if (pix < 0)
+                    goto leave;
+                }
+
+                line_h1 = (line_h1 << 1) | pix;
+                line_h2 <<= 1;
+                line_h3 <<= 1;
+
+              } while ((++x & 1) && x < hx);
+            line_l1 <<= 1; line_l2 <<= 1;  line_l3 <<= 1;
+          } while ((x & 7) && x < hx);
+          *hp++ = line_h1;
+        } while ((x & 15) && x < hx);
+        ++lp1;
+        ++lp2;
       } /* while */
       x = 0;
 
       *(hp - 1) <<= hbpl * 8 - hx;
       if ((s->i & 1) == 0) {
-	/* low resolution pixels are used twice */
-	lp1 -= lbpl;
-	lp2 -= lbpl;
+        /* low resolution pixels are used twice */
+        lp1 -= lbpl;
+        lp2 -= lbpl;
       } else
-	s->pseudo = 1;
+        s->pseudo = 1;
 
     } /* for (i = ...) */
 
@@ -2563,7 +2563,7 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
  * information by identifying which test exactly has failed.)
  */
 int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
-	       size_t *cnt)
+               size_t *cnt)
 {
   int i, j, required_length;
   unsigned long x, y;
@@ -2595,18 +2595,18 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
       s->planes = s->buffer[2];
     else
       if (s->planes != s->buffer[2])
-	return JBG_ENOCONT | 2;
+        return JBG_ENOCONT | 2;
     x = (((long) s->buffer[ 4] << 24) | ((long) s->buffer[ 5] << 16) |
-	 ((long) s->buffer[ 6] <<  8) | (long) s->buffer[ 7]);
+         ((long) s->buffer[ 6] <<  8) | (long) s->buffer[ 7]);
     y = (((long) s->buffer[ 8] << 24) | ((long) s->buffer[ 9] << 16) |
-	 ((long) s->buffer[10] <<  8) | (long) s->buffer[11]);
+         ((long) s->buffer[10] <<  8) | (long) s->buffer[11]);
     if (s->dl != 0 && ((s->xd << (s->d - s->dl + 1)) != x &&
-		       (s->yd << (s->d - s->dl + 1)) != y))
+                       (s->yd << (s->d - s->dl + 1)) != y))
       return JBG_ENOCONT | 3;
     s->xd = x;
     s->yd = y;
     s->l0 = (((long) s->buffer[12] << 24) | ((long) s->buffer[13] << 16) |
-	     ((long) s->buffer[14] <<  8) | (long) s->buffer[15]);
+             ((long) s->buffer[14] <<  8) | (long) s->buffer[15]);
     /* ITU-T T.85 trick not directly implemented by decoder; for full
      * T.85 compatibility with respect to all NEWLEN marker scenarios,
      * preprocess BIE with jbg_newlen() before passing it to the decoder,
@@ -2647,51 +2647,51 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
     s->ii[iindex[s->order & 7][PLANE]] = 0;
     if (s->dl == 0) {
       s->s      = (struct jbg_ardec_state **)
-	checked_malloc(s->planes, sizeof(struct jbg_ardec_state *));
+        checked_malloc(s->planes, sizeof(struct jbg_ardec_state *));
       s->tx     = (int **) checked_malloc(s->planes, sizeof(int *));
       s->ty     = (int **) checked_malloc(s->planes, sizeof(int *));
       s->reset  = (int **) checked_malloc(s->planes, sizeof(int *));
       s->lntp   = (int **) checked_malloc(s->planes, sizeof(int *));
       s->lhp[0] = (unsigned char **)
-	checked_malloc(s->planes, sizeof(unsigned char *));
+        checked_malloc(s->planes, sizeof(unsigned char *));
       s->lhp[1] = (unsigned char **)
-	checked_malloc(s->planes, sizeof(unsigned char *));
+        checked_malloc(s->planes, sizeof(unsigned char *));
       for (i = 0; i < s->planes; i++) {
-	s->s[i]     = (struct jbg_ardec_state *)
-	  checked_malloc(s->d - s->dl + 1, sizeof(struct jbg_ardec_state));
-	s->tx[i]    = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
-	s->ty[i]    = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
-	s->reset[i] = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
-	s->lntp[i]  = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
-	s->lhp[ s->d    & 1][i] = (unsigned char *)
-	  checked_malloc(s->yd, jbg_ceil_half(s->xd, 3));
-	s->lhp[(s->d-1) & 1][i] = (unsigned char *)
-	  checked_malloc(jbg_ceil_half(s->yd, 1), jbg_ceil_half(s->xd, 1+3));
+        s->s[i]     = (struct jbg_ardec_state *)
+          checked_malloc(s->d - s->dl + 1, sizeof(struct jbg_ardec_state));
+        s->tx[i]    = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
+        s->ty[i]    = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
+        s->reset[i] = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
+        s->lntp[i]  = (int *) checked_malloc(s->d - s->dl + 1, sizeof(int));
+        s->lhp[ s->d    & 1][i] = (unsigned char *)
+          checked_malloc(s->yd, jbg_ceil_half(s->xd, 3));
+        s->lhp[(s->d-1) & 1][i] = (unsigned char *)
+          checked_malloc(jbg_ceil_half(s->yd, 1), jbg_ceil_half(s->xd, 1+3));
       }
     } else {
       for (i = 0; i < s->planes; i++) {
-	s->s[i]     = (struct jbg_ardec_state *)
-	  checked_realloc(s->s[i], s->d - s->dl + 1,
-			  sizeof(struct jbg_ardec_state));
-	s->tx[i]    = (int *) checked_realloc(s->tx[i],
-					      s->d - s->dl + 1, sizeof(int));
-	s->ty[i]    = (int *) checked_realloc(s->ty[i],
-					      s->d - s->dl + 1, sizeof(int));
-	s->reset[i] = (int *) checked_realloc(s->reset[i],
-					      s->d - s->dl + 1, sizeof(int));
-	s->lntp[i]  = (int *) checked_realloc(s->lntp[i],
-					      s->d - s->dl + 1, sizeof(int));
-	s->lhp[ s->d    & 1][i] = (unsigned char *)
-	  checked_realloc(s->lhp[ s->d    & 1][i],
-			  s->yd, jbg_ceil_half(s->xd, 3));
-	s->lhp[(s->d-1) & 1][i] = (unsigned char *)
-	  checked_realloc(s->lhp[(s->d-1) & 1][i],
-			  jbg_ceil_half(s->yd, 1), jbg_ceil_half(s->xd, 1+3));
+        s->s[i]     = (struct jbg_ardec_state *)
+          checked_realloc(s->s[i], s->d - s->dl + 1,
+                          sizeof(struct jbg_ardec_state));
+        s->tx[i]    = (int *) checked_realloc(s->tx[i],
+                                              s->d - s->dl + 1, sizeof(int));
+        s->ty[i]    = (int *) checked_realloc(s->ty[i],
+                                              s->d - s->dl + 1, sizeof(int));
+        s->reset[i] = (int *) checked_realloc(s->reset[i],
+                                              s->d - s->dl + 1, sizeof(int));
+        s->lntp[i]  = (int *) checked_realloc(s->lntp[i],
+                                              s->d - s->dl + 1, sizeof(int));
+        s->lhp[ s->d    & 1][i] = (unsigned char *)
+          checked_realloc(s->lhp[ s->d    & 1][i],
+                          s->yd, jbg_ceil_half(s->xd, 3));
+        s->lhp[(s->d-1) & 1][i] = (unsigned char *)
+          checked_realloc(s->lhp[(s->d-1) & 1][i],
+                          jbg_ceil_half(s->yd, 1), jbg_ceil_half(s->xd, 1+3));
       }
     }
     for (i = 0; i < s->planes; i++)
       for (j = 0; j <= s->d - s->dl; j++)
-	arith_decode_init(s->s[i] + j, 0);
+        arith_decode_init(s->s[i] + j, 0);
     if (s->dl == 0 || (s->options & JBG_DPON && !(s->options & JBG_DPPRIV)))
       s->dppriv = jbg_dptable;
     s->comment_skip = 0;
@@ -2730,11 +2730,11 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
     /* skip COMMENT contents */
     if (s->comment_skip) {
       if (s->comment_skip <= len - *cnt) {
-	*cnt += s->comment_skip;
-	s->comment_skip = 0;
+        *cnt += s->comment_skip;
+        s->comment_skip = 0;
       } else {
-	s->comment_skip -= len - *cnt;
-	*cnt = len;
+        s->comment_skip -= len - *cnt;
+        *cnt = len;
       }
       continue;
     }
@@ -2743,7 +2743,7 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
     if (s->buf_len > 0) {
       assert(s->buffer[0] == MARKER_ESC);
       while (s->buf_len < 2 && *cnt < len)
-	s->buffer[s->buf_len++] = data[(*cnt)++];
+        s->buffer[s->buf_len++] = data[(*cnt)++];
       if (s->buf_len < 2) continue;
       switch (s->buffer[1]) {
       case MARKER_COMMENT: required_length = 6; break;
@@ -2753,120 +2753,120 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
       case MARKER_SDNORM:
       case MARKER_SDRST:   required_length = 2; break;
       case MARKER_STUFF:
-	/* forward stuffed 0xff to arithmetic decoder */
-	s->buf_len = 0;
-	decode_pscd(s, s->buffer, 2);
-	continue;
+        /* forward stuffed 0xff to arithmetic decoder */
+        s->buf_len = 0;
+        decode_pscd(s, s->buffer, 2);
+        continue;
       default:
-	return JBG_EMARKER;
+        return JBG_EMARKER;
       }
       while (s->buf_len < required_length && *cnt < len)
-	s->buffer[s->buf_len++] = data[(*cnt)++];
+        s->buffer[s->buf_len++] = data[(*cnt)++];
       if (s->buf_len < required_length) continue;
       /* now the buffer is filled with exactly one marker segment */
       switch (s->buffer[1]) {
       case MARKER_COMMENT:
-	s->comment_skip =
-	  (((long) s->buffer[2] << 24) | ((long) s->buffer[3] << 16) |
-	   ((long) s->buffer[4] <<  8) | (long) s->buffer[5]);
-	break;
+        s->comment_skip =
+          (((long) s->buffer[2] << 24) | ((long) s->buffer[3] << 16) |
+           ((long) s->buffer[4] <<  8) | (long) s->buffer[5]);
+        break;
       case MARKER_ATMOVE:
-	if (s->at_moves < JBG_ATMOVES_MAX) {
-	  s->at_line[s->at_moves] =
-	    (((long) s->buffer[2] << 24) | ((long) s->buffer[3] << 16) |
-	     ((long) s->buffer[4] <<  8) | (long) s->buffer[5]);
-	  s->at_tx[s->at_moves] = (signed char) s->buffer[6];
-	  s->at_ty[s->at_moves] = s->buffer[7];
-	  if (s->at_tx[s->at_moves] < - (int) s->mx ||
-	      s->at_tx[s->at_moves] >   (int) s->mx ||
-	      s->at_ty[s->at_moves] >   (int) s->my ||
-	      (s->at_ty[s->at_moves] == 0 && s->at_tx[s->at_moves] < 0))
-	    return JBG_EINVAL | 11;
-	  if (s->at_ty[s->at_moves] != 0)
-	    return JBG_EIMPL | 6;
-	  s->at_moves++;
-	} else
-	  return JBG_EIMPL | 7; /* more than JBG_ATMOVES_MAX ATMOVES */
-	break;
+        if (s->at_moves < JBG_ATMOVES_MAX) {
+          s->at_line[s->at_moves] =
+            (((long) s->buffer[2] << 24) | ((long) s->buffer[3] << 16) |
+             ((long) s->buffer[4] <<  8) | (long) s->buffer[5]);
+          s->at_tx[s->at_moves] = (signed char) s->buffer[6];
+          s->at_ty[s->at_moves] = s->buffer[7];
+          if (s->at_tx[s->at_moves] < - (int) s->mx ||
+              s->at_tx[s->at_moves] >   (int) s->mx ||
+              s->at_ty[s->at_moves] >   (int) s->my ||
+              (s->at_ty[s->at_moves] == 0 && s->at_tx[s->at_moves] < 0))
+            return JBG_EINVAL | 11;
+          if (s->at_ty[s->at_moves] != 0)
+            return JBG_EIMPL | 6;
+          s->at_moves++;
+        } else
+          return JBG_EIMPL | 7; /* more than JBG_ATMOVES_MAX ATMOVES */
+        break;
       case MARKER_NEWLEN:
-	y = (((long) s->buffer[2] << 24) | ((long) s->buffer[3] << 16) |
-	     ((long) s->buffer[4] <<  8) | (long) s->buffer[5]);
-	if (y > s->yd)                   return JBG_EINVAL | 12;
-	if (!(s->options & JBG_VLENGTH)) return JBG_EINVAL | 13;
-	s->yd = y;
-	/* calculate again number of stripes that will be required */
-	s->stripes = jbg_stripes(s->l0, s->yd, s->d);
-	break;
+        y = (((long) s->buffer[2] << 24) | ((long) s->buffer[3] << 16) |
+             ((long) s->buffer[4] <<  8) | (long) s->buffer[5]);
+        if (y > s->yd)                   return JBG_EINVAL | 12;
+        if (!(s->options & JBG_VLENGTH)) return JBG_EINVAL | 13;
+        s->yd = y;
+        /* calculate again number of stripes that will be required */
+        s->stripes = jbg_stripes(s->l0, s->yd, s->d);
+        break;
       case MARKER_ABORT:
-	return JBG_EABORT;
+        return JBG_EABORT;
 
       case MARKER_SDNORM:
       case MARKER_SDRST:
-	/* decode final pixels based on trailing zero bytes */
-	decode_pscd(s, s->buffer, 2);
-
-	arith_decode_init(s->s[s->ii[iindex[s->order & 7][PLANE]]] +
-			  s->ii[iindex[s->order & 7][LAYER]] - s->dl,
-			  s->ii[iindex[s->order & 7][STRIPE]] != s->stripes - 1
-			  && s->buffer[1] != MARKER_SDRST);
-
-	s->reset[s->ii[iindex[s->order & 7][PLANE]]]
-	  [s->ii[iindex[s->order & 7][LAYER]] - s->dl] =
-	    (s->buffer[1] == MARKER_SDRST);
-
-	/* prepare for next SDE */
-	s->x = 0;
-	s->i = 0;
-	s->pseudo = 1;
-	s->at_moves = 0;
-
-	/* increment layer/stripe/plane loop variables */
-	/* start and end value for each loop: */
-	is[iindex[s->order & 7][STRIPE]] = 0;
-	ie[iindex[s->order & 7][STRIPE]] = s->stripes - 1;
-	is[iindex[s->order & 7][LAYER]] = s->dl;
-	ie[iindex[s->order & 7][LAYER]] = s->d;
-	is[iindex[s->order & 7][PLANE]] = 0;
-	ie[iindex[s->order & 7][PLANE]] = s->planes - 1;
-	i = 2;  /* index to innermost loop */
-	do {
-	  j = 0;  /* carry flag */
-	  if (++s->ii[i] > ie[i]) {
-	    /* handling overflow of loop variable */
-	    j = 1;
-	    if (i > 0)
-	      s->ii[i] = is[i];
-	  }
-	} while (--i >= 0 && j);
-
-	s->buf_len = 0;
-
-	/* check whether this have been all SDEs */
-	if (j) {
+        /* decode final pixels based on trailing zero bytes */
+        decode_pscd(s, s->buffer, 2);
+
+        arith_decode_init(s->s[s->ii[iindex[s->order & 7][PLANE]]] +
+                          s->ii[iindex[s->order & 7][LAYER]] - s->dl,
+                          s->ii[iindex[s->order & 7][STRIPE]] != s->stripes - 1
+                          && s->buffer[1] != MARKER_SDRST);
+
+        s->reset[s->ii[iindex[s->order & 7][PLANE]]]
+          [s->ii[iindex[s->order & 7][LAYER]] - s->dl] =
+            (s->buffer[1] == MARKER_SDRST);
+
+        /* prepare for next SDE */
+        s->x = 0;
+        s->i = 0;
+        s->pseudo = 1;
+        s->at_moves = 0;
+
+        /* increment layer/stripe/plane loop variables */
+        /* start and end value for each loop: */
+        is[iindex[s->order & 7][STRIPE]] = 0;
+        ie[iindex[s->order & 7][STRIPE]] = s->stripes - 1;
+        is[iindex[s->order & 7][LAYER]] = s->dl;
+        ie[iindex[s->order & 7][LAYER]] = s->d;
+        is[iindex[s->order & 7][PLANE]] = 0;
+        ie[iindex[s->order & 7][PLANE]] = s->planes - 1;
+        i = 2;  /* index to innermost loop */
+        do {
+          j = 0;  /* carry flag */
+          if (++s->ii[i] > ie[i]) {
+            /* handling overflow of loop variable */
+            j = 1;
+            if (i > 0)
+              s->ii[i] = is[i];
+          }
+        } while (--i >= 0 && j);
+
+        s->buf_len = 0;
+
+        /* check whether this have been all SDEs */
+        if (j) {
 #ifdef DEBUG
-	  fprintf(stderr, "This was the final SDE in this BIE, "
-		  "%ld bytes left.\n", (long) (len - *cnt));
+          fprintf(stderr, "This was the final SDE in this BIE, "
+                  "%ld bytes left.\n", (long) (len - *cnt));
 #endif
-	  s->bie_len = 0;
-	  return JBG_EOK;
-	}
-
-	/* check whether we have to abort because of xmax/ymax */
-	if (iindex[s->order & 7][LAYER] == 0 && i < 0) {
-	  /* LAYER is the outermost loop and we have just gone to next layer */
-	  if (jbg_ceil_half(s->xd, s->d - s->ii[0]) > s->xmax ||
-	      jbg_ceil_half(s->yd, s->d - s->ii[0]) > s->ymax) {
-	    s->xmax = 4294967295UL;
-	    s->ymax = 4294967295UL;
-	    return JBG_EOK_INTR;
-	  }
-	  if (s->ii[0] > (unsigned long) s->dmax) {
-	    s->dmax = 256;
-	    return JBG_EOK_INTR;
-	  }
-	}
-
-	break;
+          s->bie_len = 0;
+          return JBG_EOK;
+        }
+
+        /* check whether we have to abort because of xmax/ymax */
+        if (iindex[s->order & 7][LAYER] == 0 && i < 0) {
+          /* LAYER is the outermost loop and we have just gone to next layer */
+          if (jbg_ceil_half(s->xd, s->d - s->ii[0]) > s->xmax ||
+              jbg_ceil_half(s->yd, s->d - s->ii[0]) > s->ymax) {
+            s->xmax = 4294967295UL;
+            s->ymax = 4294967295UL;
+            return JBG_EOK_INTR;
+          }
+          if (s->ii[0] > (unsigned long) s->dmax) {
+            s->dmax = 256;
+            return JBG_EOK_INTR;
+          }
+        }
+
+        break;
       }
       s->buf_len = 0;
 
@@ -2879,11 +2879,11 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
       *cnt += decode_pscd(s, data + *cnt, len - *cnt);
       if (*cnt < len && data[*cnt] != 0xff) {
 #ifdef DEBUG
-	fprintf(stderr, "PSCD was longer than expected, unread bytes "
-		"%02x %02x %02x %02x ...\n", data[*cnt], data[*cnt+1],
-		data[*cnt+2], data[*cnt+3]);
+        fprintf(stderr, "PSCD was longer than expected, unread bytes "
+                "%02x %02x %02x %02x ...\n", data[*cnt], data[*cnt+1],
+                data[*cnt+2], data[*cnt+3]);
 #endif
-	return JBG_EINVAL | 14;
+        return JBG_EINVAL | 14;
       }
 
     }
@@ -2967,8 +2967,8 @@ unsigned long jbg_dec_getsize(const struct jbg_dec_state *s)
       return 0;
     else
       return
-	jbg_ceil_half(s->xd, s->d - (s->ii[0] - 1) + 3) * /* overflow risk? */
-	jbg_ceil_half(s->yd, s->d - (s->ii[0] - 1));
+        jbg_ceil_half(s->xd, s->d - (s->ii[0] - 1) + 3) * /* overflow risk? */
+        jbg_ceil_half(s->yd, s->d - (s->ii[0] - 1));
   }
 
   return jbg_ceil_half(s->xd, 3) * s->yd;
@@ -2989,9 +2989,9 @@ unsigned long jbg_dec_getsize_merged(const struct jbg_dec_state *s)
       return 0;
     else
       return
-	jbg_ceil_half(s->xd, s->d - (s->ii[0] - 1)) * /* overflow risk? */
-	jbg_ceil_half(s->yd, s->d - (s->ii[0] - 1)) *
-	((s->planes + 7) / 8);
+        jbg_ceil_half(s->xd, s->d - (s->ii[0] - 1)) * /* overflow risk? */
+        jbg_ceil_half(s->yd, s->d - (s->ii[0] - 1)) *
+        ((s->planes + 7) / 8);
   }
 
   return s->xd * s->yd * ((s->planes + 7) / 8);
@@ -3045,9 +3045,9 @@ void jbg_dec_free(struct jbg_dec_state *s)
  * actually transfer to dest.
  */
 void jbg_split_planes(unsigned long x, unsigned long y, int has_planes,
-		      int encode_planes,
-		      const unsigned char *src, unsigned char **dest,
-		      int use_graycode)
+                      int encode_planes,
+                      const unsigned char *src, unsigned char **dest,
+                      int use_graycode)
 {
   unsigned long bpl = jbg_ceil_half(x, 3);  /* bytes per line in dest plane */
   unsigned long line, i;
@@ -3068,29 +3068,29 @@ void jbg_split_planes(unsigned long x, unsigned long y, int has_planes,
   for (line = 0; line < y; line++) {                 /* lines loop */
     for (i = 0; i * 8 < x; i++) {                    /* dest bytes loop */
       for (k = 0; k < 8 && i * 8 + k < x; k++) {     /* pixel loop */
-	prev = 0;
-	for (p = 0; p < encode_planes; p++) {        /* bit planes loop */
-	  /* calculate which bit in *src do we want */
-	  bitno = (msb - p) & 7;
-	  /* put this bit with its left neighbor right adjusted into bits */
-	  bits = (prev | *src) >> bitno;
-	  /* go to next *src byte, but keep old */
-	  if (bitno == 0)
-	    prev = *src++ << 8;
-	  /* make space for inserting new bit */
-	  dest[p][bpl * line + i] <<= 1;
-	  /* insert bit, if requested apply Gray encoding */
-	  dest[p][bpl * line + i] |= (bits ^ (use_graycode & (bits>>1))) & 1;
-	  /*
-	   * Theorem: Let b(n),...,b(1),b(0) be the digits of a
-	   * binary word and let g(n),...,g(1),g(0) be the digits of the
-	   * corresponding Gray code word, then g(i) = b(i) xor b(i+1).
-	   */
-	}
-	/* skip unused *src bytes */
-	for (;p < has_planes; p++)
-	  if (((msb - p) & 7) == 0)
-	    src++;
+        prev = 0;
+        for (p = 0; p < encode_planes; p++) {        /* bit planes loop */
+          /* calculate which bit in *src do we want */
+          bitno = (msb - p) & 7;
+          /* put this bit with its left neighbor right adjusted into bits */
+          bits = (prev | *src) >> bitno;
+          /* go to next *src byte, but keep old */
+          if (bitno == 0)
+            prev = *src++ << 8;
+          /* make space for inserting new bit */
+          dest[p][bpl * line + i] <<= 1;
+          /* insert bit, if requested apply Gray encoding */
+          dest[p][bpl * line + i] |= (bits ^ (use_graycode & (bits>>1))) & 1;
+          /*
+           * Theorem: Let b(n),...,b(1),b(0) be the digits of a
+           * binary word and let g(n),...,g(1),g(0) be the digits of the
+           * corresponding Gray code word, then g(i) = b(i) xor b(i+1).
+           */
+        }
+        /* skip unused *src bytes */
+        for (;p < has_planes; p++)
+          if (((msb - p) & 7) == 0)
+            src++;
       }
     }
     for (p = 0; p < encode_planes; p++)              /* right padding loop */
@@ -3106,8 +3106,8 @@ void jbg_split_planes(unsigned long x, unsigned long y, int has_planes,
  * jbg_split_planes().
  */
 void jbg_dec_merge_planes(const struct jbg_dec_state *s, int use_graycode,
-			  void (*data_out)(unsigned char *start, size_t len,
-					   void *file), void *file)
+                          void (*data_out)(unsigned char *start, size_t len,
+                                           void *file), void *file)
 {
 #define BUFLEN 4096
   unsigned long bpl, line, i;
@@ -3139,19 +3139,19 @@ void jbg_dec_merge_planes(const struct jbg_dec_state *s, int use_graycode,
   for (line = 0; line < y; line++) {                    /* lines loop */
     for (i = 0; i * 8 < x; i++) {                       /* src bytes loop */
       for (k = 0; k < 8 && i * 8 + k < x; k++) {        /* pixel loop */
-	v = 0;
-	for (p = 0; p < s->planes;) {                   /* dest bytes loop */
-	  do {
-	    v = (v << 1) |
-	      (((src[p][bpl * line + i] >> (7 - k)) & 1) ^
-	       (use_graycode & v));
-	  } while ((s->planes - ++p) & 7);
-	  *bp++ = v;
-	  if (bp - buf == BUFLEN) {
-	    data_out(buf, BUFLEN, file);
-	    bp = buf;
-	  }
-	}
+        v = 0;
+        for (p = 0; p < s->planes;) {                   /* dest bytes loop */
+          do {
+            v = (v << 1) |
+              (((src[p][bpl * line + i] >> (7 - k)) & 1) ^
+               (use_graycode & v));
+          } while ((s->planes - ++p) & 7);
+          *bp++ = v;
+          if (bp - buf == BUFLEN) {
+            data_out(buf, BUFLEN, file);
+            bp = buf;
+          }
+        }
       }
     }
   }
@@ -3186,15 +3186,15 @@ static unsigned char *jbg_next_pscdms(unsigned char *p, size_t len)
   if (p[0] != MARKER_ESC || p[1] == MARKER_STUFF) {
     do {
       while (p[0] == MARKER_ESC && p[1] == MARKER_STUFF) {
-	p += 2;
-	len -= 2;
-	if (len < 2)
-	  return NULL; /* not enough bytes left for complete marker segment */
+        p += 2;
+        len -= 2;
+        if (len < 2)
+          return NULL; /* not enough bytes left for complete marker segment */
       }
       assert(len >= 2);
       pp = (unsigned char *) memchr(p, MARKER_ESC, len - 1);
       if (!pp)
-	return NULL; /* no marker segment terminates the PSCD */
+        return NULL; /* no marker segment terminates the PSCD */
       l = pp - p;
       assert(l < len);
       p += l;
@@ -3208,19 +3208,19 @@ static unsigned char *jbg_next_pscdms(unsigned char *p, size_t len)
       return p + 2;
     case MARKER_NEWLEN:
       if (len < 6)
-	return NULL; /* not enough bytes left for complete marker segment */
+        return NULL; /* not enough bytes left for complete marker segment */
       return p + 6;
     case MARKER_ATMOVE:
       if (len < 8)
-	return NULL; /* not enough bytes left for complete marker segment */
+        return NULL; /* not enough bytes left for complete marker segment */
       return p + 8;
     case MARKER_COMMENT:
       if (len < 6)
-	return NULL; /* not enough bytes left for complete marker segment */
+        return NULL; /* not enough bytes left for complete marker segment */
       l = (((long) p[2] << 24) | ((long) p[3] << 16) |
-	   ((long) p[4] <<  8) |  (long) p[5]);
+           ((long) p[4] <<  8) |  (long) p[5]);
       if (len - 6 < l)
-	return NULL; /* not enough bytes left for complete marker segment */
+        return NULL; /* not enough bytes left for complete marker segment */
       return p + 6 + l;
     default:
       /* unknown marker sequence encountered */
@@ -3265,18 +3265,18 @@ int jbg_newlen(unsigned char *bie, size_t len)
     else if (p[0] == MARKER_ESC)
       switch (p[1]) {
       case MARKER_NEWLEN:
-	y = (((long) bie[ 8] << 24) | ((long) bie[ 9] << 16) |
-	     ((long) bie[10] <<  8) |  (long) bie[11]);
-	yn = (((long) p[2] << 24) | ((long) p[3] << 16) |
-	      ((long) p[4] <<  8) |  (long) p[5]);
-	if (yn > y) return JBG_EINVAL | 12;
-	/* overwrite YD in BIH with YD from NEWLEN */
-	for (i = 0; i < 4; i++) {
-	  bie[8+i] = p[2+i];
-	}
-	return JBG_EOK;
+        y = (((long) bie[ 8] << 24) | ((long) bie[ 9] << 16) |
+             ((long) bie[10] <<  8) |  (long) bie[11]);
+        yn = (((long) p[2] << 24) | ((long) p[3] << 16) |
+              ((long) p[4] <<  8) |  (long) p[5]);
+        if (yn > y) return JBG_EINVAL | 12;
+        /* overwrite YD in BIH with YD from NEWLEN */
+        for (i = 0; i < 4; i++) {
+          bie[8+i] = p[2+i];
+        }
+        return JBG_EOK;
       case MARKER_ABORT:
-	return JBG_EABORT;
+        return JBG_EABORT;
       }
   }
   return JBG_EINVAL | 0;
diff --git a/converter/other/jbig/libjbig/jbig_ar.c b/converter/other/jbig/libjbig/jbig_ar.c
index d23a317d..194e13eb 100644
--- a/converter/other/jbig/libjbig/jbig_ar.c
+++ b/converter/other/jbig/libjbig/jbig_ar.c
@@ -22,7 +22,7 @@
  *  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.
- * 
+ *
  *  If you want to use this program under different license conditions,
  *  then contact the author for an arrangement.
  */
@@ -106,7 +106,7 @@ static unsigned char nlpstab[113] = {
 void arith_encode_init(struct jbg_arenc_state *s, int reuse_st)
 {
   int i;
-  
+
   if (!reuse_st)
     for (i = 0; i < 4096; s->st[i++] = 0) ;
   s->c = 0;
@@ -114,7 +114,7 @@ void arith_encode_init(struct jbg_arenc_state *s, int reuse_st)
   s->sc = 0;
   s->ct = 11;
   s->buffer = -1;    /* empty */
-  
+
   return;
 }
 
@@ -136,15 +136,15 @@ void arith_encode_flush(struct jbg_arenc_state *s)
     if (s->buffer >= 0) {
       s->byte_out(s->buffer + 1, s->file);
       if (s->buffer + 1 == MARKER_ESC)
-	s->byte_out(MARKER_STUFF, s->file);
+        s->byte_out(MARKER_STUFF, s->file);
     }
     /* output 0x00 bytes only when more non-0x00 will follow */
     if (s->c & 0x7fff800L)
       for (; s->sc; --s->sc)
-	s->byte_out(0x00, s->file);
+        s->byte_out(0x00, s->file);
   } else {
     if (s->buffer >= 0)
-      s->byte_out(s->buffer, s->file); 
+      s->byte_out(s->buffer, s->file);
     /* T.82 figure 30 says buffer+1 for the above line! Typo? */
     for (; s->sc; --s->sc) {
       s->byte_out(0xff, s->file);
@@ -159,7 +159,7 @@ void arith_encode_flush(struct jbg_arenc_state *s)
     if (s->c & 0x7f800L) {
       s->byte_out((s->c >> 11) & 0xff, s->file);
       if (((s->c >> 11) & 0xff) == MARKER_ESC)
-	s->byte_out(MARKER_STUFF, s->file);
+        s->byte_out(MARKER_STUFF, s->file);
     }
   }
 
@@ -167,7 +167,7 @@ void arith_encode_flush(struct jbg_arenc_state *s)
 }
 
 
-void arith_encode(struct jbg_arenc_state *s, int cx, int pix) 
+void arith_encode(struct jbg_arenc_state *s, int cx, int pix)
 {
   register unsigned lsz, ss;
   register unsigned char *st;
@@ -181,9 +181,9 @@ void arith_encode(struct jbg_arenc_state *s, int cx, int pix)
 
 #if 0
   fprintf(stderr, "pix = %d, cx = %d, mps = %d, st = %3d, lsz = 0x%04x, "
-	  "a = 0x%05lx, c = 0x%08lx, ct = %2d, buf = 0x%02x\n",
-	  pix, cx, !!(s->st[cx] & 0x80), ss, lsz, s->a, s->c, s->ct,
-	  s->buffer);
+          "a = 0x%05lx, c = 0x%08lx, ct = %2d, buf = 0x%02x\n",
+          pix, cx, !!(s->st[cx] & 0x80), ss, lsz, s->a, s->c, s->ct,
+          s->buffer);
 #endif
 
   if (((pix << 7) ^ s->st[cx]) & 0x80) {
@@ -225,36 +225,36 @@ void arith_encode(struct jbg_arenc_state *s, int cx, int pix)
       /* another byte is ready for output */
       temp = s->c >> 19;
       if (temp & 0xffffff00L) {
-	/* handle overflow over all buffered 0xff bytes */
-	if (s->buffer >= 0) {
-	  ++s->buffer;
-	  s->byte_out(s->buffer, s->file);
-	  if (s->buffer == MARKER_ESC)
-	    s->byte_out(MARKER_STUFF, s->file);
-	}
-	for (; s->sc; --s->sc)
-	  s->byte_out(0x00, s->file);
-	s->buffer = temp & 0xff;  /* new output byte, might overflow later */
-	assert(s->buffer != 0xff);
-	/* can s->buffer really never become 0xff here? */
+        /* handle overflow over all buffered 0xff bytes */
+        if (s->buffer >= 0) {
+          ++s->buffer;
+          s->byte_out(s->buffer, s->file);
+          if (s->buffer == MARKER_ESC)
+            s->byte_out(MARKER_STUFF, s->file);
+        }
+        for (; s->sc; --s->sc)
+          s->byte_out(0x00, s->file);
+        s->buffer = temp & 0xff;  /* new output byte, might overflow later */
+        assert(s->buffer != 0xff);
+        /* can s->buffer really never become 0xff here? */
       } else if (temp == 0xff) {
-	/* buffer 0xff byte (which might overflow later) */
-	++s->sc;
+        /* buffer 0xff byte (which might overflow later) */
+        ++s->sc;
       } else {
-	/* output all buffered 0xff bytes, they will not overflow any more */
-	if (s->buffer >= 0)
-	  s->byte_out(s->buffer, s->file);
-	for (; s->sc; --s->sc) {
-	  s->byte_out(0xff, s->file);
-	  s->byte_out(MARKER_STUFF, s->file);
-	}
-	s->buffer = temp;   /* buffer new output byte (can still overflow) */
+        /* output all buffered 0xff bytes, they will not overflow any more */
+        if (s->buffer >= 0)
+          s->byte_out(s->buffer, s->file);
+        for (; s->sc; --s->sc) {
+          s->byte_out(0xff, s->file);
+          s->byte_out(MARKER_STUFF, s->file);
+        }
+        s->buffer = temp;   /* buffer new output byte (can still overflow) */
       }
       s->c &= 0x7ffffL;
       s->ct = 8;
     }
   } while (s->a < 0x8000);
- 
+
   return;
 }
 
@@ -262,7 +262,7 @@ void arith_encode(struct jbg_arenc_state *s, int cx, int pix)
 void arith_decode_init(struct jbg_ardec_state *s, int reuse_st)
 {
   int i;
-  
+
   if (!reuse_st)
     for (i = 0; i < 4096; s->st[i++] = 0) ;
   s->c = 0;
@@ -295,7 +295,7 @@ void arith_decode_init(struct jbg_ardec_state *s, int reuse_st)
  *   decoded.
  *
  * s->pscd_ptr == s->pscd_end - 1:
- * 
+ *
  *   The decoder has used up all provided PSCD bytes except for the
  *   very last byte, because that has the value 0xff. The decoder can
  *   at this point not yet tell whether this 0xff belongs to a
@@ -336,27 +336,27 @@ int arith_decode(struct jbg_ardec_state *s, int cx)
     while (s->ct <= 8 && s->ct >= 0) {
       /* first we can move a new byte into s->c */
       if (s->pscd_ptr >= s->pscd_end) {
-	return -1;  /* more bytes needed */
+        return -1;  /* more bytes needed */
       }
-      if (*s->pscd_ptr == 0xff) 
-	if (s->pscd_ptr + 1 >= s->pscd_end) {
-	  return -1; /* final 0xff byte not processed */
-	} else {
-	  if (*(s->pscd_ptr + 1) == MARKER_STUFF) {
-	    s->c |= 0xffL << (8 - s->ct);
-	    s->ct += 8;
-	    s->pscd_ptr += 2;
-	  } else {
-	    s->ct = -1; /* start padding with zero bytes */
-	    if (s->nopadding) {
-	      s->nopadding = 0;
-	      return -2; /* subsequent symbols might depend on zero padding */
-	    }
-	  }
-	}
+      if (*s->pscd_ptr == 0xff)
+        if (s->pscd_ptr + 1 >= s->pscd_end) {
+          return -1; /* final 0xff byte not processed */
+        } else {
+          if (*(s->pscd_ptr + 1) == MARKER_STUFF) {
+            s->c |= 0xffL << (8 - s->ct);
+            s->ct += 8;
+            s->pscd_ptr += 2;
+          } else {
+            s->ct = -1; /* start padding with zero bytes */
+            if (s->nopadding) {
+              s->nopadding = 0;
+              return -2; /* subsequent symbols might depend on zero padding */
+            }
+          }
+        }
       else {
-	s->c |= (long)*(s->pscd_ptr++) << (8 - s->ct);
-	s->ct += 8;
+        s->c |= (long)*(s->pscd_ptr++) << (8 - s->ct);
+        s->ct += 8;
       }
     }
     s->c <<= 1;
@@ -373,8 +373,8 @@ int arith_decode(struct jbg_ardec_state *s, int cx)
 
 #if 0
   fprintf(stderr, "cx = %d, mps = %d, st = %3d, lsz = 0x%04x, a = 0x%05lx, "
-	  "c = 0x%08lx, ct = %2d\n",
-	  cx, !!(s->st[cx] & 0x80), ss, lsz, s->a, s->c, s->ct);
+          "c = 0x%08lx, ct = %2d\n",
+          cx, !!(s->st[cx] & 0x80), ss, lsz, s->a, s->c, s->ct);
 #endif
 
   if ((s->c >> 16) < (s->a -= lsz))
@@ -383,15 +383,15 @@ int arith_decode(struct jbg_ardec_state *s, int cx)
     else {
       /* MPS_EXCHANGE */
       if (s->a < lsz) {
-	pix = 1 - (*st >> 7);
-	/* Check whether MPS/LPS exchange is necessary
-	 * and chose next probability estimator status */
-	*st &= 0x80;
-	*st ^= nlpstab[ss];
+        pix = 1 - (*st >> 7);
+        /* Check whether MPS/LPS exchange is necessary
+         * and chose next probability estimator status */
+        *st &= 0x80;
+        *st ^= nlpstab[ss];
       } else {
-	pix = *st >> 7;
-	*st &= 0x80;
-	*st |= nmpstab[ss];
+        pix = *st >> 7;
+        *st &= 0x80;
+        *st |= nmpstab[ss];
       }
     }
   else {
diff --git a/converter/other/jbig/pnmtojbig.c b/converter/other/jbig/pnmtojbig.c
index f5188c7b..5757680e 100644
--- a/converter/other/jbig/pnmtojbig.c
+++ b/converter/other/jbig/pnmtojbig.c
@@ -1,6 +1,6 @@
 /*
     pnmtojbig - PNM to JBIG converter
-  
+
     This program was derived from pbmtojbg.c in Markus Kuhn's
     JBIG-KIT package by Bryan Henderson on 2000.05.11
 
@@ -34,7 +34,7 @@
      bits in it.
 
 */
-  
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -44,7 +44,7 @@
 #include "mallocvar.h"
 #include "pnm.h"
 
-static unsigned long total_length = 0;  
+static unsigned long total_length = 0;
   /* used for determining output file length */
 
 /*
@@ -54,12 +54,12 @@ static void
 *checkedmalloc(size_t n)
 {
   void *p;
-  
+
   if ((p = malloc(n)) == NULL) {
     fprintf(stderr, "Sorry, not enough memory available!\n");
     exit(1);
   }
-  
+
   return p;
 }
 
@@ -92,13 +92,13 @@ readPbm(FILE *            const fin,
     int row;
     bitmap = (unsigned char **) checkedmalloc(sizeof(unsigned char *));
     bitmap[0] = (unsigned char *) checkedmalloc(bytes_per_line * rows);
-    
+
     for (row = 0; row < rows; row++)
         pbm_readpbmrow_packed(fin, &bitmap[0][row*bytes_per_line],
                               cols, RPBM_FORMAT);
 
     *bitmapP = bitmap;
-} 
+}
 
 
 
@@ -121,7 +121,7 @@ readImage(FILE * const fin,
            pixel.  The 'bpp' bytes for each pixel are arranged MSB first
            and its numerical value is the value from the PNM input.
            The pixels are laid out in row-major format in this rectangle.
-           
+
            The point of this data structure is it is what jbg_split_planes()
            wants for input.
         */
@@ -130,7 +130,7 @@ readImage(FILE * const fin,
 
     pnm_row = pnm_allocrow(cols);  /* row buffer */
     MALLOCARRAY_NOFAIL(image, cols * rows * bpp);
-    
+
     for (row = 0; row < rows; ++row) {
         unsigned int col;
         pnm_readpnmrow(fin, pnm_row, cols, maxval, format);
@@ -145,7 +145,7 @@ readImage(FILE * const fin,
     pnm_freerow(pnm_row);
     *imageP = image;
 }
-      
+
 
 
 static void
@@ -154,12 +154,12 @@ convertImageToBitmap(unsigned char *   const image,
                      unsigned int      const encode_planes,
                      unsigned int      const bytes_per_line,
                      unsigned int      const lines) {
-    
+
     /* Convert image[] into bitmap[]  */
-    
+
     unsigned char ** bitmap;
     unsigned int i;
-    
+
     MALLOCARRAY_NOFAIL(bitmap, encode_planes);
     for (i = 0; i < encode_planes; ++i)
         MALLOCARRAY_NOFAIL(bitmap[i], bytes_per_line * lines);
@@ -193,10 +193,10 @@ readPnm(FILE *            const fin,
     jbg_split_planes(cols, rows, planes, encode_planes, image, bitmap,
                      use_graycode);
     free(image);
-    
+
     /* Invert the image if it is just one plane.  See top of this file
        for an explanation why.  Because of the separate handling of PBM,
-       this is for exceptional PGM files.  
+       this is for exceptional PGM files.
     */
 
     if (encode_planes == 1) {
@@ -206,7 +206,7 @@ readPnm(FILE *            const fin,
             for (i = 0; i < bytes_per_line; i++)
                 bitmap[0][(row*bytes_per_line) + i] ^= 0xff;
 
-            if (cols % 8 > 0) {   
+            if (cols % 8 > 0) {
                 bitmap[0][ (row+1)*bytes_per_line  -1] >>= 8-cols%8;
                 bitmap[0][ (row+1)*bytes_per_line  -1] <<= 8-cols%8;
             }
@@ -230,7 +230,7 @@ main(int argc, char **argv) {
     unsigned char **bitmap;
     /* This is an array of the planes of the image.  Each plane is a
        two-dimensional array of pixels laid out in row-major format.
-       format with each pixel being one bit.  A byte in the array 
+       format with each pixel being one bit.  A byte in the array
        contains 8 pixels left to right, msb to lsb.
     */
 
@@ -372,8 +372,8 @@ main(int argc, char **argv) {
     /* In a JBIG file, maxvals are determined only by the number of planes,
        so must be a power of 2 minus 1
     */
-  
-    if ((1UL << planes)-1 != maxval) 
+
+    if ((1UL << planes)-1 != maxval)
         pm_error("Input image has unacceptable maxval: %d.  JBIG files must "
                  "have a maxval which is a power of 2 minus 1.  Use "
                  "Ppmdepth to adjust the image's maxval", maxval);
@@ -386,8 +386,8 @@ main(int argc, char **argv) {
     if (bpp == 1 && PNM_FORMAT_TYPE(format) == PBM_TYPE)
         readPbm(fin, cols, rows, &bitmap);
     else
-        readPnm(fin, cols, rows, maxval, format, bpp, 
-                planes, encode_planes, use_graycode, 
+        readPnm(fin, cols, rows, maxval, format, bpp,
+                planes, encode_planes, use_graycode,
                 &bitmap);
 
     /* Apply JBIG algorithm and write BIE to output file */
diff --git a/converter/other/jpeg2000/libjasper/base/jas_debug.c b/converter/other/jpeg2000/libjasper/base/jas_debug.c
index 4248178f..1bfdef51 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_debug.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_debug.c
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -132,22 +132,22 @@ static int jas_dbglevel = 0;
 /* Set the library debug level. */
 int jas_setdbglevel(int dbglevel)
 {
-	int olddbglevel;
+        int olddbglevel;
 
-	/* Save the old debug level. */
-	olddbglevel = jas_dbglevel;
+        /* Save the old debug level. */
+        olddbglevel = jas_dbglevel;
 
-	/* Change the debug level. */
-	jas_dbglevel = dbglevel;
+        /* Change the debug level. */
+        jas_dbglevel = dbglevel;
 
-	/* Return the old debug level. */
-	return olddbglevel;
+        /* Return the old debug level. */
+        return olddbglevel;
 }
 
 /* Get the library debug level. */
 int jas_getdbglevel()
 {
-	return jas_dbglevel;
+        return jas_dbglevel;
 }
 
 /******************************************************************************\
@@ -157,30 +157,30 @@ int jas_getdbglevel()
 /* Perform formatted output to standard error. */
 int jas_eprintf(const char *fmt, ...)
 {
-	int ret;
-	va_list ap;
+        int ret;
+        va_list ap;
 
-	va_start(ap, fmt);
-	ret = vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	return ret;
+        va_start(ap, fmt);
+        ret = vfprintf(stderr, fmt, ap);
+        va_end(ap);
+        return ret;
 }
 
 /* Dump memory to a stream. */
 int jas_memdump(FILE *out, void *data, size_t len)
 {
-	int i;
-	int j;
-	unsigned char *dp;
-	dp = data;
-	for (i = 0; i < len; i += 16) {
-		fprintf(out, "%04x:", i);
-		for (j = 0; j < 16; ++j) {
-			if (i + j < len) {
-				fprintf(out, " %02x", dp[i + j]);
-			}
-		}
-		fprintf(out, "\n");
-	}
-	return 0;
+        int i;
+        int j;
+        unsigned char *dp;
+        dp = data;
+        for (i = 0; i < len; i += 16) {
+                fprintf(out, "%04x:", i);
+                for (j = 0; j < 16; ++j) {
+                        if (i + j < len) {
+                                fprintf(out, " %02x", dp[i + j]);
+                        }
+                }
+                fprintf(out, "\n");
+        }
+        return 0;
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_getopt.c b/converter/other/jpeg2000/libjasper/base/jas_getopt.c
index 7f579b3e..e12340c2 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_getopt.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_getopt.c
@@ -2,18 +2,18 @@
  * Copyright (c) 1999-2000, Image Power, Inc. and the University of
  *   British Columbia.
  * Copyright (c) 2001-2002 Michael David Adams.
- * All rights reserved. 
+ * All rights reserved.
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -140,78 +140,78 @@ char *jas_optarg = 0;
 
 static jas_opt_t *jas_optlookup(jas_opt_t *opts, char *name)
 {
-	jas_opt_t *opt;
+        jas_opt_t *opt;
 
-	for (opt = opts; opt->id >= 0 && opt->name; ++opt) {
-		if (!strcmp(opt->name, name)) {
-			return opt;
-		}
-	}
-	return 0;
+        for (opt = opts; opt->id >= 0 && opt->name; ++opt) {
+                if (!strcmp(opt->name, name)) {
+                        return opt;
+                }
+        }
+        return 0;
 }
 
 int jas_getopt(int argc, char **argv, jas_opt_t *opts)
 {
-	char *cp;
-	int id;
-	int hasarg;
-	jas_opt_t *opt;
-	char *s;
+        char *cp;
+        int id;
+        int hasarg;
+        jas_opt_t *opt;
+        char *s;
 
-	if (!jas_optind) {
-		jas_optind = JAS_MIN(1, argc);
-	}
-	while (jas_optind < argc) {
-		s = cp = argv[jas_optind];
-		if (*cp == '-') {
-			/* We are processing an option. */
-			++jas_optind;
-			if (*++cp == '-') {
-				/* We are processing a long option. */
-				++cp;
-				if (*cp == '\0') {
-					/* This is the end of the options. */
-					return JAS_GETOPT_EOF;
-				}
-				if (!(opt = jas_optlookup(opts, cp))) {
-					if (jas_opterr) {
-						fprintf(stderr, "unknown long option %s\n", s);
-					}
-					return JAS_GETOPT_ERR;
-				}
-				hasarg = (opt->flags & JAS_OPT_HASARG) != 0;
-				id = opt->id;
-			} else {
-				/* We are processing a short option. */
-				if (strlen(cp) != 1 ||
-				  !(opt = jas_optlookup(opts, cp))) {
-					if (jas_opterr) {
-						fprintf(stderr, "unknown short option %s\n", s);
-					}
-					return JAS_GETOPT_ERR;
-				}
-				hasarg = (opt->flags & JAS_OPT_HASARG) != 0;
-				id = opt->id;
-			}
-			if (hasarg) {
-				/* The option has an argument. */
-				if (jas_optind >= argc) {
-					if (jas_opterr) {
-						fprintf(stderr, "missing argument for option %s\n", s);
-					}
-					return JAS_GETOPT_ERR;
-				}
-				jas_optarg = argv[jas_optind];
-				++jas_optind;
-			} else {
-				/* The option does not have an argument. */
-				jas_optarg = 0;
-			}
-			return id;
-		} else {
-			/* We are not processing an option. */
-			return JAS_GETOPT_EOF;
-		}
-	}
-	return JAS_GETOPT_EOF;
+        if (!jas_optind) {
+                jas_optind = JAS_MIN(1, argc);
+        }
+        while (jas_optind < argc) {
+                s = cp = argv[jas_optind];
+                if (*cp == '-') {
+                        /* We are processing an option. */
+                        ++jas_optind;
+                        if (*++cp == '-') {
+                                /* We are processing a long option. */
+                                ++cp;
+                                if (*cp == '\0') {
+                                        /* This is the end of the options. */
+                                        return JAS_GETOPT_EOF;
+                                }
+                                if (!(opt = jas_optlookup(opts, cp))) {
+                                        if (jas_opterr) {
+                                                fprintf(stderr, "unknown long option %s\n", s);
+                                        }
+                                        return JAS_GETOPT_ERR;
+                                }
+                                hasarg = (opt->flags & JAS_OPT_HASARG) != 0;
+                                id = opt->id;
+                        } else {
+                                /* We are processing a short option. */
+                                if (strlen(cp) != 1 ||
+                                  !(opt = jas_optlookup(opts, cp))) {
+                                        if (jas_opterr) {
+                                                fprintf(stderr, "unknown short option %s\n", s);
+                                        }
+                                        return JAS_GETOPT_ERR;
+                                }
+                                hasarg = (opt->flags & JAS_OPT_HASARG) != 0;
+                                id = opt->id;
+                        }
+                        if (hasarg) {
+                                /* The option has an argument. */
+                                if (jas_optind >= argc) {
+                                        if (jas_opterr) {
+                                                fprintf(stderr, "missing argument for option %s\n", s);
+                                        }
+                                        return JAS_GETOPT_ERR;
+                                }
+                                jas_optarg = argv[jas_optind];
+                                ++jas_optind;
+                        } else {
+                                /* The option does not have an argument. */
+                                jas_optarg = 0;
+                        }
+                        return id;
+                } else {
+                        /* We are not processing an option. */
+                        return JAS_GETOPT_EOF;
+                }
+        }
+        return JAS_GETOPT_EOF;
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_image.c b/converter/other/jpeg2000/libjasper/base/jas_image.c
index c6f984c1..49a0db79 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_image.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_image.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -166,215 +166,215 @@ static jas_image_fmtinfo_t jas_image_fmtinfos[JAS_IMAGE_MAXFMTS];
 jas_image_t *jas_image_create(uint_fast16_t numcmpts, jas_image_cmptparm_t *cmptparms,
   int colorspace)
 {
-	jas_image_t *image;
-	uint_fast32_t rawsize;
-	uint_fast32_t inmem;
-	uint_fast16_t cmptno;
-	jas_image_cmptparm_t *cmptparm;
-
-	if (!(image = jas_image_create0())) {
-		return 0;
-	}
-
-	image->colorspace_ = colorspace;
-	image->maxcmpts_ = numcmpts;
-	image->inmem_ = true;
-
-	/* Allocate memory for the per-component information. */
-	if (!(image->cmpts_ = jas_malloc(image->maxcmpts_ *
-	  sizeof(jas_image_cmpt_t *)))) {
-		jas_image_destroy(image);
-		return 0;
-	}
-	/* Initialize in case of failure. */
-	for (cmptno = 0; cmptno < image->maxcmpts_; ++cmptno) {
-		image->cmpts_[cmptno] = 0;
-	}
-
-	/* Compute the approximate raw size of the image. */
-	rawsize = 0;
-	for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,
-	  ++cmptparm) {
-		rawsize += cmptparm->width * cmptparm->height *
-		  (cmptparm->prec + 7) / 8;
-	}
-	/* Decide whether to buffer the image data in memory, based on the
-	  raw size of the image. */
-	inmem = (rawsize < JAS_IMAGE_INMEMTHRESH);
-
-	/* Create the individual image components. */
-	for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,
-	  ++cmptparm) {
-		if (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx,
-		  cmptparm->tly, cmptparm->hstep, cmptparm->vstep,
-		  cmptparm->width, cmptparm->height, cmptparm->prec,
-		  cmptparm->sgnd, inmem))) {
-			jas_image_destroy(image);
-			return 0;
-		}
-		++image->numcmpts_;
-	}
-
-	/* Determine the bounding box for all of the components on the
-	  reference grid (i.e., the image area) */
-	jas_image_setbbox(image);
-
-	return image;
+        jas_image_t *image;
+        uint_fast32_t rawsize;
+        uint_fast32_t inmem;
+        uint_fast16_t cmptno;
+        jas_image_cmptparm_t *cmptparm;
+
+        if (!(image = jas_image_create0())) {
+                return 0;
+        }
+
+        image->colorspace_ = colorspace;
+        image->maxcmpts_ = numcmpts;
+        image->inmem_ = true;
+
+        /* Allocate memory for the per-component information. */
+        if (!(image->cmpts_ = jas_malloc(image->maxcmpts_ *
+          sizeof(jas_image_cmpt_t *)))) {
+                jas_image_destroy(image);
+                return 0;
+        }
+        /* Initialize in case of failure. */
+        for (cmptno = 0; cmptno < image->maxcmpts_; ++cmptno) {
+                image->cmpts_[cmptno] = 0;
+        }
+
+        /* Compute the approximate raw size of the image. */
+        rawsize = 0;
+        for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,
+          ++cmptparm) {
+                rawsize += cmptparm->width * cmptparm->height *
+                  (cmptparm->prec + 7) / 8;
+        }
+        /* Decide whether to buffer the image data in memory, based on the
+          raw size of the image. */
+        inmem = (rawsize < JAS_IMAGE_INMEMTHRESH);
+
+        /* Create the individual image components. */
+        for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,
+          ++cmptparm) {
+                if (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx,
+                  cmptparm->tly, cmptparm->hstep, cmptparm->vstep,
+                  cmptparm->width, cmptparm->height, cmptparm->prec,
+                  cmptparm->sgnd, inmem))) {
+                        jas_image_destroy(image);
+                        return 0;
+                }
+                ++image->numcmpts_;
+        }
+
+        /* Determine the bounding box for all of the components on the
+          reference grid (i.e., the image area) */
+        jas_image_setbbox(image);
+
+        return image;
 }
 
 jas_image_t *jas_image_create0()
 {
-	jas_image_t *image;
+        jas_image_t *image;
 
-	if (!(image = jas_malloc(sizeof(jas_image_t)))) {
-		return 0;
-	}
+        if (!(image = jas_malloc(sizeof(jas_image_t)))) {
+                return 0;
+        }
 
-	image->tlx_ = 0;
-	image->tly_ = 0;
-	image->brx_ = 0;
-	image->bry_ = 0;
-	image->colorspace_ = JAS_IMAGE_CS_UNKNOWN;
-	image->numcmpts_ = 0;
-	image->maxcmpts_ = 0;
-	image->cmpts_ = 0;
-	image->inmem_ = true;
-	image->iccp_ = 0;
-	image->iccplen_ = 0;
+        image->tlx_ = 0;
+        image->tly_ = 0;
+        image->brx_ = 0;
+        image->bry_ = 0;
+        image->colorspace_ = JAS_IMAGE_CS_UNKNOWN;
+        image->numcmpts_ = 0;
+        image->maxcmpts_ = 0;
+        image->cmpts_ = 0;
+        image->inmem_ = true;
+        image->iccp_ = 0;
+        image->iccplen_ = 0;
 
-	return image;
+        return image;
 }
 
 jas_image_t *jas_image_copy(jas_image_t *image)
 {
-	jas_image_t *newimage;
-	int cmptno;
+        jas_image_t *newimage;
+        int cmptno;
 
-	newimage = jas_image_create0();
-	if (jas_image_growcmpts(newimage, image->numcmpts_)) {
-		goto error;
-	}
-	for (cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
-		if (!(newimage->cmpts_[cmptno] = jas_image_cmpt_copy(image->cmpts_[cmptno]))) {
-			goto error;
-		}
-		++newimage->numcmpts_;
-	}
+        newimage = jas_image_create0();
+        if (jas_image_growcmpts(newimage, image->numcmpts_)) {
+                goto error;
+        }
+        for (cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
+                if (!(newimage->cmpts_[cmptno] = jas_image_cmpt_copy(image->cmpts_[cmptno]))) {
+                        goto error;
+                }
+                ++newimage->numcmpts_;
+        }
 
-	jas_image_setbbox(newimage);
+        jas_image_setbbox(newimage);
 
-	return newimage;
+        return newimage;
 error:
-	if (newimage) {
-		jas_image_destroy(newimage);
-	}
-	return 0;
+        if (newimage) {
+                jas_image_destroy(newimage);
+        }
+        return 0;
 }
 
 static jas_image_cmpt_t *jas_image_cmpt_create0()
 {
-	jas_image_cmpt_t *cmpt;
-	if (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) {
-		return 0;
-	}
-	memset(cmpt, 0, sizeof(jas_image_cmpt_t));
-	cmpt->type_ = JAS_IMAGE_CT_UNKNOWN;
-	return cmpt;
+        jas_image_cmpt_t *cmpt;
+        if (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) {
+                return 0;
+        }
+        memset(cmpt, 0, sizeof(jas_image_cmpt_t));
+        cmpt->type_ = JAS_IMAGE_CT_UNKNOWN;
+        return cmpt;
 }
 
 static jas_image_cmpt_t *jas_image_cmpt_copy(jas_image_cmpt_t *cmpt)
 {
-	jas_image_cmpt_t *newcmpt;
-
-	if (!(newcmpt = jas_image_cmpt_create0())) {
-		return 0;
-	}
-	newcmpt->tlx_ = cmpt->tlx_;
-	newcmpt->tly_ = cmpt->tly_;
-	newcmpt->hstep_ = cmpt->hstep_;
-	newcmpt->vstep_ = cmpt->vstep_;
-	newcmpt->width_ = cmpt->width_;
-	newcmpt->height_ = cmpt->height_;
-	newcmpt->prec_ = cmpt->prec_;
-	newcmpt->sgnd_ = cmpt->sgnd_;
-	newcmpt->cps_ = cmpt->cps_;
-	newcmpt->type_ = cmpt->type_;
-	if (!(newcmpt->stream_ = jas_stream_memopen(0, 0))) {
-		return 0;
-	}
-	if (jas_stream_seek(cmpt->stream_, 0, SEEK_SET)) {
-		return 0;
-	}
-	if (jas_stream_copy(newcmpt->stream_, cmpt->stream_, -1)) {
-		return 0;
-	}
-	if (jas_stream_seek(newcmpt->stream_, 0, SEEK_SET)) {
-		return 0;
-	}
-	return newcmpt;
+        jas_image_cmpt_t *newcmpt;
+
+        if (!(newcmpt = jas_image_cmpt_create0())) {
+                return 0;
+        }
+        newcmpt->tlx_ = cmpt->tlx_;
+        newcmpt->tly_ = cmpt->tly_;
+        newcmpt->hstep_ = cmpt->hstep_;
+        newcmpt->vstep_ = cmpt->vstep_;
+        newcmpt->width_ = cmpt->width_;
+        newcmpt->height_ = cmpt->height_;
+        newcmpt->prec_ = cmpt->prec_;
+        newcmpt->sgnd_ = cmpt->sgnd_;
+        newcmpt->cps_ = cmpt->cps_;
+        newcmpt->type_ = cmpt->type_;
+        if (!(newcmpt->stream_ = jas_stream_memopen(0, 0))) {
+                return 0;
+        }
+        if (jas_stream_seek(cmpt->stream_, 0, SEEK_SET)) {
+                return 0;
+        }
+        if (jas_stream_copy(newcmpt->stream_, cmpt->stream_, -1)) {
+                return 0;
+        }
+        if (jas_stream_seek(newcmpt->stream_, 0, SEEK_SET)) {
+                return 0;
+        }
+        return newcmpt;
 }
 
 void jas_image_destroy(jas_image_t *image)
 {
-	int i;
+        int i;
 
-	if (image->cmpts_) {
-		for (i = 0; i < image->numcmpts_; ++i) {
-			jas_image_cmpt_destroy(image->cmpts_[i]);
-			image->cmpts_[i] = 0;
-		}
-		jas_free(image->cmpts_);
-	}
-	jas_free(image);
+        if (image->cmpts_) {
+                for (i = 0; i < image->numcmpts_; ++i) {
+                        jas_image_cmpt_destroy(image->cmpts_[i]);
+                        image->cmpts_[i] = 0;
+                }
+                jas_free(image->cmpts_);
+        }
+        jas_free(image);
 }
 
 static jas_image_cmpt_t *jas_image_cmpt_create(uint_fast32_t tlx, uint_fast32_t tly,
   uint_fast32_t hstep, uint_fast32_t vstep, uint_fast32_t width, uint_fast32_t
   height, uint_fast16_t depth, bool sgnd, uint_fast32_t inmem)
 {
-	jas_image_cmpt_t *cmpt;
-	long size;
-
-	if (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) {
-		return 0;
-	}
-
-	cmpt->tlx_ = tlx;
-	cmpt->tly_ = tly;
-	cmpt->hstep_ = hstep;
-	cmpt->vstep_ = vstep;
-	cmpt->width_ = width;
-	cmpt->height_ = height;
-	cmpt->prec_ = depth;
-	cmpt->sgnd_ = sgnd;
-	cmpt->stream_ = 0;
-	cmpt->cps_ = (depth + 7) / 8;
-
-	size = cmpt->width_ * cmpt->height_ * cmpt->cps_;
-	cmpt->stream_ = (inmem) ? jas_stream_memopen(0, size) : jas_stream_tmpfile();
-	if (!cmpt->stream_) {
-		jas_image_cmpt_destroy(cmpt);
-		return 0;
-	}
-
-	/* Zero the component data.  This isn't necessary, but it is
-	convenient for debugging purposes. */
-	if (jas_stream_seek(cmpt->stream_, size - 1, SEEK_SET) < 0 ||
-	  jas_stream_putc(cmpt->stream_, 0) == EOF ||
-	  jas_stream_seek(cmpt->stream_, 0, SEEK_SET) < 0) {
-		jas_image_cmpt_destroy(cmpt);
-		return 0;
-	}
-
-	return cmpt;
+        jas_image_cmpt_t *cmpt;
+        long size;
+
+        if (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) {
+                return 0;
+        }
+
+        cmpt->tlx_ = tlx;
+        cmpt->tly_ = tly;
+        cmpt->hstep_ = hstep;
+        cmpt->vstep_ = vstep;
+        cmpt->width_ = width;
+        cmpt->height_ = height;
+        cmpt->prec_ = depth;
+        cmpt->sgnd_ = sgnd;
+        cmpt->stream_ = 0;
+        cmpt->cps_ = (depth + 7) / 8;
+
+        size = cmpt->width_ * cmpt->height_ * cmpt->cps_;
+        cmpt->stream_ = (inmem) ? jas_stream_memopen(0, size) : jas_stream_tmpfile();
+        if (!cmpt->stream_) {
+                jas_image_cmpt_destroy(cmpt);
+                return 0;
+        }
+
+        /* Zero the component data.  This isn't necessary, but it is
+        convenient for debugging purposes. */
+        if (jas_stream_seek(cmpt->stream_, size - 1, SEEK_SET) < 0 ||
+          jas_stream_putc(cmpt->stream_, 0) == EOF ||
+          jas_stream_seek(cmpt->stream_, 0, SEEK_SET) < 0) {
+                jas_image_cmpt_destroy(cmpt);
+                return 0;
+        }
+
+        return cmpt;
 }
 
 static void jas_image_cmpt_destroy(jas_image_cmpt_t *cmpt)
 {
-	if (cmpt->stream_) {
-		jas_stream_close(cmpt->stream_);
-	}
-	jas_free(cmpt);
+        if (cmpt->stream_) {
+                jas_stream_close(cmpt->stream_);
+        }
+        jas_free(cmpt);
 }
 
 /*****************************************************************************\
@@ -383,53 +383,53 @@ static void jas_image_cmpt_destroy(jas_image_cmpt_t *cmpt)
 
 void
 pmjas_image_decode(jas_stream_t * const in,
-				   int            const fmtArg,
-				   const char *   const optstr,
-				   jas_image_t ** const imagePP,
-				   const char **  const errorP) {
+                                   int            const fmtArg,
+                                   const char *   const optstr,
+                                   jas_image_t ** const imagePP,
+                                   const char **  const errorP) {
 /*----------------------------------------------------------------------------
   Create an image from a stream in some specified format
 -----------------------------------------------------------------------------*/
-	jas_image_fmtinfo_t *fmtinfo;
-	int fmt;
-
-	/* If possible, try to determine the format of the input data. */
-	if (fmtArg < 0) {
-		if ((fmt = jas_image_getfmt(in)) < 0) {
-			pm_asprintf(errorP, "jas_image_getfmt failed");
-			return;
-		}
-	} else
-		fmt = fmtArg;
-
-	if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
-		pm_asprintf(errorP, "jas_image_lookupfmtbyid of format %d failed",
-					fmt);
-		return;
-	}
-	{
-		const char * error;
-
-		(*fmtinfo->ops.decode)(in, optstr, imagePP, &error);
-		if (error) {
-			pm_asprintf(errorP, "decoder failed.  %s", error);
-			pm_strfree(error);
-		} else {
-			*errorP = NULL;
-		}
-	}
+        jas_image_fmtinfo_t *fmtinfo;
+        int fmt;
+
+        /* If possible, try to determine the format of the input data. */
+        if (fmtArg < 0) {
+                if ((fmt = jas_image_getfmt(in)) < 0) {
+                        pm_asprintf(errorP, "jas_image_getfmt failed");
+                        return;
+                }
+        } else
+                fmt = fmtArg;
+
+        if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
+                pm_asprintf(errorP, "jas_image_lookupfmtbyid of format %d failed",
+                                        fmt);
+                return;
+        }
+        {
+                const char * error;
+
+                (*fmtinfo->ops.decode)(in, optstr, imagePP, &error);
+                if (error) {
+                        pm_asprintf(errorP, "decoder failed.  %s", error);
+                        pm_strfree(error);
+                } else {
+                        *errorP = NULL;
+                }
+        }
 }
 
 
 
 int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt, char *optstr)
 {
-	jas_image_fmtinfo_t *fmtinfo;
-	if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
-		return -1;
-	}
-	return (fmtinfo->ops.encode) ? (*fmtinfo->ops.encode)(image, out,
-	  optstr) : (-1);
+        jas_image_fmtinfo_t *fmtinfo;
+        if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
+                return -1;
+        }
+        return (fmtinfo->ops.encode) ? (*fmtinfo->ops.encode)(image, out,
+          optstr) : (-1);
 }
 
 /******************************************************************************\
@@ -439,137 +439,137 @@ int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt, char *optst
 int jas_image_readcmpt(jas_image_t *image, uint_fast16_t cmptno, uint_fast32_t x, uint_fast32_t y, uint_fast32_t width,
   uint_fast32_t height, jas_matrix_t *data)
 {
-	jas_image_cmpt_t *cmpt;
-	uint_fast32_t i;
-	uint_fast32_t j;
-	int k;
-	jas_seqent_t v;
-	int c;
-	jas_seqent_t *dr;
-	jas_seqent_t *d;
-	int drs;
-
-	if (cmptno >= image->numcmpts_) {
-		return -1;
-	}
-
-	cmpt = image->cmpts_[cmptno];
-	if (x >= cmpt->width_ || y >= cmpt->height_ ||
-	  x + width > cmpt->width_ ||
-	  y + height > cmpt->height_) {
-		return -1;
-	}
-
-	if (jas_matrix_numrows(data) != height || jas_matrix_numcols(data) != width) {
-		if (jas_matrix_resize(data, height, width)) {
-			return -1;
-		}
-	}
-
-	dr = jas_matrix_getref(data, 0, 0);
-	drs = jas_matrix_rowstep(data);
-	for (i = 0; i < height; ++i, dr += drs) {
-		d = dr;
-		if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x)
-		  * cmpt->cps_, SEEK_SET) < 0) {
-			return -1;
-		}
-		for (j = width; j > 0; --j, ++d) {
-			v = 0;
-			for (k = cmpt->cps_; k > 0; --k) {
-				if ((c = jas_stream_getc(cmpt->stream_)) == EOF) {
-					return -1;
-				}
-				v = (v << 8) | (c & 0xff);
-			}
-			*d = bitstoint(v, cmpt->prec_, cmpt->sgnd_);
-		}
-	}
-
-	return 0;
+        jas_image_cmpt_t *cmpt;
+        uint_fast32_t i;
+        uint_fast32_t j;
+        int k;
+        jas_seqent_t v;
+        int c;
+        jas_seqent_t *dr;
+        jas_seqent_t *d;
+        int drs;
+
+        if (cmptno >= image->numcmpts_) {
+                return -1;
+        }
+
+        cmpt = image->cmpts_[cmptno];
+        if (x >= cmpt->width_ || y >= cmpt->height_ ||
+          x + width > cmpt->width_ ||
+          y + height > cmpt->height_) {
+                return -1;
+        }
+
+        if (jas_matrix_numrows(data) != height || jas_matrix_numcols(data) != width) {
+                if (jas_matrix_resize(data, height, width)) {
+                        return -1;
+                }
+        }
+
+        dr = jas_matrix_getref(data, 0, 0);
+        drs = jas_matrix_rowstep(data);
+        for (i = 0; i < height; ++i, dr += drs) {
+                d = dr;
+                if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x)
+                  * cmpt->cps_, SEEK_SET) < 0) {
+                        return -1;
+                }
+                for (j = width; j > 0; --j, ++d) {
+                        v = 0;
+                        for (k = cmpt->cps_; k > 0; --k) {
+                                if ((c = jas_stream_getc(cmpt->stream_)) == EOF) {
+                                        return -1;
+                                }
+                                v = (v << 8) | (c & 0xff);
+                        }
+                        *d = bitstoint(v, cmpt->prec_, cmpt->sgnd_);
+                }
+        }
+
+        return 0;
 }
 
 #if 0
 int_fast64_t jas_image_readcmpt1(jas_image_t *image, uint_fast16_t cmptno,
   uint_fast32_t x, uint_fast32_t y)
 {
-	jas_image_cmpt_t *cmpt;
-	int k;
-	int c;
-	int_fast64_t v;
-	cmpt = image->cmpts_[cmptno];
-	if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
-	  SEEK_SET) < 0) {
-		goto error;
-	}
-	v = 0;
-	for (k = cmpt->cps_; k > 0; --k) {
-		if ((c = jas_stream_getc(cmpt->stream_)) == EOF) {
-			goto error;
-		}
-		v = (v << 8) | (c & 0xff);
-	}
+        jas_image_cmpt_t *cmpt;
+        int k;
+        int c;
+        int_fast64_t v;
+        cmpt = image->cmpts_[cmptno];
+        if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
+          SEEK_SET) < 0) {
+                goto error;
+        }
+        v = 0;
+        for (k = cmpt->cps_; k > 0; --k) {
+                if ((c = jas_stream_getc(cmpt->stream_)) == EOF) {
+                        goto error;
+                }
+                v = (v << 8) | (c & 0xff);
+        }
 if (cmpt->sgnd_) {
-	abort();
+        abort();
 }
 
-	return v;
+        return v;
 
 error:
-	return 0;
+        return 0;
 }
 #endif
 
 int jas_image_writecmpt(jas_image_t *image, uint_fast16_t cmptno, uint_fast32_t x, uint_fast32_t y, uint_fast32_t width,
   uint_fast32_t height, jas_matrix_t *data)
 {
-	jas_image_cmpt_t *cmpt;
-	uint_fast32_t i;
-	uint_fast32_t j;
-	jas_seqent_t *d;
-	jas_seqent_t *dr;
-	int drs;
-	jas_seqent_t v;
-	int k;
-	int c;
-
-	if (cmptno >= image->numcmpts_) {
-		return -1;
-	}
-
-	cmpt = image->cmpts_[cmptno];
-	if (x >= cmpt->width_ || y >= cmpt->height_ ||
-	  x + width > cmpt->width_ ||
-	  y + height > cmpt->height_) {
-		return -1;
-	}
-
-	if (jas_matrix_numrows(data) != height || jas_matrix_numcols(data) != width) {
-		return -1;
-	}
-
-	dr = jas_matrix_getref(data, 0, 0);
-	drs = jas_matrix_rowstep(data);
-	for (i = 0; i < height; ++i, dr += drs) {
-		d = dr;
-		if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x)
-		  * cmpt->cps_, SEEK_SET) < 0) {
-			return -1;
-		}
-		for (j = width; j > 0; --j, ++d) {
-			v = inttobits(*d, cmpt->prec_, cmpt->sgnd_);
-			for (k = cmpt->cps_; k > 0; --k) {
-				c = (v >> (8 * (cmpt->cps_ - 1))) & 0xff;
-				if (jas_stream_putc(cmpt->stream_,
-				  (unsigned char) c) == EOF) {
-					return -1;
-				}
-				v <<= 8;
-			}
-		}
-	}
-
-	return 0;
+        jas_image_cmpt_t *cmpt;
+        uint_fast32_t i;
+        uint_fast32_t j;
+        jas_seqent_t *d;
+        jas_seqent_t *dr;
+        int drs;
+        jas_seqent_t v;
+        int k;
+        int c;
+
+        if (cmptno >= image->numcmpts_) {
+                return -1;
+        }
+
+        cmpt = image->cmpts_[cmptno];
+        if (x >= cmpt->width_ || y >= cmpt->height_ ||
+          x + width > cmpt->width_ ||
+          y + height > cmpt->height_) {
+                return -1;
+        }
+
+        if (jas_matrix_numrows(data) != height || jas_matrix_numcols(data) != width) {
+                return -1;
+        }
+
+        dr = jas_matrix_getref(data, 0, 0);
+        drs = jas_matrix_rowstep(data);
+        for (i = 0; i < height; ++i, dr += drs) {
+                d = dr;
+                if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x)
+                  * cmpt->cps_, SEEK_SET) < 0) {
+                        return -1;
+                }
+                for (j = width; j > 0; --j, ++d) {
+                        v = inttobits(*d, cmpt->prec_, cmpt->sgnd_);
+                        for (k = cmpt->cps_; k > 0; --k) {
+                                c = (v >> (8 * (cmpt->cps_ - 1))) & 0xff;
+                                if (jas_stream_putc(cmpt->stream_,
+                                  (unsigned char) c) == EOF) {
+                                        return -1;
+                                }
+                                v <<= 8;
+                        }
+                }
+        }
+
+        return 0;
 }
 
 /******************************************************************************\
@@ -578,112 +578,112 @@ int jas_image_writecmpt(jas_image_t *image, uint_fast16_t cmptno, uint_fast32_t
 
 void jas_image_clearfmts()
 {
-	int i;
-	jas_image_fmtinfo_t *fmtinfo;
-	for (i = 0; i < jas_image_numfmts; ++i) {
-		fmtinfo = &jas_image_fmtinfos[i];
-		if (fmtinfo->name) {
-			jas_free(fmtinfo->name);
-			fmtinfo->name = 0;
-		}
-		if (fmtinfo->ext) {
-			jas_free(fmtinfo->ext);
-			fmtinfo->ext = 0;
-		}
-		if (fmtinfo->desc) {
-			jas_free(fmtinfo->desc);
-			fmtinfo->desc = 0;
-		}
-	}
-	jas_image_numfmts = 0;
-}
-
-int jas_image_addfmt(int id, const char *name, const char *ext, 
+        int i;
+        jas_image_fmtinfo_t *fmtinfo;
+        for (i = 0; i < jas_image_numfmts; ++i) {
+                fmtinfo = &jas_image_fmtinfos[i];
+                if (fmtinfo->name) {
+                        jas_free(fmtinfo->name);
+                        fmtinfo->name = 0;
+                }
+                if (fmtinfo->ext) {
+                        jas_free(fmtinfo->ext);
+                        fmtinfo->ext = 0;
+                }
+                if (fmtinfo->desc) {
+                        jas_free(fmtinfo->desc);
+                        fmtinfo->desc = 0;
+                }
+        }
+        jas_image_numfmts = 0;
+}
+
+int jas_image_addfmt(int id, const char *name, const char *ext,
   const char *desc,
   jas_image_fmtops_t *ops)
 {
-	jas_image_fmtinfo_t *fmtinfo;
-	assert(id >= 0 && name && ext && ops);
-	if (jas_image_numfmts >= JAS_IMAGE_MAXFMTS) {
-		return -1;
-	}
-	fmtinfo = &jas_image_fmtinfos[jas_image_numfmts];
-	fmtinfo->id = id;
-	if (!(fmtinfo->name = jas_strdup(name))) {
-		return -1;
-	}
-	if (!(fmtinfo->ext = jas_strdup(ext))) {
-		jas_free(fmtinfo->name);
-		return -1;
-	}
-	if (!(fmtinfo->desc = jas_strdup(desc))) {
-		jas_free(fmtinfo->name);
-		jas_free(fmtinfo->ext);
-		return -1;
-	}
-	fmtinfo->ops = *ops;
-	++jas_image_numfmts;
-	return 0;
+        jas_image_fmtinfo_t *fmtinfo;
+        assert(id >= 0 && name && ext && ops);
+        if (jas_image_numfmts >= JAS_IMAGE_MAXFMTS) {
+                return -1;
+        }
+        fmtinfo = &jas_image_fmtinfos[jas_image_numfmts];
+        fmtinfo->id = id;
+        if (!(fmtinfo->name = jas_strdup(name))) {
+                return -1;
+        }
+        if (!(fmtinfo->ext = jas_strdup(ext))) {
+                jas_free(fmtinfo->name);
+                return -1;
+        }
+        if (!(fmtinfo->desc = jas_strdup(desc))) {
+                jas_free(fmtinfo->name);
+                jas_free(fmtinfo->ext);
+                return -1;
+        }
+        fmtinfo->ops = *ops;
+        ++jas_image_numfmts;
+        return 0;
 }
 
 int jas_image_strtofmt(char *name)
 {
-	jas_image_fmtinfo_t *fmtinfo;
-	if (!(fmtinfo = jas_image_lookupfmtbyname(name))) {
-		return -1;
-	}
-	return fmtinfo->id;
+        jas_image_fmtinfo_t *fmtinfo;
+        if (!(fmtinfo = jas_image_lookupfmtbyname(name))) {
+                return -1;
+        }
+        return fmtinfo->id;
 }
 
 char *jas_image_fmttostr(int fmt)
 {
-	jas_image_fmtinfo_t *fmtinfo;
-	if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
-		return 0;
-	}
-	return fmtinfo->name;
+        jas_image_fmtinfo_t *fmtinfo;
+        if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
+                return 0;
+        }
+        return fmtinfo->name;
 }
 
 int jas_image_getfmt(jas_stream_t *in)
 {
-	jas_image_fmtinfo_t *fmtinfo;
-	int found;
-	int i;
-
-	/* Check for data in each of the formats we know. */
-	found = 0;
-	for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i,
-	  ++fmtinfo) {
-		if (fmtinfo->ops.validate) {
-			/* Is the input data valid for this format? */
-			if (!(*fmtinfo->ops.validate)(in)) {
-				found = 1;
-				break;
-			}
-		}
-	}
-	return found ? fmtinfo->id : (-1);
+        jas_image_fmtinfo_t *fmtinfo;
+        int found;
+        int i;
+
+        /* Check for data in each of the formats we know. */
+        found = 0;
+        for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i,
+          ++fmtinfo) {
+                if (fmtinfo->ops.validate) {
+                        /* Is the input data valid for this format? */
+                        if (!(*fmtinfo->ops.validate)(in)) {
+                                found = 1;
+                                break;
+                        }
+                }
+        }
+        return found ? fmtinfo->id : (-1);
 }
 
 int jas_image_fmtfromname(char *name)
 {
-	int i;
-	char *ext;
-	jas_image_fmtinfo_t *fmtinfo;
-	/* Get the file name extension. */
-	if (!(ext = strrchr(name, '.'))) {
-		return -1;
-	}
-	++ext;
-	/* Try to find a format that uses this extension. */
-	for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i,
-	  ++fmtinfo) {
-		/* Do we have a match? */
-		if (!strcmp(ext, fmtinfo->ext)) {
-			return fmtinfo->id;
-		}
-	}
-	return -1;
+        int i;
+        char *ext;
+        jas_image_fmtinfo_t *fmtinfo;
+        /* Get the file name extension. */
+        if (!(ext = strrchr(name, '.'))) {
+                return -1;
+        }
+        ++ext;
+        /* Try to find a format that uses this extension. */
+        for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i,
+          ++fmtinfo) {
+                /* Do we have a match? */
+                if (!strcmp(ext, fmtinfo->ext)) {
+                        return fmtinfo->id;
+                }
+        }
+        return -1;
 }
 
 /*****************************************************************************\
@@ -710,71 +710,71 @@ jas_image_rawsize(jas_image_t * const imageP) {
 
 void jas_image_delcmpt(jas_image_t *image, uint_fast16_t cmptno)
 {
-	if (cmptno >= image->numcmpts_) {
-		return;
-	}
-	jas_image_cmpt_destroy(image->cmpts_[cmptno]);
-	if (cmptno < image->numcmpts_) {
-		memmove(&image->cmpts_[cmptno], &image->cmpts_[cmptno + 1],
-		  (image->numcmpts_ - 1 - cmptno) * sizeof(jas_image_cmpt_t *));
-	}
-	--image->numcmpts_;
+        if (cmptno >= image->numcmpts_) {
+                return;
+        }
+        jas_image_cmpt_destroy(image->cmpts_[cmptno]);
+        if (cmptno < image->numcmpts_) {
+                memmove(&image->cmpts_[cmptno], &image->cmpts_[cmptno + 1],
+                  (image->numcmpts_ - 1 - cmptno) * sizeof(jas_image_cmpt_t *));
+        }
+        --image->numcmpts_;
 
-	jas_image_setbbox(image);
+        jas_image_setbbox(image);
 }
 
 int jas_image_addcmpt(jas_image_t *image, uint_fast16_t cmptno,
   jas_image_cmptparm_t *cmptparm)
 {
-	jas_image_cmpt_t *newcmpt;
-	assert(cmptno <= image->numcmpts_);
-	if (image->numcmpts_ >= image->maxcmpts_) {
-		if (jas_image_growcmpts(image, image->maxcmpts_ + 128)) {
-			return -1;
-		}
-	}
-	if (!(newcmpt = jas_image_cmpt_create(cmptparm->tlx,
-	  cmptparm->tly, cmptparm->hstep, cmptparm->vstep,
-	  cmptparm->width, cmptparm->height, cmptparm->prec,
-	  cmptparm->sgnd, 1))) {
-		return -1;
-	}
-	if (cmptno < image->numcmpts_) {
-		memmove(&image->cmpts_[cmptno + 1], &image->cmpts_[cmptno],
-		  (image->numcmpts_ - cmptno) * sizeof(jas_image_cmpt_t *));
-	}
-	image->cmpts_[cmptno] = newcmpt;
-	++image->numcmpts_;
-
-	jas_image_setbbox(image);
-
-	return 0;
+        jas_image_cmpt_t *newcmpt;
+        assert(cmptno <= image->numcmpts_);
+        if (image->numcmpts_ >= image->maxcmpts_) {
+                if (jas_image_growcmpts(image, image->maxcmpts_ + 128)) {
+                        return -1;
+                }
+        }
+        if (!(newcmpt = jas_image_cmpt_create(cmptparm->tlx,
+          cmptparm->tly, cmptparm->hstep, cmptparm->vstep,
+          cmptparm->width, cmptparm->height, cmptparm->prec,
+          cmptparm->sgnd, 1))) {
+                return -1;
+        }
+        if (cmptno < image->numcmpts_) {
+                memmove(&image->cmpts_[cmptno + 1], &image->cmpts_[cmptno],
+                  (image->numcmpts_ - cmptno) * sizeof(jas_image_cmpt_t *));
+        }
+        image->cmpts_[cmptno] = newcmpt;
+        ++image->numcmpts_;
+
+        jas_image_setbbox(image);
+
+        return 0;
 }
 
 jas_image_fmtinfo_t *jas_image_lookupfmtbyid(int id)
 {
-	int i;
-	jas_image_fmtinfo_t *fmtinfo;
+        int i;
+        jas_image_fmtinfo_t *fmtinfo;
 
-	for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i, ++fmtinfo) {
-		if (fmtinfo->id == id) {
-			return fmtinfo;
-		}
-	}
-	return 0;
+        for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i, ++fmtinfo) {
+                if (fmtinfo->id == id) {
+                        return fmtinfo;
+                }
+        }
+        return 0;
 }
 
 jas_image_fmtinfo_t *jas_image_lookupfmtbyname(const char *name)
 {
-	int i;
-	jas_image_fmtinfo_t *fmtinfo;
+        int i;
+        jas_image_fmtinfo_t *fmtinfo;
 
-	for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i, ++fmtinfo) {
-		if (!strcmp(fmtinfo->name, name)) {
-			return fmtinfo;
-		}
-	}
-	return 0;
+        for (i = 0, fmtinfo = jas_image_fmtinfos; i < jas_image_numfmts; ++i, ++fmtinfo) {
+                if (!strcmp(fmtinfo->name, name)) {
+                        return fmtinfo;
+                }
+        }
+        return 0;
 }
 
 
@@ -783,220 +783,220 @@ jas_image_fmtinfo_t *jas_image_lookupfmtbyname(const char *name)
 
 static uint_fast32_t inttobits(jas_seqent_t v, int prec, bool sgnd)
 {
-	uint_fast32_t ret;
-	ret = ((sgnd && v < 0) ? ((1 << prec) + v) : v) & JAS_ONES(prec);
-	return ret;
+        uint_fast32_t ret;
+        ret = ((sgnd && v < 0) ? ((1 << prec) + v) : v) & JAS_ONES(prec);
+        return ret;
 }
 
 static jas_seqent_t bitstoint(uint_fast32_t v, int prec, bool sgnd)
 {
-	jas_seqent_t ret;
-	v &= JAS_ONES(prec);
-	ret = (sgnd && (v & (1 << (prec - 1)))) ? (v - (1 << prec)) : v;
-	return ret;
+        jas_seqent_t ret;
+        v &= JAS_ONES(prec);
+        ret = (sgnd && (v & (1 << (prec - 1)))) ? (v - (1 << prec)) : v;
+        return ret;
 }
 
 static void jas_image_setbbox(jas_image_t *image)
 {
-	jas_image_cmpt_t *cmpt;
-	int cmptno;
-	int_fast32_t x;
-	int_fast32_t y;
-
-	if (image->numcmpts_ > 0) {
-		/* Determine the bounding box for all of the components on the
-		  reference grid (i.e., the image area) */
-		cmpt = image->cmpts_[0];
-		image->tlx_ = cmpt->tlx_;
-		image->tly_ = cmpt->tly_;
-		image->brx_ = cmpt->tlx_ + cmpt->hstep_ * (cmpt->width_ - 1) + 1;
-		image->bry_ = cmpt->tly_ + cmpt->vstep_ * (cmpt->height_ - 1) + 1;
-		for (cmptno = 1; cmptno < image->numcmpts_; ++cmptno) {
-			cmpt = image->cmpts_[cmptno];
-			if (image->tlx_ > cmpt->tlx_) {
-				image->tlx_ = cmpt->tlx_;
-			}
-			if (image->tly_ > cmpt->tly_) {
-				image->tly_ = cmpt->tly_;
-			}
-			x = cmpt->tlx_ + cmpt->hstep_ * (cmpt->width_ - 1) + 1;
-			if (image->brx_ < x) {
-				image->brx_ = x;
-			}
-			y = cmpt->tly_ + cmpt->vstep_ * (cmpt->height_ - 1) + 1;
-			if (image->bry_ < y) {
-				image->bry_ = y;
-			}
-		}
-	} else {
-		image->tlx_ = 0;
-		image->tly_ = 0;
-		image->brx_ = 0;
-		image->bry_ = 0;
-	}
+        jas_image_cmpt_t *cmpt;
+        int cmptno;
+        int_fast32_t x;
+        int_fast32_t y;
+
+        if (image->numcmpts_ > 0) {
+                /* Determine the bounding box for all of the components on the
+                  reference grid (i.e., the image area) */
+                cmpt = image->cmpts_[0];
+                image->tlx_ = cmpt->tlx_;
+                image->tly_ = cmpt->tly_;
+                image->brx_ = cmpt->tlx_ + cmpt->hstep_ * (cmpt->width_ - 1) + 1;
+                image->bry_ = cmpt->tly_ + cmpt->vstep_ * (cmpt->height_ - 1) + 1;
+                for (cmptno = 1; cmptno < image->numcmpts_; ++cmptno) {
+                        cmpt = image->cmpts_[cmptno];
+                        if (image->tlx_ > cmpt->tlx_) {
+                                image->tlx_ = cmpt->tlx_;
+                        }
+                        if (image->tly_ > cmpt->tly_) {
+                                image->tly_ = cmpt->tly_;
+                        }
+                        x = cmpt->tlx_ + cmpt->hstep_ * (cmpt->width_ - 1) + 1;
+                        if (image->brx_ < x) {
+                                image->brx_ = x;
+                        }
+                        y = cmpt->tly_ + cmpt->vstep_ * (cmpt->height_ - 1) + 1;
+                        if (image->bry_ < y) {
+                                image->bry_ = y;
+                        }
+                }
+        } else {
+                image->tlx_ = 0;
+                image->tly_ = 0;
+                image->brx_ = 0;
+                image->bry_ = 0;
+        }
 }
 
 static int jas_image_growcmpts(jas_image_t *image, int maxcmpts)
 {
-	jas_image_cmpt_t **newcmpts;
-	int cmptno;
+        jas_image_cmpt_t **newcmpts;
+        int cmptno;
 
-	newcmpts = (!image->cmpts_) ? jas_malloc(maxcmpts * sizeof(jas_image_cmpt_t *)) :
-	  jas_realloc(image->cmpts_, maxcmpts * sizeof(jas_image_cmpt_t *));
-	if (!newcmpts) {
-		return -1;
-	}
-	image->cmpts_ = newcmpts;
-	image->maxcmpts_ = maxcmpts;
-	for (cmptno = image->numcmpts_; cmptno < image->maxcmpts_; ++cmptno) {
-		image->cmpts_[cmptno] = 0;
-	}
-	return 0;
+        newcmpts = (!image->cmpts_) ? jas_malloc(maxcmpts * sizeof(jas_image_cmpt_t *)) :
+          jas_realloc(image->cmpts_, maxcmpts * sizeof(jas_image_cmpt_t *));
+        if (!newcmpts) {
+                return -1;
+        }
+        image->cmpts_ = newcmpts;
+        image->maxcmpts_ = maxcmpts;
+        for (cmptno = image->numcmpts_; cmptno < image->maxcmpts_; ++cmptno) {
+                image->cmpts_[cmptno] = 0;
+        }
+        return 0;
 }
 
 int jas_image_copycmpt(jas_image_t *dstimage, int dstcmptno, jas_image_t *srcimage,
   int srccmptno)
 {
-	jas_image_cmpt_t *newcmpt;
-	if (dstimage->numcmpts_ >= dstimage->maxcmpts_) {
-		if (jas_image_growcmpts(dstimage, dstimage->maxcmpts_ + 128)) {
-			return -1;
-		}
-	}
-	if (!(newcmpt = jas_image_cmpt_copy(srcimage->cmpts_[srccmptno]))) {
-		return -1;
-	}
-	if (dstcmptno < dstimage->numcmpts_) {
-		memmove(&dstimage->cmpts_[dstcmptno + 1], &dstimage->cmpts_[dstcmptno],
-		  (dstimage->numcmpts_ - dstcmptno) * sizeof(jas_image_cmpt_t *));
-	}
-	dstimage->cmpts_[dstcmptno] = newcmpt;
-	++dstimage->numcmpts_;
-
-	jas_image_setbbox(dstimage);
-	return 0;
+        jas_image_cmpt_t *newcmpt;
+        if (dstimage->numcmpts_ >= dstimage->maxcmpts_) {
+                if (jas_image_growcmpts(dstimage, dstimage->maxcmpts_ + 128)) {
+                        return -1;
+                }
+        }
+        if (!(newcmpt = jas_image_cmpt_copy(srcimage->cmpts_[srccmptno]))) {
+                return -1;
+        }
+        if (dstcmptno < dstimage->numcmpts_) {
+                memmove(&dstimage->cmpts_[dstcmptno + 1], &dstimage->cmpts_[dstcmptno],
+                  (dstimage->numcmpts_ - dstcmptno) * sizeof(jas_image_cmpt_t *));
+        }
+        dstimage->cmpts_[dstcmptno] = newcmpt;
+        ++dstimage->numcmpts_;
+
+        jas_image_setbbox(dstimage);
+        return 0;
 }
 
 void jas_image_dump(jas_image_t *image, FILE *out)
 {
-	int cmptno;
-	jas_seq2d_t *data;
-	jas_image_cmpt_t *cmpt;
-	if (!(data = jas_seq2d_create(0, 0, 1, 1))) {
-		abort();
-	}
-	for (cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
-		cmpt = image->cmpts_[cmptno];
-		fprintf(out, "prec=%d sgnd=%d\n", (int)cmpt->prec_, cmpt->sgnd_);
-		if (jas_image_readcmpt(image, cmptno, 0, 0, 1, 1, data)) {
-			abort();
-		}
-		fprintf(out, "tlsample %ld\n", (long) jas_seq2d_get(data, 0, 0));
-	}
-	jas_seq2d_destroy(data);
+        int cmptno;
+        jas_seq2d_t *data;
+        jas_image_cmpt_t *cmpt;
+        if (!(data = jas_seq2d_create(0, 0, 1, 1))) {
+                abort();
+        }
+        for (cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
+                cmpt = image->cmpts_[cmptno];
+                fprintf(out, "prec=%d sgnd=%d\n", (int)cmpt->prec_, cmpt->sgnd_);
+                if (jas_image_readcmpt(image, cmptno, 0, 0, 1, 1, data)) {
+                        abort();
+                }
+                fprintf(out, "tlsample %ld\n", (long) jas_seq2d_get(data, 0, 0));
+        }
+        jas_seq2d_destroy(data);
 }
 
 int jas_image_depalettize(jas_image_t *image, int cmptno, int numlutents,
   int_fast32_t *lutents, int dtype, int newcmptno)
 {
-	jas_image_cmptparm_t cmptparms;
-	int_fast32_t v;
-	int i;
-	int j;
-	jas_image_cmpt_t *cmpt;
-
-	cmpt = image->cmpts_[cmptno];
-	cmptparms.tlx = cmpt->tlx_;
-	cmptparms.tly = cmpt->tly_;
-	cmptparms.hstep = cmpt->hstep_;
-	cmptparms.vstep = cmpt->vstep_;
-	cmptparms.width = cmpt->width_;
-	cmptparms.height = cmpt->height_;
-	cmptparms.prec = JAS_IMAGE_CDT_GETPREC(dtype);
-	cmptparms.sgnd = JAS_IMAGE_CDT_GETSGND(dtype);
-
-	if (numlutents < 1) {
-		return -1;
-	}
-
-	if (jas_image_addcmpt(image, newcmptno, &cmptparms)) {
-		return -1;
-	}
-	if (newcmptno <= cmptno) {
-		++cmptno;
-		cmpt = image->cmpts_[cmptno];
-	}
-
-	for (j = 0; j < cmpt->height_; ++j) {
-		for (i = 0; i < cmpt->width_; ++i) {
-			v = jas_image_readcmptsample(image, cmptno, i, j);
-			if (v < 0) {
-				v = 0;
-			} else if (v >= numlutents) {
-				v = numlutents - 1;
-			}
-			jas_image_writecmptsample(image, newcmptno, i, j,
-			  lutents[v]);
-		}
-	}
-	return 0;
+        jas_image_cmptparm_t cmptparms;
+        int_fast32_t v;
+        int i;
+        int j;
+        jas_image_cmpt_t *cmpt;
+
+        cmpt = image->cmpts_[cmptno];
+        cmptparms.tlx = cmpt->tlx_;
+        cmptparms.tly = cmpt->tly_;
+        cmptparms.hstep = cmpt->hstep_;
+        cmptparms.vstep = cmpt->vstep_;
+        cmptparms.width = cmpt->width_;
+        cmptparms.height = cmpt->height_;
+        cmptparms.prec = JAS_IMAGE_CDT_GETPREC(dtype);
+        cmptparms.sgnd = JAS_IMAGE_CDT_GETSGND(dtype);
+
+        if (numlutents < 1) {
+                return -1;
+        }
+
+        if (jas_image_addcmpt(image, newcmptno, &cmptparms)) {
+                return -1;
+        }
+        if (newcmptno <= cmptno) {
+                ++cmptno;
+                cmpt = image->cmpts_[cmptno];
+        }
+
+        for (j = 0; j < cmpt->height_; ++j) {
+                for (i = 0; i < cmpt->width_; ++i) {
+                        v = jas_image_readcmptsample(image, cmptno, i, j);
+                        if (v < 0) {
+                                v = 0;
+                        } else if (v >= numlutents) {
+                                v = numlutents - 1;
+                        }
+                        jas_image_writecmptsample(image, newcmptno, i, j,
+                          lutents[v]);
+                }
+        }
+        return 0;
 }
 
 int jas_image_readcmptsample(jas_image_t *image, int cmptno, int x, int y)
 {
-	jas_image_cmpt_t *cmpt;
-	uint_fast32_t v;
-	int k;
-	int c;
+        jas_image_cmpt_t *cmpt;
+        uint_fast32_t v;
+        int k;
+        int c;
 
-	cmpt = image->cmpts_[cmptno];
+        cmpt = image->cmpts_[cmptno];
 
-	if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
-	  SEEK_SET) < 0) {
-		return -1;
-	}
-	v = 0;
-	for (k = cmpt->cps_; k > 0; --k) {
-		if ((c = jas_stream_getc(cmpt->stream_)) == EOF) {
-			return -1;
-		}
-		v = (v << 8) | (c & 0xff);
-	}
-	return bitstoint(v, cmpt->prec_, cmpt->sgnd_);
+        if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
+          SEEK_SET) < 0) {
+                return -1;
+        }
+        v = 0;
+        for (k = cmpt->cps_; k > 0; --k) {
+                if ((c = jas_stream_getc(cmpt->stream_)) == EOF) {
+                        return -1;
+                }
+                v = (v << 8) | (c & 0xff);
+        }
+        return bitstoint(v, cmpt->prec_, cmpt->sgnd_);
 }
 
 void jas_image_writecmptsample(jas_image_t *image, int cmptno, int x, int y,
   int_fast32_t v)
 {
-	jas_image_cmpt_t *cmpt;
-	uint_fast32_t t;
-	int k;
-	int c;
+        jas_image_cmpt_t *cmpt;
+        uint_fast32_t t;
+        int k;
+        int c;
 
-	cmpt = image->cmpts_[cmptno];
+        cmpt = image->cmpts_[cmptno];
 
-	if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
-	  SEEK_SET) < 0) {
-		return;
-	}
-	t = inttobits(v, cmpt->prec_, cmpt->sgnd_);
-	for (k = cmpt->cps_; k > 0; --k) {
-		c = (t >> (8 * (cmpt->cps_ - 1))) & 0xff;
-		if (jas_stream_putc(cmpt->stream_, (unsigned char) c) == EOF) {
-			return;
-		}
-		t <<= 8;
-	}
+        if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
+          SEEK_SET) < 0) {
+                return;
+        }
+        t = inttobits(v, cmpt->prec_, cmpt->sgnd_);
+        for (k = cmpt->cps_; k > 0; --k) {
+                c = (t >> (8 * (cmpt->cps_ - 1))) & 0xff;
+                if (jas_stream_putc(cmpt->stream_, (unsigned char) c) == EOF) {
+                        return;
+                }
+                t <<= 8;
+        }
 }
 
 int jas_image_getcmptbytype(jas_image_t *image, int ctype)
 {
-	int cmptno;
+        int cmptno;
 
-	for (cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
-		if (image->cmpts_[cmptno]->type_ == ctype) {
-			return cmptno;
-		}
-	}
+        for (cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
+                if (image->cmpts_[cmptno]->type_ == ctype) {
+                        return cmptno;
+                }
+        }
     return -1;
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_init.c b/converter/other/jpeg2000/libjasper/base/jas_init.c
index c1114bf7..8d79a7fe 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_init.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_init.c
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -123,78 +123,78 @@
 /* Initialize the image format table. */
 int jas_init()
 {
-	jas_image_fmtops_t fmtops;
-	int fmtid;
+        jas_image_fmtops_t fmtops;
+        int fmtid;
 
-	fmtid = 0;
+        fmtid = 0;
 
 #if !defined(EXCLUDE_MIF_SUPPORT)
-	fmtops.decode = mif_decode;
-	fmtops.encode = mif_encode;
-	fmtops.validate = mif_validate;
-	jas_image_addfmt(fmtid, "mif", "mif", "My Image Format (MIF)", &fmtops);
-	++fmtid;
+        fmtops.decode = mif_decode;
+        fmtops.encode = mif_encode;
+        fmtops.validate = mif_validate;
+        jas_image_addfmt(fmtid, "mif", "mif", "My Image Format (MIF)", &fmtops);
+        ++fmtid;
 #endif
 
 #if !defined(EXCLUDE_PNM_SUPPORT)
-	fmtops.decode = pnm_decode;
-	fmtops.encode = pnm_encode;
-	fmtops.validate = pnm_validate;
-	jas_image_addfmt(fmtid, "pnm", "pnm", "Portable Graymap/Pixmap (PNM)",
-	  &fmtops);
-	jas_image_addfmt(fmtid, "pnm", "pgm", "Portable Graymap/Pixmap (PNM)",
-	  &fmtops);
-	jas_image_addfmt(fmtid, "pnm", "ppm", "Portable Graymap/Pixmap (PNM)",
-	  &fmtops);
-	++fmtid;
+        fmtops.decode = pnm_decode;
+        fmtops.encode = pnm_encode;
+        fmtops.validate = pnm_validate;
+        jas_image_addfmt(fmtid, "pnm", "pnm", "Portable Graymap/Pixmap (PNM)",
+          &fmtops);
+        jas_image_addfmt(fmtid, "pnm", "pgm", "Portable Graymap/Pixmap (PNM)",
+          &fmtops);
+        jas_image_addfmt(fmtid, "pnm", "ppm", "Portable Graymap/Pixmap (PNM)",
+          &fmtops);
+        ++fmtid;
 #endif
 
 #if !defined(EXCLUDE_BMP_SUPPORT)
-	fmtops.decode = bmp_decode;
-	fmtops.encode = bmp_encode;
-	fmtops.validate = bmp_validate;
-	jas_image_addfmt(fmtid, "bmp", "bmp", "Microsoft Bitmap (BMP)", &fmtops);
-	++fmtid;
+        fmtops.decode = bmp_decode;
+        fmtops.encode = bmp_encode;
+        fmtops.validate = bmp_validate;
+        jas_image_addfmt(fmtid, "bmp", "bmp", "Microsoft Bitmap (BMP)", &fmtops);
+        ++fmtid;
 #endif
 
 #if !defined(EXCLUDE_RAS_SUPPORT)
-	fmtops.decode = ras_decode;
-	fmtops.encode = ras_encode;
-	fmtops.validate = ras_validate;
-	jas_image_addfmt(fmtid, "ras", "ras", "Sun Rasterfile (RAS)", &fmtops);
-	++fmtid;
+        fmtops.decode = ras_decode;
+        fmtops.encode = ras_encode;
+        fmtops.validate = ras_validate;
+        jas_image_addfmt(fmtid, "ras", "ras", "Sun Rasterfile (RAS)", &fmtops);
+        ++fmtid;
 #endif
 
 #if !defined(EXCLUDE_JP2_SUPPORT)
-	fmtops.decode = jp2_decode;
-	fmtops.encode = jp2_encode;
-	fmtops.validate = jp2_validate;
-	jas_image_addfmt(fmtid, "jp2", "jp2",
-	  "JPEG-2000 JP2 File Format Syntax (ISO/IEC 15444-1)", &fmtops);
-	++fmtid;
-	fmtops.decode = jpc_decode;
-	fmtops.encode = jpc_encode;
-	fmtops.validate = jpc_validate;
-	jas_image_addfmt(fmtid, "jpc", "jpc",
-	  "JPEG-2000 Code Stream Syntax (ISO/IEC 15444-1)", &fmtops);
-	++fmtid;
+        fmtops.decode = jp2_decode;
+        fmtops.encode = jp2_encode;
+        fmtops.validate = jp2_validate;
+        jas_image_addfmt(fmtid, "jp2", "jp2",
+          "JPEG-2000 JP2 File Format Syntax (ISO/IEC 15444-1)", &fmtops);
+        ++fmtid;
+        fmtops.decode = jpc_decode;
+        fmtops.encode = jpc_encode;
+        fmtops.validate = jpc_validate;
+        jas_image_addfmt(fmtid, "jpc", "jpc",
+          "JPEG-2000 Code Stream Syntax (ISO/IEC 15444-1)", &fmtops);
+        ++fmtid;
 #endif
 
 #if !defined(EXCLUDE_JPG_SUPPORT)
-	fmtops.decode = jpg_decode;
-	fmtops.encode = jpg_encode;
-	fmtops.validate = jpg_validate;
-	jas_image_addfmt(fmtid, "jpg", "jpg", "JPEG (ISO/IEC 10918-1)", &fmtops);
-	++fmtid;
+        fmtops.decode = jpg_decode;
+        fmtops.encode = jpg_encode;
+        fmtops.validate = jpg_validate;
+        jas_image_addfmt(fmtid, "jpg", "jpg", "JPEG (ISO/IEC 10918-1)", &fmtops);
+        ++fmtid;
 #endif
 
 #if !defined(EXCLUDE_PGX_SUPPORT)
-	fmtops.decode = pgx_decode;
-	fmtops.encode = pgx_encode;
-	fmtops.validate = pgx_validate;
-	jas_image_addfmt(fmtid, "pgx", "pgx", "JPEG-2000 VM Format (PGX)", &fmtops);
-	++fmtid;
+        fmtops.decode = pgx_decode;
+        fmtops.encode = pgx_encode;
+        fmtops.validate = pgx_validate;
+        jas_image_addfmt(fmtid, "pgx", "pgx", "JPEG-2000 VM Format (PGX)", &fmtops);
+        ++fmtid;
 #endif
 
-	return 0;
+        return 0;
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_malloc.c b/converter/other/jpeg2000/libjasper/base/jas_malloc.c
index 43c4d3cd..a8b85033 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_malloc.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_malloc.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -139,29 +139,29 @@
 
 void *jas_malloc(size_t size)
 {
-	return malloc(size);
+        return malloc(size);
 }
 
 void jas_free(void *ptr)
 {
-	free(ptr);
+        free(ptr);
 }
 
 void *jas_realloc(void *ptr, size_t size)
 {
-	return realloc(ptr, size);
+        return realloc(ptr, size);
 }
 
 void *jas_calloc(size_t nmemb, size_t size)
 {
-	void *ptr;
-	size_t n;
-	n = nmemb * size;
-	if (!(ptr = jas_malloc(n * sizeof(char)))) {
-		return 0;
-	}
-	memset(ptr, 0, n);
-	return ptr;
+        void *ptr;
+        size_t n;
+        n = nmemb * size;
+        if (!(ptr = jas_malloc(n * sizeof(char)))) {
+                return 0;
+        }
+        memset(ptr, 0, n);
+        return ptr;
 }
 
 #endif
diff --git a/converter/other/jpeg2000/libjasper/base/jas_seq.c b/converter/other/jpeg2000/libjasper/base/jas_seq.c
index 12dc1595..5aa2a75f 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_seq.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_seq.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -134,108 +134,108 @@
 
 jas_matrix_t *jas_seq2d_create(int xstart, int ystart, int xend, int yend)
 {
-	jas_matrix_t *matrix;
-	assert(xstart <= xend && ystart <= yend);
-	if (!(matrix = jas_matrix_create(yend - ystart, xend - xstart))) {
-		return 0;
-	}
-	matrix->xstart_ = xstart;
-	matrix->ystart_ = ystart;
-	matrix->xend_ = xend;
-	matrix->yend_ = yend;
-	return matrix;
+        jas_matrix_t *matrix;
+        assert(xstart <= xend && ystart <= yend);
+        if (!(matrix = jas_matrix_create(yend - ystart, xend - xstart))) {
+                return 0;
+        }
+        matrix->xstart_ = xstart;
+        matrix->ystart_ = ystart;
+        matrix->xend_ = xend;
+        matrix->yend_ = yend;
+        return matrix;
 }
 
 jas_matrix_t *jas_matrix_create(int numrows, int numcols)
 {
-	jas_matrix_t *matrix;
-	int i;
-
-	if (!(matrix = jas_malloc(sizeof(jas_matrix_t)))) {
-		return 0;
-	}
-	matrix->flags_ = 0;
-	matrix->numrows_ = numrows;
-	matrix->numcols_ = numcols;
-	matrix->rows_ = 0;
-	matrix->maxrows_ = numrows;
-	matrix->data_ = 0;
-	matrix->datasize_ = numrows * numcols;
-
-	if (matrix->maxrows_ > 0) {
-		if (!(matrix->rows_ = jas_malloc(matrix->maxrows_ *
-		  sizeof(jas_seqent_t *)))) {
-			jas_matrix_destroy(matrix);
-			return 0;
-		}
-	}
-
-	if (matrix->datasize_ > 0) {
-		if (!(matrix->data_ = jas_malloc(matrix->datasize_ *
-		  sizeof(jas_seqent_t)))) {
-			jas_matrix_destroy(matrix);
-			return 0;
-		}
-	}
-
-	for (i = 0; i < numrows; ++i) {
-		matrix->rows_[i] = &matrix->data_[i * matrix->numcols_];
-	}
-
-	for (i = 0; i < matrix->datasize_; ++i) {
-		matrix->data_[i] = 0;
-	}
-
-	matrix->xstart_ = 0;
-	matrix->ystart_ = 0;
-	matrix->xend_ = matrix->numcols_;
-	matrix->yend_ = matrix->numrows_;
-
-	return matrix;
+        jas_matrix_t *matrix;
+        int i;
+
+        if (!(matrix = jas_malloc(sizeof(jas_matrix_t)))) {
+                return 0;
+        }
+        matrix->flags_ = 0;
+        matrix->numrows_ = numrows;
+        matrix->numcols_ = numcols;
+        matrix->rows_ = 0;
+        matrix->maxrows_ = numrows;
+        matrix->data_ = 0;
+        matrix->datasize_ = numrows * numcols;
+
+        if (matrix->maxrows_ > 0) {
+                if (!(matrix->rows_ = jas_malloc(matrix->maxrows_ *
+                  sizeof(jas_seqent_t *)))) {
+                        jas_matrix_destroy(matrix);
+                        return 0;
+                }
+        }
+
+        if (matrix->datasize_ > 0) {
+                if (!(matrix->data_ = jas_malloc(matrix->datasize_ *
+                  sizeof(jas_seqent_t)))) {
+                        jas_matrix_destroy(matrix);
+                        return 0;
+                }
+        }
+
+        for (i = 0; i < numrows; ++i) {
+                matrix->rows_[i] = &matrix->data_[i * matrix->numcols_];
+        }
+
+        for (i = 0; i < matrix->datasize_; ++i) {
+                matrix->data_[i] = 0;
+        }
+
+        matrix->xstart_ = 0;
+        matrix->ystart_ = 0;
+        matrix->xend_ = matrix->numcols_;
+        matrix->yend_ = matrix->numrows_;
+
+        return matrix;
 }
 
 void jas_matrix_destroy(jas_matrix_t *matrix)
 {
-	if (matrix->data_) {
-		assert(!(matrix->flags_ & JAS_MATRIX_REF));
-		jas_free(matrix->data_);
-		matrix->data_ = 0;
-	}
-	if (matrix->rows_) {
-		jas_free(matrix->rows_);
-		matrix->rows_ = 0;
-	}
-	jas_free(matrix);
+        if (matrix->data_) {
+                assert(!(matrix->flags_ & JAS_MATRIX_REF));
+                jas_free(matrix->data_);
+                matrix->data_ = 0;
+        }
+        if (matrix->rows_) {
+                jas_free(matrix->rows_);
+                matrix->rows_ = 0;
+        }
+        jas_free(matrix);
 }
 
 jas_seq2d_t *jas_seq2d_copy(jas_seq2d_t *x)
 {
-	jas_matrix_t *y;
-	int i;
-	int j;
-	y = jas_seq2d_create(jas_seq2d_xstart(x), jas_seq2d_ystart(x), jas_seq2d_xend(x),
-	  jas_seq2d_yend(x));
-	assert(y);
-	for (i = 0; i < x->numrows_; ++i) {
-		for (j = 0; j < x->numcols_; ++j) {
-			*jas_matrix_getref(y, i, j) = jas_matrix_get(x, i, j);
-		}
-	}
-	return y;
+        jas_matrix_t *y;
+        int i;
+        int j;
+        y = jas_seq2d_create(jas_seq2d_xstart(x), jas_seq2d_ystart(x), jas_seq2d_xend(x),
+          jas_seq2d_yend(x));
+        assert(y);
+        for (i = 0; i < x->numrows_; ++i) {
+                for (j = 0; j < x->numcols_; ++j) {
+                        *jas_matrix_getref(y, i, j) = jas_matrix_get(x, i, j);
+                }
+        }
+        return y;
 }
 
 jas_matrix_t *jas_matrix_copy(jas_matrix_t *x)
 {
-	jas_matrix_t *y;
-	int i;
-	int j;
-	y = jas_matrix_create(x->numrows_, x->numcols_);
-	for (i = 0; i < x->numrows_; ++i) {
-		for (j = 0; j < x->numcols_; ++j) {
-			*jas_matrix_getref(y, i, j) = jas_matrix_get(x, i, j);
-		}
-	}
-	return y;
+        jas_matrix_t *y;
+        int i;
+        int j;
+        y = jas_matrix_create(x->numrows_, x->numcols_);
+        for (i = 0; i < x->numrows_; ++i) {
+                for (j = 0; j < x->numcols_; ++j) {
+                        *jas_matrix_getref(y, i, j) = jas_matrix_get(x, i, j);
+                }
+        }
+        return y;
 }
 
 /******************************************************************************\
@@ -245,39 +245,39 @@ jas_matrix_t *jas_matrix_copy(jas_matrix_t *x)
 void jas_seq2d_bindsub(jas_matrix_t *s, jas_matrix_t *s1, int xstart, int ystart,
   int xend, int yend)
 {
-	jas_matrix_bindsub(s, s1, ystart - s1->ystart_, xstart - s1->xstart_,
-	  yend - s1->ystart_ - 1, xend - s1->xstart_ - 1);
+        jas_matrix_bindsub(s, s1, ystart - s1->ystart_, xstart - s1->xstart_,
+          yend - s1->ystart_ - 1, xend - s1->xstart_ - 1);
 }
 
 void jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, int r0, int c0,
   int r1, int c1)
 {
-	int i;
-
-	if (mat0->data_) {
-		if (!(mat0->flags_ & JAS_MATRIX_REF)) {
-			jas_free(mat0->data_);
-		}
-		mat0->data_ = 0;
-		mat0->datasize_ = 0;
-	}
-	if (mat0->rows_) {
-		jas_free(mat0->rows_);
-		mat0->rows_ = 0;
-	}
-	mat0->flags_ |= JAS_MATRIX_REF;
-	mat0->numrows_ = r1 - r0 + 1;
-	mat0->numcols_ = c1 - c0 + 1;
-	mat0->maxrows_ = mat0->numrows_;
-	mat0->rows_ = jas_malloc(mat0->maxrows_ * sizeof(jas_seqent_t *));
-	for (i = 0; i < mat0->numrows_; ++i) {
-		mat0->rows_[i] = mat1->rows_[r0 + i] + c0;
-	}
-
-	mat0->xstart_ = mat1->xstart_ + c0;
-	mat0->ystart_ = mat1->ystart_ + r0;
-	mat0->xend_ = mat0->xstart_ + mat0->numcols_;
-	mat0->yend_ = mat0->ystart_ + mat0->numrows_;
+        int i;
+
+        if (mat0->data_) {
+                if (!(mat0->flags_ & JAS_MATRIX_REF)) {
+                        jas_free(mat0->data_);
+                }
+                mat0->data_ = 0;
+                mat0->datasize_ = 0;
+        }
+        if (mat0->rows_) {
+                jas_free(mat0->rows_);
+                mat0->rows_ = 0;
+        }
+        mat0->flags_ |= JAS_MATRIX_REF;
+        mat0->numrows_ = r1 - r0 + 1;
+        mat0->numcols_ = c1 - c0 + 1;
+        mat0->maxrows_ = mat0->numrows_;
+        mat0->rows_ = jas_malloc(mat0->maxrows_ * sizeof(jas_seqent_t *));
+        for (i = 0; i < mat0->numrows_; ++i) {
+                mat0->rows_[i] = mat1->rows_[r0 + i] + c0;
+        }
+
+        mat0->xstart_ = mat1->xstart_ + c0;
+        mat0->ystart_ = mat1->ystart_ + r0;
+        mat0->xend_ = mat0->xstart_ + mat0->numcols_;
+        mat0->yend_ = mat0->ystart_ + mat0->numrows_;
 }
 
 /******************************************************************************\
@@ -286,102 +286,102 @@ void jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, int r0, int c0,
 
 int jas_matrix_cmp(jas_matrix_t *mat0, jas_matrix_t *mat1)
 {
-	int i;
-	int j;
-
-	if (mat0->numrows_ != mat1->numrows_ || mat0->numcols_ !=
-	  mat1->numcols_) {
-		return 1;
-	}
-	for (i = 0; i < mat0->numrows_; i++) {
-		for (j = 0; j < mat0->numcols_; j++) {
-			if (jas_matrix_get(mat0, i, j) != jas_matrix_get(mat1, i, j)) {
-				return 1;
-			}
-		}
-	}
-	return 0;
+        int i;
+        int j;
+
+        if (mat0->numrows_ != mat1->numrows_ || mat0->numcols_ !=
+          mat1->numcols_) {
+                return 1;
+        }
+        for (i = 0; i < mat0->numrows_; i++) {
+                for (j = 0; j < mat0->numcols_; j++) {
+                        if (jas_matrix_get(mat0, i, j) != jas_matrix_get(mat1, i, j)) {
+                                return 1;
+                        }
+                }
+        }
+        return 0;
 }
 
 void jas_matrix_divpow2(jas_matrix_t *matrix, int n)
 {
-	int i;
-	int j;
-	jas_seqent_t *rowstart;
-	int rowstep;
-	jas_seqent_t *data;
-
-	rowstep = jas_matrix_rowstep(matrix);
-	for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
-	  rowstart += rowstep) {
-		for (j = matrix->numcols_, data = rowstart; j > 0; --j,
-		  ++data) {
-			*data = (*data >= 0) ? ((*data) >> n) :
-			  (-((-(*data)) >> n));
-		}
-	}
+        int i;
+        int j;
+        jas_seqent_t *rowstart;
+        int rowstep;
+        jas_seqent_t *data;
+
+        rowstep = jas_matrix_rowstep(matrix);
+        for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
+          rowstart += rowstep) {
+                for (j = matrix->numcols_, data = rowstart; j > 0; --j,
+                  ++data) {
+                        *data = (*data >= 0) ? ((*data) >> n) :
+                          (-((-(*data)) >> n));
+                }
+        }
 }
 
 void jas_matrix_clip(jas_matrix_t *matrix, jas_seqent_t minval, jas_seqent_t maxval)
 {
-	int i;
-	int j;
-	jas_seqent_t v;
-	jas_seqent_t *rowstart;
-	jas_seqent_t *data;
-	int rowstep;
-
-	rowstep = jas_matrix_rowstep(matrix);
-	for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
-	  rowstart += rowstep) {
-		data = rowstart;
-		for (j = matrix->numcols_, data = rowstart; j > 0; --j,
-		  ++data) {
-			v = *data;
-			if (v < minval) {
-				*data = minval;
-			} else if (v > maxval) {
-				*data = maxval;
-			}
-		}
-	}
+        int i;
+        int j;
+        jas_seqent_t v;
+        jas_seqent_t *rowstart;
+        jas_seqent_t *data;
+        int rowstep;
+
+        rowstep = jas_matrix_rowstep(matrix);
+        for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
+          rowstart += rowstep) {
+                data = rowstart;
+                for (j = matrix->numcols_, data = rowstart; j > 0; --j,
+                  ++data) {
+                        v = *data;
+                        if (v < minval) {
+                                *data = minval;
+                        } else if (v > maxval) {
+                                *data = maxval;
+                        }
+                }
+        }
 }
 
 void jas_matrix_asr(jas_matrix_t *matrix, int n)
 {
-	int i;
-	int j;
-	jas_seqent_t *rowstart;
-	int rowstep;
-	jas_seqent_t *data;
-
-	assert(n >= 0);
-	rowstep = jas_matrix_rowstep(matrix);
-	for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
-	  rowstart += rowstep) {
-		for (j = matrix->numcols_, data = rowstart; j > 0; --j,
-		  ++data) {
-			*data >>= n;
-		}
-	}
+        int i;
+        int j;
+        jas_seqent_t *rowstart;
+        int rowstep;
+        jas_seqent_t *data;
+
+        assert(n >= 0);
+        rowstep = jas_matrix_rowstep(matrix);
+        for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
+          rowstart += rowstep) {
+                for (j = matrix->numcols_, data = rowstart; j > 0; --j,
+                  ++data) {
+                        *data >>= n;
+                }
+        }
 }
 
 void jas_matrix_asl(jas_matrix_t *matrix, int n)
 {
-	int i;
-	int j;
-	jas_seqent_t *rowstart;
-	int rowstep;
-	jas_seqent_t *data;
-
-	rowstep = jas_matrix_rowstep(matrix);
-	for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
-	  rowstart += rowstep) {
-		for (j = matrix->numcols_, data = rowstart; j > 0; --j,
-		  ++data) {
-			*data <<= n;
-		}
-	}
+        int i;
+        int j;
+        jas_seqent_t *rowstart;
+        int rowstep;
+        jas_seqent_t *data;
+
+        rowstep = jas_matrix_rowstep(matrix);
+        for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
+          rowstart += rowstep) {
+                for (j = matrix->numcols_, data = rowstart; j > 0; --j,
+                  ++data) {
+                        *data <<= n;
+                }
+        }
 }
 
 /******************************************************************************\
@@ -390,87 +390,87 @@ void jas_matrix_asl(jas_matrix_t *matrix, int n)
 
 int jas_matrix_resize(jas_matrix_t *matrix, int numrows, int numcols)
 {
-	int size;
-	int i;
+        int size;
+        int i;
 
-	size = numrows * numcols;
-	if (size > matrix->datasize_ || numrows > matrix->maxrows_) {
-		return -1;
-	}
+        size = numrows * numcols;
+        if (size > matrix->datasize_ || numrows > matrix->maxrows_) {
+                return -1;
+        }
 
-	matrix->numrows_ = numrows;
-	matrix->numcols_ = numcols;
+        matrix->numrows_ = numrows;
+        matrix->numcols_ = numcols;
 
-	for (i = 0; i < numrows; ++i) {
-		matrix->rows_[i] = &matrix->data_[numcols * i];
-	}
+        for (i = 0; i < numrows; ++i) {
+                matrix->rows_[i] = &matrix->data_[numcols * i];
+        }
 
-	return 0;
+        return 0;
 }
 
 int jas_matrix_output(jas_matrix_t *matrix, FILE *out)
 {
-	int i;
-	int j;
-	jas_seqent_t x;
+        int i;
+        int j;
+        jas_seqent_t x;
 
-	fprintf(out, "%d %d\n",
+        fprintf(out, "%d %d\n",
             (int)jas_matrix_numrows(matrix), (int)jas_matrix_numcols(matrix));
-	for (i = 0; i < jas_matrix_numrows(matrix); ++i) {
-		for (j = 0; j < jas_matrix_numcols(matrix); ++j) {
-			x = jas_matrix_get(matrix, i, j);
-			fprintf(out, "%ld", JAS_CAST(long, x));
-			if (j < jas_matrix_numcols(matrix) - 1) {
-				fprintf(out, " ");
-			}
-		}
-		fprintf(out, "\n");
-	}
-	return 0;
+        for (i = 0; i < jas_matrix_numrows(matrix); ++i) {
+                for (j = 0; j < jas_matrix_numcols(matrix); ++j) {
+                        x = jas_matrix_get(matrix, i, j);
+                        fprintf(out, "%ld", JAS_CAST(long, x));
+                        if (j < jas_matrix_numcols(matrix) - 1) {
+                                fprintf(out, " ");
+                        }
+                }
+                fprintf(out, "\n");
+        }
+        return 0;
 }
 
 void jas_matrix_setall(jas_matrix_t *matrix, jas_seqent_t val)
 {
-	int i;
-	int j;
-	jas_seqent_t *rowstart;
-	int rowstep;
-	jas_seqent_t *data;
-
-	rowstep = jas_matrix_rowstep(matrix);
-	for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
-	  rowstart += rowstep) {
-		for (j = matrix->numcols_, data = rowstart; j > 0; --j,
-		  ++data) {
-			*data = val;
-		}
-	}
+        int i;
+        int j;
+        jas_seqent_t *rowstart;
+        int rowstep;
+        jas_seqent_t *data;
+
+        rowstep = jas_matrix_rowstep(matrix);
+        for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,
+          rowstart += rowstep) {
+                for (j = matrix->numcols_, data = rowstart; j > 0; --j,
+                  ++data) {
+                        *data = val;
+                }
+        }
 }
 
 jas_matrix_t *jas_matrix_input(FILE *in)
 {
-	jas_matrix_t *matrix;
-	int i;
-	int j;
-	long x;
-	int numrows;
-	int numcols;
-
-	if (fscanf(in, "%d %d", &numrows, &numcols) != 2)
-		return 0;
-	if (!(matrix = jas_matrix_create(numrows, numcols)))
-		return 0;
-
-	/* Get matrix data. */
-	for (i = 0; i < jas_matrix_numrows(matrix); i++) {
-		for (j = 0; j < jas_matrix_numcols(matrix); j++) {
-			if (fscanf(in, "%ld", &x) != 1) {
-				jas_matrix_destroy(matrix);
-				return 0;
-			}
-			jas_matrix_set(matrix, i, j, JAS_CAST(jas_seqent_t, x));
-		}
-	}
-
-	return matrix;
+        jas_matrix_t *matrix;
+        int i;
+        int j;
+        long x;
+        int numrows;
+        int numcols;
+
+        if (fscanf(in, "%d %d", &numrows, &numcols) != 2)
+                return 0;
+        if (!(matrix = jas_matrix_create(numrows, numcols)))
+                return 0;
+
+        /* Get matrix data. */
+        for (i = 0; i < jas_matrix_numrows(matrix); i++) {
+                for (j = 0; j < jas_matrix_numcols(matrix); j++) {
+                        if (fscanf(in, "%ld", &x) != 1) {
+                                jas_matrix_destroy(matrix);
+                                return 0;
+                        }
+                        jas_matrix_set(matrix, i, j, JAS_CAST(jas_seqent_t, x));
+                }
+        }
+
+        return matrix;
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_stream.c b/converter/other/jpeg2000/libjasper/base/jas_stream.c
index a4b3a27c..d5ddcff2 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_stream.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_stream.c
@@ -169,24 +169,24 @@ static int file_close(jas_stream_obj_t *obj);
 \******************************************************************************/
 
 static jas_stream_ops_t jas_stream_fileops = {
-	file_read,
-	file_write,
-	file_seek,
-	file_close
+        file_read,
+        file_write,
+        file_seek,
+        file_close
 };
 
 static jas_stream_ops_t jas_stream_sfileops = {
-	sfile_read,
-	sfile_write,
-	sfile_seek,
-	sfile_close
+        sfile_read,
+        sfile_write,
+        sfile_seek,
+        sfile_close
 };
 
 static jas_stream_ops_t jas_stream_memops = {
-	mem_read,
-	mem_write,
-	mem_seek,
-	mem_close
+        mem_read,
+        mem_write,
+        mem_seek,
+        mem_close
 };
 
 /******************************************************************************\
@@ -195,214 +195,214 @@ static jas_stream_ops_t jas_stream_memops = {
 
 static jas_stream_t *jas_stream_create()
 {
-	jas_stream_t *stream;
-
-	if (!(stream = jas_malloc(sizeof(jas_stream_t)))) {
-		return 0;
-	}
-	stream->openmode_ = 0;
-	stream->bufmode_ = 0;
-	stream->flags_ = 0;
-	stream->bufbase_ = 0;
-	stream->bufstart_ = 0;
-	stream->bufsize_ = 0;
-	stream->ptr_ = 0;
-	stream->cnt_ = 0;
-	stream->ops_ = 0;
-	stream->obj_ = 0;
-	stream->rwcnt_ = 0;
-	stream->rwlimit_ = -1;
-
-	return stream;
+        jas_stream_t *stream;
+
+        if (!(stream = jas_malloc(sizeof(jas_stream_t)))) {
+                return 0;
+        }
+        stream->openmode_ = 0;
+        stream->bufmode_ = 0;
+        stream->flags_ = 0;
+        stream->bufbase_ = 0;
+        stream->bufstart_ = 0;
+        stream->bufsize_ = 0;
+        stream->ptr_ = 0;
+        stream->cnt_ = 0;
+        stream->ops_ = 0;
+        stream->obj_ = 0;
+        stream->rwcnt_ = 0;
+        stream->rwlimit_ = -1;
+
+        return stream;
 }
 
 jas_stream_t *jas_stream_memopen(char *buf, int bufsize)
 {
-	jas_stream_t *stream;
-	jas_stream_memobj_t *obj;
-
-	if (!(stream = jas_stream_create())) {
-		return 0;
-	}
-
-	/* A stream associated with a memory buffer is always opened
-	for both reading and writing in binary mode. */
-	stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;
-
-	/* Since the stream data is already resident in memory, buffering
-	is not necessary. */
-	/* But... It still may be faster to use buffering anyways. */
-	jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
-
-	/* Select the operations for a memory stream. */
-	stream->ops_ = &jas_stream_memops;
-
-	/* Allocate memory for the underlying memory stream object. */
-	if (!(obj = jas_malloc(sizeof(jas_stream_memobj_t)))) {
-		jas_stream_destroy(stream);
-		return 0;
-	}
-	stream->obj_ = (void *) obj;
-
-	/* Initialize a few important members of the memory stream object. */
-	obj->myalloc_ = 0;
-	obj->buf_ = 0;
-
-	/* If the buffer size specified is nonpositive, then the buffer
-	is allocated internally and automatically grown as needed. */
-	if (bufsize <= 0) {
-		obj->bufsize_ = 1024;
-		obj->growable_ = 1;
-	} else {
-		obj->bufsize_ = bufsize;
-		obj->growable_ = 0;
-	}
-	if (buf) {
-		obj->buf_ = (unsigned char *) buf;
-	} else {
-		obj->buf_ = jas_malloc(obj->bufsize_ * sizeof(char));
-		obj->myalloc_ = 1;
-	}
-	if (!obj->buf_) {
-		jas_stream_close(stream);
-		return 0;
-	}
-
-	if (bufsize > 0 && buf) {
-		/* If a buffer was supplied by the caller and its length is positive,
-		  make the associated buffer data appear in the stream initially. */
-		obj->len_ = bufsize;
-	} else {
-		/* The stream is initially empty. */
-		obj->len_ = 0;
-	}
-	obj->pos_ = 0;
-
-	return stream;
+        jas_stream_t *stream;
+        jas_stream_memobj_t *obj;
+
+        if (!(stream = jas_stream_create())) {
+                return 0;
+        }
+
+        /* A stream associated with a memory buffer is always opened
+        for both reading and writing in binary mode. */
+        stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;
+
+        /* Since the stream data is already resident in memory, buffering
+        is not necessary. */
+        /* But... It still may be faster to use buffering anyways. */
+        jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
+
+        /* Select the operations for a memory stream. */
+        stream->ops_ = &jas_stream_memops;
+
+        /* Allocate memory for the underlying memory stream object. */
+        if (!(obj = jas_malloc(sizeof(jas_stream_memobj_t)))) {
+                jas_stream_destroy(stream);
+                return 0;
+        }
+        stream->obj_ = (void *) obj;
+
+        /* Initialize a few important members of the memory stream object. */
+        obj->myalloc_ = 0;
+        obj->buf_ = 0;
+
+        /* If the buffer size specified is nonpositive, then the buffer
+        is allocated internally and automatically grown as needed. */
+        if (bufsize <= 0) {
+                obj->bufsize_ = 1024;
+                obj->growable_ = 1;
+        } else {
+                obj->bufsize_ = bufsize;
+                obj->growable_ = 0;
+        }
+        if (buf) {
+                obj->buf_ = (unsigned char *) buf;
+        } else {
+                obj->buf_ = jas_malloc(obj->bufsize_ * sizeof(char));
+                obj->myalloc_ = 1;
+        }
+        if (!obj->buf_) {
+                jas_stream_close(stream);
+                return 0;
+        }
+
+        if (bufsize > 0 && buf) {
+                /* If a buffer was supplied by the caller and its length is positive,
+                  make the associated buffer data appear in the stream initially. */
+                obj->len_ = bufsize;
+        } else {
+                /* The stream is initially empty. */
+                obj->len_ = 0;
+        }
+        obj->pos_ = 0;
+
+        return stream;
 }
 
 jas_stream_t *jas_stream_fopen(const char *filename, const char *mode)
 {
-	jas_stream_t *stream;
-	int *obj;
-	int openflags;
-
-	/* Allocate a stream object. */
-	if (!(stream = jas_stream_create())) {
-		return 0;
-	}
-
-	/* Parse the mode string. */
-	stream->openmode_ = jas_strtoopenmode(mode);
-
-	/* Determine the correct flags to use for opening the file. */
-	if ((stream->openmode_ & JAS_STREAM_READ) &&
-	  (stream->openmode_ & JAS_STREAM_WRITE)) {
-		openflags = O_RDWR;
-	} else if (stream->openmode_ & JAS_STREAM_READ) {
-		openflags = O_RDONLY;
-	} else if (stream->openmode_ & JAS_STREAM_WRITE) {
-		openflags = O_WRONLY;
-	} else {
-		openflags = 0;
-	}
-	if (stream->openmode_ & JAS_STREAM_APPEND) {
-		openflags |= O_APPEND;
-	}
-	if (stream->openmode_ & JAS_STREAM_BINARY) {
-		openflags |= O_BINARY;
-	}
-	if (stream->openmode_ & JAS_STREAM_CREATE) {
-		openflags |= O_CREAT | O_TRUNC;
-	}
-
-	/* Allocate space for the underlying file stream object. */
-	if (!(obj = jas_malloc(sizeof(int)))) {
-		jas_stream_destroy(stream);
-		return 0;
-	}
-	stream->obj_ = (void *) obj;
-
-	/* Select the operations for a file stream object. */
-	stream->ops_ = &jas_stream_fileops;
-
-	/* Open the underlying file. */
-	if ((*obj = open(filename, openflags, JAS_STREAM_PERMS)) < 0) {
-		jas_stream_destroy(stream);
-		return 0;
-	}
-
-	/* By default, use full buffering for this type of stream. */
-	jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
-
-	return stream;
+        jas_stream_t *stream;
+        int *obj;
+        int openflags;
+
+        /* Allocate a stream object. */
+        if (!(stream = jas_stream_create())) {
+                return 0;
+        }
+
+        /* Parse the mode string. */
+        stream->openmode_ = jas_strtoopenmode(mode);
+
+        /* Determine the correct flags to use for opening the file. */
+        if ((stream->openmode_ & JAS_STREAM_READ) &&
+          (stream->openmode_ & JAS_STREAM_WRITE)) {
+                openflags = O_RDWR;
+        } else if (stream->openmode_ & JAS_STREAM_READ) {
+                openflags = O_RDONLY;
+        } else if (stream->openmode_ & JAS_STREAM_WRITE) {
+                openflags = O_WRONLY;
+        } else {
+                openflags = 0;
+        }
+        if (stream->openmode_ & JAS_STREAM_APPEND) {
+                openflags |= O_APPEND;
+        }
+        if (stream->openmode_ & JAS_STREAM_BINARY) {
+                openflags |= O_BINARY;
+        }
+        if (stream->openmode_ & JAS_STREAM_CREATE) {
+                openflags |= O_CREAT | O_TRUNC;
+        }
+
+        /* Allocate space for the underlying file stream object. */
+        if (!(obj = jas_malloc(sizeof(int)))) {
+                jas_stream_destroy(stream);
+                return 0;
+        }
+        stream->obj_ = (void *) obj;
+
+        /* Select the operations for a file stream object. */
+        stream->ops_ = &jas_stream_fileops;
+
+        /* Open the underlying file. */
+        if ((*obj = open(filename, openflags, JAS_STREAM_PERMS)) < 0) {
+                jas_stream_destroy(stream);
+                return 0;
+        }
+
+        /* By default, use full buffering for this type of stream. */
+        jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
+
+        return stream;
 }
 
 jas_stream_t *jas_stream_freopen(const char *path, const char *mode, FILE *fp)
 {
-	jas_stream_t *stream;
-	int openflags;
-
-	/* Allocate a stream object. */
-	if (!(stream = jas_stream_create())) {
-		return 0;
-	}
-
-	/* Parse the mode string. */
-	stream->openmode_ = jas_strtoopenmode(mode);
-
-	/* Determine the correct flags to use for opening the file. */
-	if ((stream->openmode_ & JAS_STREAM_READ) &&
-	  (stream->openmode_ & JAS_STREAM_WRITE)) {
-		openflags = O_RDWR;
-	} else if (stream->openmode_ & JAS_STREAM_READ) {
-		openflags = O_RDONLY;
-	} else if (stream->openmode_ & JAS_STREAM_WRITE) {
-		openflags = O_WRONLY;
-	} else {
-		openflags = 0;
-	}
-	if (stream->openmode_ & JAS_STREAM_APPEND) {
-		openflags |= O_APPEND;
-	}
-	if (stream->openmode_ & JAS_STREAM_BINARY) {
-		openflags |= O_BINARY;
-	}
-	if (stream->openmode_ & JAS_STREAM_CREATE) {
-		openflags |= O_CREAT | O_TRUNC;
-	}
-
-	stream->obj_ = JAS_CAST(void *, fp);
-
-	/* Select the operations for a file stream object. */
-	stream->ops_ = &jas_stream_sfileops;
-
-	/* By default, use full buffering for this type of stream. */
-	jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
-
-	return stream;
+        jas_stream_t *stream;
+        int openflags;
+
+        /* Allocate a stream object. */
+        if (!(stream = jas_stream_create())) {
+                return 0;
+        }
+
+        /* Parse the mode string. */
+        stream->openmode_ = jas_strtoopenmode(mode);
+
+        /* Determine the correct flags to use for opening the file. */
+        if ((stream->openmode_ & JAS_STREAM_READ) &&
+          (stream->openmode_ & JAS_STREAM_WRITE)) {
+                openflags = O_RDWR;
+        } else if (stream->openmode_ & JAS_STREAM_READ) {
+                openflags = O_RDONLY;
+        } else if (stream->openmode_ & JAS_STREAM_WRITE) {
+                openflags = O_WRONLY;
+        } else {
+                openflags = 0;
+        }
+        if (stream->openmode_ & JAS_STREAM_APPEND) {
+                openflags |= O_APPEND;
+        }
+        if (stream->openmode_ & JAS_STREAM_BINARY) {
+                openflags |= O_BINARY;
+        }
+        if (stream->openmode_ & JAS_STREAM_CREATE) {
+                openflags |= O_CREAT | O_TRUNC;
+        }
+
+        stream->obj_ = JAS_CAST(void *, fp);
+
+        /* Select the operations for a file stream object. */
+        stream->ops_ = &jas_stream_sfileops;
+
+        /* By default, use full buffering for this type of stream. */
+        jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
+
+        return stream;
 }
 
 
 jas_stream_t *jas_stream_tmpfile()
 {
-	jas_stream_t *stream;
-	int *obj;
+        jas_stream_t *stream;
+        int *obj;
 
-	if (!(stream = jas_stream_create())) {
-		return 0;
-	}
+        if (!(stream = jas_stream_create())) {
+                return 0;
+        }
 
-	/* A temporary file stream is always opened for both reading and
-	writing in binary mode. */
-	stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;
+        /* A temporary file stream is always opened for both reading and
+        writing in binary mode. */
+        stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;
 
-	/* Allocate memory for the underlying temporary file object. */
-	if (!(obj = jas_malloc(sizeof(int)))) {
-		jas_stream_destroy(stream);
-		return 0;
-	}
-	stream->obj_ = obj;
+        /* Allocate memory for the underlying temporary file object. */
+        if (!(obj = jas_malloc(sizeof(int)))) {
+                jas_stream_destroy(stream);
+                return 0;
+        }
+        stream->obj_ = obj;
 
     {
         /* This is a Netpbm enhancement.  Original Jasper library uses
@@ -423,88 +423,88 @@ jas_stream_t *jas_stream_tmpfile()
             return 0;
         }
     }
-	/* Use full buffering. */
-	jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
+        /* Use full buffering. */
+        jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
 
-	stream->ops_ = &jas_stream_fileops;
+        stream->ops_ = &jas_stream_fileops;
 
-	return stream;
+        return stream;
 }
 
 jas_stream_t *jas_stream_fdopen(int fd, const char *mode)
 {
-	jas_stream_t *stream;
-	int *obj;
+        jas_stream_t *stream;
+        int *obj;
 
-	/* Allocate a stream object. */
-	if (!(stream = jas_stream_create())) {
-		return 0;
-	}
+        /* Allocate a stream object. */
+        if (!(stream = jas_stream_create())) {
+                return 0;
+        }
 
-	/* Parse the mode string. */
-	stream->openmode_ = jas_strtoopenmode(mode);
+        /* Parse the mode string. */
+        stream->openmode_ = jas_strtoopenmode(mode);
 
 #if defined(HAVE_SETMODE) && defined(O_BINARY)
-	/* Argh!!!  Someone ought to banish text mode (i.e., O_TEXT) to the
-	  greatest depths of purgatory! */
-	/* Ensure that the file descriptor is in binary mode, if the caller
-	  has specified the binary mode flag.  Arguably, the caller ought to
-	  take care of this, but text mode is a ugly wart anyways, so we save
-	  the caller some grief by handling this within the stream library. */
-	/* This ugliness is mainly for the benefit of those who run the
-	  JasPer software under Windows from shells that insist on opening
-	  files in text mode.  For example, in the Cygwin environment,
-	  shells often open files in text mode when I/O redirection is
-	  used.  Grr... */
-	if (stream->openmode_ & JAS_STREAM_BINARY) {
-		setmode(fd, O_BINARY);
-	}
+        /* Argh!!!  Someone ought to banish text mode (i.e., O_TEXT) to the
+          greatest depths of purgatory! */
+        /* Ensure that the file descriptor is in binary mode, if the caller
+          has specified the binary mode flag.  Arguably, the caller ought to
+          take care of this, but text mode is a ugly wart anyways, so we save
+          the caller some grief by handling this within the stream library. */
+        /* This ugliness is mainly for the benefit of those who run the
+          JasPer software under Windows from shells that insist on opening
+          files in text mode.  For example, in the Cygwin environment,
+          shells often open files in text mode when I/O redirection is
+          used.  Grr... */
+        if (stream->openmode_ & JAS_STREAM_BINARY) {
+                setmode(fd, O_BINARY);
+        }
 #endif
 
-	/* Allocate space for the underlying file stream object. */
-	if (!(obj = jas_malloc(sizeof(int)))) {
-		jas_stream_destroy(stream);
-		return 0;
-	}
-	stream->obj_ = (void *) obj;
-	*obj = fd;
+        /* Allocate space for the underlying file stream object. */
+        if (!(obj = jas_malloc(sizeof(int)))) {
+                jas_stream_destroy(stream);
+                return 0;
+        }
+        stream->obj_ = (void *) obj;
+        *obj = fd;
 
-	/* By default, use full buffering for this type of stream. */
-	jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
+        /* By default, use full buffering for this type of stream. */
+        jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
 
-	/* Select the operations for a file stream object. */
-	stream->ops_ = &jas_stream_fileops;
+        /* Select the operations for a file stream object. */
+        stream->ops_ = &jas_stream_fileops;
 
 /* Do not close the underlying file descriptor when the stream is closed. */
-	stream->openmode_ |= JAS_STREAM_NOCLOSE;
+        stream->openmode_ |= JAS_STREAM_NOCLOSE;
 
-	return stream;
+        return stream;
 }
 
 static void jas_stream_destroy(jas_stream_t *stream)
 {
-	/* If the memory for the buffer was allocated with malloc, free
-	this memory. */
-	if ((stream->bufmode_ & JAS_STREAM_FREEBUF) && stream->bufbase_) {
-		jas_free(stream->bufbase_);
-		stream->bufbase_ = 0;
-	}
-	jas_free(stream);
+        /* If the memory for the buffer was allocated with malloc, free
+        this memory. */
+        if ((stream->bufmode_ & JAS_STREAM_FREEBUF) && stream->bufbase_) {
+                jas_free(stream->bufbase_);
+                stream->bufbase_ = 0;
+        }
+        jas_free(stream);
 }
 
 int jas_stream_close(jas_stream_t *stream)
 {
-	/* Flush buffer if necessary. */
-	jas_stream_flush(stream);
+        /* Flush buffer if necessary. */
+        jas_stream_flush(stream);
 
-	/* Close the underlying stream object. */
-	if (!(stream->openmode_ & JAS_STREAM_NOCLOSE)) {
-		(*stream->ops_->close_)(stream->obj_);
-	}
+        /* Close the underlying stream object. */
+        if (!(stream->openmode_ & JAS_STREAM_NOCLOSE)) {
+                (*stream->ops_->close_)(stream->obj_);
+        }
 
-	jas_stream_destroy(stream);
+        jas_stream_destroy(stream);
 
-	return 0;
+        return 0;
 }
 
 /******************************************************************************\
@@ -513,71 +513,71 @@ int jas_stream_close(jas_stream_t *stream)
 
 int jas_stream_getc_func(jas_stream_t *stream)
 {
-	assert(stream->ptr_ - stream->bufbase_ <= stream->bufsize_ +
-	  JAS_STREAM_MAXPUTBACK);
-	return jas_stream_getc_macro(stream);
+        assert(stream->ptr_ - stream->bufbase_ <= stream->bufsize_ +
+          JAS_STREAM_MAXPUTBACK);
+        return jas_stream_getc_macro(stream);
 }
 
 int jas_stream_putc_func(jas_stream_t *stream, int c)
 {
-	assert(stream->ptr_ - stream->bufstart_ <= stream->bufsize_);
-	return jas_stream_putc_macro(stream, c);
+        assert(stream->ptr_ - stream->bufstart_ <= stream->bufsize_);
+        return jas_stream_putc_macro(stream, c);
 }
 
 int jas_stream_ungetc(jas_stream_t *stream, int c)
 {
-	if (!stream->ptr_ || stream->ptr_ == stream->bufbase_) {
-		return -1;
-	}
-
-	/* Reset the EOF indicator (since we now have at least one character
-	  to read). */
-	stream->flags_ &= ~JAS_STREAM_EOF;
-
-	--stream->rwcnt_;
-	--stream->ptr_;
-	++stream->cnt_;
-	*stream->ptr_ = c;
-	return 0;
+        if (!stream->ptr_ || stream->ptr_ == stream->bufbase_) {
+                return -1;
+        }
+
+        /* Reset the EOF indicator (since we now have at least one character
+          to read). */
+        stream->flags_ &= ~JAS_STREAM_EOF;
+
+        --stream->rwcnt_;
+        --stream->ptr_;
+        ++stream->cnt_;
+        *stream->ptr_ = c;
+        return 0;
 }
 
 int jas_stream_read(jas_stream_t *stream, void *buf, int cnt)
 {
-	int n;
-	int c;
-	char *bufptr;
-
-	bufptr = buf;
-
-	n = 0;
-	while (n < cnt) {
-		if ((c = jas_stream_getc(stream)) == EOF) {
-			return n;
-		}
-		*bufptr++ = c;
-		++n;
-	}
-
-	return n;
+        int n;
+        int c;
+        char *bufptr;
+
+        bufptr = buf;
+
+        n = 0;
+        while (n < cnt) {
+                if ((c = jas_stream_getc(stream)) == EOF) {
+                        return n;
+                }
+                *bufptr++ = c;
+                ++n;
+        }
+
+        return n;
 }
 
 int jas_stream_write(jas_stream_t *stream, const void *buf, int cnt)
 {
-	int n;
-	const char *bufptr;
-
-	bufptr = buf;
-
-	n = 0;
-	while (n < cnt) {
-		if (jas_stream_putc(stream, *bufptr) == EOF) {
-			return n;
-		}
-		++bufptr;
-		++n;
-	}
+        int n;
+        const char *bufptr;
+
+        bufptr = buf;
+
+        n = 0;
+        while (n < cnt) {
+                if (jas_stream_putc(stream, *bufptr) == EOF) {
+                        return n;
+                }
+                ++bufptr;
+                ++n;
+        }
 
-	return n;
+        return n;
 }
 
 /* Note: This function uses a fixed size buffer.  Therefore, it cannot
@@ -585,59 +585,59 @@ int jas_stream_write(jas_stream_t *stream, const void *buf, int cnt)
   by the buffer. */
 int jas_stream_printf(jas_stream_t *stream, const char *fmt, ...)
 {
-	va_list ap;
-	char buf[4096];
-	int ret;
-
-	va_start(ap, fmt);
-	ret = vsprintf(buf, fmt, ap);
-	jas_stream_puts(stream, buf);
-	va_end(ap);
-	return ret;
+        va_list ap;
+        char buf[4096];
+        int ret;
+
+        va_start(ap, fmt);
+        ret = vsprintf(buf, fmt, ap);
+        jas_stream_puts(stream, buf);
+        va_end(ap);
+        return ret;
 }
 
 int jas_stream_puts(jas_stream_t *stream, const char *s)
 {
-	while (*s != '\0') {
-		if (jas_stream_putc_macro(stream, *s) == EOF) {
-			return -1;
-		}
-		++s;
-	}
-	return 0;
+        while (*s != '\0') {
+                if (jas_stream_putc_macro(stream, *s) == EOF) {
+                        return -1;
+                }
+                ++s;
+        }
+        return 0;
 }
 
 char *jas_stream_gets(jas_stream_t *stream, char *buf, int bufsize)
 {
-	int c;
-	char *bufptr;
-	assert(bufsize > 0);
-
-	bufptr = buf;
-	while (bufsize > 1) {
-		if ((c = jas_stream_getc(stream)) == EOF) {
-			break;
-		}
-		*bufptr++ = c;
-		--bufsize;
-		if (c == '\n') {
-			break;
-		}
-	}
-	*bufptr = '\0';
-	return buf;
+        int c;
+        char *bufptr;
+        assert(bufsize > 0);
+
+        bufptr = buf;
+        while (bufsize > 1) {
+                if ((c = jas_stream_getc(stream)) == EOF) {
+                        break;
+                }
+                *bufptr++ = c;
+                --bufsize;
+                if (c == '\n') {
+                        break;
+                }
+        }
+        *bufptr = '\0';
+        return buf;
 }
 
 int jas_stream_gobble(jas_stream_t *stream, int n)
 {
-	int m;
-	m = n;
-	for (m = n; m > 0; --m) {
-		if (jas_stream_getc(stream) == EOF) {
-			return n - m;
-		}
-	}
-	return n;
+        int m;
+        m = n;
+        for (m = n; m > 0; --m) {
+                if (jas_stream_getc(stream) == EOF) {
+                        return n - m;
+                }
+        }
+        return n;
 }
 
 /******************************************************************************\
@@ -646,73 +646,73 @@ int jas_stream_gobble(jas_stream_t *stream, int n)
 
 int jas_stream_isseekable(jas_stream_t *stream)
 {
-	if (stream->ops_ == &jas_stream_memops) {
-		return 1;
-	} else if (stream->ops_ == &jas_stream_fileops) {
-		if ((*stream->ops_->seek_)(stream->obj_, 0, SEEK_CUR) < 0) {
-			return 0;
-		}
-		return 1;
-	} else {
-		return 0;
-	}
+        if (stream->ops_ == &jas_stream_memops) {
+                return 1;
+        } else if (stream->ops_ == &jas_stream_fileops) {
+                if ((*stream->ops_->seek_)(stream->obj_, 0, SEEK_CUR) < 0) {
+                        return 0;
+                }
+                return 1;
+        } else {
+                return 0;
+        }
 }
 
 int jas_stream_rewind(jas_stream_t *stream)
 {
-	return jas_stream_seek(stream, 0, SEEK_SET);
+        return jas_stream_seek(stream, 0, SEEK_SET);
 }
 
 long jas_stream_seek(jas_stream_t *stream, long offset, int origin)
 {
-	long newpos;
-
-	/* The buffer cannot be in use for both reading and writing. */
-	assert(!((stream->bufmode_ & JAS_STREAM_RDBUF) && (stream->bufmode_ &
-	  JAS_STREAM_WRBUF)));
-
-	/* Reset the EOF indicator (since we may not be at the EOF anymore). */
-	stream->flags_ &= ~JAS_STREAM_EOF;
-
-	if (stream->bufmode_ & JAS_STREAM_RDBUF) {
-		if (origin == SEEK_CUR) {
-			offset -= stream->cnt_;
-		}
-	} else if (stream->bufmode_ & JAS_STREAM_WRBUF) {
-		if (jas_stream_flush(stream)) {
-			return -1;
-		}
-	}
-	stream->cnt_ = 0;
-	stream->ptr_ = stream->bufstart_;
-	stream->bufmode_ &= ~(JAS_STREAM_RDBUF | JAS_STREAM_WRBUF);
-
-	if ((newpos = (*stream->ops_->seek_)(stream->obj_, offset, origin))
-	  < 0) {
-		return -1;
-	}
-
-	return newpos;
+        long newpos;
+
+        /* The buffer cannot be in use for both reading and writing. */
+        assert(!((stream->bufmode_ & JAS_STREAM_RDBUF) && (stream->bufmode_ &
+          JAS_STREAM_WRBUF)));
+
+        /* Reset the EOF indicator (since we may not be at the EOF anymore). */
+        stream->flags_ &= ~JAS_STREAM_EOF;
+
+        if (stream->bufmode_ & JAS_STREAM_RDBUF) {
+                if (origin == SEEK_CUR) {
+                        offset -= stream->cnt_;
+                }
+        } else if (stream->bufmode_ & JAS_STREAM_WRBUF) {
+                if (jas_stream_flush(stream)) {
+                        return -1;
+                }
+        }
+        stream->cnt_ = 0;
+        stream->ptr_ = stream->bufstart_;
+        stream->bufmode_ &= ~(JAS_STREAM_RDBUF | JAS_STREAM_WRBUF);
+
+        if ((newpos = (*stream->ops_->seek_)(stream->obj_, offset, origin))
+          < 0) {
+                return -1;
+        }
+
+        return newpos;
 }
 
 long jas_stream_tell(jas_stream_t *stream)
 {
-	int adjust;
-	int offset;
-
-	if (stream->bufmode_ & JAS_STREAM_RDBUF) {
-		adjust = -stream->cnt_;
-	} else if (stream->bufmode_ & JAS_STREAM_WRBUF) {
-		adjust = stream->ptr_ - stream->bufstart_;
-	} else {
-		adjust = 0;
-	}
-
-	if ((offset = (*stream->ops_->seek_)(stream->obj_, 0, SEEK_CUR)) < 0) {
-		return -1;
-	}
-
-	return offset + adjust;
+        int adjust;
+        int offset;
+
+        if (stream->bufmode_ & JAS_STREAM_RDBUF) {
+                adjust = -stream->cnt_;
+        } else if (stream->bufmode_ & JAS_STREAM_WRBUF) {
+                adjust = stream->ptr_ - stream->bufstart_;
+        } else {
+                adjust = 0;
+        }
+
+        if ((offset = (*stream->ops_->seek_)(stream->obj_, 0, SEEK_CUR)) < 0) {
+                return -1;
+        }
+
+        return offset + adjust;
 }
 
 /******************************************************************************\
@@ -722,45 +722,45 @@ long jas_stream_tell(jas_stream_t *stream)
 static void jas_stream_initbuf(jas_stream_t *stream, int bufmode, char *buf,
   int bufsize)
 {
-	/* If this function is being called, the buffer should not have been
-	  initialized yet. */
-	assert(!stream->bufbase_);
-
-	if (bufmode != JAS_STREAM_UNBUF) {
-		/* The full- or line-buffered mode is being employed. */
-		if (!buf) {
-			/* The caller has not specified a buffer to employ, so allocate
-			  one. */
-			if ((stream->bufbase_ = jas_malloc(JAS_STREAM_BUFSIZE +
-			  JAS_STREAM_MAXPUTBACK))) {
-				stream->bufmode_ |= JAS_STREAM_FREEBUF;
-				stream->bufsize_ = JAS_STREAM_BUFSIZE;
-			} else {
-				/* The buffer allocation has failed.  Resort to unbuffered
-				  operation. */
-				stream->bufbase_ = stream->tinybuf_;
-				stream->bufsize_ = 1;
-			}
-		} else {
-			/* The caller has specified a buffer to employ. */
-			/* The buffer must be large enough to accommodate maximum
-			  putback. */
-			assert(bufsize > JAS_STREAM_MAXPUTBACK);
-			stream->bufbase_ = JAS_CAST(unsigned char *, buf);
-			stream->bufsize_ = bufsize - JAS_STREAM_MAXPUTBACK;
-		}
-	} else {
-		/* The unbuffered mode is being employed. */
-		/* A buffer should not have been supplied by the caller. */
-		assert(!buf);
-		/* Use a trivial one-character buffer. */
-		stream->bufbase_ = stream->tinybuf_;
-		stream->bufsize_ = 1;
-	}
-	stream->bufstart_ = &stream->bufbase_[JAS_STREAM_MAXPUTBACK];
-	stream->ptr_ = stream->bufstart_;
-	stream->cnt_ = 0;
-	stream->bufmode_ |= bufmode & JAS_STREAM_BUFMODEMASK;
+        /* If this function is being called, the buffer should not have been
+          initialized yet. */
+        assert(!stream->bufbase_);
+
+        if (bufmode != JAS_STREAM_UNBUF) {
+                /* The full- or line-buffered mode is being employed. */
+                if (!buf) {
+                        /* The caller has not specified a buffer to employ, so allocate
+                          one. */
+                        if ((stream->bufbase_ = jas_malloc(JAS_STREAM_BUFSIZE +
+                          JAS_STREAM_MAXPUTBACK))) {
+                                stream->bufmode_ |= JAS_STREAM_FREEBUF;
+                                stream->bufsize_ = JAS_STREAM_BUFSIZE;
+                        } else {
+                                /* The buffer allocation has failed.  Resort to unbuffered
+                                  operation. */
+                                stream->bufbase_ = stream->tinybuf_;
+                                stream->bufsize_ = 1;
+                        }
+                } else {
+                        /* The caller has specified a buffer to employ. */
+                        /* The buffer must be large enough to accommodate maximum
+                          putback. */
+                        assert(bufsize > JAS_STREAM_MAXPUTBACK);
+                        stream->bufbase_ = JAS_CAST(unsigned char *, buf);
+                        stream->bufsize_ = bufsize - JAS_STREAM_MAXPUTBACK;
+                }
+        } else {
+                /* The unbuffered mode is being employed. */
+                /* A buffer should not have been supplied by the caller. */
+                assert(!buf);
+                /* Use a trivial one-character buffer. */
+                stream->bufbase_ = stream->tinybuf_;
+                stream->bufsize_ = 1;
+        }
+        stream->bufstart_ = &stream->bufbase_[JAS_STREAM_MAXPUTBACK];
+        stream->ptr_ = stream->bufstart_;
+        stream->cnt_ = 0;
+        stream->bufmode_ |= bufmode & JAS_STREAM_BUFMODEMASK;
 }
 
 /******************************************************************************\
@@ -769,97 +769,97 @@ static void jas_stream_initbuf(jas_stream_t *stream, int bufmode, char *buf,
 
 int jas_stream_flush(jas_stream_t *stream)
 {
-	if (stream->bufmode_ & JAS_STREAM_RDBUF) {
-		return 0;
-	}
-	return jas_stream_flushbuf(stream, EOF);
+        if (stream->bufmode_ & JAS_STREAM_RDBUF) {
+                return 0;
+        }
+        return jas_stream_flushbuf(stream, EOF);
 }
 
 int jas_stream_fillbuf(jas_stream_t *stream, int getflag)
 {
-	int c;
-
-	/* The stream must not be in an error or EOF state. */
-	if ((stream->flags_ & (JAS_STREAM_ERRMASK)) != 0) {
-		return EOF;
-	}
-
-	/* The stream must be open for reading. */
-	if ((stream->openmode_ & JAS_STREAM_READ) == 0) {
-		return EOF;
-	}
-
-	/* Make a half-hearted attempt to confirm that the buffer is not
-	currently being used for writing.  This check is not intended
-	to be foolproof! */
-	assert((stream->bufmode_ & JAS_STREAM_WRBUF) == 0);
-
-	assert(stream->ptr_ - stream->bufstart_ <= stream->bufsize_);
-
-	/* Mark the buffer as being used for reading. */
-	stream->bufmode_ |= JAS_STREAM_RDBUF;
-
-	/* Read new data into the buffer. */
-	stream->ptr_ = stream->bufstart_;
-	if ((stream->cnt_ = (*stream->ops_->read_)(stream->obj_,
-	  (char *) stream->bufstart_, stream->bufsize_)) <= 0) {
-		if (stream->cnt_ < 0) {
-			stream->flags_ |= JAS_STREAM_ERR;
-		} else {
-			stream->flags_ |= JAS_STREAM_EOF;
-		}
-		stream->cnt_ = 0;
-		return EOF;
-	}
-
-	assert(stream->cnt_ > 0);
-	/* Get or peek at the first character in the buffer. */
-	c = (getflag) ? jas_stream_getc2(stream) : (*stream->ptr_);
-
-	return c;
+        int c;
+
+        /* The stream must not be in an error or EOF state. */
+        if ((stream->flags_ & (JAS_STREAM_ERRMASK)) != 0) {
+                return EOF;
+        }
+
+        /* The stream must be open for reading. */
+        if ((stream->openmode_ & JAS_STREAM_READ) == 0) {
+                return EOF;
+        }
+
+        /* Make a half-hearted attempt to confirm that the buffer is not
+        currently being used for writing.  This check is not intended
+        to be foolproof! */
+        assert((stream->bufmode_ & JAS_STREAM_WRBUF) == 0);
+
+        assert(stream->ptr_ - stream->bufstart_ <= stream->bufsize_);
+
+        /* Mark the buffer as being used for reading. */
+        stream->bufmode_ |= JAS_STREAM_RDBUF;
+
+        /* Read new data into the buffer. */
+        stream->ptr_ = stream->bufstart_;
+        if ((stream->cnt_ = (*stream->ops_->read_)(stream->obj_,
+          (char *) stream->bufstart_, stream->bufsize_)) <= 0) {
+                if (stream->cnt_ < 0) {
+                        stream->flags_ |= JAS_STREAM_ERR;
+                } else {
+                        stream->flags_ |= JAS_STREAM_EOF;
+                }
+                stream->cnt_ = 0;
+                return EOF;
+        }
+
+        assert(stream->cnt_ > 0);
+        /* Get or peek at the first character in the buffer. */
+        c = (getflag) ? jas_stream_getc2(stream) : (*stream->ptr_);
+
+        return c;
 }
 
 int jas_stream_flushbuf(jas_stream_t *stream, int c)
 {
-	int len;
-	int n;
-
-	/* The stream should not be in an error or EOF state. */
-	if ((stream->flags_ & (JAS_STREAM_ERRMASK)) != 0) {
-		return EOF;
-	}
-
-	/* The stream must be open for writing. */
-	if ((stream->openmode_ & (JAS_STREAM_WRITE | JAS_STREAM_APPEND)) == 0) {
-		return EOF;
-	}
-
-	/* The buffer should not currently be in use for reading. */
-	assert(!(stream->bufmode_ & JAS_STREAM_RDBUF));
-
-	/* Note: Do not use the quantity stream->cnt to determine the number
-	of characters in the buffer!  Depending on how this function was
-	called, the stream->cnt value may be "off-by-one". */
-	len = stream->ptr_ - stream->bufstart_;
-	if (len > 0) {
-		n = (*stream->ops_->write_)(stream->obj_, (char *)
-		  stream->bufstart_, len);
-		if (n != len) {
-			stream->flags_ |= JAS_STREAM_ERR;
-			return EOF;
-		}
-	}
-	stream->cnt_ = stream->bufsize_;
-	stream->ptr_ = stream->bufstart_;
-
-	stream->bufmode_ |= JAS_STREAM_WRBUF;
-
-	if (c != EOF) {
-		assert(stream->cnt_ > 0);
-		jas_stream_putc2(stream, c);
-	}
-
-	return 0;
+        int len;
+        int n;
+
+        /* The stream should not be in an error or EOF state. */
+        if ((stream->flags_ & (JAS_STREAM_ERRMASK)) != 0) {
+                return EOF;
+        }
+
+        /* The stream must be open for writing. */
+        if ((stream->openmode_ & (JAS_STREAM_WRITE | JAS_STREAM_APPEND)) == 0) {
+                return EOF;
+        }
+
+        /* The buffer should not currently be in use for reading. */
+        assert(!(stream->bufmode_ & JAS_STREAM_RDBUF));
+
+        /* Note: Do not use the quantity stream->cnt to determine the number
+        of characters in the buffer!  Depending on how this function was
+        called, the stream->cnt value may be "off-by-one". */
+        len = stream->ptr_ - stream->bufstart_;
+        if (len > 0) {
+                n = (*stream->ops_->write_)(stream->obj_, (char *)
+                  stream->bufstart_, len);
+                if (n != len) {
+                        stream->flags_ |= JAS_STREAM_ERR;
+                        return EOF;
+                }
+        }
+        stream->cnt_ = stream->bufsize_;
+        stream->ptr_ = stream->bufstart_;
+
+        stream->bufmode_ |= JAS_STREAM_WRBUF;
+
+        if (c != EOF) {
+                assert(stream->cnt_ > 0);
+                jas_stream_putc2(stream, c);
+        }
+
+        return 0;
 }
 
 /******************************************************************************\
@@ -868,134 +868,134 @@ int jas_stream_flushbuf(jas_stream_t *stream, int c)
 
 static int jas_strtoopenmode(const char *s)
 {
-	int openmode = 0;
-	while (*s != '\0') {
-		switch (*s) {
-		case 'r':
-			openmode |= JAS_STREAM_READ;
-			break;
-		case 'w':
-			openmode |= JAS_STREAM_WRITE | JAS_STREAM_CREATE;
-			break;
-		case 'b':
-			openmode |= JAS_STREAM_BINARY;
-			break;
-		case 'a':
-			openmode |= JAS_STREAM_APPEND;
-			break;
-		case '+':
-			openmode |= JAS_STREAM_READ | JAS_STREAM_WRITE;
-			break;
-		default:
-			break;
-		}
-		++s;
-	}
-	return openmode;
+        int openmode = 0;
+        while (*s != '\0') {
+                switch (*s) {
+                case 'r':
+                        openmode |= JAS_STREAM_READ;
+                        break;
+                case 'w':
+                        openmode |= JAS_STREAM_WRITE | JAS_STREAM_CREATE;
+                        break;
+                case 'b':
+                        openmode |= JAS_STREAM_BINARY;
+                        break;
+                case 'a':
+                        openmode |= JAS_STREAM_APPEND;
+                        break;
+                case '+':
+                        openmode |= JAS_STREAM_READ | JAS_STREAM_WRITE;
+                        break;
+                default:
+                        break;
+                }
+                ++s;
+        }
+        return openmode;
 }
 
 int jas_stream_copy(jas_stream_t *out, jas_stream_t *in, int n)
 {
-	int all;
-	int c;
-	int m;
-
-	all = (n < 0) ? 1 : 0;
-
-	m = n;
-	while (all || m > 0) {
-		if ((c = jas_stream_getc_macro(in)) == EOF) {
-			/* The next character of input could not be read. */
-			/* Return with an error if an I/O error occurred
-			  (not including EOF) or if an explicit copy count
-			  was specified. */
-			return (!all || jas_stream_error(in)) ? (-1) : 0;
-		}
-		if (jas_stream_putc_macro(out, c) == EOF) {
-			return -1;
-		}
-		--m;
-	}
-	return 0;
+        int all;
+        int c;
+        int m;
+
+        all = (n < 0) ? 1 : 0;
+
+        m = n;
+        while (all || m > 0) {
+                if ((c = jas_stream_getc_macro(in)) == EOF) {
+                        /* The next character of input could not be read. */
+                        /* Return with an error if an I/O error occurred
+                          (not including EOF) or if an explicit copy count
+                          was specified. */
+                        return (!all || jas_stream_error(in)) ? (-1) : 0;
+                }
+                if (jas_stream_putc_macro(out, c) == EOF) {
+                        return -1;
+                }
+                --m;
+        }
+        return 0;
 }
 
 long jas_stream_setrwcount(jas_stream_t *stream, long rwcnt)
 {
-	int old;
+        int old;
 
-	old = stream->rwcnt_;
-	stream->rwcnt_ = rwcnt;
-	return old;
+        old = stream->rwcnt_;
+        stream->rwcnt_ = rwcnt;
+        return old;
 }
 
 int jas_stream_display(jas_stream_t *stream, FILE *fp, int n)
 {
-	unsigned char buf[16];
-	int i;
-	int j;
-	int m;
-	int c;
-	int display;
-	int cnt;
-
-	cnt = n - (n % 16);
-	display = 1;
-
-	for (i = 0; i < n; i += 16) {
-		if (n > 16 && i > 0) {
-			display = (i >= cnt) ? 1 : 0;
-		}
-		if (display) {
-			fprintf(fp, "%08x:", i);
-		}
-		m = JAS_MIN(n - i, 16);
-		for (j = 0; j < m; ++j) {
-			if ((c = jas_stream_getc(stream)) == EOF) {
-				abort();
-				return -1;
-			}
-			buf[j] = c;
-		}
-		if (display) {
-			for (j = 0; j < m; ++j) {
-				fprintf(fp, " %02x", buf[j]);
-			}
-			fputc(' ', fp);
-			for (; j < 16; ++j) {
-				fprintf(fp, "   ");
-			}
-			for (j = 0; j < m; ++j) {
-				if (isprint(buf[j])) {
-					fputc(buf[j], fp);
-				} else {
-					fputc(' ', fp);
-				}
-			}
-			fprintf(fp, "\n");
-		}
-
-
-	}
-	return 0;
+        unsigned char buf[16];
+        int i;
+        int j;
+        int m;
+        int c;
+        int display;
+        int cnt;
+
+        cnt = n - (n % 16);
+        display = 1;
+
+        for (i = 0; i < n; i += 16) {
+                if (n > 16 && i > 0) {
+                        display = (i >= cnt) ? 1 : 0;
+                }
+                if (display) {
+                        fprintf(fp, "%08x:", i);
+                }
+                m = JAS_MIN(n - i, 16);
+                for (j = 0; j < m; ++j) {
+                        if ((c = jas_stream_getc(stream)) == EOF) {
+                                abort();
+                                return -1;
+                        }
+                        buf[j] = c;
+                }
+                if (display) {
+                        for (j = 0; j < m; ++j) {
+                                fprintf(fp, " %02x", buf[j]);
+                        }
+                        fputc(' ', fp);
+                        for (; j < 16; ++j) {
+                                fprintf(fp, "   ");
+                        }
+                        for (j = 0; j < m; ++j) {
+                                if (isprint(buf[j])) {
+                                        fputc(buf[j], fp);
+                                } else {
+                                        fputc(' ', fp);
+                                }
+                        }
+                        fprintf(fp, "\n");
+                }
+
+
+        }
+        return 0;
 }
 
 long jas_stream_length(jas_stream_t *stream)
 {
-	long oldpos;
-	long pos;
-	if ((oldpos = jas_stream_tell(stream)) < 0) {
-		return -1;
-	}
-	if (jas_stream_seek(stream, 0, SEEK_END) < 0) {
-		return -1;
-	}
-	if ((pos = jas_stream_tell(stream)) < 0) {
-		return -1;
-	}
-	if (jas_stream_seek(stream, oldpos, SEEK_SET) < 0) {
-		return -1;
-	}
-	return pos;
+        long oldpos;
+        long pos;
+        if ((oldpos = jas_stream_tell(stream)) < 0) {
+                return -1;
+        }
+        if (jas_stream_seek(stream, 0, SEEK_END) < 0) {
+                return -1;
+        }
+        if ((pos = jas_stream_tell(stream)) < 0) {
+                return -1;
+        }
+        if (jas_stream_seek(stream, oldpos, SEEK_SET) < 0) {
+                return -1;
+        }
+        return pos;
 }
 
 /******************************************************************************\
@@ -1004,109 +1004,109 @@ long jas_stream_length(jas_stream_t *stream)
 
 static int mem_read(jas_stream_obj_t *obj, char *buf, int cnt)
 {
-	int n;
-	jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
-	n = m->len_ - m->pos_;
-	cnt = JAS_MIN(n, cnt);
-	memcpy(buf, &m->buf_[m->pos_], cnt);
-	m->pos_ += cnt;
-	return cnt;
+        int n;
+        jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
+        n = m->len_ - m->pos_;
+        cnt = JAS_MIN(n, cnt);
+        memcpy(buf, &m->buf_[m->pos_], cnt);
+        m->pos_ += cnt;
+        return cnt;
 }
 
 static int mem_resize(jas_stream_memobj_t *m, int bufsize)
 {
-	unsigned char *buf;
-
-	assert(m->buf_);
-	if (!(buf = jas_realloc(m->buf_, bufsize * sizeof(unsigned char)))) {
-		return -1;
-	}
-	m->buf_ = buf;
-	m->bufsize_ = bufsize;
-	return 0;
+        unsigned char *buf;
+
+        assert(m->buf_);
+        if (!(buf = jas_realloc(m->buf_, bufsize * sizeof(unsigned char)))) {
+                return -1;
+        }
+        m->buf_ = buf;
+        m->bufsize_ = bufsize;
+        return 0;
 }
 
 static int mem_write(jas_stream_obj_t *obj, char *buf, int cnt)
 {
-	int n;
-	int ret;
-	jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
-	long newbufsize;
-	long newpos;
-
-	newpos = m->pos_ + cnt;
-	if (newpos > m->bufsize_ && m->growable_) {
-		newbufsize = m->bufsize_;
-		while (newbufsize < newpos) {
-			newbufsize <<= 1;
-			assert(newbufsize >= 0);
-		}
-		if (mem_resize(m, newbufsize)) {
-			return -1;
-		}
-	}
-	if (m->pos_ > m->len_) {
-		/* The current position is beyond the end of the file, so
-		  pad the file to the current position with zeros. */
-		n = JAS_MIN(m->pos_, m->bufsize_) - m->len_;
-		if (n > 0) {
-			memset(&m->buf_[m->len_], 0, n);
-			m->len_ += n;
-		}
-		if (m->pos_ != m->len_) {
-			/* The buffer is not big enough. */
-			return 0;
-		}
-	}
-	n = m->bufsize_ - m->pos_;
-	ret = JAS_MIN(n, cnt);
-	if (ret > 0) {
-		memcpy(&m->buf_[m->pos_], buf, ret);
-		m->pos_ += ret;
-	}
-	if (m->pos_ > m->len_) {
-		m->len_ = m->pos_;
-	}
+        int n;
+        int ret;
+        jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
+        long newbufsize;
+        long newpos;
+
+        newpos = m->pos_ + cnt;
+        if (newpos > m->bufsize_ && m->growable_) {
+                newbufsize = m->bufsize_;
+                while (newbufsize < newpos) {
+                        newbufsize <<= 1;
+                        assert(newbufsize >= 0);
+                }
+                if (mem_resize(m, newbufsize)) {
+                        return -1;
+                }
+        }
+        if (m->pos_ > m->len_) {
+                /* The current position is beyond the end of the file, so
+                  pad the file to the current position with zeros. */
+                n = JAS_MIN(m->pos_, m->bufsize_) - m->len_;
+                if (n > 0) {
+                        memset(&m->buf_[m->len_], 0, n);
+                        m->len_ += n;
+                }
+                if (m->pos_ != m->len_) {
+                        /* The buffer is not big enough. */
+                        return 0;
+                }
+        }
+        n = m->bufsize_ - m->pos_;
+        ret = JAS_MIN(n, cnt);
+        if (ret > 0) {
+                memcpy(&m->buf_[m->pos_], buf, ret);
+                m->pos_ += ret;
+        }
+        if (m->pos_ > m->len_) {
+                m->len_ = m->pos_;
+        }
 assert(ret == cnt);
-	return ret;
+        return ret;
 }
 
 static long mem_seek(jas_stream_obj_t *obj, long offset, int origin)
 {
-	jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
-	long newpos;
-
-	switch (origin) {
-	case SEEK_SET:
-		newpos = offset;
-		break;
-	case SEEK_END:
-		newpos = m->len_ - offset;
-		break;
-	case SEEK_CUR:
-		newpos = m->pos_ + offset;
-		break;
-	default:
-		abort();
-		break;
-	}
-	if (newpos < 0) {
-		return -1;
-	}
-	m->pos_ = newpos;
-
-	return m->pos_;
+        jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
+        long newpos;
+
+        switch (origin) {
+        case SEEK_SET:
+                newpos = offset;
+                break;
+        case SEEK_END:
+                newpos = m->len_ - offset;
+                break;
+        case SEEK_CUR:
+                newpos = m->pos_ + offset;
+                break;
+        default:
+                abort();
+                break;
+        }
+        if (newpos < 0) {
+                return -1;
+        }
+        m->pos_ = newpos;
+
+        return m->pos_;
 }
 
 static int mem_close(jas_stream_obj_t *obj)
 {
-	jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
-	if (m->myalloc_ && m->buf_) {
-		jas_free(m->buf_);
-		m->buf_ = 0;
-	}
-	jas_free(obj);
-	return 0;
+        jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;
+        if (m->myalloc_ && m->buf_) {
+                jas_free(m->buf_);
+                m->buf_ = 0;
+        }
+        jas_free(obj);
+        return 0;
 }
 
 /******************************************************************************\
@@ -1115,31 +1115,31 @@ static int mem_close(jas_stream_obj_t *obj)
 
 static int file_read(jas_stream_obj_t *obj, char *buf, int cnt)
 {
-	int fd;
-	fd = *((int *)obj);
-	return read(fd, buf, cnt);
+        int fd;
+        fd = *((int *)obj);
+        return read(fd, buf, cnt);
 }
 
 static int file_write(jas_stream_obj_t *obj, char *buf, int cnt)
 {
-	int fd;
-	fd = *((int *)obj);
-	return write(fd, buf, cnt);
+        int fd;
+        fd = *((int *)obj);
+        return write(fd, buf, cnt);
 }
 
 static long file_seek(jas_stream_obj_t *obj, long offset, int origin)
 {
-	int fd;
-	fd = *((int *)obj);
-	return lseek(fd, offset, origin);
+        int fd;
+        fd = *((int *)obj);
+        return lseek(fd, offset, origin);
 }
 
 static int file_close(jas_stream_obj_t *obj)
 {
-	int fd;
-	fd = *((int *)obj);
-	jas_free(obj);
-	return close(fd);
+        int fd;
+        fd = *((int *)obj);
+        jas_free(obj);
+        return close(fd);
 }
 
 /******************************************************************************\
@@ -1148,28 +1148,28 @@ static int file_close(jas_stream_obj_t *obj)
 
 static int sfile_read(jas_stream_obj_t *obj, char *buf, int cnt)
 {
-	FILE *fp;
-	fp = JAS_CAST(FILE *, obj);
-	return fread(buf, 1, cnt, fp);
+        FILE *fp;
+        fp = JAS_CAST(FILE *, obj);
+        return fread(buf, 1, cnt, fp);
 }
 
 static int sfile_write(jas_stream_obj_t *obj, char *buf, int cnt)
 {
-	FILE *fp;
-	fp = JAS_CAST(FILE *, obj);
-	return fwrite(buf, 1, cnt, fp);
+        FILE *fp;
+        fp = JAS_CAST(FILE *, obj);
+        return fwrite(buf, 1, cnt, fp);
 }
 
 static long sfile_seek(jas_stream_obj_t *obj, long offset, int origin)
 {
-	FILE *fp;
-	fp = JAS_CAST(FILE *, obj);
-	return fseek(fp, offset, origin);
+        FILE *fp;
+        fp = JAS_CAST(FILE *, obj);
+        return fseek(fp, offset, origin);
 }
 
 static int sfile_close(jas_stream_obj_t *obj)
 {
-	FILE *fp;
-	fp = JAS_CAST(FILE *, obj);
-	return fclose(fp);
+        FILE *fp;
+        fp = JAS_CAST(FILE *, obj);
+        return fclose(fp);
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_string.c b/converter/other/jpeg2000/libjasper/base/jas_string.c
index 945731a1..b3c45b78 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_string.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_string.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -134,12 +134,12 @@
 
 char *jas_strdup(const char *s)
 {
-	int n;
-	char *p;
-	n = strlen(s) + 1;
-	if (!(p = jas_malloc(n * sizeof(char)))) {
-		return 0;
-	}
-	strcpy(p, s);
-	return p;
+        int n;
+        char *p;
+        n = strlen(s) + 1;
+        if (!(p = jas_malloc(n * sizeof(char)))) {
+                return 0;
+        }
+        strcpy(p, s);
+        return p;
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_tvp.c b/converter/other/jpeg2000/libjasper/base/jas_tvp.c
index aab12703..43b2fd41 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_tvp.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_tvp.c
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -132,8 +132,8 @@
 \******************************************************************************/
 
 /* Is the specified character valid for a tag name? */
-#define	JAS_TVP_ISTAG(x) \
-	(isalpha(x) || (x) == '_' || isdigit(x))
+#define JAS_TVP_ISTAG(x) \
+        (isalpha(x) || (x) == '_' || isdigit(x))
 
 /******************************************************************************\
 * Code for creating and destroying a tag-value parser.
@@ -141,26 +141,26 @@
 
 jas_tvparser_t *jas_tvparser_create(const char *s)
 {
-	jas_tvparser_t *tvp;
-	if (!(tvp = jas_malloc(sizeof(jas_tvparser_t)))) {
-		return 0;
-	}
-	if (!(tvp->buf = jas_strdup(s))) {
-		jas_tvparser_destroy(tvp);
-		return 0;
-	}
-	tvp->pos = tvp->buf;
-	tvp->tag = 0;
-	tvp->val = 0;
-	return tvp;
+        jas_tvparser_t *tvp;
+        if (!(tvp = jas_malloc(sizeof(jas_tvparser_t)))) {
+                return 0;
+        }
+        if (!(tvp->buf = jas_strdup(s))) {
+                jas_tvparser_destroy(tvp);
+                return 0;
+        }
+        tvp->pos = tvp->buf;
+        tvp->tag = 0;
+        tvp->val = 0;
+        return tvp;
 }
 
 void jas_tvparser_destroy(jas_tvparser_t *tvp)
 {
-	if (tvp->buf) {
-		jas_free(tvp->buf);
-	}
-	jas_free(tvp);
+        if (tvp->buf) {
+                jas_free(tvp->buf);
+        }
+        jas_free(tvp);
 }
 
 /******************************************************************************\
@@ -170,73 +170,73 @@ void jas_tvparser_destroy(jas_tvparser_t *tvp)
 /* Get the next tag-value pair. */
 int jas_tvparser_next(jas_tvparser_t *tvp)
 {
-	char *p;
-	char *tag;
-	const char *val;
+        char *p;
+        char *tag;
+        const char *val;
 
-	/* Skip any leading whitespace. */
-	p = tvp->pos;
-	while (*p != '\0' && isspace(*p)) {
-		++p;
-	}
+        /* Skip any leading whitespace. */
+        p = tvp->pos;
+        while (*p != '\0' && isspace(*p)) {
+                ++p;
+        }
 
-	/* Has the end of the input data been reached? */
-	if (*p == '\0') {
-		/* No more tags are present. */
-		tvp->pos = p;
-		return 1;
-	}
+        /* Has the end of the input data been reached? */
+        if (*p == '\0') {
+                /* No more tags are present. */
+                tvp->pos = p;
+                return 1;
+        }
 
-	/* Does the tag name begin with a valid character? */
-	if (!JAS_TVP_ISTAG(*p)) {
-		return -1;
-	}
+        /* Does the tag name begin with a valid character? */
+        if (!JAS_TVP_ISTAG(*p)) {
+                return -1;
+        }
 
-	/* Remember where the tag name begins. */
-	tag = p;
+        /* Remember where the tag name begins. */
+        tag = p;
 
-	/* Find the end of the tag name. */
-	while (*p != '\0' && JAS_TVP_ISTAG(*p)) {
-		++p;
-	}
+        /* Find the end of the tag name. */
+        while (*p != '\0' && JAS_TVP_ISTAG(*p)) {
+                ++p;
+        }
 
-	/* Has the end of the input data been reached? */
-	if (*p == '\0') {
-		/* The value field is empty. */
-		tvp->tag = tag;
-		tvp->val = "";
-		tvp->pos = p;
-		return 0;
-	}
+        /* Has the end of the input data been reached? */
+        if (*p == '\0') {
+                /* The value field is empty. */
+                tvp->tag = tag;
+                tvp->val = "";
+                tvp->pos = p;
+                return 0;
+        }
 
-	/* Is a value field not present? */
-	if (*p != '=') {
-		if (*p != '\0' && !isspace(*p)) {
-			return -1;
-		}
-		*p++ = '\0';
-		tvp->tag = tag;
-		tvp->val = "";
-		tvp->pos = p;
-		return 0;
-	}
+        /* Is a value field not present? */
+        if (*p != '=') {
+                if (*p != '\0' && !isspace(*p)) {
+                        return -1;
+                }
+                *p++ = '\0';
+                tvp->tag = tag;
+                tvp->val = "";
+                tvp->pos = p;
+                return 0;
+        }
 
-	*p++ = '\0';
+        *p++ = '\0';
 
-	val = p;
-	while (*p != '\0' && !isspace(*p)) {
-		++p;
-	}
+        val = p;
+        while (*p != '\0' && !isspace(*p)) {
+                ++p;
+        }
 
-	if (*p != '\0') {
-		*p++ = '\0';
-	}
+        if (*p != '\0') {
+                *p++ = '\0';
+        }
 
-	tvp->pos = p;
-	tvp->tag = tag;
-	tvp->val = val;
+        tvp->pos = p;
+        tvp->tag = tag;
+        tvp->val = val;
 
-	return 0;
+        return 0;
 }
 
 /******************************************************************************\
@@ -246,13 +246,13 @@ int jas_tvparser_next(jas_tvparser_t *tvp)
 /* Get the current tag. */
 char *jas_tvparser_gettag(jas_tvparser_t *tvp)
 {
-	return tvp->tag;
+        return tvp->tag;
 }
 
 /* Get the current value. */
 const char *jas_tvparser_getval(jas_tvparser_t *tvp)
 {
-	return tvp->val;
+        return tvp->val;
 }
 
 /******************************************************************************\
@@ -262,15 +262,15 @@ const char *jas_tvparser_getval(jas_tvparser_t *tvp)
 /* Lookup a tag by name. */
 jas_taginfo_t *jas_taginfos_lookup(jas_taginfo_t *taginfos, const char *name)
 {
-	jas_taginfo_t *taginfo;
-	taginfo = taginfos;
-	while (taginfo->id >= 0) {
-		if (!strcmp(taginfo->name, name)) {
-			return taginfo;
-		}
-		++taginfo;
-	}
-	return 0;
+        jas_taginfo_t *taginfo;
+        taginfo = taginfos;
+        while (taginfo->id >= 0) {
+                if (!strcmp(taginfo->name, name)) {
+                        return taginfo;
+                }
+                ++taginfo;
+        }
+        return 0;
 }
 
 /* This function is simply for convenience. */
@@ -278,9 +278,9 @@ jas_taginfo_t *jas_taginfos_lookup(jas_taginfo_t *taginfos, const char *name)
   using this function.   This function never returns a null pointer.  */
 jas_taginfo_t *jas_taginfo_nonull(jas_taginfo_t *taginfo)
 {
-	static jas_taginfo_t invalidtaginfo = {
-		-1, 0
-	};
-	
-	return taginfo ? taginfo : &invalidtaginfo;
+        static jas_taginfo_t invalidtaginfo = {
+                -1, 0
+        };
+       
+        return taginfo ? taginfo : &invalidtaginfo;
 }
diff --git a/converter/other/jpeg2000/libjasper/base/jas_version.c b/converter/other/jpeg2000/libjasper/base/jas_version.c
index 5608c4d4..675a3883 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_version.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_version.c
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -112,5 +112,5 @@
 
 const char *jas_getversion()
 {
-	return JAS_VERSION;
+        return JAS_VERSION;
 }
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_debug.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_debug.h
index 6c597c59..77b65967 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_debug.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_debug.h
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -136,10 +136,10 @@ extern "C" {
 /* Output debugging information to standard error provided that the debug
   level is set sufficiently high. */
 #if defined(DEBUG)
-#define	JAS_DBGLOG(n, x) \
-	((jas_getdbglevel() >= (n)) ? (jas_eprintf x) : 0)
+#define JAS_DBGLOG(n, x) \
+        ((jas_getdbglevel() >= (n)) ? (jas_eprintf x) : 0)
 #else
-#define	JAS_DBGLOG(n, x)
+#define JAS_DBGLOG(n, x)
 #endif
 
 /* Get the library debug level. */
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_fix.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_fix.h
index 9599eb1c..7816b13e 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_fix.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_fix.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -138,16 +138,16 @@ extern "C" {
 \******************************************************************************/
 
 /* The representation of the value zero. */
-#define	JAS_FIX_ZERO(fix_t, fracbits) \
-	JAS_CAST(fix_t, 0)
+#define JAS_FIX_ZERO(fix_t, fracbits) \
+        JAS_CAST(fix_t, 0)
 
 /* The representation of the value one. */
-#define	JAS_FIX_ONE(fix_t, fracbits) \
-	(JAS_CAST(fix_t, 1) << (fracbits))
+#define JAS_FIX_ONE(fix_t, fracbits) \
+        (JAS_CAST(fix_t, 1) << (fracbits))
 
 /* The representation of the value one half. */
-#define	JAS_FIX_HALF(fix_t, fracbits) \
-	(JAS_CAST(fix_t, 1) << ((fracbits) - 1))
+#define JAS_FIX_HALF(fix_t, fracbits) \
+        (JAS_CAST(fix_t, 1) << ((fracbits) - 1))
 
 /******************************************************************************\
 * Conversion operations.
@@ -155,19 +155,19 @@ extern "C" {
 
 /* Convert an int to a fixed-point number. */
 #define JAS_INTTOFIX(fix_t, fracbits, x) \
-	JAS_CAST(fix_t, (x) << (fracbits))
+        JAS_CAST(fix_t, (x) << (fracbits))
 
 /* Convert a fixed-point number to an int. */
 #define JAS_FIXTOINT(fix_t, fracbits, x) \
-	JAS_CAST(int, (x) >> (fracbits))
+        JAS_CAST(int, (x) >> (fracbits))
 
 /* Convert a fixed-point number to a double. */
 #define JAS_FIXTODBL(fix_t, fracbits, x) \
-	(JAS_CAST(double, x) / (JAS_CAST(fix_t, 1) << (fracbits)))
+        (JAS_CAST(double, x) / (JAS_CAST(fix_t, 1) << (fracbits)))
 
 /* Convert a double to a fixed-point number. */
 #define JAS_DBLTOFIX(fix_t, fracbits, x) \
-	JAS_CAST(fix_t, ((x) * JAS_CAST(double, JAS_CAST(fix_t, 1) << (fracbits))))
+        JAS_CAST(fix_t, ((x) * JAS_CAST(double, JAS_CAST(fix_t, 1) << (fracbits))))
 
 /******************************************************************************\
 * Basic arithmetic operations.
@@ -181,128 +181,128 @@ extern "C" {
 
 /* Calculate the sum of two fixed-point numbers. */
 #if !defined(DEBUG_OVERFLOW)
-#define JAS_FIX_ADD			JAS_FIX_ADD_FAST
+#define JAS_FIX_ADD                     JAS_FIX_ADD_FAST
 #else
-#define JAS_FIX_ADD			JAS_FIX_ADD_OFLOW
+#define JAS_FIX_ADD                     JAS_FIX_ADD_OFLOW
 #endif
 
 /* Calculate the sum of two fixed-point numbers without overflow checking. */
-#define	JAS_FIX_ADD_FAST(fix_t, fracbits, x, y)	((x) + (y))
+#define JAS_FIX_ADD_FAST(fix_t, fracbits, x, y) ((x) + (y))
 
 /* Calculate the sum of two fixed-point numbers with overflow checking. */
-#define	JAS_FIX_ADD_OFLOW(fix_t, fracbits, x, y) \
-	((x) >= 0) ? \
-	  (((y) >= 0) ? ((x) + (y) >= 0 || JAS_FIX_OFLOW(), (x) + (y)) : \
-	  ((x) + (y))) : \
-	  (((y) >= 0) ? ((x) + (y)) : ((x) + (y) < 0 || JAS_FIX_OFLOW(), \
-	  (x) + (y)))
+#define JAS_FIX_ADD_OFLOW(fix_t, fracbits, x, y) \
+        ((x) >= 0) ? \
+          (((y) >= 0) ? ((x) + (y) >= 0 || JAS_FIX_OFLOW(), (x) + (y)) : \
+          ((x) + (y))) : \
+          (((y) >= 0) ? ((x) + (y)) : ((x) + (y) < 0 || JAS_FIX_OFLOW(), \
+          (x) + (y)))
 
 /* Calculate the product of two fixed-point numbers. */
 #if !defined(DEBUG_OVERFLOW)
-#define JAS_FIX_MUL			JAS_FIX_MUL_FAST
+#define JAS_FIX_MUL                     JAS_FIX_MUL_FAST
 #else
-#define JAS_FIX_MUL			JAS_FIX_MUL_OFLOW
+#define JAS_FIX_MUL                     JAS_FIX_MUL_OFLOW
 #endif
 
 /* Calculate the product of two fixed-point numbers without overflow
   checking. */
-#define	JAS_FIX_MUL_FAST(fix_t, fracbits, bigfix_t, x, y) \
-	JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y)) >> \
-	  (fracbits))
+#define JAS_FIX_MUL_FAST(fix_t, fracbits, bigfix_t, x, y) \
+        JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y)) >> \
+          (fracbits))
 
 /* Calculate the product of two fixed-point numbers with overflow
   checking. */
 #define JAS_FIX_MUL_OFLOW(fix_t, fracbits, bigfix_t, x, y) \
-	((JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y) >> (fracbits)) == \
-	  JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y) >> \
-	  (fracbits))) ? \
-	  JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y) >> \
-	  (fracbits))) : JAS_FIX_OFLOW())
+        ((JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y) >> (fracbits)) == \
+          JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y) >> \
+          (fracbits))) ? \
+          JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) * JAS_CAST(bigfix_t, y) >> \
+          (fracbits))) : JAS_FIX_OFLOW())
 
 /* Calculate the product of a fixed-point number and an int. */
 #if !defined(DEBUG_OVERFLOW)
-#define	JAS_FIX_MULBYINT	JAS_FIX_MULBYINT_FAST
+#define JAS_FIX_MULBYINT        JAS_FIX_MULBYINT_FAST
 #else
-#define	JAS_FIX_MULBYINT	JAS_FIX_MULBYINT_OFLOW
+#define JAS_FIX_MULBYINT        JAS_FIX_MULBYINT_OFLOW
 #endif
 
 /* Calculate the product of a fixed-point number and an int without overflow
   checking. */
-#define	JAS_FIX_MULBYINT_FAST(fix_t, fracbits, x, y) \
-	JAS_CAST(fix_t, ((x) * (y)))
+#define JAS_FIX_MULBYINT_FAST(fix_t, fracbits, x, y) \
+        JAS_CAST(fix_t, ((x) * (y)))
 
 /* Calculate the product of a fixed-point number and an int with overflow
   checking. */
-#define	JAS_FIX_MULBYINT_OFLOW(fix_t, fracbits, x, y) \
-	JAS_FIX_MULBYINT_FAST(fix_t, fracbits, x, y)
+#define JAS_FIX_MULBYINT_OFLOW(fix_t, fracbits, x, y) \
+        JAS_FIX_MULBYINT_FAST(fix_t, fracbits, x, y)
 
 /* Calculate the quotient of two fixed-point numbers. */
 #if !defined(DEBUG_OVERFLOW)
-#define JAS_FIX_DIV			JAS_FIX_DIV_FAST
+#define JAS_FIX_DIV                     JAS_FIX_DIV_FAST
 #else
-#define JAS_FIX_DIV			JAS_FIX_DIV_UFLOW
+#define JAS_FIX_DIV                     JAS_FIX_DIV_UFLOW
 #endif
 
 /* Calculate the quotient of two fixed-point numbers without underflow
   checking. */
-#define	JAS_FIX_DIV_FAST(fix_t, fracbits, bigfix_t, x, y) \
-	JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) << (fracbits)) / (y))
+#define JAS_FIX_DIV_FAST(fix_t, fracbits, bigfix_t, x, y) \
+        JAS_CAST(fix_t, (JAS_CAST(bigfix_t, x) << (fracbits)) / (y))
 
 /* Calculate the quotient of two fixed-point numbers with underflow
   checking. */
 #define JAS_FIX_DIV_UFLOW(fix_t, fracbits, bigfix_t, x, y) \
-	JAS_FIX_DIV_FAST(fix_t, fracbits, bigfix_t, x, y)
+        JAS_FIX_DIV_FAST(fix_t, fracbits, bigfix_t, x, y)
 
 /* Negate a fixed-point number. */
 #if !defined(DEBUG_OVERFLOW)
-#define	JAS_FIX_NEG			JAS_FIX_NEG_FAST
+#define JAS_FIX_NEG                     JAS_FIX_NEG_FAST
 #else
-#define	JAS_FIX_NEG			JAS_FIX_NEG_OFLOW
+#define JAS_FIX_NEG                     JAS_FIX_NEG_OFLOW
 #endif
 
 /* Negate a fixed-point number without overflow checking. */
-#define	JAS_FIX_NEG_FAST(fix_t, fracbits, x) \
-	(-(x))
+#define JAS_FIX_NEG_FAST(fix_t, fracbits, x) \
+        (-(x))
 
 /* Negate a fixed-point number with overflow checking. */
 /* Yes, overflow is actually possible for two's complement representations,
   although highly unlikely to occur. */
-#define	JAS_FIX_NEG_OFLOW(fix_t, fracbits, x) \
-	(((x) < 0) ? (-(x) > 0 || JAS_FIX_OFLOW(), -(x)) : (-(x)))
+#define JAS_FIX_NEG_OFLOW(fix_t, fracbits, x) \
+        (((x) < 0) ? (-(x) > 0 || JAS_FIX_OFLOW(), -(x)) : (-(x)))
 
 /* Perform an arithmetic shift left of a fixed-point number. */
 #if !defined(DEBUG_OVERFLOW)
-#define	JAS_FIX_ASL			JAS_FIX_ASL_FAST
+#define JAS_FIX_ASL                     JAS_FIX_ASL_FAST
 #else
-#define	JAS_FIX_ASL			JAS_FIX_ASL_OFLOW
+#define JAS_FIX_ASL                     JAS_FIX_ASL_OFLOW
 #endif
 
 /* Perform an arithmetic shift left of a fixed-point number without overflow
   checking. */
-#define	JAS_FIX_ASL_FAST(fix_t, fracbits, x, n) \
-	((x) << (n))
+#define JAS_FIX_ASL_FAST(fix_t, fracbits, x, n) \
+        ((x) << (n))
 
 /* Perform an arithmetic shift left of a fixed-point number with overflow
   checking. */
-#define	JAS_FIX_ASL_OFLOW(fix_t, fracbits, x, n) \
-	((((x) << (n)) >> (n)) == (x) || JAS_FIX_OFLOW(), (x) << (n))
+#define JAS_FIX_ASL_OFLOW(fix_t, fracbits, x, n) \
+        ((((x) << (n)) >> (n)) == (x) || JAS_FIX_OFLOW(), (x) << (n))
 
 /* Perform an arithmetic shift right of a fixed-point number. */
 #if !defined(DEBUG_OVERFLOW)
-#define	JAS_FIX_ASR			JAS_FIX_ASR_FAST
+#define JAS_FIX_ASR                     JAS_FIX_ASR_FAST
 #else
-#define	JAS_FIX_ASR			JAS_FIX_ASR_UFLOW
+#define JAS_FIX_ASR                     JAS_FIX_ASR_UFLOW
 #endif
 
 /* Perform an arithmetic shift right of a fixed-point number without underflow
   checking. */
-#define	JAS_FIX_ASR_FAST(fix_t, fracbits, x, n) \
-	((x) >> (n))
+#define JAS_FIX_ASR_FAST(fix_t, fracbits, x, n) \
+        ((x) >> (n))
 
 /* Perform an arithmetic shift right of a fixed-point number with underflow
   checking. */
-#define	JAS_FIX_ASR_UFLOW(fix_t, fracbits, x, n) \
-	JAS_FIX_ASR_FAST(fix_t, fracbits, x, n)
+#define JAS_FIX_ASR_UFLOW(fix_t, fracbits, x, n) \
+        JAS_FIX_ASR_FAST(fix_t, fracbits, x, n)
 
 /******************************************************************************\
 * Other basic arithmetic operations.
@@ -310,35 +310,35 @@ extern "C" {
 
 /* Calculate the difference between two fixed-point numbers. */
 #define JAS_FIX_SUB(fix_t, fracbits, x, y) \
-	JAS_FIX_ADD(fix_t, fracbits, x, JAS_FIX_NEG(fix_t, fracbits, y))
+        JAS_FIX_ADD(fix_t, fracbits, x, JAS_FIX_NEG(fix_t, fracbits, y))
 
 /* Add one fixed-point number to another. */
 #define JAS_FIX_PLUSEQ(fix_t, fracbits, x, y) \
-	((x) = JAS_FIX_ADD(fix_t, fracbits, x, y))
+        ((x) = JAS_FIX_ADD(fix_t, fracbits, x, y))
 
 /* Subtract one fixed-point number from another. */
 #define JAS_FIX_MINUSEQ(fix_t, fracbits, x, y) \
-	((x) = JAS_FIX_SUB(fix_t, fracbits, x, y))
+        ((x) = JAS_FIX_SUB(fix_t, fracbits, x, y))
 
 /* Multiply one fixed-point number by another. */
-#define	JAS_FIX_MULEQ(fix_t, fracbits, bigfix_t, x, y) \
-	((x) = JAS_FIX_MUL(fix_t, fracbits, bigfix_t, x, y))
+#define JAS_FIX_MULEQ(fix_t, fracbits, bigfix_t, x, y) \
+        ((x) = JAS_FIX_MUL(fix_t, fracbits, bigfix_t, x, y))
 
 /******************************************************************************\
 * Miscellaneous operations.
 \******************************************************************************/
 
 /* Calculate the absolute value of a fixed-point number. */
-#define	JAS_FIX_ABS(fix_t, fracbits, x) \
-	(((x) >= 0) ? (x) : (JAS_FIX_NEG(fix_t, fracbits, x)))
+#define JAS_FIX_ABS(fix_t, fracbits, x) \
+        (((x) >= 0) ? (x) : (JAS_FIX_NEG(fix_t, fracbits, x)))
 
 /* Is a fixed-point number an integer? */
-#define	JAS_FIX_ISINT(fix_t, fracbits, x) \
-	(JAS_FIX_FLOOR(fix_t, fracbits, x) == (x))
+#define JAS_FIX_ISINT(fix_t, fracbits, x) \
+        (JAS_FIX_FLOOR(fix_t, fracbits, x) == (x))
 
 /* Get the sign of a fixed-point number. */
 #define JAS_FIX_SGN(fix_t, fracbits, x) \
-	((x) >= 0 ? 1 : (-1))
+        ((x) >= 0 ? 1 : (-1))
 
 /******************************************************************************\
 * Relational operations.
@@ -346,45 +346,45 @@ extern "C" {
 
 /* Compare two fixed-point numbers. */
 #define JAS_FIX_CMP(fix_t, fracbits, x, y) \
-	((x) > (y) ? 1 : (((x) == (y)) ? 0 : (-1)))
+        ((x) > (y) ? 1 : (((x) == (y)) ? 0 : (-1)))
 
 /* Less than. */
-#define	JAS_FIX_LT(fix_t, fracbits, x, y) \
-	((x) < (y))
+#define JAS_FIX_LT(fix_t, fracbits, x, y) \
+        ((x) < (y))
 
 /* Less than or equal. */
-#define	JAS_FIX_LTE(fix_t, fracbits, x, y) \
-	((x) <= (y))
+#define JAS_FIX_LTE(fix_t, fracbits, x, y) \
+        ((x) <= (y))
 
 /* Greater than. */
-#define	JAS_FIX_GT(fix_t, fracbits, x, y) \
-	((x) > (y))
+#define JAS_FIX_GT(fix_t, fracbits, x, y) \
+        ((x) > (y))
 
 /* Greater than or equal. */
-#define	JAS_FIX_GTE(fix_t, fracbits, x, y) \
-	((x) >= (y))
+#define JAS_FIX_GTE(fix_t, fracbits, x, y) \
+        ((x) >= (y))
 
 /******************************************************************************\
 * Rounding functions.
 \******************************************************************************/
 
 /* Round a fixed-point number to the nearest integer. */
-#define	JAS_FIX_ROUND(fix_t, fracbits, x) \
-	(((x) < 0) ? JAS_FIX_FLOOR(fix_t, fracbits, JAS_FIX_ADD(fix_t, fracbits, \
-	  (x), JAS_FIX_HALF(fix_t, fracbits))) : \
-	  JAS_FIX_NEG(fix_t, fracbits, JAS_FIX_FLOOR(fix_t, fracbits, \
-	  JAS_FIX_ADD(fix_t, fracbits, (-(x)), JAS_FIX_HALF(fix_t, fracbits)))))
+#define JAS_FIX_ROUND(fix_t, fracbits, x) \
+        (((x) < 0) ? JAS_FIX_FLOOR(fix_t, fracbits, JAS_FIX_ADD(fix_t, fracbits, \
+          (x), JAS_FIX_HALF(fix_t, fracbits))) : \
+          JAS_FIX_NEG(fix_t, fracbits, JAS_FIX_FLOOR(fix_t, fracbits, \
+          JAS_FIX_ADD(fix_t, fracbits, (-(x)), JAS_FIX_HALF(fix_t, fracbits)))))
 
 /* Round a fixed-point number to the nearest integer in the direction of
   negative infinity (i.e., the floor function). */
-#define	JAS_FIX_FLOOR(fix_t, fracbits, x) \
-	((x) & (~((JAS_CAST(fix_t, 1) << (fracbits)) - 1)))
+#define JAS_FIX_FLOOR(fix_t, fracbits, x) \
+        ((x) & (~((JAS_CAST(fix_t, 1) << (fracbits)) - 1)))
 
 /* Round a fixed-point number to the nearest integer in the direction
   of zero. */
 #define JAS_FIX_TRUNC(fix_t, fracbits, x) \
-	(((x) >= 0) ? JAS_FIX_FLOOR(fix_t, fracbits, x) : \
-	  JAS_FIX_CEIL(fix_t, fracbits, x))
+        (((x) >= 0) ? JAS_FIX_FLOOR(fix_t, fracbits, x) : \
+          JAS_FIX_CEIL(fix_t, fracbits, x))
 
 /******************************************************************************\
 * The below macros are for internal library use only.  Do not invoke them
@@ -392,12 +392,12 @@ extern "C" {
 \******************************************************************************/
 
 /* Handle overflow. */
-#define	JAS_FIX_OFLOW() \
-	fprintf(stderr, "overflow error: file %s, line %d\n", __FILE__, __LINE__)
+#define JAS_FIX_OFLOW() \
+        fprintf(stderr, "overflow error: file %s, line %d\n", __FILE__, __LINE__)
 
 /* Handle underflow. */
-#define	JAS_FIX_UFLOW() \
-	fprintf(stderr, "underflow error: file %s, line %d\n", __FILE__, __LINE__)
+#define JAS_FIX_UFLOW() \
+        fprintf(stderr, "underflow error: file %s, line %d\n", __FILE__, __LINE__)
 
 #ifdef __cplusplus
 }
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_getopt.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_getopt.h
index 4f272dc9..31087948 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_getopt.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_getopt.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -127,11 +127,11 @@ extern "C" {
 * Constants.
 \******************************************************************************/
 
-#define	JAS_GETOPT_EOF	(-1)
-#define	JAS_GETOPT_ERR	'?'
+#define JAS_GETOPT_EOF  (-1)
+#define JAS_GETOPT_ERR  '?'
 
 /* option flags. */
-#define	JAS_OPT_HASARG	0x01	/* option has argument */
+#define JAS_OPT_HASARG  0x01    /* option has argument */
 
 /******************************************************************************\
 * Types.
@@ -140,14 +140,14 @@ extern "C" {
 /* Command line option type. */
 typedef struct {
 
-	int id;
-	/* The unique identifier for this option. */
+        int id;
+        /* The unique identifier for this option. */
 
-	char *name;
-	/* The name of this option. */
+        char *name;
+        /* The name of this option. */
 
-	int flags;
-	/* option flags. */
+        int flags;
+        /* option flags. */
 
 } jas_opt_t;
 
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_image.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_image.h
index 20170986..56bb6cdf 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_image.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_image.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -140,36 +140,36 @@ extern "C" {
  */
 
 /* The threshold at which image data is no longer stored in memory. */
-#define JAS_IMAGE_INMEMTHRESH	(16 * 1024 * 1024)
+#define JAS_IMAGE_INMEMTHRESH   (16 * 1024 * 1024)
 
 /*
  * Color models.
  */
 
-#define JAS_IMAGE_CS_UNKNOWN	0	/* Unknown */
-#define	JAS_IMAGE_CS_GRAY	1	/* Standard Gray */
-#define	JAS_IMAGE_CS_RGB	2	/* Standard RGB */
-#define	JAS_IMAGE_CS_YCBCR	3	/* Standard YCC */
+#define JAS_IMAGE_CS_UNKNOWN    0       /* Unknown */
+#define JAS_IMAGE_CS_GRAY       1       /* Standard Gray */
+#define JAS_IMAGE_CS_RGB        2       /* Standard RGB */
+#define JAS_IMAGE_CS_YCBCR      3       /* Standard YCC */
 #if 0
-#define	JAS_IMAGE_CM_ICC	4	/* ICC Profile */
+#define JAS_IMAGE_CM_ICC        4       /* ICC Profile */
 #endif
 /*
  * Component types
  */
 
-#define	JAS_IMAGE_CT_UNKNOWN	0x10000
-#define	JAS_IMAGE_CT_COLOR(n)	((n) & 0x7fff)
-#define	JAS_IMAGE_CT_OPACITY	0x08000
+#define JAS_IMAGE_CT_UNKNOWN    0x10000
+#define JAS_IMAGE_CT_COLOR(n)   ((n) & 0x7fff)
+#define JAS_IMAGE_CT_OPACITY    0x08000
 
-#define	JAS_IMAGE_CT_RGB_R	0
-#define	JAS_IMAGE_CT_RGB_G	1
-#define	JAS_IMAGE_CT_RGB_B	2
+#define JAS_IMAGE_CT_RGB_R      0
+#define JAS_IMAGE_CT_RGB_G      1
+#define JAS_IMAGE_CT_RGB_B      2
 
-#define	JAS_IMAGE_CT_YCBCR_Y	0
-#define	JAS_IMAGE_CT_YCBCR_CB	1
-#define	JAS_IMAGE_CT_YCBCR_CR	2
+#define JAS_IMAGE_CT_YCBCR_Y    0
+#define JAS_IMAGE_CT_YCBCR_CB   1
+#define JAS_IMAGE_CT_YCBCR_CR   2
 
-#define	JAS_IMAGE_CT_GRAY_Y	0
+#define JAS_IMAGE_CT_GRAY_Y     0
 
 /*****************************************************************************\
 * Image class and supporting classes.
@@ -179,40 +179,40 @@ extern "C" {
 
 typedef struct {
 
-	uint_fast32_t tlx_;
-	/* The x-coordinate of the top-left corner of the component. */
+        uint_fast32_t tlx_;
+        /* The x-coordinate of the top-left corner of the component. */
 
-	uint_fast32_t tly_;
-	/* The y-coordinate of the top-left corner of the component. */
+        uint_fast32_t tly_;
+        /* The y-coordinate of the top-left corner of the component. */
 
-	uint_fast32_t hstep_;
-	/* The horizontal sampling period in units of the reference grid. */
+        uint_fast32_t hstep_;
+        /* The horizontal sampling period in units of the reference grid. */
 
-	uint_fast32_t vstep_;
-	/* The vertical sampling period in units of the reference grid. */
+        uint_fast32_t vstep_;
+        /* The vertical sampling period in units of the reference grid. */
 
-	uint_fast32_t width_;
-	/* The component width in samples. */
+        uint_fast32_t width_;
+        /* The component width in samples. */
 
-	uint_fast32_t height_;
-	/* The component height in samples. */
+        uint_fast32_t height_;
+        /* The component height in samples. */
 
-	uint_fast16_t prec_;
-	/* The precision of the sample data (i.e., the number of bits per
-	sample).  If the samples are signed values, this quantity
-	includes the sign bit. */
+        uint_fast16_t prec_;
+        /* The precision of the sample data (i.e., the number of bits per
+        sample).  If the samples are signed values, this quantity
+        includes the sign bit. */
 
-	uint_fast8_t sgnd_;
-	/* The signedness of the sample data. */
+        uint_fast8_t sgnd_;
+        /* The signedness of the sample data. */
 
-	jas_stream_t *stream_;
-	/* The stream containing the component data. */
+        jas_stream_t *stream_;
+        /* The stream containing the component data. */
 
-	int cps_;
-	/* The number of characters per sample in the stream. */
+        int cps_;
+        /* The number of characters per sample in the stream. */
 
-	uint_fast32_t type_;
-	/* The type of component (e.g., opacity, red, green, blue, luma). */
+        uint_fast32_t type_;
+        /* The type of component (e.g., opacity, red, green, blue, luma). */
 
 } jas_image_cmpt_t;
 
@@ -220,40 +220,40 @@ typedef struct {
 
 typedef struct {
 
-	uint_fast32_t tlx_;
-	/* The x-coordinate of the top-left corner of the image bounding box. */
+        uint_fast32_t tlx_;
+        /* The x-coordinate of the top-left corner of the image bounding box. */
 
-	uint_fast32_t tly_;
-	/* The y-coordinate of the top-left corner of the image bounding box. */
+        uint_fast32_t tly_;
+        /* The y-coordinate of the top-left corner of the image bounding box. */
 
-	uint_fast32_t brx_;
-	/* The x-coordinate of the bottom-right corner of the image bounding
-	  box (plus one). */
+        uint_fast32_t brx_;
+        /* The x-coordinate of the bottom-right corner of the image bounding
+          box (plus one). */
 
-	uint_fast32_t bry_;
-	/* The y-coordinate of the bottom-right corner of the image bounding
-	  box (plus one). */
+        uint_fast32_t bry_;
+        /* The y-coordinate of the bottom-right corner of the image bounding
+          box (plus one). */
 
-	uint_fast16_t numcmpts_;
-	/* The number of components. */
+        uint_fast16_t numcmpts_;
+        /* The number of components. */
 
-	uint_fast16_t maxcmpts_;
-	/* The maximum number of components that this image can have (i.e., the
-	  allocated size of the components array). */
+        uint_fast16_t maxcmpts_;
+        /* The maximum number of components that this image can have (i.e., the
+          allocated size of the components array). */
 
-	jas_image_cmpt_t **cmpts_;
-	/* Per-component information. */
+        jas_image_cmpt_t **cmpts_;
+        /* Per-component information. */
 
-	int colorspace_;
-	/* The color space used (e.g., RGB, YCbCr, gray).  This field is only
-	of particular relevance in the case of a multi-component image. */
+        int colorspace_;
+        /* The color space used (e.g., RGB, YCbCr, gray).  This field is only
+        of particular relevance in the case of a multi-component image. */
 
-	unsigned char *iccp_;
-	/* ICC profile information. */
+        unsigned char *iccp_;
+        /* ICC profile information. */
 
-	int iccplen_;
+        int iccplen_;
 
-	bool inmem_;
+        bool inmem_;
 
 } jas_image_t;
 
@@ -263,29 +263,29 @@ typedef struct {
 
 typedef struct {
 
-	uint_fast32_t tlx;
-	/* The x-coordinate of the top-left corner of the component. */
+        uint_fast32_t tlx;
+        /* The x-coordinate of the top-left corner of the component. */
 
-	uint_fast32_t tly;
-	/* The y-coordinate of the top-left corner of the component. */
+        uint_fast32_t tly;
+        /* The y-coordinate of the top-left corner of the component. */
 
-	uint_fast32_t hstep;
-	/* The horizontal sampling period in units of the reference grid. */
+        uint_fast32_t hstep;
+        /* The horizontal sampling period in units of the reference grid. */
 
-	uint_fast32_t vstep;
-	/* The vertical sampling period in units of the reference grid. */
+        uint_fast32_t vstep;
+        /* The vertical sampling period in units of the reference grid. */
 
-	uint_fast32_t width;
-	/* The width of the component in samples. */
+        uint_fast32_t width;
+        /* The width of the component in samples. */
 
-	uint_fast32_t height;
-	/* The height of the component in samples. */
+        uint_fast32_t height;
+        /* The height of the component in samples. */
 
-	uint_fast16_t prec;
-	/* The precision of the component sample data. */
+        uint_fast16_t prec;
+        /* The precision of the component sample data. */
 
-	bool sgnd;
-	/* The signedness of the component sample data. */
+        bool sgnd;
+        /* The signedness of the component sample data. */
 
 } jas_image_cmptparm_t;
 
@@ -293,24 +293,24 @@ typedef struct {
 * File format related classes.
 \******************************************************************************/
 
-#define	JAS_IMAGE_MAXFMTS	32
+#define JAS_IMAGE_MAXFMTS       32
 /* The maximum number of image data formats we can handle. */
 
 /* Image format-dependent operations. */
 
 typedef struct {
 
-	void (*decode)(jas_stream_t * const in,
-				   const char *   const opts,
-				   jas_image_t ** const imagePP,
-				   const char **  const errorP);
-	/* Decode image data from a stream. */
+        void (*decode)(jas_stream_t * const in,
+                                   const char *   const opts,
+                                   jas_image_t ** const imagePP,
+                                   const char **  const errorP);
+        /* Decode image data from a stream. */
 
-	int (*encode)(jas_image_t *image, jas_stream_t *out, char *opts);
-	/* Encode image data to a stream. */
+        int (*encode)(jas_image_t *image, jas_stream_t *out, char *opts);
+        /* Encode image data to a stream. */
 
-	int (*validate)(jas_stream_t *in);
-	/* Determine if stream data is in a particular format. */
+        int (*validate)(jas_stream_t *in);
+        /* Determine if stream data is in a particular format. */
 
 } jas_image_fmtops_t;
 
@@ -318,20 +318,20 @@ typedef struct {
 
 typedef struct {
 
-	int id;
-	/* The ID for this format. */
+        int id;
+        /* The ID for this format. */
 
-	char *name;
-	/* The name by which this format is identified. */
+        char *name;
+        /* The name by which this format is identified. */
 
-	char *ext;
-	/* The file name extension associated with this format. */
+        char *ext;
+        /* The file name extension associated with this format. */
 
-	char *desc;
-	/* A brief description of the format. */
+        char *desc;
+        /* A brief description of the format. */
 
-	jas_image_fmtops_t ops;
-	/* The operations for this format. */
+        jas_image_fmtops_t ops;
+        /* The operations for this format. */
 
 } jas_image_fmtinfo_t;
 
@@ -354,92 +354,92 @@ void jas_image_destroy(jas_image_t *image);
 
 /* Get the width of the image in units of the image reference grid. */
 #define jas_image_width(image) \
-	((image)->brx_ - (image)->tlx_)
+        ((image)->brx_ - (image)->tlx_)
 
 /* Get the height of the image in units of the image reference grid. */
-#define	jas_image_height(image) \
-	((image)->bry_ - (image)->tly_)
+#define jas_image_height(image) \
+        ((image)->bry_ - (image)->tly_)
 
 /* Get the x-coordinate of the top-left corner of the image bounding box
   on the reference grid. */
 #define jas_image_tlx(image) \
-	((image)->tlx_)
+        ((image)->tlx_)
 
 /* Get the y-coordinate of the top-left corner of the image bounding box
   on the reference grid. */
 #define jas_image_tly(image) \
-	((image)->tly_)
+        ((image)->tly_)
 
 /* Get the x-coordinate of the bottom-right corner of the image bounding box
   on the reference grid (plus one). */
 #define jas_image_brx(image) \
-	((image)->brx_)
+        ((image)->brx_)
 
 /* Get the y-coordinate of the bottom-right corner of the image bounding box
   on the reference grid (plus one). */
 #define jas_image_bry(image) \
-	((image)->bry_)
+        ((image)->bry_)
 
 /* Get the number of image components. */
-#define	jas_image_numcmpts(image) \
-	((image)->numcmpts_)
+#define jas_image_numcmpts(image) \
+        ((image)->numcmpts_)
 
 /* Get the color model used by the image. */
-#define	jas_image_colorspace(image) \
-	((image)->colorspace_)
+#define jas_image_colorspace(image) \
+        ((image)->colorspace_)
 
 /* Set the color model for an image. */
 #define jas_image_setcolorspace(image, colorspace) \
-	((image)->colorspace_ = (colorspace))
+        ((image)->colorspace_ = (colorspace))
 
 #define jas_image_cmpttype(image, cmptno) \
-	((image)->cmpts_[(cmptno)]->type_)
+        ((image)->cmpts_[(cmptno)]->type_)
 #define jas_image_setcmpttype(image, cmptno, type) \
-	((image)->cmpts_[(cmptno)]->type_ = (type))
+        ((image)->cmpts_[(cmptno)]->type_ = (type))
 
 /* Get the width of a component. */
-#define	jas_image_cmptwidth(image, cmptno) \
-	((image)->cmpts_[cmptno]->width_)
+#define jas_image_cmptwidth(image, cmptno) \
+        ((image)->cmpts_[cmptno]->width_)
 
 /* Get the height of a component. */
-#define	jas_image_cmptheight(image, cmptno) \
-	((image)->cmpts_[cmptno]->height_)
+#define jas_image_cmptheight(image, cmptno) \
+        ((image)->cmpts_[cmptno]->height_)
 
 /* Get the signedness of the sample data for a component. */
-#define	jas_image_cmptsgnd(image, cmptno) \
-	((image)->cmpts_[cmptno]->sgnd_)
+#define jas_image_cmptsgnd(image, cmptno) \
+        ((image)->cmpts_[cmptno]->sgnd_)
 
 /* Get the precision of the sample data for a component. */
-#define	jas_image_cmptprec(image, cmptno) \
-	((image)->cmpts_[cmptno]->prec_)
+#define jas_image_cmptprec(image, cmptno) \
+        ((image)->cmpts_[cmptno]->prec_)
 
 /* Get the horizontal subsampling factor for a component. */
-#define	jas_image_cmpthstep(image, cmptno) \
-	((image)->cmpts_[cmptno]->hstep_)
+#define jas_image_cmpthstep(image, cmptno) \
+        ((image)->cmpts_[cmptno]->hstep_)
 
 /* Get the vertical subsampling factor for a component. */
-#define	jas_image_cmptvstep(image, cmptno) \
-	((image)->cmpts_[cmptno]->vstep_)
+#define jas_image_cmptvstep(image, cmptno) \
+        ((image)->cmpts_[cmptno]->vstep_)
 
 /* Get the x-coordinate of the top-left corner of a component. */
-#define	jas_image_cmpttlx(image, cmptno) \
-	((image)->cmpts_[cmptno]->tlx_)
+#define jas_image_cmpttlx(image, cmptno) \
+        ((image)->cmpts_[cmptno]->tlx_)
 
 /* Get the y-coordinate of the top-left corner of a component. */
-#define	jas_image_cmpttly(image, cmptno) \
-	((image)->cmpts_[cmptno]->tly_)
+#define jas_image_cmpttly(image, cmptno) \
+        ((image)->cmpts_[cmptno]->tly_)
 
 /* Get the x-coordinate of the bottom-right corner of a component
   (plus "one"). */
-#define	jas_image_cmptbrx(image, cmptno) \
-	((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \
-	  (image)->cmpts_[cmptno]->hstep_)
+#define jas_image_cmptbrx(image, cmptno) \
+        ((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \
+          (image)->cmpts_[cmptno]->hstep_)
 
 /* Get the y-coordinate of the bottom-right corner of a component
   (plus "one"). */
-#define	jas_image_cmptbry(image, cmptno) \
-	((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \
-	  (image)->cmpts_[cmptno]->vstep_)
+#define jas_image_cmptbry(image, cmptno) \
+        ((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \
+          (image)->cmpts_[cmptno]->vstep_)
 
 /* Get the raw size of an image (i.e., the nominal size of the image without
   any compression. */
@@ -449,10 +449,10 @@ uint_fast32_t jas_image_rawsize(jas_image_t *image);
 
 void
 pmjas_image_decode(jas_stream_t * const in,
-				   int            const fmt,
-				   const char *   const optstr,
-				   jas_image_t ** const imagePP,
-				   const char **  const errorP);
+                                   int            const fmt,
+                                   const char *   const optstr,
+                                   jas_image_t ** const imagePP,
+                                   const char **  const errorP);
 
 /* Write an image to a stream in a specified format. */
 int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt,
@@ -486,13 +486,13 @@ int_fast64_t jas_image_readcmpt1(jas_image_t *image, uint_fast16_t cmptno,
   uint_fast32_t x, uint_fast32_t y);
 #endif
 
-#define	JAS_IMAGE_CDT_GETSGND(dtype) (((dtype) >> 7) & 1)
-#define	JAS_IMAGE_CDT_SETSGND(dtype) (((dtype) & 1) << 7)
-#define	JAS_IMAGE_CDT_GETPREC(dtype) ((dtype) & 0x7f)
-#define	JAS_IMAGE_CDT_SETPREC(dtype) ((dtype) & 0x7f)
+#define JAS_IMAGE_CDT_GETSGND(dtype) (((dtype) >> 7) & 1)
+#define JAS_IMAGE_CDT_SETSGND(dtype) (((dtype) & 1) << 7)
+#define JAS_IMAGE_CDT_GETPREC(dtype) ((dtype) & 0x7f)
+#define JAS_IMAGE_CDT_SETPREC(dtype) ((dtype) & 0x7f)
 
-#define	jas_image_cmptdtype(image, cmptno) \
-	(JAS_IMAGE_CDT_SETSGND((image)->cmpts_[cmptno]->sgnd_) | JAS_IMAGE_CDT_SETPREC((image)->cmpts_[cmptno]->prec_))
+#define jas_image_cmptdtype(image, cmptno) \
+        (JAS_IMAGE_CDT_SETSGND((image)->cmpts_[cmptno]->sgnd_) | JAS_IMAGE_CDT_SETPREC((image)->cmpts_[cmptno]->prec_))
 
 void jas_image_dump(jas_image_t *image, FILE *out);
 
@@ -513,7 +513,7 @@ int jas_image_getcmptbytype(jas_image_t *image, int ctype);
 void jas_image_clearfmts(void);
 
 /* Add entry to table of image formats. */
-int jas_image_addfmt(int id, const char *name, const char *ext, 
+int jas_image_addfmt(int id, const char *name, const char *ext,
   const char *desc,
   jas_image_fmtops_t *ops);
 
@@ -578,9 +578,9 @@ int bmp_validate(jas_stream_t *in);
 /* Format-dependent operations for JP2 capability. */
 void
 jp2_decode(jas_stream_t * const in,
-		   const char *   const optstr,
-		   jas_image_t ** const imagePP,
-		   const char **  const errorP);
+                   const char *   const optstr,
+                   jas_image_t ** const imagePP,
+                   const char **  const errorP);
 int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
 int jp2_validate(jas_stream_t *in);
 #endif
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_init.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_init.h
index 4ebeaa87..8d84a10b 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_init.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_init.h
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_malloc.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_malloc.h
index fe5b6172..c2a32581 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_malloc.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_malloc.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -138,10 +138,10 @@ extern "C" {
 /* This is somewhat of a hack, but it's a useful hack. :-) */
 /* Use my own custom memory allocator for debugging. */
 #include "../../../../local/src/memalloc.h"
-#define jas_malloc	MEMALLOC
-#define	jas_free	MEMFREE
-#define	jas_realloc	MEMREALLOC
-#define	jas_calloc	MEMCALLOC
+#define jas_malloc      MEMALLOC
+#define jas_free        MEMFREE
+#define jas_realloc     MEMREALLOC
+#define jas_calloc      MEMCALLOC
 #endif
 
 /******************************************************************************\
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_math.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_math.h
index a43051e5..2baac725 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_math.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_math.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -116,16 +116,16 @@
  * $Id$
  */
 
-#ifndef	JAS_MATH_H
-#define	JAS_MATH_H
+#ifndef JAS_MATH_H
+#define JAS_MATH_H
 
 /******************************************************************************\
 * Includes
 \******************************************************************************/
 
-#include	<assert.h>
-#include	<stdio.h>
-#include	<string.h>
+#include        <assert.h>
+#include        <stdio.h>
+#include        <string.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -136,25 +136,25 @@ extern "C" {
 \******************************************************************************/
 
 /* Compute the absolute value. */
-#define	JAS_ABS(x) \
-	(((x) >= 0) ? (x) : (-(x)))
+#define JAS_ABS(x) \
+        (((x) >= 0) ? (x) : (-(x)))
 
 /* Compute the minimum of two values. */
-#define	JAS_MIN(x, y) \
-	(((x) < (y)) ? (x) : (y))
+#define JAS_MIN(x, y) \
+        (((x) < (y)) ? (x) : (y))
 
 /* Compute the maximum of two values. */
-#define	JAS_MAX(x, y) \
-	(((x) > (y)) ? (x) : (y))
+#define JAS_MAX(x, y) \
+        (((x) > (y)) ? (x) : (y))
 
 /* Compute the remainder from division (where division is defined such
   that the remainder is always nonnegative). */
-#define	JAS_MOD(x, y) \
-	(((x) < 0) ? (((-x) % (y)) ? ((y) - ((-(x)) % (y))) : (0)) : ((x) % (y)))
+#define JAS_MOD(x, y) \
+        (((x) < 0) ? (((-x) % (y)) ? ((y) - ((-(x)) % (y))) : (0)) : ((x) % (y)))
 
 /* Compute the integer with the specified number of least significant bits
   set to one. */
-#define	JAS_ONES(n) \
+#define JAS_ONES(n) \
   ((1 << (n)) - 1)
 
 #ifdef __cplusplus
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_seq.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_seq.h
index 4599f50c..502470d0 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_seq.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_seq.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -135,7 +135,7 @@ extern "C" {
 \******************************************************************************/
 
 /* This matrix is a reference to another matrix. */
-#define JAS_MATRIX_REF	0x0001
+#define JAS_MATRIX_REF  0x0001
 
 /******************************************************************************\
 * Types.
@@ -151,38 +151,38 @@ typedef int_fast32_t jas_matent_t;
 
 typedef struct {
 
-	/* Additional state information. */
-	int flags_;
+        /* Additional state information. */
+        int flags_;
 
-	/* The starting horizontal index. */
-	int_fast32_t xstart_;
+        /* The starting horizontal index. */
+        int_fast32_t xstart_;
 
-	/* The starting vertical index. */
-	int_fast32_t ystart_;
+        /* The starting vertical index. */
+        int_fast32_t ystart_;
 
-	/* The ending horizontal index. */
-	int_fast32_t xend_;
+        /* The ending horizontal index. */
+        int_fast32_t xend_;
 
-	/* The ending vertical index. */
-	int_fast32_t yend_;
+        /* The ending vertical index. */
+        int_fast32_t yend_;
 
-	/* The number of rows in the matrix. */
-	int_fast32_t numrows_;
+        /* The number of rows in the matrix. */
+        int_fast32_t numrows_;
 
-	/* The number of columns in the matrix. */
-	int_fast32_t numcols_;
+        /* The number of columns in the matrix. */
+        int_fast32_t numcols_;
 
-	/* Pointers to the start of each row. */
-	jas_seqent_t **rows_;
+        /* Pointers to the start of each row. */
+        jas_seqent_t **rows_;
 
-	/* The allocated size of the rows array. */
-	int_fast32_t maxrows_;
+        /* The allocated size of the rows array. */
+        int_fast32_t maxrows_;
 
-	/* The matrix data buffer. */
-	jas_seqent_t *data_;
+        /* The matrix data buffer. */
+        jas_seqent_t *data_;
 
-	/* The allocated size of the data array. */
-	int_fast32_t datasize_;
+        /* The allocated size of the data array. */
+        int_fast32_t datasize_;
 
 } jas_matrix_t;
 
@@ -195,39 +195,39 @@ typedef jas_matrix_t jas_seq_t;
 
 /* Get the number of rows. */
 #define jas_matrix_numrows(matrix) \
-	((matrix)->numrows_)
+        ((matrix)->numrows_)
 
 /* Get the number of columns. */
 #define jas_matrix_numcols(matrix) \
-	((matrix)->numcols_)
+        ((matrix)->numcols_)
 
 /* Get a matrix element. */
 #define jas_matrix_get(matrix, i, j) \
-	((matrix)->rows_[i][j])
+        ((matrix)->rows_[i][j])
 
 /* Set a matrix element. */
 #define jas_matrix_set(matrix, i, j, v) \
-	((matrix)->rows_[i][j] = (v))
+        ((matrix)->rows_[i][j] = (v))
 
 /* Get an element from a matrix that is known to be a row or column vector. */
 #define jas_matrix_getv(matrix, i) \
-	(((matrix)->numrows_ == 1) ? ((matrix)->rows_[0][i]) : \
-	  ((matrix)->rows_[i][0]))
+        (((matrix)->numrows_ == 1) ? ((matrix)->rows_[0][i]) : \
+          ((matrix)->rows_[i][0]))
 
 /* Set an element in a matrix that is known to be a row or column vector. */
 #define jas_matrix_setv(matrix, i, v) \
-	(((matrix)->numrows_ == 1) ? ((matrix)->rows_[0][i] = (v)) : \
-	  ((matrix)->rows_[i][0] = (v)))
+        (((matrix)->numrows_ == 1) ? ((matrix)->rows_[0][i] = (v)) : \
+          ((matrix)->rows_[i][0] = (v)))
 
 /* Get the address of an element in a matrix. */
-#define	jas_matrix_getref(matrix, i, j) \
-	(&(matrix)->rows_[i][j])
+#define jas_matrix_getref(matrix, i, j) \
+        (&(matrix)->rows_[i][j])
 
-#define	jas_matrix_getvref(matrix, i) \
-	(((matrix)->numrows_ > 1) ? jas_matrix_getref(matrix, i, 0) : jas_matrix_getref(matrix, 0, i))
+#define jas_matrix_getvref(matrix, i) \
+        (((matrix)->numrows_ > 1) ? jas_matrix_getref(matrix, i, 0) : jas_matrix_getref(matrix, 0, i))
 
 #define jas_matrix_length(matrix) \
-	(max((matrix)->numrows_, (matrix)->numcols_))
+        (max((matrix)->numrows_, (matrix)->numcols_))
 
 /* Create a matrix with the specified dimensions. */
 jas_matrix_t *jas_matrix_create(int numrows, int numcols);
@@ -273,12 +273,12 @@ void jas_matrix_divpow2(jas_matrix_t *matrix, int n);
 void jas_matrix_setall(jas_matrix_t *matrix, jas_seqent_t val);
 
 /* The spacing between rows of a matrix. */
-#define	jas_matrix_rowstep(matrix) \
-	(((matrix)->numrows_ > 1) ? ((matrix)->rows_[1] - (matrix)->rows_[0]) : (0))
+#define jas_matrix_rowstep(matrix) \
+        (((matrix)->numrows_ > 1) ? ((matrix)->rows_[1] - (matrix)->rows_[0]) : (0))
 
 /* The spacing between columns of a matrix. */
-#define	jas_matrix_step(matrix) \
-	(((matrix)->numrows_ > 1) ? (jas_matrix_rowstep(matrix)) : (1))
+#define jas_matrix_step(matrix) \
+        (((matrix)->numrows_ > 1) ? (jas_matrix_rowstep(matrix)) : (1))
 
 /* Compare two matrices for equality. */
 int jas_matrix_cmp(jas_matrix_t *mat0, jas_matrix_t *mat1);
@@ -291,31 +291,31 @@ jas_seq2d_t *jas_seq2d_copy(jas_seq2d_t *x);
 
 jas_matrix_t *jas_seq2d_create(int xstart, int ystart, int xend, int yend);
 
-#define	jas_seq2d_destroy(s) \
-	jas_matrix_destroy(s)
-
-#define	jas_seq2d_xstart(s) \
-	((s)->xstart_)
-#define	jas_seq2d_ystart(s) \
-	((s)->ystart_)
-#define	jas_seq2d_xend(s) \
-	((s)->xend_)
-#define	jas_seq2d_yend(s) \
-	((s)->yend_)
-#define	jas_seq2d_getref(s, x, y) \
-	(jas_matrix_getref(s, (y) - (s)->ystart_, (x) - (s)->xstart_))
-#define	jas_seq2d_get(s, x, y) \
-	(jas_matrix_get(s, (y) - (s)->ystart_, (x) - (s)->xstart_))
-#define	jas_seq2d_rowstep(s) \
-	jas_matrix_rowstep(s)
-#define	jas_seq2d_width(s) \
-	((s)->xend_ - (s)->xstart_)
-#define	jas_seq2d_height(s) \
-	((s)->yend_ - (s)->ystart_)
-#define	jas_seq2d_setshift(s, x, y) \
-	((s)->xstart_ = (x), (s)->ystart_ = (y), \
-	  (s)->xend_ = (s)->xstart_ + (s)->numcols_, \
-	  (s)->yend_ = (s)->ystart_ + (s)->numrows_)
+#define jas_seq2d_destroy(s) \
+        jas_matrix_destroy(s)
+
+#define jas_seq2d_xstart(s) \
+        ((s)->xstart_)
+#define jas_seq2d_ystart(s) \
+        ((s)->ystart_)
+#define jas_seq2d_xend(s) \
+        ((s)->xend_)
+#define jas_seq2d_yend(s) \
+        ((s)->yend_)
+#define jas_seq2d_getref(s, x, y) \
+        (jas_matrix_getref(s, (y) - (s)->ystart_, (x) - (s)->xstart_))
+#define jas_seq2d_get(s, x, y) \
+        (jas_matrix_get(s, (y) - (s)->ystart_, (x) - (s)->xstart_))
+#define jas_seq2d_rowstep(s) \
+        jas_matrix_rowstep(s)
+#define jas_seq2d_width(s) \
+        ((s)->xend_ - (s)->xstart_)
+#define jas_seq2d_height(s) \
+        ((s)->yend_ - (s)->ystart_)
+#define jas_seq2d_setshift(s, x, y) \
+        ((s)->xstart_ = (x), (s)->ystart_ = (y), \
+          (s)->xend_ = (s)->xstart_ + (s)->numcols_, \
+          (s)->yend_ = (s)->ystart_ + (s)->numrows_)
 
 void jas_seq2d_bindsub(jas_matrix_t *s, jas_matrix_t *s1, int xstart,
   int ystart, int xend, int yend);
@@ -324,22 +324,22 @@ void jas_seq2d_bindsub(jas_matrix_t *s, jas_matrix_t *s1, int xstart,
 * Functions/macros for 1-D sequence class.
 \******************************************************************************/
 
-#define	jas_seq_create(start, end) \
-	(jas_seq2d_create(start, 0, end, 1))
+#define jas_seq_create(start, end) \
+        (jas_seq2d_create(start, 0, end, 1))
 
-#define	jas_seq_destroy(seq) \
-	(jas_seq2d_destroy(seq))
+#define jas_seq_destroy(seq) \
+        (jas_seq2d_destroy(seq))
 
 #define jas_seq_set(seq, i, v) \
-	((seq)->rows_[0][(i) - (seq)->xstart_] = (v))
-#define	jas_seq_getref(seq, i) \
-	(&(seq)->rows_[0][(i) - (seq)->xstart_])
-#define	jas_seq_get(seq, i) \
-	((seq)->rows_[0][(i) - (seq)->xstart_])
-#define	jas_seq_start(seq) \
-	((seq)->xstart_)
-#define	jas_seq_end(seq) \
-	((seq)->xend_)
+        ((seq)->rows_[0][(i) - (seq)->xstart_] = (v))
+#define jas_seq_getref(seq, i) \
+        (&(seq)->rows_[0][(i) - (seq)->xstart_])
+#define jas_seq_get(seq, i) \
+        ((seq)->rows_[0][(i) - (seq)->xstart_])
+#define jas_seq_start(seq) \
+        ((seq)->xstart_)
+#define jas_seq_end(seq) \
+        ((seq)->xend_)
 
 #ifdef __cplusplus
 }
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_stream.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_stream.h
index 1062fe1d..8d4d4a77 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_stream.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_stream.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -141,7 +141,7 @@ extern "C" {
 
 /* On most UNIX systems, we probably need to define O_BINARY ourselves. */
 #ifndef O_BINARY
-#define O_BINARY	0
+#define O_BINARY        0
 #endif
 
 /*
@@ -149,64 +149,64 @@ extern "C" {
  */
 
 /* The stream was opened for reading. */
-#define JAS_STREAM_READ	0x0001
+#define JAS_STREAM_READ 0x0001
 /* The stream was opened for writing. */
-#define JAS_STREAM_WRITE	0x0002
+#define JAS_STREAM_WRITE        0x0002
 /* The stream was opened for appending. */
-#define JAS_STREAM_APPEND	0x0004
+#define JAS_STREAM_APPEND       0x0004
 /* The stream was opened in binary mode. */
-#define JAS_STREAM_BINARY	0x0008
+#define JAS_STREAM_BINARY       0x0008
 /* The stream should be created/truncated. */
-#define JAS_STREAM_CREATE	0x0010
+#define JAS_STREAM_CREATE       0x0010
 
-#define JAS_STREAM_NOCLOSE	0x0020
+#define JAS_STREAM_NOCLOSE      0x0020
 
 /*
  * Stream buffering flags.
  */
 
 /* The stream is unbuffered. */
-#define JAS_STREAM_UNBUF	0x0000
+#define JAS_STREAM_UNBUF        0x0000
 /* The stream is line buffered. */
-#define JAS_STREAM_LINEBUF	0x0001
+#define JAS_STREAM_LINEBUF      0x0001
 /* The stream is fully buffered. */
-#define JAS_STREAM_FULLBUF	0x0002
+#define JAS_STREAM_FULLBUF      0x0002
 /* The buffering mode mask. */
-#define	JAS_STREAM_BUFMODEMASK	0x000f
+#define JAS_STREAM_BUFMODEMASK  0x000f
 
 /* The memory associated with the buffer needs to be deallocated when the
   stream is destroyed. */
-#define JAS_STREAM_FREEBUF	0x0008
+#define JAS_STREAM_FREEBUF      0x0008
 /* The buffer is currently being used for reading. */
-#define JAS_STREAM_RDBUF	0x0010
+#define JAS_STREAM_RDBUF        0x0010
 /* The buffer is currently being used for writing. */
-#define JAS_STREAM_WRBUF	0x0020
+#define JAS_STREAM_WRBUF        0x0020
 
 /*
  * Stream error flags.
  */
 
 /* The end-of-file has been encountered (on reading). */
-#define JAS_STREAM_EOF	0x0001
+#define JAS_STREAM_EOF  0x0001
 /* An I/O error has been encountered on the stream. */
-#define JAS_STREAM_ERR	0x0002
+#define JAS_STREAM_ERR  0x0002
 /* The read/write limit has been exceeded. */
-#define	JAS_STREAM_RWLIMIT	0x0004
+#define JAS_STREAM_RWLIMIT      0x0004
 /* The error mask. */
 #define JAS_STREAM_ERRMASK \
-	(JAS_STREAM_EOF | JAS_STREAM_ERR | JAS_STREAM_RWLIMIT)
+        (JAS_STREAM_EOF | JAS_STREAM_ERR | JAS_STREAM_RWLIMIT)
 
 /*
  * Other miscellaneous constants.
  */
 
 /* The default buffer size (for fully-buffered operation). */
-#define JAS_STREAM_BUFSIZE	8192
+#define JAS_STREAM_BUFSIZE      8192
 /* The default permission mask for file creation. */
-#define JAS_STREAM_PERMS	0666
+#define JAS_STREAM_PERMS        0666
 
 /* The maximum number of characters that can always be put back on a stream. */
-#define	JAS_STREAM_MAXPUTBACK	16
+#define JAS_STREAM_MAXPUTBACK   16
 
 /******************************************************************************\
 * Types.
@@ -224,17 +224,17 @@ typedef void jas_stream_obj_t;
 
 typedef struct {
 
-	/* Read characters from a file object. */
-	int (*read_)(jas_stream_obj_t *obj, char *buf, int cnt);
+        /* Read characters from a file object. */
+        int (*read_)(jas_stream_obj_t *obj, char *buf, int cnt);
 
-	/* Write characters to a file object. */
-	int (*write_)(jas_stream_obj_t *obj, char *buf, int cnt);
+        /* Write characters to a file object. */
+        int (*write_)(jas_stream_obj_t *obj, char *buf, int cnt);
 
-	/* Set the position for a file object. */
-	long (*seek_)(jas_stream_obj_t *obj, long offset, int origin);
+        /* Set the position for a file object. */
+        long (*seek_)(jas_stream_obj_t *obj, long offset, int origin);
 
-	/* Close a file object. */
-	int (*close_)(jas_stream_obj_t *obj);
+        /* Close a file object. */
+        int (*close_)(jas_stream_obj_t *obj);
 
 } jas_stream_ops_t;
 
@@ -244,46 +244,46 @@ typedef struct {
 
 typedef struct {
 
-	/* The mode in which the stream was opened. */
-	int openmode_;
+        /* The mode in which the stream was opened. */
+        int openmode_;
 
-	/* The buffering mode. */
-	int bufmode_;
+        /* The buffering mode. */
+        int bufmode_;
 
-	/* The stream status. */
-	int flags_;
+        /* The stream status. */
+        int flags_;
 
-	/* The start of the buffer area to use for reading/writing. */
-	unsigned char *bufbase_;
+        /* The start of the buffer area to use for reading/writing. */
+        unsigned char *bufbase_;
 
-	/* The start of the buffer area excluding the extra initial space for
-	  character putback. */
-	unsigned char *bufstart_;
+        /* The start of the buffer area excluding the extra initial space for
+          character putback. */
+        unsigned char *bufstart_;
 
-	/* The buffer size. */
-	int bufsize_;
+        /* The buffer size. */
+        int bufsize_;
 
-	/* The current position in the buffer. */
-	unsigned char *ptr_;
+        /* The current position in the buffer. */
+        unsigned char *ptr_;
 
-	/* The number of characters that must be read/written before
-	the buffer needs to be filled/flushed. */
-	int cnt_;
+        /* The number of characters that must be read/written before
+        the buffer needs to be filled/flushed. */
+        int cnt_;
 
-	/* A trivial buffer to be used for unbuffered operation. */
-	unsigned char tinybuf_[JAS_STREAM_MAXPUTBACK + 1];
+        /* A trivial buffer to be used for unbuffered operation. */
+        unsigned char tinybuf_[JAS_STREAM_MAXPUTBACK + 1];
 
-	/* The operations for the underlying stream file object. */
-	jas_stream_ops_t *ops_;
+        /* The operations for the underlying stream file object. */
+        jas_stream_ops_t *ops_;
 
-	/* The underlying stream file object. */
-	jas_stream_obj_t *obj_;
+        /* The underlying stream file object. */
+        jas_stream_obj_t *obj_;
 
-	/* The number of characters read/written. */
-	long rwcnt_;
+        /* The number of characters read/written. */
+        long rwcnt_;
 
-	/* The maximum number of characters that may be read/written. */
-	long rwlimit_;
+        /* The maximum number of characters that may be read/written. */
+        long rwlimit_;
 
 } jas_stream_t;
 
@@ -300,23 +300,23 @@ typedef int jas_stream_fileobj_t;
 
 typedef struct {
 
-	/* The data associated with this file. */
-	unsigned char *buf_;
+        /* The data associated with this file. */
+        unsigned char *buf_;
 
-	/* The allocated size of the buffer for holding file data. */
-	int bufsize_;
+        /* The allocated size of the buffer for holding file data. */
+        int bufsize_;
 
-	/* The length of the file. */
-	int_fast32_t len_;
+        /* The length of the file. */
+        int_fast32_t len_;
 
-	/* The seek position. */
-	int_fast32_t pos_;
+        /* The seek position. */
+        int_fast32_t pos_;
 
-	/* Is the buffer growable? */
-	int growable_;
+        /* Is the buffer growable? */
+        int growable_;
 
-	/* Was the buffer allocated internally? */
-	int myalloc_;
+        /* Was the buffer allocated internally? */
+        int myalloc_;
 
 } jas_stream_memobj_t;
 
@@ -348,26 +348,26 @@ int jas_stream_close(jas_stream_t *stream);
 
 /* Get the EOF indicator for a stream. */
 #define jas_stream_eof(stream) \
-	(((stream)->flags_ & JAS_STREAM_EOF) != 0)
+        (((stream)->flags_ & JAS_STREAM_EOF) != 0)
 
 /* Get the error indicator for a stream. */
 #define jas_stream_error(stream) \
-	(((stream)->flags_ & JAS_STREAM_ERR) != 0)
+        (((stream)->flags_ & JAS_STREAM_ERR) != 0)
 
 /* Clear the error indicator for a stream. */
 #define jas_stream_clearerr(stream) \
-	((stream)->flags_ &= ~(JAS_STREAM_ERR | JAS_STREAM_EOF))
+        ((stream)->flags_ &= ~(JAS_STREAM_ERR | JAS_STREAM_EOF))
 
 /* Get the read/write limit for a stream. */
-#define	jas_stream_getrwlimit(stream) \
-	(((const jas_stream_t *)(stream))->rwlimit_)
+#define jas_stream_getrwlimit(stream) \
+        (((const jas_stream_t *)(stream))->rwlimit_)
 
 /* Set the read/write limit for a stream. */
 int jas_stream_setrwlimit(jas_stream_t *stream, long rwlimit);
 
 /* Get the read/write count for a stream. */
-#define	jas_stream_getrwcount(stream) \
-	(((const jas_stream_t *)(stream))->rwcnt_)
+#define jas_stream_getrwcount(stream) \
+        (((const jas_stream_t *)(stream))->rwcnt_)
 
 /* Set the read/write count for a stream. */
 long jas_stream_setrwcount(jas_stream_t *stream, long rwcnt);
@@ -378,16 +378,16 @@ long jas_stream_setrwcount(jas_stream_t *stream, long rwcnt);
 
 /* Read a character from a stream. */
 #if defined(DEBUG)
-#define	jas_stream_getc(stream)	jas_stream_getc_func(stream)
+#define jas_stream_getc(stream) jas_stream_getc_func(stream)
 #else
-#define jas_stream_getc(stream)	jas_stream_getc_macro(stream)
+#define jas_stream_getc(stream) jas_stream_getc_macro(stream)
 #endif
 
 /* Write a character to a stream. */
 #if defined(DEBUG)
-#define jas_stream_putc(stream, c)	jas_stream_putc_func(stream, c)
+#define jas_stream_putc(stream, c)      jas_stream_putc_func(stream, c)
 #else
-#define jas_stream_putc(stream, c)	jas_stream_putc_macro(stream, c)
+#define jas_stream_putc(stream, c)      jas_stream_putc_macro(stream, c)
 #endif
 
 /* Read characters from a stream into a buffer. */
@@ -407,9 +407,9 @@ char *jas_stream_gets(jas_stream_t *stream, char *buf, int bufsize);
 
 /* Look at the next character to be read from a stream without actually
   removing it from the stream. */
-#define	jas_stream_peekc(stream) \
-	(((stream)->cnt_ <= 0) ? jas_stream_fillbuf(stream, 0) : \
-	  ((int)(*(stream)->ptr_)))
+#define jas_stream_peekc(stream) \
+        (((stream)->cnt_ <= 0) ? jas_stream_fillbuf(stream, 0) : \
+          ((int)(*(stream)->ptr_)))
 
 /* Put a character back on a stream. */
 int jas_stream_ungetc(jas_stream_t *stream, int c);
@@ -463,26 +463,26 @@ directly, you will die a horrible, miserable, and painful death! */
 
 /* Read a character from a stream. */
 #define jas_stream_getc_macro(stream) \
-	((!((stream)->flags_ & (JAS_STREAM_ERR | JAS_STREAM_EOF | \
-	  JAS_STREAM_RWLIMIT))) ? \
-	  (((stream)->rwlimit_ >= 0 && (stream)->rwcnt_ >= (stream)->rwlimit_) ? \
-	  (stream->flags_ |= JAS_STREAM_RWLIMIT, EOF) : \
-	  jas_stream_getc2(stream)) : EOF)
+        ((!((stream)->flags_ & (JAS_STREAM_ERR | JAS_STREAM_EOF | \
+          JAS_STREAM_RWLIMIT))) ? \
+          (((stream)->rwlimit_ >= 0 && (stream)->rwcnt_ >= (stream)->rwlimit_) ? \
+          (stream->flags_ |= JAS_STREAM_RWLIMIT, EOF) : \
+          jas_stream_getc2(stream)) : EOF)
 #define jas_stream_getc2(stream) \
-	((--(stream)->cnt_ < 0) ? jas_stream_fillbuf(stream, 1) : \
-	  (++(stream)->rwcnt_, (int)(*(stream)->ptr_++)))
+        ((--(stream)->cnt_ < 0) ? jas_stream_fillbuf(stream, 1) : \
+          (++(stream)->rwcnt_, (int)(*(stream)->ptr_++)))
 
 /* Write a character to a stream. */
 #define jas_stream_putc_macro(stream, c) \
-	((!((stream)->flags_ & (JAS_STREAM_ERR | JAS_STREAM_EOF | \
-	  JAS_STREAM_RWLIMIT))) ? \
-	  (((stream)->rwlimit_ >= 0 && (stream)->rwcnt_ >= (stream)->rwlimit_) ? \
-	  (stream->flags_ |= JAS_STREAM_RWLIMIT, EOF) : \
-	  jas_stream_putc2(stream, c)) : EOF)
+        ((!((stream)->flags_ & (JAS_STREAM_ERR | JAS_STREAM_EOF | \
+          JAS_STREAM_RWLIMIT))) ? \
+          (((stream)->rwlimit_ >= 0 && (stream)->rwcnt_ >= (stream)->rwlimit_) ? \
+          (stream->flags_ |= JAS_STREAM_RWLIMIT, EOF) : \
+          jas_stream_putc2(stream, c)) : EOF)
 #define jas_stream_putc2(stream, c) \
-	(((stream)->bufmode_ |= JAS_STREAM_WRBUF, --(stream)->cnt_ < 0) ? \
-	  jas_stream_flushbuf((stream), (unsigned char)(c)) : \
-	  (++(stream)->rwcnt_, (int)(*(stream)->ptr_++ = (c))))
+        (((stream)->bufmode_ |= JAS_STREAM_WRBUF, --(stream)->cnt_ < 0) ? \
+          jas_stream_flushbuf((stream), (unsigned char)(c)) : \
+          (++(stream)->rwcnt_, (int)(*(stream)->ptr_++ = (c))))
 
 /* These prototypes need to be here for the sake of the stream_getc and
 stream_putc macros. */
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_string.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_string.h
index 55b611ba..ff2d3af4 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_string.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_string.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -116,8 +116,8 @@
  * $Id$
  */
 
-#ifndef	JAS_STRING_H
-#define	JAS_STRING_H
+#ifndef JAS_STRING_H
+#define JAS_STRING_H
 
 /******************************************************************************\
 * Includes.
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_tvp.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_tvp.h
index 9ac50dbd..34e389bf 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_tvp.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_tvp.h
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -133,11 +133,11 @@ extern "C" {
 
 typedef struct {
 
-	int id;
-	/* The ID for the tag. */
+        int id;
+        /* The ID for the tag. */
 
-	const char *name;
-	/* The name of the tag. */
+        const char *name;
+        /* The name of the tag. */
 
 } jas_taginfo_t;
 
@@ -145,17 +145,17 @@ typedef struct {
 
 typedef struct {
 
-	char *buf;
-	/* The parsing buffer. */
+        char *buf;
+        /* The parsing buffer. */
 
-	char *tag;
-	/* The current tag name. */
+        char *tag;
+        /* The current tag name. */
 
-	const char *val;
-	/* The current value. */
+        const char *val;
+        /* The current value. */
 
-	char *pos;
-	/* The current position in the parsing buffer. */
+        char *pos;
+        /* The current position in the parsing buffer. */
 
 } jas_tvparser_t;
 
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_types.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_types.h
index fbcb2ffb..ce12e083 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_types.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_types.h
@@ -10,5 +10,5 @@
 /* The below macro is intended to be used for type casts.  By using this
   macro, type casts can be easily located in the source code with
   tools like "grep". */
-#define	JAS_CAST(t, e) \
-	((t) (e))
+#define JAS_CAST(t, e) \
+        ((t) (e))
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_version.h b/converter/other/jpeg2000/libjasper/include/jasper/jas_version.h
index 2178257c..28442f51 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jas_version.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jas_version.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -128,28 +128,28 @@ extern "C" {
 #if !defined(JAS_VERSION)
 /* The version information below should match that specified in
   the "configure.in" file! */
-#define	JAS_VERSION		"1.600.0"
+#define JAS_VERSION             "1.600.0"
 #endif
 
-#define	JAS_COPYRIGHT \
-	"Copyright (c) 1999-2000 Image Power, Inc. and the University of\n" \
-	"  British Columbia.\n" \
-	"Copyright (c) 2001-2002 Michael David Adams.\n" \
-	"All rights reserved.\n"
+#define JAS_COPYRIGHT \
+        "Copyright (c) 1999-2000 Image Power, Inc. and the University of\n" \
+        "  British Columbia.\n" \
+        "Copyright (c) 2001-2002 Michael David Adams.\n" \
+        "All rights reserved.\n"
 
-#define	JAS_NOTES \
-	"For more information about this software, please visit the following\n" \
-	"web sites/pages:\n" \
-	"    http://www.ece.ubc.ca/~mdadams/jasper\n" \
-	"    http://www.jpeg.org/software\n" \
-	"To be added to the (moderated) JasPer software announcements\n" \
-	"mailing list, send an email to:\n" \
-	"    jasper-announce-subscribe@yahoogroups.com\n" \
-	"To be added to the (unmoderated) JasPer software discussion\n" \
-	"mailing list, send an email to:\n" \
-	"    jasper-discussion-subscribe@yahoogroups.com\n" \
-	"Please send any bug reports to:\n" \
-	"    mdadams@ieee.org\n"
+#define JAS_NOTES \
+        "For more information about this software, please visit the following\n" \
+        "web sites/pages:\n" \
+        "    http://www.ece.ubc.ca/~mdadams/jasper\n" \
+        "    http://www.jpeg.org/software\n" \
+        "To be added to the (moderated) JasPer software announcements\n" \
+        "mailing list, send an email to:\n" \
+        "    jasper-announce-subscribe@yahoogroups.com\n" \
+        "To be added to the (unmoderated) JasPer software discussion\n" \
+        "mailing list, send an email to:\n" \
+        "    jasper-discussion-subscribe@yahoogroups.com\n" \
+        "Please send any bug reports to:\n" \
+        "    mdadams@ieee.org\n"
 
 /******************************************************************************\
 * Functions.
diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jasper.h b/converter/other/jpeg2000/libjasper/include/jasper/jasper.h
index b003acfa..68986c65 100644
--- a/converter/other/jpeg2000/libjasper/include/jasper/jasper.h
+++ b/converter/other/jpeg2000/libjasper/include/jasper/jasper.h
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jp2/jp2_cod.c b/converter/other/jpeg2000/libjasper/jp2/jp2_cod.c
index c99c9608..510c01a4 100644
--- a/converter/other/jpeg2000/libjasper/jp2/jp2_cod.c
+++ b/converter/other/jpeg2000/libjasper/jp2/jp2_cod.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -794,7 +794,7 @@ static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in)
             return -1;
         }
     }
-    
+   
     return 0;
 }
 
diff --git a/converter/other/jpeg2000/libjasper/jp2/jp2_cod.h b/converter/other/jpeg2000/libjasper/jp2/jp2_cod.h
index 96b48d12..86c4c3ee 100644
--- a/converter/other/jpeg2000/libjasper/jp2/jp2_cod.h
+++ b/converter/other/jpeg2000/libjasper/jp2/jp2_cod.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -129,188 +129,188 @@
 * Macros.
 \******************************************************************************/
 
-#define	JP2_SPTOBPC(s, p) \
-	((((p) - 1) & 0x7f) | (((s) & 1) << 7))
+#define JP2_SPTOBPC(s, p) \
+        ((((p) - 1) & 0x7f) | (((s) & 1) << 7))
 
 /******************************************************************************\
 * Box class.
 \******************************************************************************/
 
-#define	JP2_BOX_HDRLEN	8
+#define JP2_BOX_HDRLEN  8
 
 /* Box types. */
-#define	JP2_BOX_JP		0x6a502020	/* Signature */
-#define JP2_BOX_FTYP	0x66747970	/* File Type */
-#define	JP2_BOX_JP2H	0x6a703268	/* JP2 Header */
-#define	JP2_BOX_IHDR	0x69686472	/* Image Header */
-#define	JP2_BOX_BPCC	0x62706363	/* Bits Per Component */
-#define	JP2_BOX_COLR	0x636f6c72	/* Color Specification */
-#define	JP2_BOX_PCLR	0x70636c72	/* Palette */
-#define	JP2_BOX_CMAP	0x636d6170	/* Component Mapping */
-#define	JP2_BOX_CDEF	0x63646566	/* Channel Definition */
-#define	JP2_BOX_RES		0x72657320	/* Resolution */
-#define	JP2_BOX_RESC	0x72657363	/* Capture Resolution */
-#define	JP2_BOX_RESD	0x72657364	/* Default Display Resolution */
-#define	JP2_BOX_JP2C	0x6a703263	/* Contiguous Code Stream */
-#define	JP2_BOX_JP2I	0x6a703269	/* Intellectual Property */
-#define	JP2_BOX_XML		0x786d6c20	/* XML */
-#define	JP2_BOX_UUID	0x75756964	/* UUID */
-#define	JP2_BOX_UINF	0x75696e66	/* UUID Info */
-#define	JP2_BOX_ULST	0x75637374	/* UUID List */
-#define	JP2_BOX_URL		0x75726c20	/* URL */
-
-#define	JP2_BOX_SUPER	0x01
-#define	JP2_BOX_NODATA	0x02
+#define JP2_BOX_JP              0x6a502020      /* Signature */
+#define JP2_BOX_FTYP    0x66747970      /* File Type */
+#define JP2_BOX_JP2H    0x6a703268      /* JP2 Header */
+#define JP2_BOX_IHDR    0x69686472      /* Image Header */
+#define JP2_BOX_BPCC    0x62706363      /* Bits Per Component */
+#define JP2_BOX_COLR    0x636f6c72      /* Color Specification */
+#define JP2_BOX_PCLR    0x70636c72      /* Palette */
+#define JP2_BOX_CMAP    0x636d6170      /* Component Mapping */
+#define JP2_BOX_CDEF    0x63646566      /* Channel Definition */
+#define JP2_BOX_RES             0x72657320      /* Resolution */
+#define JP2_BOX_RESC    0x72657363      /* Capture Resolution */
+#define JP2_BOX_RESD    0x72657364      /* Default Display Resolution */
+#define JP2_BOX_JP2C    0x6a703263      /* Contiguous Code Stream */
+#define JP2_BOX_JP2I    0x6a703269      /* Intellectual Property */
+#define JP2_BOX_XML             0x786d6c20      /* XML */
+#define JP2_BOX_UUID    0x75756964      /* UUID */
+#define JP2_BOX_UINF    0x75696e66      /* UUID Info */
+#define JP2_BOX_ULST    0x75637374      /* UUID List */
+#define JP2_BOX_URL             0x75726c20      /* URL */
+
+#define JP2_BOX_SUPER   0x01
+#define JP2_BOX_NODATA  0x02
 
 /* JP box data. */
 
-#define	JP2_JP_MAGIC	0x0d0a870a
-#define	JP2_JP_LEN		12
+#define JP2_JP_MAGIC    0x0d0a870a
+#define JP2_JP_LEN              12
 
 typedef struct {
-	uint_fast32_t magic;
+        uint_fast32_t magic;
 } jp2_jp_t;
 
 /* FTYP box data. */
 
-#define	JP2_FTYP_MAXCOMPATCODES	32
-#define	JP2_FTYP_MAJVER		0x6a703220
-#define	JP2_FTYP_MINVER		0
-#define	JP2_FTYP_COMPATCODE		JP2_FTYP_MAJVER
+#define JP2_FTYP_MAXCOMPATCODES 32
+#define JP2_FTYP_MAJVER         0x6a703220
+#define JP2_FTYP_MINVER         0
+#define JP2_FTYP_COMPATCODE             JP2_FTYP_MAJVER
 
 typedef struct {
-	uint_fast32_t majver;
-	uint_fast32_t minver;
-	uint_fast32_t numcompatcodes;
-	uint_fast32_t compatcodes[JP2_FTYP_MAXCOMPATCODES];
+        uint_fast32_t majver;
+        uint_fast32_t minver;
+        uint_fast32_t numcompatcodes;
+        uint_fast32_t compatcodes[JP2_FTYP_MAXCOMPATCODES];
 } jp2_ftyp_t;
 
 /* IHDR box data. */
 
-#define	JP2_IHDR_COMPTYPE	7
-#define	JP2_IHDR_BPCNULL	255
+#define JP2_IHDR_COMPTYPE       7
+#define JP2_IHDR_BPCNULL        255
 
 typedef struct {
-	uint_fast32_t width;
-	uint_fast32_t height;
-	uint_fast16_t numcmpts;
-	uint_fast8_t bpc;
-	uint_fast8_t comptype;
-	uint_fast8_t csunk;
-	uint_fast8_t ipr;
+        uint_fast32_t width;
+        uint_fast32_t height;
+        uint_fast16_t numcmpts;
+        uint_fast8_t bpc;
+        uint_fast8_t comptype;
+        uint_fast8_t csunk;
+        uint_fast8_t ipr;
 } jp2_ihdr_t;
 
 /* BPCC box data. */
 
 typedef struct {
-	uint_fast16_t numcmpts;
-	uint_fast8_t *bpcs;
+        uint_fast16_t numcmpts;
+        uint_fast8_t *bpcs;
 } jp2_bpcc_t;
 
 /* COLR box data. */
 
-#define	JP2_COLR_ENUM	1
-#define	JP2_COLR_ICC	2
-#define	JP2_COLR_PRI	0
+#define JP2_COLR_ENUM   1
+#define JP2_COLR_ICC    2
+#define JP2_COLR_PRI    0
 
-#define	JP2_COLR_SRGB	16
-#define	JP2_COLR_SGRAY	17
-#define	JP2_COLR_SYCC	18
+#define JP2_COLR_SRGB   16
+#define JP2_COLR_SGRAY  17
+#define JP2_COLR_SYCC   18
 
 typedef struct {
-	uint_fast8_t method;
-	uint_fast8_t pri;
-	uint_fast8_t approx;
-	uint_fast32_t csid;
-	uint_fast8_t *iccp;
-	int iccplen;
-	/* XXX - Someday we ought to add ICC profile data here. */
+        uint_fast8_t method;
+        uint_fast8_t pri;
+        uint_fast8_t approx;
+        uint_fast32_t csid;
+        uint_fast8_t *iccp;
+        int iccplen;
+        /* XXX - Someday we ought to add ICC profile data here. */
 } jp2_colr_t;
 
 /* PCLR box data. */
 
 typedef struct {
-	uint_fast16_t numlutents;
-	uint_fast8_t numchans;
-	int_fast32_t *lutdata;
-	uint_fast8_t *bpc;
+        uint_fast16_t numlutents;
+        uint_fast8_t numchans;
+        int_fast32_t *lutdata;
+        uint_fast8_t *bpc;
 } jp2_pclr_t;
 
 /* CDEF box per-channel data. */
 
-#define JP2_CDEF_RGB_R	1
-#define JP2_CDEF_RGB_G	2
-#define JP2_CDEF_RGB_B	3
+#define JP2_CDEF_RGB_R  1
+#define JP2_CDEF_RGB_G  2
+#define JP2_CDEF_RGB_B  3
 
-#define JP2_CDEF_YCBCR_Y	1
-#define JP2_CDEF_YCBCR_CB	2
-#define JP2_CDEF_YCBCR_CR	3
+#define JP2_CDEF_YCBCR_Y        1
+#define JP2_CDEF_YCBCR_CB       2
+#define JP2_CDEF_YCBCR_CR       3
 
-#define	JP2_CDEF_GRAY_Y	1
+#define JP2_CDEF_GRAY_Y 1
 
-#define	JP2_CDEF_TYPE_COLOR	0
-#define	JP2_CDEF_TYPE_OPACITY	1
-#define	JP2_CDEF_TYPE_UNSPEC	65535
-#define	JP2_CDEF_ASOC_ALL	0
-#define	JP2_CDEF_ASOC_NONE	65535
+#define JP2_CDEF_TYPE_COLOR     0
+#define JP2_CDEF_TYPE_OPACITY   1
+#define JP2_CDEF_TYPE_UNSPEC    65535
+#define JP2_CDEF_ASOC_ALL       0
+#define JP2_CDEF_ASOC_NONE      65535
 
 typedef struct {
-	uint_fast16_t channo;
-	uint_fast16_t type;
-	uint_fast16_t assoc;
+        uint_fast16_t channo;
+        uint_fast16_t type;
+        uint_fast16_t assoc;
 } jp2_cdefchan_t;
 
 /* CDEF box data. */
 
 typedef struct {
-	uint_fast16_t numchans;
-	jp2_cdefchan_t *ents;
+        uint_fast16_t numchans;
+        jp2_cdefchan_t *ents;
 } jp2_cdef_t;
 
 typedef struct {
-	uint_fast16_t cmptno;
-	uint_fast8_t map;
-	uint_fast8_t pcol;
+        uint_fast16_t cmptno;
+        uint_fast8_t map;
+        uint_fast8_t pcol;
 } jp2_cmapent_t;
 
 typedef struct {
-	uint_fast16_t numchans;
-	jp2_cmapent_t *ents;
+        uint_fast16_t numchans;
+        jp2_cmapent_t *ents;
 } jp2_cmap_t;
 
-#define	JP2_CMAP_DIRECT		0
-#define	JP2_CMAP_PALETTE	1
+#define JP2_CMAP_DIRECT         0
+#define JP2_CMAP_PALETTE        1
 
 /* Generic box. */
 
 struct jp2_boxops_s;
 typedef struct {
 
-	struct jp2_boxops_s *ops;
-	struct jp2_boxinfo_s *info;
+        struct jp2_boxops_s *ops;
+        struct jp2_boxinfo_s *info;
 
-	uint_fast32_t type;
-	uint_fast32_t len;
+        uint_fast32_t type;
+        uint_fast32_t len;
 
-	union {
-		jp2_jp_t jp;
-		jp2_ftyp_t ftyp;
-		jp2_ihdr_t ihdr;
-		jp2_bpcc_t bpcc;
-		jp2_colr_t colr;
-		jp2_pclr_t pclr;
-		jp2_cdef_t cdef;
-		jp2_cmap_t cmap;
-	} data;
+        union {
+                jp2_jp_t jp;
+                jp2_ftyp_t ftyp;
+                jp2_ihdr_t ihdr;
+                jp2_bpcc_t bpcc;
+                jp2_colr_t colr;
+                jp2_pclr_t pclr;
+                jp2_cdef_t cdef;
+                jp2_cmap_t cmap;
+        } data;
 
 } jp2_box_t;
 
 typedef struct jp2_boxops_s {
-	void (*init)(jp2_box_t *box);
-	void (*destroy)(jp2_box_t *box);
-	int (*getdata)(jp2_box_t *box, jas_stream_t *in);
-	int (*putdata)(jp2_box_t *box, jas_stream_t *out);
-	void (*dumpdata)(jp2_box_t *box, FILE *out);
+        void (*init)(jp2_box_t *box);
+        void (*destroy)(jp2_box_t *box);
+        int (*getdata)(jp2_box_t *box, jas_stream_t *in);
+        int (*putdata)(jp2_box_t *box, jas_stream_t *out);
+        void (*dumpdata)(jp2_box_t *box, FILE *out);
 } jp2_boxops_t;
 
 /******************************************************************************\
@@ -318,10 +318,10 @@ typedef struct jp2_boxops_s {
 \******************************************************************************/
 
 typedef struct jp2_boxinfo_s {
-	int type;
-	const char *name;
-	int flags;
-	jp2_boxops_t ops;
+        int type;
+        const char *name;
+        int flags;
+        jp2_boxops_t ops;
 } jp2_boxinfo_t;
 
 /******************************************************************************\
@@ -335,12 +335,12 @@ int jp2_box_put(jp2_box_t *box, jas_stream_t *out);
 
 #define JP2_DTYPETOBPC(dtype) \
   ((JAS_IMAGE_CDT_GETSGND(dtype) << 7) | (JAS_IMAGE_CDT_GETPREC(dtype) - 1))
-#define	JP2_BPCTODTYPE(bpc) \
+#define JP2_BPCTODTYPE(bpc) \
   (JAS_IMAGE_CDT_SETSGND(bpc >> 7) | JAS_IMAGE_CDT_SETPREC((bpc & 0x7f) + 1))
 
-#define ICC_CS_RGB	0x52474220
-#define ICC_CS_YCBCR	0x59436272
-#define ICC_CS_GRAY	0x47524159
+#define ICC_CS_RGB      0x52474220
+#define ICC_CS_YCBCR    0x59436272
+#define ICC_CS_GRAY     0x47524159
 
 jp2_cdefchan_t *jp2_cdef_lookup(jp2_cdef_t *cdef, int channo);
 
diff --git a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c
index e8d71b0a..b056cfa9 100644
--- a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c
+++ b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -256,7 +256,7 @@ jp2_getcs(jp2_colr_t *colr) {
 
 static int
 fromiccpcs(int cs) {
-    
+   
     switch (cs) {
     case ICC_CS_RGB:
         return JAS_IMAGE_CS_RGB;
@@ -505,7 +505,7 @@ jp2_decode(jas_stream_t * const in,
     /* Determine the number of channels (which is essentially the number
       of components after any palette mappings have been applied). */
     dec->numchans = dec->cmap ?
-        dec->cmap->data.cmap.numchans : 
+        dec->cmap->data.cmap.numchans :
         jas_image_numcmpts(dec->image);
 
     /* Perform a basic sanity check on the CMAP box if present. */
diff --git a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.h b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.h
index 300be107..0da2b85f 100644
--- a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.h
+++ b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -119,15 +119,15 @@
 
 typedef struct {
 
-	jp2_box_t *pclr;
-	jp2_box_t *cdef;
-	jp2_box_t *ihdr;
-	jp2_box_t *bpcc;
-	jp2_box_t *cmap;
-	jp2_box_t *colr;
-	jas_image_t *image;
-	uint_fast16_t numchans;
-	uint_fast16_t *chantocmptlut;
+        jp2_box_t *pclr;
+        jp2_box_t *cdef;
+        jp2_box_t *ihdr;
+        jp2_box_t *bpcc;
+        jp2_box_t *cmap;
+        jp2_box_t *colr;
+        jas_image_t *image;
+        uint_fast16_t numchans;
+        uint_fast16_t *chantocmptlut;
 
 } jp2_dec_t;
 
diff --git a/converter/other/jpeg2000/libjasper/jp2/jp2_enc.c b/converter/other/jpeg2000/libjasper/jp2/jp2_enc.c
index 12538248..f57233f1 100644
--- a/converter/other/jpeg2000/libjasper/jp2/jp2_enc.c
+++ b/converter/other/jpeg2000/libjasper/jp2/jp2_enc.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -134,281 +134,281 @@ static uint_fast32_t jp2_gettypeasoc(int colorspace, int ctype);
 
 int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr)
 {
-	jp2_box_t *box;
-	jp2_ftyp_t *ftyp;
-	jp2_ihdr_t *ihdr;
-	jas_stream_t *tmpstream;
-	int allcmptssame;
-	jp2_bpcc_t *bpcc;
-	long len;
-	uint_fast16_t cmptno;
-	jp2_colr_t *colr;
-	char buf[4096];
-	uint_fast32_t overhead;
-	jp2_cdefchan_t *cdefchanent;
-	jp2_cdef_t *cdef;
-	int i;
-	uint_fast32_t typeasoc;
-
-	box = 0;
-	tmpstream = 0;
-
-	/* Output the signature box. */
-
-	if (!(box = jp2_box_create(JP2_BOX_JP))) {
-		goto error;
-	}
-	box->data.jp.magic = JP2_JP_MAGIC;
-	if (jp2_box_put(box, out)) {
-		goto error;
-	}
-	jp2_box_destroy(box);
-	box = 0;
-
-	/* Output the file type box. */
-
-	if (!(box = jp2_box_create(JP2_BOX_FTYP))) {
-		goto error;
-	}
-	ftyp = &box->data.ftyp;
-	ftyp->majver = JP2_FTYP_MAJVER;
-	ftyp->minver = JP2_FTYP_MINVER;
-	ftyp->numcompatcodes = 1;
-	ftyp->compatcodes[0] = JP2_FTYP_COMPATCODE;
-	if (jp2_box_put(box, out)) {
-		goto error;
-	}
-	jp2_box_destroy(box);
-	box = 0;
-
-	/*
-	 * Generate the data portion of the JP2 header box.
-	 * We cannot simply output the header for this box
-	 * since we do not yet know the correct value for the length
-	 * field.
-	 */
-
-	if (!(tmpstream = jas_stream_memopen(0, 0))) {
-		goto error;
-	}
-
-	/* Generate image header box. */
-
-	if (!(box = jp2_box_create(JP2_BOX_IHDR))) {
-		goto error;
-	}
-	ihdr = &box->data.ihdr;
-	ihdr->width = jas_image_width(image);
-	ihdr->height = jas_image_height(image);
-	ihdr->numcmpts = jas_image_numcmpts(image);
-	allcmptssame = 0;
-	ihdr->bpc = allcmptssame ? JP2_SPTOBPC(jas_image_cmptsgnd(image, 0),
-	  jas_image_cmptprec(image, 0)) : JP2_IHDR_BPCNULL;
-	ihdr->comptype = JP2_IHDR_COMPTYPE;
-	ihdr->csunk = 0;
-	ihdr->ipr = 0;
-	if (jp2_box_put(box, tmpstream)) {
-		goto error;
-	}
-	jp2_box_destroy(box);
-	box = 0;
-
-	/* Generate bits per component box. */
-
-	if (!allcmptssame) {
-		if (!(box = jp2_box_create(JP2_BOX_BPCC))) {
-			goto error;
-		}
-		bpcc = &box->data.bpcc;
-		bpcc->numcmpts = jas_image_numcmpts(image);
-		if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts *
-		  sizeof(uint_fast8_t)))) {
-			goto error;
-		}
-		for (cmptno = 0; cmptno < bpcc->numcmpts; ++cmptno) {
-			bpcc->bpcs[cmptno] = JP2_SPTOBPC(jas_image_cmptsgnd(image,
-			  cmptno), jas_image_cmptprec(image, cmptno));
-		}
-		if (jp2_box_put(box, tmpstream)) {
-			goto error;
-		}
-		jp2_box_destroy(box);
-		box = 0;
-	}
-
-	/* Generate color specification box. */
-
-	if (!(box = jp2_box_create(JP2_BOX_COLR))) {
-		goto error;
-	}
-	colr = &box->data.colr;
-	colr->method = JP2_COLR_ENUM;
-	colr->pri = JP2_COLR_PRI;
-	colr->approx = 0;
-	colr->csid = (jas_image_colorspace(image) == JAS_IMAGE_CS_RGB) ? JP2_COLR_SRGB :
-	  JP2_COLR_SGRAY;
-	if (jp2_box_put(box, tmpstream)) {
-		goto error;
-	}
-	jp2_box_destroy(box);
-	box = 0;
-
-	if (!(jas_image_colorspace(image) == JAS_IMAGE_CS_RGB &&
-	  jas_image_numcmpts(image) == 3 &&
-	  jas_image_getcmptbytype(image, 0) ==
-	  JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_R) &&
-	  jas_image_getcmptbytype(image, 1) ==
-	  JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_G) &&
-	  jas_image_getcmptbytype(image, 2) ==
-	  JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_B)) &&
-	  !(jas_image_colorspace(image) == JAS_IMAGE_CS_YCBCR &&
-	  jas_image_numcmpts(image) != 3 &&
-	  jas_image_getcmptbytype(image, 0) ==
-	  JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_Y) &&
-	  jas_image_getcmptbytype(image, 1) ==
-	  JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CB) &&
-	  jas_image_getcmptbytype(image, 2) ==
-	  JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CR)) &&
-	  !(jas_image_colorspace(image) == JAS_IMAGE_CS_GRAY &&
-	  jas_image_numcmpts(image) == 1 &&
-	  jas_image_getcmptbytype(image, 0) ==
-	  JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y))) {
-
-		if (!(box = jp2_box_create(JP2_BOX_CDEF))) {
-			goto error;
-		}
-		cdef = &box->data.cdef;
-		cdef->numchans = jas_image_numcmpts(image);
-		cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t));
-		for (i = 0; i < jas_image_numcmpts(image); ++i) {
-			cdefchanent = &cdef->ents[i];
-			cdefchanent->channo = i;
-			typeasoc = jp2_gettypeasoc(jas_image_colorspace(image), jas_image_cmpttype(image, i));
-			cdefchanent->type = typeasoc >> 16;
-			cdefchanent->assoc = typeasoc & 0x7fff;
-		}
-		jp2_box_destroy(box);
-		box = 0;
-	}
-
-	/* Determine the total length of the JP2 header box. */
-
-	len = jas_stream_tell(tmpstream);
-	jas_stream_rewind(tmpstream);
-
-	/*
-	 * Output the JP2 header box and all of the boxes which it contains.
-	 */
-
-	if (!(box = jp2_box_create(JP2_BOX_JP2H))) {
-		goto error;
-	}
-	box->len = len + JP2_BOX_HDRLEN;
-	if (jp2_box_put(box, out)) {
-		goto error;
-	}
-	jp2_box_destroy(box);
-	box = 0;
-
-	if (jas_stream_copy(out, tmpstream, len)) {
-		goto error;
-	}
-
-	jas_stream_close(tmpstream);
-	tmpstream = 0;
-
-	/*
-	 * Output the contiguous code stream box.
-	 */
-
-	if (!(box = jp2_box_create(JP2_BOX_JP2C))) {
-		goto error;
-	}
-	box->len = 0;
-	if (jp2_box_put(box, out)) {
-		goto error;
-	}
-	jp2_box_destroy(box);
-	box = 0;
-
-	/* Output the JPEG-2000 code stream. */
-
-	overhead = jas_stream_getrwcount(out);
-	sprintf(buf, "%s\n_jp2overhead=%lu\n", (optstr ? optstr : ""),
-	  (unsigned long) overhead);
-
-	if (jpc_encode(image, out, buf)) {
-		goto error;
-	}
-
-	return 0;
-	abort();
+        jp2_box_t *box;
+        jp2_ftyp_t *ftyp;
+        jp2_ihdr_t *ihdr;
+        jas_stream_t *tmpstream;
+        int allcmptssame;
+        jp2_bpcc_t *bpcc;
+        long len;
+        uint_fast16_t cmptno;
+        jp2_colr_t *colr;
+        char buf[4096];
+        uint_fast32_t overhead;
+        jp2_cdefchan_t *cdefchanent;
+        jp2_cdef_t *cdef;
+        int i;
+        uint_fast32_t typeasoc;
+
+        box = 0;
+        tmpstream = 0;
+
+        /* Output the signature box. */
+
+        if (!(box = jp2_box_create(JP2_BOX_JP))) {
+                goto error;
+        }
+        box->data.jp.magic = JP2_JP_MAGIC;
+        if (jp2_box_put(box, out)) {
+                goto error;
+        }
+        jp2_box_destroy(box);
+        box = 0;
+
+        /* Output the file type box. */
+
+        if (!(box = jp2_box_create(JP2_BOX_FTYP))) {
+                goto error;
+        }
+        ftyp = &box->data.ftyp;
+        ftyp->majver = JP2_FTYP_MAJVER;
+        ftyp->minver = JP2_FTYP_MINVER;
+        ftyp->numcompatcodes = 1;
+        ftyp->compatcodes[0] = JP2_FTYP_COMPATCODE;
+        if (jp2_box_put(box, out)) {
+                goto error;
+        }
+        jp2_box_destroy(box);
+        box = 0;
+
+        /*
+         * Generate the data portion of the JP2 header box.
+         * We cannot simply output the header for this box
+         * since we do not yet know the correct value for the length
+         * field.
+         */
+
+        if (!(tmpstream = jas_stream_memopen(0, 0))) {
+                goto error;
+        }
+
+        /* Generate image header box. */
+
+        if (!(box = jp2_box_create(JP2_BOX_IHDR))) {
+                goto error;
+        }
+        ihdr = &box->data.ihdr;
+        ihdr->width = jas_image_width(image);
+        ihdr->height = jas_image_height(image);
+        ihdr->numcmpts = jas_image_numcmpts(image);
+        allcmptssame = 0;
+        ihdr->bpc = allcmptssame ? JP2_SPTOBPC(jas_image_cmptsgnd(image, 0),
+          jas_image_cmptprec(image, 0)) : JP2_IHDR_BPCNULL;
+        ihdr->comptype = JP2_IHDR_COMPTYPE;
+        ihdr->csunk = 0;
+        ihdr->ipr = 0;
+        if (jp2_box_put(box, tmpstream)) {
+                goto error;
+        }
+        jp2_box_destroy(box);
+        box = 0;
+
+        /* Generate bits per component box. */
+
+        if (!allcmptssame) {
+                if (!(box = jp2_box_create(JP2_BOX_BPCC))) {
+                        goto error;
+                }
+                bpcc = &box->data.bpcc;
+                bpcc->numcmpts = jas_image_numcmpts(image);
+                if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts *
+                  sizeof(uint_fast8_t)))) {
+                        goto error;
+                }
+                for (cmptno = 0; cmptno < bpcc->numcmpts; ++cmptno) {
+                        bpcc->bpcs[cmptno] = JP2_SPTOBPC(jas_image_cmptsgnd(image,
+                          cmptno), jas_image_cmptprec(image, cmptno));
+                }
+                if (jp2_box_put(box, tmpstream)) {
+                        goto error;
+                }
+                jp2_box_destroy(box);
+                box = 0;
+        }
+
+        /* Generate color specification box. */
+
+        if (!(box = jp2_box_create(JP2_BOX_COLR))) {
+                goto error;
+        }
+        colr = &box->data.colr;
+        colr->method = JP2_COLR_ENUM;
+        colr->pri = JP2_COLR_PRI;
+        colr->approx = 0;
+        colr->csid = (jas_image_colorspace(image) == JAS_IMAGE_CS_RGB) ? JP2_COLR_SRGB :
+          JP2_COLR_SGRAY;
+        if (jp2_box_put(box, tmpstream)) {
+                goto error;
+        }
+        jp2_box_destroy(box);
+        box = 0;
+
+        if (!(jas_image_colorspace(image) == JAS_IMAGE_CS_RGB &&
+          jas_image_numcmpts(image) == 3 &&
+          jas_image_getcmptbytype(image, 0) ==
+          JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_R) &&
+          jas_image_getcmptbytype(image, 1) ==
+          JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_G) &&
+          jas_image_getcmptbytype(image, 2) ==
+          JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_B)) &&
+          !(jas_image_colorspace(image) == JAS_IMAGE_CS_YCBCR &&
+          jas_image_numcmpts(image) != 3 &&
+          jas_image_getcmptbytype(image, 0) ==
+          JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_Y) &&
+          jas_image_getcmptbytype(image, 1) ==
+          JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CB) &&
+          jas_image_getcmptbytype(image, 2) ==
+          JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CR)) &&
+          !(jas_image_colorspace(image) == JAS_IMAGE_CS_GRAY &&
+          jas_image_numcmpts(image) == 1 &&
+          jas_image_getcmptbytype(image, 0) ==
+          JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y))) {
+
+                if (!(box = jp2_box_create(JP2_BOX_CDEF))) {
+                        goto error;
+                }
+                cdef = &box->data.cdef;
+                cdef->numchans = jas_image_numcmpts(image);
+                cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t));
+                for (i = 0; i < jas_image_numcmpts(image); ++i) {
+                        cdefchanent = &cdef->ents[i];
+                        cdefchanent->channo = i;
+                        typeasoc = jp2_gettypeasoc(jas_image_colorspace(image), jas_image_cmpttype(image, i));
+                        cdefchanent->type = typeasoc >> 16;
+                        cdefchanent->assoc = typeasoc & 0x7fff;
+                }
+                jp2_box_destroy(box);
+                box = 0;
+        }
+
+        /* Determine the total length of the JP2 header box. */
+
+        len = jas_stream_tell(tmpstream);
+        jas_stream_rewind(tmpstream);
+
+        /*
+         * Output the JP2 header box and all of the boxes which it contains.
+         */
+
+        if (!(box = jp2_box_create(JP2_BOX_JP2H))) {
+                goto error;
+        }
+        box->len = len + JP2_BOX_HDRLEN;
+        if (jp2_box_put(box, out)) {
+                goto error;
+        }
+        jp2_box_destroy(box);
+        box = 0;
+
+        if (jas_stream_copy(out, tmpstream, len)) {
+                goto error;
+        }
+
+        jas_stream_close(tmpstream);
+        tmpstream = 0;
+
+        /*
+         * Output the contiguous code stream box.
+         */
+
+        if (!(box = jp2_box_create(JP2_BOX_JP2C))) {
+                goto error;
+        }
+        box->len = 0;
+        if (jp2_box_put(box, out)) {
+                goto error;
+        }
+        jp2_box_destroy(box);
+        box = 0;
+
+        /* Output the JPEG-2000 code stream. */
+
+        overhead = jas_stream_getrwcount(out);
+        sprintf(buf, "%s\n_jp2overhead=%lu\n", (optstr ? optstr : ""),
+          (unsigned long) overhead);
+
+        if (jpc_encode(image, out, buf)) {
+                goto error;
+        }
+
+        return 0;
+        abort();
 
 error:
 
-	if (box) {
-		jp2_box_destroy(box);
-	}
-	if (tmpstream) {
-		jas_stream_close(tmpstream);
-	}
-	return -1;
+        if (box) {
+                jp2_box_destroy(box);
+        }
+        if (tmpstream) {
+                jas_stream_close(tmpstream);
+        }
+        return -1;
 }
 
 
 static uint_fast32_t jp2_gettypeasoc(int colorspace, int ctype)
 {
-	int type;
-	int asoc;
-
-	if (ctype & JAS_IMAGE_CT_OPACITY) {
-		type = JP2_CDEF_TYPE_OPACITY;
-		asoc = JP2_CDEF_ASOC_ALL;
-		goto done;
-	}
-
-	type = JP2_CDEF_TYPE_UNSPEC;
-	asoc = JP2_CDEF_ASOC_NONE;
-	switch (colorspace) {
-	case JAS_IMAGE_CS_RGB:
-		switch (JAS_IMAGE_CT_COLOR(ctype)) {
-		case JAS_IMAGE_CT_RGB_R:
-			type = JP2_CDEF_TYPE_COLOR;
-			asoc = JP2_CDEF_RGB_R;
-			break;
-		case JAS_IMAGE_CT_RGB_G:
-			type = JP2_CDEF_TYPE_COLOR;
-			asoc = JP2_CDEF_RGB_G;
-			break;
-		case JAS_IMAGE_CT_RGB_B:
-			type = JP2_CDEF_TYPE_COLOR;
-			asoc = JP2_CDEF_RGB_B;
-			break;
-		}
-		break;
-	case JAS_IMAGE_CS_YCBCR:
-		switch (JAS_IMAGE_CT_COLOR(ctype)) {
-		case JAS_IMAGE_CT_YCBCR_Y:
-			type = JP2_CDEF_TYPE_COLOR;
-			asoc = JP2_CDEF_YCBCR_Y;
-			break;
-		case JAS_IMAGE_CT_YCBCR_CB:
-			type = JP2_CDEF_TYPE_COLOR;
-			asoc = JP2_CDEF_YCBCR_CB;
-			break;
-		case JAS_IMAGE_CT_YCBCR_CR:
-			type = JP2_CDEF_TYPE_COLOR;
-			asoc = JP2_CDEF_YCBCR_CR;
-			break;
-		}
-		break;
-	case JAS_IMAGE_CS_GRAY:
-		type = JP2_CDEF_TYPE_COLOR;
-		asoc = JP2_CDEF_GRAY_Y;
-		break;
-	}
+        int type;
+        int asoc;
+
+        if (ctype & JAS_IMAGE_CT_OPACITY) {
+                type = JP2_CDEF_TYPE_OPACITY;
+                asoc = JP2_CDEF_ASOC_ALL;
+                goto done;
+        }
+
+        type = JP2_CDEF_TYPE_UNSPEC;
+        asoc = JP2_CDEF_ASOC_NONE;
+        switch (colorspace) {
+        case JAS_IMAGE_CS_RGB:
+                switch (JAS_IMAGE_CT_COLOR(ctype)) {
+                case JAS_IMAGE_CT_RGB_R:
+                        type = JP2_CDEF_TYPE_COLOR;
+                        asoc = JP2_CDEF_RGB_R;
+                        break;
+                case JAS_IMAGE_CT_RGB_G:
+                        type = JP2_CDEF_TYPE_COLOR;
+                        asoc = JP2_CDEF_RGB_G;
+                        break;
+                case JAS_IMAGE_CT_RGB_B:
+                        type = JP2_CDEF_TYPE_COLOR;
+                        asoc = JP2_CDEF_RGB_B;
+                        break;
+                }
+                break;
+        case JAS_IMAGE_CS_YCBCR:
+                switch (JAS_IMAGE_CT_COLOR(ctype)) {
+                case JAS_IMAGE_CT_YCBCR_Y:
+                        type = JP2_CDEF_TYPE_COLOR;
+                        asoc = JP2_CDEF_YCBCR_Y;
+                        break;
+                case JAS_IMAGE_CT_YCBCR_CB:
+                        type = JP2_CDEF_TYPE_COLOR;
+                        asoc = JP2_CDEF_YCBCR_CB;
+                        break;
+                case JAS_IMAGE_CT_YCBCR_CR:
+                        type = JP2_CDEF_TYPE_COLOR;
+                        asoc = JP2_CDEF_YCBCR_CR;
+                        break;
+                }
+                break;
+        case JAS_IMAGE_CS_GRAY:
+                type = JP2_CDEF_TYPE_COLOR;
+                asoc = JP2_CDEF_GRAY_Y;
+                break;
+        }
 
 done:
-	return (type << 16) | asoc;
+        return (type << 16) | asoc;
 }
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c
index c66fcd99..3f693fff 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -137,66 +137,66 @@
 /* Allocate a new bit stream. */
 static jpc_bitstream_t *jpc_bitstream_alloc()
 {
-	jpc_bitstream_t *bitstream;
-
-	/* Allocate memory for the new bit stream object. */
-	if (!(bitstream = jas_malloc(sizeof(jpc_bitstream_t)))) {
-		return 0;
-	}
-	/* Initialize all of the data members. */
-	bitstream->stream_ = 0;
-	bitstream->cnt_ = 0;
-	bitstream->flags_ = 0;
-	bitstream->openmode_ = 0;
-
-	return bitstream;
+        jpc_bitstream_t *bitstream;
+
+        /* Allocate memory for the new bit stream object. */
+        if (!(bitstream = jas_malloc(sizeof(jpc_bitstream_t)))) {
+                return 0;
+        }
+        /* Initialize all of the data members. */
+        bitstream->stream_ = 0;
+        bitstream->cnt_ = 0;
+        bitstream->flags_ = 0;
+        bitstream->openmode_ = 0;
+
+        return bitstream;
 }
 
 /* Open a bit stream from a stream. */
 jpc_bitstream_t *jpc_bitstream_sopen(jas_stream_t *stream, const char *mode)
 {
-	jpc_bitstream_t *bitstream;
+        jpc_bitstream_t *bitstream;
 
-	if (!(bitstream = jpc_bitstream_alloc())) {
-		return 0;
-	}
+        if (!(bitstream = jpc_bitstream_alloc())) {
+                return 0;
+        }
 
-	/* By default, do not close the underlying (character) stream, upon
-	  the close of the bit stream. */
-	bitstream->flags_ = JPC_BITSTREAM_NOCLOSE;
+        /* By default, do not close the underlying (character) stream, upon
+          the close of the bit stream. */
+        bitstream->flags_ = JPC_BITSTREAM_NOCLOSE;
 
-	bitstream->stream_ = stream;
-	bitstream->openmode_ = (mode[0] == 'w') ? JPC_BITSTREAM_WRITE :
-	  JPC_BITSTREAM_READ;
+        bitstream->stream_ = stream;
+        bitstream->openmode_ = (mode[0] == 'w') ? JPC_BITSTREAM_WRITE :
+          JPC_BITSTREAM_READ;
 
-	/* Mark the data buffer as empty. */
-	bitstream->cnt_ = (bitstream->openmode_ == JPC_BITSTREAM_READ) ? 0 : 8;
-	bitstream->buf_ = 0;
+        /* Mark the data buffer as empty. */
+        bitstream->cnt_ = (bitstream->openmode_ == JPC_BITSTREAM_READ) ? 0 : 8;
+        bitstream->buf_ = 0;
 
-	return bitstream;
+        return bitstream;
 }
 
 /* Close a bit stream. */
 int jpc_bitstream_close(jpc_bitstream_t *bitstream)
 {
-	int ret = 0;
-
-	/* Align to the next byte boundary while considering the effects of
-	  bit stuffing. */
-	if (jpc_bitstream_align(bitstream)) {
-		ret = -1;
-	}
-
-	/* If necessary, close the underlying (character) stream. */
-	if (!(bitstream->flags_ & JPC_BITSTREAM_NOCLOSE) && bitstream->stream_) {
-		if (jas_stream_close(bitstream->stream_)) {
-			ret = -1;
-		}
-		bitstream->stream_ = 0;
-	}
-
-	jas_free(bitstream);
-	return ret;
+        int ret = 0;
+
+        /* Align to the next byte boundary while considering the effects of
+          bit stuffing. */
+        if (jpc_bitstream_align(bitstream)) {
+                ret = -1;
+        }
+
+        /* If necessary, close the underlying (character) stream. */
+        if (!(bitstream->flags_ & JPC_BITSTREAM_NOCLOSE) && bitstream->stream_) {
+                if (jas_stream_close(bitstream->stream_)) {
+                        ret = -1;
+                }
+                bitstream->stream_ = 0;
+        }
+
+        jas_free(bitstream);
+        return ret;
 }
 
 /******************************************************************************\
@@ -206,64 +206,64 @@ int jpc_bitstream_close(jpc_bitstream_t *bitstream)
 /* Get a bit from a bit stream. */
 int jpc_bitstream_getbit_func(jpc_bitstream_t *bitstream)
 {
-	int ret;
-	JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func(%p)\n", bitstream));
-	ret = jpc_bitstream_getbit_macro(bitstream);
-	JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func -> %d\n", ret));
-	return ret;
+        int ret;
+        JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func(%p)\n", bitstream));
+        ret = jpc_bitstream_getbit_macro(bitstream);
+        JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func -> %d\n", ret));
+        return ret;
 }
 
 /* Put a bit to a bit stream. */
 int jpc_bitstream_putbit_func(jpc_bitstream_t *bitstream, int b)
 {
-	int ret;
-	JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func(%p, %d)\n", bitstream, b));
-	ret = jpc_bitstream_putbit_macro(bitstream, b);
-	JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func() -> %d\n", ret));
-	return ret;
+        int ret;
+        JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func(%p, %d)\n", bitstream, b));
+        ret = jpc_bitstream_putbit_macro(bitstream, b);
+        JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func() -> %d\n", ret));
+        return ret;
 }
 
 /* Get one or more bits from a bit stream. */
 long jpc_bitstream_getbits(jpc_bitstream_t *bitstream, int n)
 {
-	long v;
-	int u;
-
-	/* We can reliably get at most 31 bits since ISO/IEC 9899 only
-	  guarantees that a long can represent values up to 2^31-1. */
-	assert(n >= 0 && n < 32);
-
-	/* Get the number of bits requested from the specified bit stream. */
-	v = 0;
-	while (--n >= 0) {
-		if ((u = jpc_bitstream_getbit(bitstream)) < 0) {
-			return -1;
-		}
-		v = (v << 1) | u;
-	}
-	return v;
+        long v;
+        int u;
+
+        /* We can reliably get at most 31 bits since ISO/IEC 9899 only
+          guarantees that a long can represent values up to 2^31-1. */
+        assert(n >= 0 && n < 32);
+
+        /* Get the number of bits requested from the specified bit stream. */
+        v = 0;
+        while (--n >= 0) {
+                if ((u = jpc_bitstream_getbit(bitstream)) < 0) {
+                        return -1;
+                }
+                v = (v << 1) | u;
+        }
+        return v;
 }
 
 /* Put one or more bits to a bit stream. */
 int jpc_bitstream_putbits(jpc_bitstream_t *bitstream, int n, long v)
 {
-	int m;
-
-	/* We can reliably put at most 31 bits since ISO/IEC 9899 only
-	  guarantees that a long can represent values up to 2^31-1. */
-	assert(n >= 0 && n < 32);
-	/* Ensure that only the bits to be output are nonzero. */
-	assert(!(v & (~JAS_ONES(n))));
-
-	/* Put the desired number of bits to the specified bit stream. */
-	m = n - 1;
-	while (--n >= 0) {
-		if (jpc_bitstream_putbit(bitstream, (v >> m) & 1) == EOF) {
-			return EOF;
-		}
-		v <<= 1;
-	}
-	return 0;
+        int m;
+
+        /* We can reliably put at most 31 bits since ISO/IEC 9899 only
+          guarantees that a long can represent values up to 2^31-1. */
+        assert(n >= 0 && n < 32);
+        /* Ensure that only the bits to be output are nonzero. */
+        assert(!(v & (~JAS_ONES(n))));
+
+        /* Put the desired number of bits to the specified bit stream. */
+        m = n - 1;
+        while (--n >= 0) {
+                if (jpc_bitstream_putbit(bitstream, (v >> m) & 1) == EOF) {
+                        return EOF;
+                }
+                v <<= 1;
+        }
+        return 0;
 }
 
 /******************************************************************************\
@@ -273,30 +273,30 @@ int jpc_bitstream_putbits(jpc_bitstream_t *bitstream, int n, long v)
 /* Fill the buffer for a bit stream. */
 int jpc_bitstream_fillbuf(jpc_bitstream_t *bitstream)
 {
-	int c;
-	/* Note: The count has already been decremented by the caller. */
-	assert(bitstream->openmode_ & JPC_BITSTREAM_READ);
-	assert(bitstream->cnt_ <= 0);
-
-	if (bitstream->flags_ & JPC_BITSTREAM_ERR) {
-		bitstream->cnt_ = 0;
-		return -1;
-	}
-
-	if (bitstream->flags_ & JPC_BITSTREAM_EOF) {
-		bitstream->buf_ = 0x7f;
-		bitstream->cnt_ = 7;
-		return 1;
-	}
-
-	bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff;
-	if ((c = jas_stream_getc((bitstream)->stream_)) == EOF) {
-		bitstream->flags_ |= JPC_BITSTREAM_EOF;
-		return 1;
-	}
-	bitstream->cnt_ = (bitstream->buf_ == 0xff00) ? 6 : 7;
-	bitstream->buf_ |= c & ((1 << (bitstream->cnt_ + 1)) - 1);
-	return (bitstream->buf_ >> bitstream->cnt_) & 1;
+        int c;
+        /* Note: The count has already been decremented by the caller. */
+        assert(bitstream->openmode_ & JPC_BITSTREAM_READ);
+        assert(bitstream->cnt_ <= 0);
+
+        if (bitstream->flags_ & JPC_BITSTREAM_ERR) {
+                bitstream->cnt_ = 0;
+                return -1;
+        }
+
+        if (bitstream->flags_ & JPC_BITSTREAM_EOF) {
+                bitstream->buf_ = 0x7f;
+                bitstream->cnt_ = 7;
+                return 1;
+        }
+
+        bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff;
+        if ((c = jas_stream_getc((bitstream)->stream_)) == EOF) {
+                bitstream->flags_ |= JPC_BITSTREAM_EOF;
+                return 1;
+        }
+        bitstream->cnt_ = (bitstream->buf_ == 0xff00) ? 6 : 7;
+        bitstream->buf_ |= c & ((1 << (bitstream->cnt_ + 1)) - 1);
+        return (bitstream->buf_ >> bitstream->cnt_) & 1;
 }
 
 
@@ -308,167 +308,167 @@ int jpc_bitstream_fillbuf(jpc_bitstream_t *bitstream)
   the effects of bit stuffing)? */
 int jpc_bitstream_needalign(jpc_bitstream_t *bitstream)
 {
-	if (bitstream->openmode_ & JPC_BITSTREAM_READ) {
-		/* The bit stream is open for reading. */
-		/* If there are any bits buffered for reading, or the
-		  previous byte forced a stuffed bit, alignment is
-		  required. */
-		if ((bitstream->cnt_ < 8 && bitstream->cnt_ > 0) ||
-		  ((bitstream->buf_ >> 8) & 0xff) == 0xff) {
-			return 1;
-		}
-	} else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) {
-		/* The bit stream is open for writing. */
-		/* If there are any bits buffered for writing, or the
-		  previous byte forced a stuffed bit, alignment is
-		  required. */
-		if ((bitstream->cnt_ < 8 && bitstream->cnt_ >= 0) ||
-		  ((bitstream->buf_ >> 8) & 0xff) == 0xff) {
-			return 1;
-		}
-	} else {
-		/* This should not happen.  Famous last words, eh? :-) */
-		assert(0);
-		return -1;
-	}
-	return 0;
+        if (bitstream->openmode_ & JPC_BITSTREAM_READ) {
+                /* The bit stream is open for reading. */
+                /* If there are any bits buffered for reading, or the
+                  previous byte forced a stuffed bit, alignment is
+                  required. */
+                if ((bitstream->cnt_ < 8 && bitstream->cnt_ > 0) ||
+                  ((bitstream->buf_ >> 8) & 0xff) == 0xff) {
+                        return 1;
+                }
+        } else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) {
+                /* The bit stream is open for writing. */
+                /* If there are any bits buffered for writing, or the
+                  previous byte forced a stuffed bit, alignment is
+                  required. */
+                if ((bitstream->cnt_ < 8 && bitstream->cnt_ >= 0) ||
+                  ((bitstream->buf_ >> 8) & 0xff) == 0xff) {
+                        return 1;
+                }
+        } else {
+                /* This should not happen.  Famous last words, eh? :-) */
+                assert(0);
+                return -1;
+        }
+        return 0;
 }
 
 /* How many additional bytes would be output if we align the bit stream? */
 int jpc_bitstream_pending(jpc_bitstream_t *bitstream)
 {
-	if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) {
-		/* The bit stream is being used for writing. */
+        if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) {
+                /* The bit stream is being used for writing. */
 #if 1
-		/* XXX - Is this really correct?  Check someday... */
-		if (bitstream->cnt_ < 8) {
-			return 1;
-		}
+                /* XXX - Is this really correct?  Check someday... */
+                if (bitstream->cnt_ < 8) {
+                        return 1;
+                }
 #else
-		if (bitstream->cnt_ < 8) {
-			if (((bitstream->buf_ >> 8) & 0xff) == 0xff) {
-				return 2;
-			}
-			return 1;
-		}
+                if (bitstream->cnt_ < 8) {
+                        if (((bitstream->buf_ >> 8) & 0xff) == 0xff) {
+                                return 2;
+                        }
+                        return 1;
+                }
 #endif
-		return 0;
-	} else {
-		/* This operation should not be invoked on a bit stream that
-		  is being used for reading. */
-		return -1;
-	}
+                return 0;
+        } else {
+                /* This operation should not be invoked on a bit stream that
+                  is being used for reading. */
+                return -1;
+        }
 }
 
 /* Align the bit stream to a byte boundary. */
 int jpc_bitstream_align(jpc_bitstream_t *bitstream)
 {
-	int ret;
-	if (bitstream->openmode_ & JPC_BITSTREAM_READ) {
-		ret = jpc_bitstream_inalign(bitstream, 0, 0);
-	} else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) {
-		ret = jpc_bitstream_outalign(bitstream, 0);
-	}
-	return ret;
+        int ret;
+        if (bitstream->openmode_ & JPC_BITSTREAM_READ) {
+                ret = jpc_bitstream_inalign(bitstream, 0, 0);
+        } else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) {
+                ret = jpc_bitstream_outalign(bitstream, 0);
+        }
+        return ret;
 }
 
 /* Align a bit stream in the input case. */
 int jpc_bitstream_inalign(jpc_bitstream_t *bitstream, int fillmask,
   int filldata)
 {
-	int n;
-	int v;
-	int u;
-	int numfill;
-	int m;
-
-	numfill = 7;
-	m = 0;
-	v = 0;
-	if (bitstream->cnt_ > 0) {
-		n = bitstream->cnt_;
-	} else if (!bitstream->cnt_) {
-		n = ((bitstream->buf_ & 0xff) == 0xff) ? 7 : 0;
-	} else {
-		n = 0;
-	}
-	if (n > 0) {
-		if ((u = jpc_bitstream_getbits(bitstream, n)) < 0) {
-			return -1;
-		}
-		m += n;
-		v = (v << n) | u;
-	}
-	if ((bitstream->buf_ & 0xff) == 0xff) {
-		if ((u = jpc_bitstream_getbits(bitstream, 7)) < 0) {
-			return -1;
-		}
-		v = (v << 7) | u;
-		m += 7;
-	}
-	if (m > numfill) {
-		v >>= m - numfill;
-	} else {
-		filldata >>= numfill - m;
-		fillmask >>= numfill - m;
-	}
-	if (((~(v ^ filldata)) & fillmask) != fillmask) {
-		/* The actual fill pattern does not match the expected one. */
-		return 1;
-	}
-
-	return 0;
+        int n;
+        int v;
+        int u;
+        int numfill;
+        int m;
+
+        numfill = 7;
+        m = 0;
+        v = 0;
+        if (bitstream->cnt_ > 0) {
+                n = bitstream->cnt_;
+        } else if (!bitstream->cnt_) {
+                n = ((bitstream->buf_ & 0xff) == 0xff) ? 7 : 0;
+        } else {
+                n = 0;
+        }
+        if (n > 0) {
+                if ((u = jpc_bitstream_getbits(bitstream, n)) < 0) {
+                        return -1;
+                }
+                m += n;
+                v = (v << n) | u;
+        }
+        if ((bitstream->buf_ & 0xff) == 0xff) {
+                if ((u = jpc_bitstream_getbits(bitstream, 7)) < 0) {
+                        return -1;
+                }
+                v = (v << 7) | u;
+                m += 7;
+        }
+        if (m > numfill) {
+                v >>= m - numfill;
+        } else {
+                filldata >>= numfill - m;
+                fillmask >>= numfill - m;
+        }
+        if (((~(v ^ filldata)) & fillmask) != fillmask) {
+                /* The actual fill pattern does not match the expected one. */
+                return 1;
+        }
+
+        return 0;
 }
 
 /* Align a bit stream in the output case. */
 int jpc_bitstream_outalign(jpc_bitstream_t *bitstream, int filldata)
 {
-	int n;
-	int v;
-
-	/* Ensure that this bit stream is open for writing. */
-	assert(bitstream->openmode_ & JPC_BITSTREAM_WRITE);
-
-	/* Ensure that the first bit of fill data is zero. */
-	/* Note: The first bit of fill data must be zero.  If this were not
-	  the case, the fill data itself could cause further bit stuffing to
-	  be required (which would cause numerous complications). */
-	assert(!(filldata & (~0x3f)));
-
-	if (!bitstream->cnt_) {
-		if ((bitstream->buf_ & 0xff) == 0xff) {
-			n = 7;
-			v = filldata;
-		} else {
-			n = 0;
-			v = 0;
-		}
-	} else if (bitstream->cnt_ > 0 && bitstream->cnt_ < 8) {
-		n = bitstream->cnt_;
-		v = filldata >> (7 - n);
-	} else {
-		n = 0;
-		v = 0;
-		return 0;
-	}
-
-	/* Write the appropriate fill data to the bit stream. */
-	if (n > 0) {
-		if (jpc_bitstream_putbits(bitstream, n, v)) {
-			return -1;
-		}
-	}
-	if (bitstream->cnt_ < 8) {
-		assert(bitstream->cnt_ >= 0 && bitstream->cnt_ < 8);
-		assert((bitstream->buf_ & 0xff) != 0xff);
-		/* Force the pending byte of output to be written to the
-		  underlying (character) stream. */
-		if (jas_stream_putc(bitstream->stream_, bitstream->buf_ & 0xff) == EOF) {
-			return -1;
-		}
-		bitstream->cnt_ = 8;
-		bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff;
-	}
-
-	return 0;
+        int n;
+        int v;
+
+        /* Ensure that this bit stream is open for writing. */
+        assert(bitstream->openmode_ & JPC_BITSTREAM_WRITE);
+
+        /* Ensure that the first bit of fill data is zero. */
+        /* Note: The first bit of fill data must be zero.  If this were not
+          the case, the fill data itself could cause further bit stuffing to
+          be required (which would cause numerous complications). */
+        assert(!(filldata & (~0x3f)));
+
+        if (!bitstream->cnt_) {
+                if ((bitstream->buf_ & 0xff) == 0xff) {
+                        n = 7;
+                        v = filldata;
+                } else {
+                        n = 0;
+                        v = 0;
+                }
+        } else if (bitstream->cnt_ > 0 && bitstream->cnt_ < 8) {
+                n = bitstream->cnt_;
+                v = filldata >> (7 - n);
+        } else {
+                n = 0;
+                v = 0;
+                return 0;
+        }
+
+        /* Write the appropriate fill data to the bit stream. */
+        if (n > 0) {
+                if (jpc_bitstream_putbits(bitstream, n, v)) {
+                        return -1;
+                }
+        }
+        if (bitstream->cnt_ < 8) {
+                assert(bitstream->cnt_ >= 0 && bitstream->cnt_ < 8);
+                assert((bitstream->buf_ & 0xff) != 0xff);
+                /* Force the pending byte of output to be written to the
+                  underlying (character) stream. */
+                if (jas_stream_putc(bitstream->stream_, bitstream->buf_ & 0xff) == EOF) {
+                        return -1;
+                }
+                bitstream->cnt_ = 8;
+                bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff;
+        }
+
+        return 0;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h
index edb0a2df..2137a435 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -137,20 +137,20 @@
  */
 
 /* Bit stream open for reading. */
-#define	JPC_BITSTREAM_READ	0x01
+#define JPC_BITSTREAM_READ      0x01
 /* Bit stream open for writing. */
-#define	JPC_BITSTREAM_WRITE	0x02
+#define JPC_BITSTREAM_WRITE     0x02
 
 /*
  * Bit stream flags.
  */
 
 /* Do not close underlying character stream. */
-#define	JPC_BITSTREAM_NOCLOSE	0x01
+#define JPC_BITSTREAM_NOCLOSE   0x01
 /* End of file has been reached while reading. */
-#define	JPC_BITSTREAM_EOF	0x02
+#define JPC_BITSTREAM_EOF       0x02
 /* An I/O error has occurred. */
-#define	JPC_BITSTREAM_ERR	0x04
+#define JPC_BITSTREAM_ERR       0x04
 
 /******************************************************************************\
 * Types.
@@ -160,20 +160,20 @@
 
 typedef struct {
 
-	/* Some miscellaneous flags. */
-	int flags_;
+        /* Some miscellaneous flags. */
+        int flags_;
 
-	/* The input/output buffer. */
-	uint_fast16_t buf_;
+        /* The input/output buffer. */
+        uint_fast16_t buf_;
 
-	/* The number of bits remaining in the byte being read/written. */
-	int cnt_;
+        /* The number of bits remaining in the byte being read/written. */
+        int cnt_;
 
-	/* The underlying stream associated with this bit stream. */
-	jas_stream_t *stream_;
+        /* The underlying stream associated with this bit stream. */
+        jas_stream_t *stream_;
 
-	/* The mode in which this bit stream was opened. */
-	int openmode_;
+        /* The mode in which this bit stream was opened. */
+        int openmode_;
 
 } jpc_bitstream_t;
 
@@ -193,20 +193,20 @@ int jpc_bitstream_close(jpc_bitstream_t *bitstream);
 
 /* Read a bit from a bit stream. */
 #if defined(DEBUG)
-#define	jpc_bitstream_getbit(bitstream) \
-	jpc_bitstream_getbit_func(bitstream)
+#define jpc_bitstream_getbit(bitstream) \
+        jpc_bitstream_getbit_func(bitstream)
 #else
 #define jpc_bitstream_getbit(bitstream) \
-	jpc_bitstream_getbit_macro(bitstream)
+        jpc_bitstream_getbit_macro(bitstream)
 #endif
 
 /* Write a bit to a bit stream. */
 #if defined(DEBUG)
-#define	jpc_bitstream_putbit(bitstream, v) \
-	jpc_bitstream_putbit_func(bitstream, v)
+#define jpc_bitstream_putbit(bitstream, v) \
+        jpc_bitstream_putbit_func(bitstream, v)
 #else
-#define	jpc_bitstream_putbit(bitstream, v) \
-	jpc_bitstream_putbit_macro(bitstream, v)
+#define jpc_bitstream_putbit(bitstream, v) \
+        jpc_bitstream_putbit_macro(bitstream, v)
 #endif
 
 /* Read one or more bits from a bit stream. */
@@ -245,7 +245,7 @@ int jpc_bitstream_pending(jpc_bitstream_t *bitstream);
 
 /* Has EOF been encountered on a bit stream? */
 #define jpc_bitstream_eof(bitstream) \
-	((bitstream)->flags_ & JPC_BITSTREAM_EOF)
+        ((bitstream)->flags_ & JPC_BITSTREAM_EOF)
 
 /******************************************************************************\
 * Internals.
@@ -260,21 +260,21 @@ int jpc_bitstream_putbit_func(jpc_bitstream_t *bitstream, int v);
 
 int jpc_bitstream_fillbuf(jpc_bitstream_t *bitstream);
 
-#define	jpc_bitstream_getbit_macro(bitstream) \
-	(assert((bitstream)->openmode_ & JPC_BITSTREAM_READ), \
-	  (--(bitstream)->cnt_ >= 0) ? \
-	  (((bitstream)->buf_ >> (bitstream)->cnt_) & 1) : \
-	  jpc_bitstream_fillbuf(bitstream))
+#define jpc_bitstream_getbit_macro(bitstream) \
+        (assert((bitstream)->openmode_ & JPC_BITSTREAM_READ), \
+          (--(bitstream)->cnt_ >= 0) ? \
+          (((bitstream)->buf_ >> (bitstream)->cnt_) & 1) : \
+          jpc_bitstream_fillbuf(bitstream))
 
 #define jpc_bitstream_putbit_macro(bitstream, bit) \
-	(assert((bitstream)->openmode_ & JPC_BITSTREAM_WRITE), \
-	  (--(bitstream)->cnt_ < 0) ? \
-	  ((bitstream)->buf_ = ((bitstream)->buf_ << 8) & 0xffff, \
-	  (bitstream)->cnt_ = ((bitstream)->buf_ == 0xff00) ? 6 : 7, \
-	  (bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \
-	  (jas_stream_putc((bitstream)->stream_, (bitstream)->buf_ >> 8) == EOF) \
-	  ? (EOF) : ((bit) & 1)) : \
-	  ((bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \
-	  (bit) & 1))
+        (assert((bitstream)->openmode_ & JPC_BITSTREAM_WRITE), \
+          (--(bitstream)->cnt_ < 0) ? \
+          ((bitstream)->buf_ = ((bitstream)->buf_ << 8) & 0xffff, \
+          (bitstream)->cnt_ = ((bitstream)->buf_ == 0xff00) ? 6 : 7, \
+          (bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \
+          (jas_stream_putc((bitstream)->stream_, (bitstream)->buf_ >> 8) == EOF) \
+          ? (EOF) : ((bit) & 1)) : \
+          ((bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \
+          (bit) & 1))
 
 #endif
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h
index 9b3ddbee..cff7e72b 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -122,6 +122,6 @@
 \******************************************************************************/
 
 /* The nominal word size used by this implementation. */
-#define	JPC_PREC	32
+#define JPC_PREC        32
 
 #endif
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c
index 559f36cf..441f8995 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h
index 4bff677c..13787d40 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -133,13 +133,13 @@
 \******************************************************************************/
 
 /* The maximum number of resolution levels. */
-#define	JPC_MAXRLVLS	33
+#define JPC_MAXRLVLS    33
 
 /* The maximum number of bands. */
-#define	JPC_MAXBANDS	(3 * JPC_MAXRLVLS + 1)
+#define JPC_MAXBANDS    (3 * JPC_MAXRLVLS + 1)
 
 /* The maximum number of layers. */
-#define JPC_MAXLYRS	16384
+#define JPC_MAXLYRS     16384
 
 /**************************************\
 * Code stream.
@@ -150,15 +150,15 @@
  */
 
 /* Initial. */
-#define	JPC_CS_INIT	0
+#define JPC_CS_INIT     0
 /* Main header. */
-#define	JPC_CS_MHDR	1
+#define JPC_CS_MHDR     1
 /* Tile-part header. */
-#define	JPC_CS_THDR	2
+#define JPC_CS_THDR     2
 /* Main trailer. */
-#define	JPC_CS_MTLR	3
+#define JPC_CS_MTLR     3
 /* Tile-part data. */
-#define	JPC_CS_TDATA	4
+#define JPC_CS_TDATA    4
 
 /*
  * Unfortunately, the code stream syntax was not designed in such a way that
@@ -174,8 +174,8 @@
 
 typedef struct {
 
-	/* The number of components. */
-	int numcomps;
+        /* The number of components. */
+        int numcomps;
 
 } jpc_cstate_t;
 
@@ -185,18 +185,18 @@ typedef struct {
 
 typedef struct {
 
-	/* The tile number. */
-	uint_fast16_t tileno;
+        /* The tile number. */
+        uint_fast16_t tileno;
 
-	/* The combined length of the marker segment and its auxiliary data
-	  (i.e., packet data). */
-	uint_fast32_t len;
+        /* The combined length of the marker segment and its auxiliary data
+          (i.e., packet data). */
+        uint_fast32_t len;
 
-	/* The tile-part instance. */
-	uint_fast8_t partno;
+        /* The tile-part instance. */
+        uint_fast8_t partno;
 
-	/* The number of tile-parts. */
-	uint_fast8_t numparts;
+        /* The number of tile-parts. */
+        uint_fast8_t numparts;
 
 } jpc_sot_t;
 
@@ -208,19 +208,19 @@ typedef struct {
 
 typedef struct {
 
-	/* The precision of the samples. */
-	uint_fast8_t prec;
+        /* The precision of the samples. */
+        uint_fast8_t prec;
 
-	/* The signedness of the samples. */
-	uint_fast8_t sgnd;
+        /* The signedness of the samples. */
+        uint_fast8_t sgnd;
 
-	/* The horizontal separation of samples with respect to the reference
-	  grid. */
-	uint_fast8_t hsamp;
+        /* The horizontal separation of samples with respect to the reference
+          grid. */
+        uint_fast8_t hsamp;
 
-	/* The vertical separation of samples with respect to the reference
-	  grid. */
-	uint_fast8_t vsamp;
+        /* The vertical separation of samples with respect to the reference
+          grid. */
+        uint_fast8_t vsamp;
 
 } jpc_sizcomp_t;
 
@@ -228,42 +228,42 @@ typedef struct {
 
 typedef struct {
 
-	/* The code stream capabilities. */
-	uint_fast16_t caps;
+        /* The code stream capabilities. */
+        uint_fast16_t caps;
 
-	/* The width of the image in units of the reference grid. */
-	uint_fast32_t width;
+        /* The width of the image in units of the reference grid. */
+        uint_fast32_t width;
 
-	/* The height of the image in units of the reference grid. */
-	uint_fast32_t height;
+        /* The height of the image in units of the reference grid. */
+        uint_fast32_t height;
 
-	/* The horizontal offset from the origin of the reference grid to the
-	  left side of the image area. */
-	uint_fast32_t xoff;
+        /* The horizontal offset from the origin of the reference grid to the
+          left side of the image area. */
+        uint_fast32_t xoff;
 
-	/* The vertical offset from the origin of the reference grid to the
-	  top side of the image area. */
-	uint_fast32_t yoff;
+        /* The vertical offset from the origin of the reference grid to the
+          top side of the image area. */
+        uint_fast32_t yoff;
 
-	/* The nominal width of a tile in units of the reference grid. */
-	uint_fast32_t tilewidth;
+        /* The nominal width of a tile in units of the reference grid. */
+        uint_fast32_t tilewidth;
 
-	/* The nominal height of a tile in units of the reference grid. */
-	uint_fast32_t tileheight;
+        /* The nominal height of a tile in units of the reference grid. */
+        uint_fast32_t tileheight;
 
-	/* The horizontal offset from the origin of the reference grid to the
-	  left side of the first tile. */
-	uint_fast32_t tilexoff;
+        /* The horizontal offset from the origin of the reference grid to the
+          left side of the first tile. */
+        uint_fast32_t tilexoff;
 
-	/* The vertical offset from the origin of the reference grid to the
-	  top side of the first tile. */
-	uint_fast32_t tileyoff;
+        /* The vertical offset from the origin of the reference grid to the
+          top side of the first tile. */
+        uint_fast32_t tileyoff;
 
-	/* The number of components. */
-	uint_fast16_t numcomps;
+        /* The number of components. */
+        uint_fast16_t numcomps;
 
-	/* The per-component information. */
-	jpc_sizcomp_t *comps;
+        /* The per-component information. */
+        jpc_sizcomp_t *comps;
 
 } jpc_siz_t;
 
@@ -276,11 +276,11 @@ typedef struct {
  */
 
 /* Precincts may be used. */
-#define	JPC_COX_PRT	0x01
+#define JPC_COX_PRT     0x01
 /* SOP marker segments may be used. */
-#define	JPC_COD_SOP	0x02
+#define JPC_COD_SOP     0x02
 /* EPH marker segments may be used. */
-#define	JPC_COD_EPH	0x04
+#define JPC_COD_EPH     0x04
 
 /*
  * Progression order constants.
@@ -288,50 +288,50 @@ typedef struct {
 
 /* Layer-resolution-component-precinct progressive
   (i.e., progressive by fidelity). */
-#define	JPC_COD_LRCPPRG	0
+#define JPC_COD_LRCPPRG 0
 /* Resolution-layer-component-precinct progressive
   (i.e., progressive by resolution). */
-#define	JPC_COD_RLCPPRG	1
+#define JPC_COD_RLCPPRG 1
 /* Resolution-precinct-component-layer progressive. */
-#define	JPC_COD_RPCLPRG	2
+#define JPC_COD_RPCLPRG 2
 /* Precinct-component-resolution-layer progressive. */
-#define	JPC_COD_PCRLPRG	3
+#define JPC_COD_PCRLPRG 3
 /* Component-position-resolution-layer progressive. */
-#define	JPC_COD_CPRLPRG	4
+#define JPC_COD_CPRLPRG 4
 
 /*
  * Code block style constants.
  */
 
-#define	JPC_COX_LAZY	0x01 /* Selective arithmetic coding bypass. */
-#define	JPC_COX_RESET	0x02 /* Reset context probabilities. */
-#define	JPC_COX_TERMALL	0x04 /* Terminate all coding passes. */
-#define	JPC_COX_VSC		0x08 /* Vertical stripe causal context formation. */
-#define	JPC_COX_PTERM	0x10 /* Predictable termination. */
-#define	JPC_COX_SEGSYM	0x20 /* Use segmentation symbols. */
+#define JPC_COX_LAZY    0x01 /* Selective arithmetic coding bypass. */
+#define JPC_COX_RESET   0x02 /* Reset context probabilities. */
+#define JPC_COX_TERMALL 0x04 /* Terminate all coding passes. */
+#define JPC_COX_VSC             0x08 /* Vertical stripe causal context formation. */
+#define JPC_COX_PTERM   0x10 /* Predictable termination. */
+#define JPC_COX_SEGSYM  0x20 /* Use segmentation symbols. */
 
 /* Transform constants. */
-#define	JPC_COX_INS	0x00 /* Irreversible 9/7. */
-#define	JPC_COX_RFT	0x01 /* Reversible 5/3. */
+#define JPC_COX_INS     0x00 /* Irreversible 9/7. */
+#define JPC_COX_RFT     0x01 /* Reversible 5/3. */
 
 /* Multicomponent transform constants. */
-#define	JPC_COD_NOMCT	0x00 /* No multicomponent transform. */
-#define	JPC_COD_MCT		0x01 /* Multicomponent transform. */
+#define JPC_COD_NOMCT   0x00 /* No multicomponent transform. */
+#define JPC_COD_MCT             0x01 /* Multicomponent transform. */
 
 /* Get the code block size value from the code block size exponent. */
-#define	JPC_COX_CBLKSIZEEXPN(x)		((x) - 2)
+#define JPC_COX_CBLKSIZEEXPN(x)         ((x) - 2)
 /* Get the code block size exponent from the code block size value. */
-#define	JPC_COX_GETCBLKSIZEEXPN(x)	((x) + 2)
+#define JPC_COX_GETCBLKSIZEEXPN(x)      ((x) + 2)
 
 /* Per resolution-level information. */
 
 typedef struct {
 
-	/* The packet partition width. */
-	uint_fast8_t parwidthval;
+        /* The packet partition width. */
+        uint_fast8_t parwidthval;
 
-	/* The packet partition height. */
-	uint_fast8_t parheightval;
+        /* The packet partition height. */
+        uint_fast8_t parheightval;
 
 } jpc_coxrlvl_t;
 
@@ -339,29 +339,29 @@ typedef struct {
 
 typedef struct {
 
-	/* The coding style. */
-	uint_fast8_t csty;
+        /* The coding style. */
+        uint_fast8_t csty;
 
-	/* The number of decomposition levels. */
-	uint_fast8_t numdlvls;
+        /* The number of decomposition levels. */
+        uint_fast8_t numdlvls;
 
-	/* The nominal code block width specifier. */
-	uint_fast8_t cblkwidthval;
+        /* The nominal code block width specifier. */
+        uint_fast8_t cblkwidthval;
 
-	/* The nominal code block height specifier. */
-	uint_fast8_t cblkheightval;
+        /* The nominal code block height specifier. */
+        uint_fast8_t cblkheightval;
 
-	/* The style of coding passes. */
-	uint_fast8_t cblksty;
+        /* The style of coding passes. */
+        uint_fast8_t cblksty;
 
-	/* The QMFB employed. */
-	uint_fast8_t qmfbid;
+        /* The QMFB employed. */
+        uint_fast8_t qmfbid;
 
-	/* The number of resolution levels. */
-	int numrlvls;
+        /* The number of resolution levels. */
+        int numrlvls;
 
-	/* The per-resolution-level information. */
-	jpc_coxrlvl_t rlvls[JPC_MAXRLVLS];
+        /* The per-resolution-level information. */
+        jpc_coxrlvl_t rlvls[JPC_MAXRLVLS];
 
 } jpc_coxcp_t;
 
@@ -369,20 +369,20 @@ typedef struct {
 
 typedef struct {
 
-	/* The general coding style. */
-	uint_fast8_t csty;
+        /* The general coding style. */
+        uint_fast8_t csty;
 
-	/* The progression order. */
-	uint_fast8_t prg;
+        /* The progression order. */
+        uint_fast8_t prg;
 
-	/* The number of layers. */
-	uint_fast16_t numlyrs;
+        /* The number of layers. */
+        uint_fast16_t numlyrs;
 
-	/* The multicomponent transform. */
-	uint_fast8_t mctrans;
+        /* The multicomponent transform. */
+        uint_fast8_t mctrans;
 
-	/* Component-related parameters. */
-	jpc_coxcp_t compparms;
+        /* Component-related parameters. */
+        jpc_coxcp_t compparms;
 
 } jpc_cod_t;
 
@@ -390,11 +390,11 @@ typedef struct {
 
 typedef struct {
 
-	/* The component number. */
-	uint_fast16_t compno;
+        /* The component number. */
+        uint_fast16_t compno;
 
-	/* Component-related parameters. */
-	jpc_coxcp_t compparms;
+        /* Component-related parameters. */
+        jpc_coxcp_t compparms;
 
 } jpc_coc_t;
 
@@ -403,18 +403,18 @@ typedef struct {
 \**************************************/
 
 /* The maxshift ROI style. */
-#define	JPC_RGN_MAXSHIFT	0x00
+#define JPC_RGN_MAXSHIFT        0x00
 
 typedef struct {
 
-	/* The component to which the marker applies. */
-	uint_fast16_t compno;
+        /* The component to which the marker applies. */
+        uint_fast16_t compno;
 
-	/* The ROI style. */
-	uint_fast8_t roisty;
+        /* The ROI style. */
+        uint_fast8_t roisty;
 
-	/* The ROI shift value. */
-	uint_fast8_t roishift;
+        /* The ROI shift value. */
+        uint_fast8_t roishift;
 
 } jpc_rgn_t;
 
@@ -426,34 +426,34 @@ typedef struct {
  * Quantization style constants.
  */
 
-#define	JPC_QCX_NOQNT	0 /* No quantization. */
-#define	JPC_QCX_SIQNT	1 /* Scalar quantization, implicit. */
-#define	JPC_QCX_SEQNT	2 /* Scalar quantization, explicit. */
+#define JPC_QCX_NOQNT   0 /* No quantization. */
+#define JPC_QCX_SIQNT   1 /* Scalar quantization, implicit. */
+#define JPC_QCX_SEQNT   2 /* Scalar quantization, explicit. */
 
 /*
  * Stepsize manipulation macros.
  */
 
-#define	JPC_QCX_GETEXPN(x)	((x) >> 11)
-#define	JPC_QCX_GETMANT(x)	((x) & 0x07ff)
-#define	JPC_QCX_EXPN(x)		(assert(!((x) & (~0x1f))), (((x) & 0x1f) << 11))
-#define	JPC_QCX_MANT(x)		(assert(!((x) & (~0x7ff))), ((x) & 0x7ff))
+#define JPC_QCX_GETEXPN(x)      ((x) >> 11)
+#define JPC_QCX_GETMANT(x)      ((x) & 0x07ff)
+#define JPC_QCX_EXPN(x)         (assert(!((x) & (~0x1f))), (((x) & 0x1f) << 11))
+#define JPC_QCX_MANT(x)         (assert(!((x) & (~0x7ff))), ((x) & 0x7ff))
 
 /* Per component information. */
 
 typedef struct {
 
-	/* The quantization style. */
-	uint_fast8_t qntsty;
+        /* The quantization style. */
+        uint_fast8_t qntsty;
 
-	/* The number of step sizes. */
-	int numstepsizes;
+        /* The number of step sizes. */
+        int numstepsizes;
 
-	/* The step sizes. */
-	uint_fast16_t *stepsizes;
+        /* The step sizes. */
+        uint_fast16_t *stepsizes;
 
-	/* The number of guard bits. */
-	uint_fast8_t numguard;
+        /* The number of guard bits. */
+        uint_fast8_t numguard;
 
 } jpc_qcxcp_t;
 
@@ -461,11 +461,11 @@ typedef struct {
 
 typedef struct {
 
-	/* The component associated with this marker segment. */
-	uint_fast16_t compno;
+        /* The component associated with this marker segment. */
+        uint_fast16_t compno;
 
-	/* The parameters. */
-	jpc_qcxcp_t compparms;
+        /* The parameters. */
+        jpc_qcxcp_t compparms;
 
 } jpc_qcc_t;
 
@@ -473,8 +473,8 @@ typedef struct {
 
 typedef struct {
 
-	/* The parameters. */
-	jpc_qcxcp_t compparms;
+        /* The parameters. */
+        jpc_qcxcp_t compparms;
 
 } jpc_qcd_t;
 
@@ -484,28 +484,28 @@ typedef struct {
 
 typedef struct {
 
-	/* The progression order. */
-	uint_fast8_t prgord;
+        /* The progression order. */
+        uint_fast8_t prgord;
 
-	/* The lower bound (inclusive) on the resolution level for the
-	  progression order volume. */
-	uint_fast8_t rlvlnostart;
+        /* The lower bound (inclusive) on the resolution level for the
+          progression order volume. */
+        uint_fast8_t rlvlnostart;
 
-	/* The upper bound (exclusive) on the resolution level for the
-	  progression order volume. */
-	uint_fast8_t rlvlnoend;
+        /* The upper bound (exclusive) on the resolution level for the
+          progression order volume. */
+        uint_fast8_t rlvlnoend;
 
-	/* The lower bound (inclusive) on the component for the progression
-	  order volume. */
-	uint_fast16_t compnostart;
+        /* The lower bound (inclusive) on the component for the progression
+          order volume. */
+        uint_fast16_t compnostart;
 
-	/* The upper bound (exclusive) on the component for the progression
-	  order volume. */
-	uint_fast16_t compnoend;
+        /* The upper bound (exclusive) on the component for the progression
+          order volume. */
+        uint_fast16_t compnoend;
 
-	/* The upper bound (exclusive) on the layer for the progression
-	  order volume. */
-	uint_fast16_t lyrnoend;
+        /* The upper bound (exclusive) on the layer for the progression
+          order volume. */
+        uint_fast16_t lyrnoend;
 
 } jpc_pocpchg_t;
 
@@ -516,11 +516,11 @@ typedef jpc_pocpchg_t jpc_pchg_t;
 
 typedef struct {
 
-	/* The number of progression order changes. */
-	int numpchgs;
+        /* The number of progression order changes. */
+        int numpchgs;
 
-	/* The per-progression-order-change information. */
-	jpc_pocpchg_t *pchgs;
+        /* The per-progression-order-change information. */
+        jpc_pocpchg_t *pchgs;
 
 } jpc_poc_t;
 
@@ -532,14 +532,14 @@ typedef struct {
 
 typedef struct {
 
-	/* The index. */
-	uint_fast8_t ind;
+        /* The index. */
+        uint_fast8_t ind;
 
-	/* The length. */
-	uint_fast16_t len;
+        /* The length. */
+        uint_fast16_t len;
 
-	/* The data. */
-	unsigned char *data;
+        /* The data. */
+        unsigned char *data;
 
 } jpc_ppm_t;
 
@@ -547,14 +547,14 @@ typedef struct {
 
 typedef struct {
 
-	/* The index. */
-	uint_fast8_t ind;
+        /* The index. */
+        uint_fast8_t ind;
 
-	/* The length. */
-	uint_fast32_t len;
+        /* The length. */
+        uint_fast32_t len;
 
-	/* The data. */
-	unsigned char *data;
+        /* The data. */
+        unsigned char *data;
 
 } jpc_ppt_t;
 
@@ -566,19 +566,19 @@ typedef struct {
  * Registration IDs.
  */
 
-#define	JPC_COM_BIN		0x00
-#define	JPC_COM_LATIN	0x01
+#define JPC_COM_BIN             0x00
+#define JPC_COM_LATIN   0x01
 
 typedef struct {
 
-	/* The registration ID. */
-	uint_fast16_t regid;
+        /* The registration ID. */
+        uint_fast16_t regid;
 
-	/* The length of the data in bytes. */
-	uint_fast16_t len;
+        /* The length of the data in bytes. */
+        uint_fast16_t len;
 
-	/* The data. */
-	unsigned char *data;
+        /* The data. */
+        unsigned char *data;
 
 } jpc_com_t;
 
@@ -588,8 +588,8 @@ typedef struct {
 
 typedef struct {
 
-	/* The sequence number. */
-	uint_fast16_t seqno;
+        /* The sequence number. */
+        uint_fast16_t seqno;
 
 } jpc_sop_t;
 
@@ -601,21 +601,21 @@ typedef struct {
 
 typedef struct {
 
-	/* The horizontal offset. */
-	uint_fast16_t hoff;
+        /* The horizontal offset. */
+        uint_fast16_t hoff;
 
-	/* The vertical offset. */
-	uint_fast16_t voff;
+        /* The vertical offset. */
+        uint_fast16_t voff;
 
 } jpc_crgcomp_t;
 
 typedef struct {
 
-	/* The number of components. */
-	int numcomps;
+        /* The number of components. */
+        int numcomps;
 
-	/* Per component information. */
-	jpc_crgcomp_t *comps;
+        /* Per component information. */
+        jpc_crgcomp_t *comps;
 
 } jpc_crg_t;
 
@@ -625,11 +625,11 @@ typedef struct {
 
 typedef struct {
 
-	/* The data. */
-	unsigned char *data;
+        /* The data. */
+        unsigned char *data;
 
-	/* The length. */
-	uint_fast16_t len;
+        /* The length. */
+        uint_fast16_t len;
 
 } jpc_unk_t;
 
@@ -638,26 +638,26 @@ typedef struct {
 \**************************************/
 
 typedef union {
-	int soc;	/* unused */
-	jpc_sot_t sot;
-	int sod;	/* unused */
-	int eoc;	/* unused */
-	jpc_siz_t siz;
-	jpc_cod_t cod;
-	jpc_coc_t coc;
-	jpc_rgn_t rgn;
-	jpc_qcd_t qcd;
-	jpc_qcc_t qcc;
-	jpc_poc_t poc;
-	/* jpc_plm_t plm; */
-	/* jpc_plt_t plt; */
-	jpc_ppm_t ppm;
-	jpc_ppt_t ppt;
-	jpc_sop_t sop;
-	int eph;	/* unused */
-	jpc_com_t com;
-	jpc_crg_t crg;
-	jpc_unk_t unk;
+        int soc;        /* unused */
+        jpc_sot_t sot;
+        int sod;        /* unused */
+        int eoc;        /* unused */
+        jpc_siz_t siz;
+        jpc_cod_t cod;
+        jpc_coc_t coc;
+        jpc_rgn_t rgn;
+        jpc_qcd_t qcd;
+        jpc_qcc_t qcc;
+        jpc_poc_t poc;
+        /* jpc_plm_t plm; */
+        /* jpc_plt_t plt; */
+        jpc_ppm_t ppm;
+        jpc_ppt_t ppt;
+        jpc_sop_t sop;
+        int eph;        /* unused */
+        jpc_com_t com;
+        jpc_crg_t crg;
+        jpc_unk_t unk;
 } jpc_msparms_t;
 
 /**************************************\
@@ -667,47 +667,47 @@ typedef union {
 /* Marker segment IDs. */
 
 /* The smallest valid marker value. */
-#define	JPC_MS_MIN	0xff00
+#define JPC_MS_MIN      0xff00
 
 /* The largest valid marker value. */
-#define	JPC_MS_MAX	0xffff
+#define JPC_MS_MAX      0xffff
 
 /* The minimum marker value that cannot occur within packet data. */
-#define	JPC_MS_INMIN	0xff80
+#define JPC_MS_INMIN    0xff80
 /* The maximum marker value that cannot occur within packet data. */
-#define	JPC_MS_INMAX	0xffff
+#define JPC_MS_INMAX    0xffff
 
 /* Delimiting marker segments. */
-#define	JPC_MS_SOC	0xff4f /* Start of code stream (SOC). */
-#define	JPC_MS_SOT	0xff90 /* Start of tile-part (SOT). */
-#define	JPC_MS_SOD	0xff93 /* Start of data (SOD). */
-#define	JPC_MS_EOC	0xffd9 /* End of code stream (EOC). */
+#define JPC_MS_SOC      0xff4f /* Start of code stream (SOC). */
+#define JPC_MS_SOT      0xff90 /* Start of tile-part (SOT). */
+#define JPC_MS_SOD      0xff93 /* Start of data (SOD). */
+#define JPC_MS_EOC      0xffd9 /* End of code stream (EOC). */
 
 /* Fixed information marker segments. */
-#define	JPC_MS_SIZ	0xff51 /* Image and tile size (SIZ). */
+#define JPC_MS_SIZ      0xff51 /* Image and tile size (SIZ). */
 
 /* Functional marker segments. */
-#define	JPC_MS_COD	0xff52 /* Coding style default (COD). */
-#define JPC_MS_COC	0xff53 /* Coding style component (COC). */
-#define	JPC_MS_RGN	0xff5e /* Region of interest (RGN). */
-#define JPC_MS_QCD	0xff5c /* Quantization default (QCD). */
-#define JPC_MS_QCC	0xff5d /* Quantization component (QCC). */
-#define JPC_MS_POC	0xff5f /* Progression order default (POC). */
+#define JPC_MS_COD      0xff52 /* Coding style default (COD). */
+#define JPC_MS_COC      0xff53 /* Coding style component (COC). */
+#define JPC_MS_RGN      0xff5e /* Region of interest (RGN). */
+#define JPC_MS_QCD      0xff5c /* Quantization default (QCD). */
+#define JPC_MS_QCC      0xff5d /* Quantization component (QCC). */
+#define JPC_MS_POC      0xff5f /* Progression order default (POC). */
 
 /* Pointer marker segments. */
-#define	JPC_MS_TLM	0xff55 /* Tile-part lengths, main header (TLM). */
-#define	JPC_MS_PLM	0xff57 /* Packet length, main header (PLM). */
-#define	JPC_MS_PLT	0xff58 /* Packet length, tile-part header (PLT). */
-#define	JPC_MS_PPM	0xff60 /* Packed packet headers, main header (PPM). */
-#define	JPC_MS_PPT	0xff61 /* Packet packet headers, tile-part header (PPT). */
+#define JPC_MS_TLM      0xff55 /* Tile-part lengths, main header (TLM). */
+#define JPC_MS_PLM      0xff57 /* Packet length, main header (PLM). */
+#define JPC_MS_PLT      0xff58 /* Packet length, tile-part header (PLT). */
+#define JPC_MS_PPM      0xff60 /* Packed packet headers, main header (PPM). */
+#define JPC_MS_PPT      0xff61 /* Packet packet headers, tile-part header (PPT). */
 
 /* In bit stream marker segments. */
-#define	JPC_MS_SOP	0xff91	/* Start of packet (SOP). */
-#define	JPC_MS_EPH	0xff92	/* End of packet header (EPH). */
+#define JPC_MS_SOP      0xff91  /* Start of packet (SOP). */
+#define JPC_MS_EPH      0xff92  /* End of packet header (EPH). */
 
 /* Informational marker segments. */
-#define	JPC_MS_CRG	0xff63 /* Component registration (CRG). */
-#define JPC_MS_COM	0xff64 /* Comment (COM). */
+#define JPC_MS_CRG      0xff63 /* Component registration (CRG). */
+#define JPC_MS_COM      0xff64 /* Comment (COM). */
 
 /* Forward declaration. */
 struct jpc_msops_s;
@@ -716,20 +716,20 @@ struct jpc_msops_s;
 
 typedef struct {
 
-	/* The type of marker segment. */
-	uint_fast16_t id;
+        /* The type of marker segment. */
+        uint_fast16_t id;
 
-	/* The length of the marker segment. */
-	uint_fast16_t len;
+        /* The length of the marker segment. */
+        uint_fast16_t len;
 
-	/* The starting offset within the stream. */
-	uint_fast32_t off;
+        /* The starting offset within the stream. */
+        uint_fast32_t off;
 
-	/* The parameters of the marker segment. */
-	jpc_msparms_t parms;
+        /* The parameters of the marker segment. */
+        jpc_msparms_t parms;
 
-	/* The marker segment operations. */
-	struct jpc_msops_s *ops;
+        /* The marker segment operations. */
+        struct jpc_msops_s *ops;
 
 } jpc_ms_t;
 
@@ -737,17 +737,17 @@ typedef struct {
 
 typedef struct jpc_msops_s {
 
-	/* Destroy the marker segment parameters. */
-	void (*destroyparms)(jpc_ms_t *ms);
+        /* Destroy the marker segment parameters. */
+        void (*destroyparms)(jpc_ms_t *ms);
 
-	/* Get the marker segment parameters from a stream. */
-	int (*getparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in);
+        /* Get the marker segment parameters from a stream. */
+        int (*getparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in);
 
-	/* Put the marker segment parameters to a stream. */
-	int (*putparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);
+        /* Put the marker segment parameters to a stream. */
+        int (*putparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);
 
-	/* Dump the marker segment parameters (for debugging). */
-	int (*dumpparms)(jpc_ms_t *ms, FILE *out);
+        /* Dump the marker segment parameters (for debugging). */
+        int (*dumpparms)(jpc_ms_t *ms, FILE *out);
 
 } jpc_msops_t;
 
@@ -768,13 +768,13 @@ jpc_ms_t *jpc_ms_create(int type);
 void jpc_ms_destroy(jpc_ms_t *ms);
 
 /* Does a marker segment have parameters? */
-#define	JPC_MS_HASPARMS(x) \
-	(!((x) == JPC_MS_SOC || (x) == JPC_MS_SOD || (x) == JPC_MS_EOC || \
-	  (x) == JPC_MS_EPH || ((x) >= 0xff30 && (x) <= 0xff3f)))
+#define JPC_MS_HASPARMS(x) \
+        (!((x) == JPC_MS_SOC || (x) == JPC_MS_SOD || (x) == JPC_MS_EOC || \
+          (x) == JPC_MS_EPH || ((x) >= 0xff30 && (x) <= 0xff3f)))
 
 /* Get the marker segment type. */
-#define	jpc_ms_gettype(ms) \
-	((ms)->id)
+#define jpc_ms_gettype(ms) \
+        ((ms)->id)
 
 /* Read a marker segment from a stream. */
 jpc_ms_t *jpc_getms(jas_stream_t *in, jpc_cstate_t *cstate);
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
index 140169ec..1cca46b7 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -793,7 +793,7 @@ rlvl->bands = 0;
                 rlvl->numhprcs = 0;
                 rlvl->numvprcs = 0;
                 continue;
-            }   
+            }  
             if (!rlvlno) {
                 tlcbgxstart = tlprcxstart;
                 tlcbgystart = tlprcystart;
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h
index fe0e9616..11fceb36 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -141,14 +141,14 @@
 
 typedef struct {
 
-	/* The index for this entry. */
-	uint_fast16_t ind;
+        /* The index for this entry. */
+        uint_fast16_t ind;
 
-	/* The data length. */
-	uint_fast32_t len;
+        /* The data length. */
+        uint_fast32_t len;
 
-	/* The data. */
-	unsigned char *data;
+        /* The data. */
+        unsigned char *data;
 
 } jpc_ppxstabent_t;
 
@@ -156,15 +156,15 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of entries. */
-	int numents;
+        /* The number of entries. */
+        int numents;
 
-	/* The maximum number of entries (i.e., the allocated size of the array
-	  below). */
-	int maxents;
+        /* The maximum number of entries (i.e., the allocated size of the array
+          below). */
+        int maxents;
 
-	/* The table entries. */
-	jpc_ppxstabent_t **ents;
+        /* The table entries. */
+        jpc_ppxstabent_t **ents;
 
 } jpc_ppxstab_t;
 
@@ -172,15 +172,15 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of streams in this list. */
-	int numstreams;
+        /* The number of streams in this list. */
+        int numstreams;
 
-	/* The maximum number of streams that can be accommodated without
-	  growing the streams array. */
-	int maxstreams;
+        /* The maximum number of streams that can be accommodated without
+          growing the streams array. */
+        int maxstreams;
 
-	/* The streams. */
-	jas_stream_t **streams;
+        /* The streams. */
+        jas_stream_t **streams;
 
 } jpc_streamlist_t;
 
@@ -192,47 +192,47 @@ typedef struct {
 
 typedef struct {
 
-	/* How were various coding parameters set? */
-	int flags;
+        /* How were various coding parameters set? */
+        int flags;
 
-	/* Per-component coding style parameters (e.g., explicit precinct sizes) */
-	uint_fast8_t csty;
+        /* Per-component coding style parameters (e.g., explicit precinct sizes) */
+        uint_fast8_t csty;
 
-	/* The number of resolution levels. */
-	uint_fast8_t numrlvls;
+        /* The number of resolution levels. */
+        uint_fast8_t numrlvls;
 
-	/* The code block width exponent. */
-	uint_fast8_t cblkwidthexpn;
+        /* The code block width exponent. */
+        uint_fast8_t cblkwidthexpn;
 
-	/* The code block height exponent. */
-	uint_fast8_t cblkheightexpn;
+        /* The code block height exponent. */
+        uint_fast8_t cblkheightexpn;
 
-	/* The QMFB ID. */
-	uint_fast8_t qmfbid;
+        /* The QMFB ID. */
+        uint_fast8_t qmfbid;
 
-	/* The quantization style. */
-	uint_fast8_t qsty;
+        /* The quantization style. */
+        uint_fast8_t qsty;
 
-	/* The number of quantizer step sizes. */
-	uint_fast16_t numstepsizes;
+        /* The number of quantizer step sizes. */
+        uint_fast16_t numstepsizes;
 
-	/* The step sizes. */
-	uint_fast16_t stepsizes[3 * JPC_MAXRLVLS + 1];
+        /* The step sizes. */
+        uint_fast16_t stepsizes[3 * JPC_MAXRLVLS + 1];
 
-	/* The number of guard bits. */
-	uint_fast8_t numguardbits;
+        /* The number of guard bits. */
+        uint_fast8_t numguardbits;
 
-	/* The ROI shift value. */
-	uint_fast8_t roishift;
+        /* The ROI shift value. */
+        uint_fast8_t roishift;
 
-	/* The code block parameters. */
-	uint_fast8_t cblkctx;
+        /* The code block parameters. */
+        uint_fast8_t cblkctx;
 
-	/* The precinct width exponents. */
-	uint_fast8_t prcwidthexpns[JPC_MAXRLVLS];
+        /* The precinct width exponents. */
+        uint_fast8_t prcwidthexpns[JPC_MAXRLVLS];
 
-	/* The precinct height exponents. */
-	uint_fast8_t prcheightexpns[JPC_MAXRLVLS];
+        /* The precinct height exponents. */
+        uint_fast8_t prcheightexpns[JPC_MAXRLVLS];
 
 } jpc_dec_ccp_t;
 
@@ -240,29 +240,29 @@ typedef struct {
 
 typedef struct {
 
-	/* How were these coding parameters set? */
-	int flags;
+        /* How were these coding parameters set? */
+        int flags;
 
-	/* Progression change list. */
-	jpc_pchglist_t *pchglist;
+        /* Progression change list. */
+        jpc_pchglist_t *pchglist;
 
-	/* Progression order. */
-	uint_fast8_t prgord;
+        /* Progression order. */
+        uint_fast8_t prgord;
 
-	/* The number of layers. */
-	uint_fast16_t numlyrs;
+        /* The number of layers. */
+        uint_fast16_t numlyrs;
 
-	/* The MCT ID. */
-	uint_fast8_t mctid;
+        /* The MCT ID. */
+        uint_fast8_t mctid;
 
-	/* The coding style parameters (e.g., SOP, EPH). */
-	uint_fast8_t csty;
+        /* The coding style parameters (e.g., SOP, EPH). */
+        uint_fast8_t csty;
 
-	/* The number of components. */
-	uint_fast16_t numcomps;
+        /* The number of components. */
+        uint_fast16_t numcomps;
 
-	/* The per-component coding parameters. */
-	jpc_dec_ccp_t *ccps;
+        /* The per-component coding parameters. */
+        jpc_dec_ccp_t *ccps;
 
 } jpc_dec_cp_t;
 
@@ -274,38 +274,38 @@ typedef struct {
 
 typedef struct jpc_dec_seg_s {
 
-	/* The next segment in the list. */
-	struct jpc_dec_seg_s *next;
+        /* The next segment in the list. */
+        struct jpc_dec_seg_s *next;
 
-	/* The previous segment in the list. */
-	struct jpc_dec_seg_s *prev;
+        /* The previous segment in the list. */
+        struct jpc_dec_seg_s *prev;
 
-	/* The starting pass number for this segment. */
-	int passno;
+        /* The starting pass number for this segment. */
+        int passno;
 
-	/* The number of passes in this segment. */
-	int numpasses;
+        /* The number of passes in this segment. */
+        int numpasses;
 
-	/* The maximum number of passes in this segment. */
-	int maxpasses;
+        /* The maximum number of passes in this segment. */
+        int maxpasses;
 
-	/* The type of data in this segment (i.e., MQ or raw). */
-	int type;
+        /* The type of data in this segment (i.e., MQ or raw). */
+        int type;
 
-	/* A stream containing the data for this segment. */
-	jas_stream_t *stream;
+        /* A stream containing the data for this segment. */
+        jas_stream_t *stream;
 
-	/* The number of bytes destined for this segment from the packet
-	  currently being decoded. */
-	int cnt;
+        /* The number of bytes destined for this segment from the packet
+          currently being decoded. */
+        int cnt;
 
-	/* A flag indicating if this segment has been terminated. */
-	int complete;
+        /* A flag indicating if this segment has been terminated. */
+        int complete;
 
-	/* The layer number to which this segment belongs. */
-	/* If the segment spans multiple layers, then the largest layer number
-	  spanned by the segment is used. */
-	int lyrno;
+        /* The layer number to which this segment belongs. */
+        /* If the segment spans multiple layers, then the largest layer number
+          spanned by the segment is used. */
+        int lyrno;
 
 } jpc_dec_seg_t;
 
@@ -313,11 +313,11 @@ typedef struct jpc_dec_seg_s {
 
 typedef struct {
 
-	/* The first entry in the list. */
-	jpc_dec_seg_t *head;
+        /* The first entry in the list. */
+        jpc_dec_seg_t *head;
 
-	/* The last entry in the list. */
-	jpc_dec_seg_t *tail;
+        /* The last entry in the list. */
+        jpc_dec_seg_t *tail;
 
 } jpc_dec_seglist_t;
 
@@ -325,35 +325,35 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of passes. */
-	int numpasses;
+        /* The number of passes. */
+        int numpasses;
 
-	/* A list of segments that still need to be decoded. */
-	jpc_dec_seglist_t segs;
+        /* A list of segments that still need to be decoded. */
+        jpc_dec_seglist_t segs;
 
-	/* The first incomplete/partial segment. */
-	jpc_dec_seg_t *curseg;
+        /* The first incomplete/partial segment. */
+        jpc_dec_seg_t *curseg;
 
-	/* The number of leading insignificant bit planes for this code block. */
-	int numimsbs;
+        /* The number of leading insignificant bit planes for this code block. */
+        int numimsbs;
 
-	/* The number of bits used to encode pass data lengths. */
-	int numlenbits;
+        /* The number of bits used to encode pass data lengths. */
+        int numlenbits;
 
-	/* The first pass number containing data for this code block. */
-	int firstpassno;
+        /* The first pass number containing data for this code block. */
+        int firstpassno;
 
-	/* The MQ decoder. */
-	jpc_mqdec_t *mqdec;
+        /* The MQ decoder. */
+        jpc_mqdec_t *mqdec;
 
-	/* The raw bit stream decoder. */
-	jpc_bitstream_t *nulldec;
+        /* The raw bit stream decoder. */
+        jpc_bitstream_t *nulldec;
 
-	/* The per-sample state information for this code block. */
-	jas_matrix_t *flags;
+        /* The per-sample state information for this code block. */
+        jas_matrix_t *flags;
 
-	/* The sample data associated with this code block. */
-	jas_matrix_t *data;
+        /* The sample data associated with this code block. */
+        jas_matrix_t *data;
 
 } jpc_dec_cblk_t;
 
@@ -361,39 +361,39 @@ typedef struct {
 
 typedef struct {
 
-	/* The x-coordinate of the top-left corner of the precinct. */
-	uint_fast32_t xstart;
+        /* The x-coordinate of the top-left corner of the precinct. */
+        uint_fast32_t xstart;
 
-	/* The y-coordinate of the top-left corner of the precinct. */
-	uint_fast32_t ystart;
+        /* The y-coordinate of the top-left corner of the precinct. */
+        uint_fast32_t ystart;
 
-	/* The x-coordinate of the bottom-right corner of the precinct
-	  (plus one). */
-	uint_fast32_t xend;
+        /* The x-coordinate of the bottom-right corner of the precinct
+          (plus one). */
+        uint_fast32_t xend;
 
-	/* The y-coordinate of the bottom-right corner of the precinct
-	  (plus one). */
-	uint_fast32_t yend;
+        /* The y-coordinate of the bottom-right corner of the precinct
+          (plus one). */
+        uint_fast32_t yend;
 
-	/* The number of code blocks spanning this precinct in the horizontal
-	  direction. */
-	int numhcblks;
+        /* The number of code blocks spanning this precinct in the horizontal
+          direction. */
+        int numhcblks;
 
-	/* The number of code blocks spanning this precinct in the vertical
-	  direction. */
-	int numvcblks;
+        /* The number of code blocks spanning this precinct in the vertical
+          direction. */
+        int numvcblks;
 
-	/* The total number of code blocks in this precinct. */
-	int numcblks;
+        /* The total number of code blocks in this precinct. */
+        int numcblks;
 
-	/* The per code block information. */
-	jpc_dec_cblk_t *cblks;
+        /* The per code block information. */
+        jpc_dec_cblk_t *cblks;
 
-	/* The inclusion tag tree. */
-	jpc_tagtree_t *incltagtree;
+        /* The inclusion tag tree. */
+        jpc_tagtree_t *incltagtree;
 
-	/* The insignificant MSBs tag tree. */
-	jpc_tagtree_t *numimsbstagtree;
+        /* The insignificant MSBs tag tree. */
+        jpc_tagtree_t *numimsbstagtree;
 
 } jpc_dec_prc_t;
 
@@ -401,29 +401,29 @@ typedef struct {
 
 typedef struct {
 
-	/* The per-code-block-group state information. */
-	jpc_dec_prc_t *prcs;
+        /* The per-code-block-group state information. */
+        jpc_dec_prc_t *prcs;
 
-	/* The sample data associated with this band. */
-	jas_matrix_t *data;
+        /* The sample data associated with this band. */
+        jas_matrix_t *data;
 
-	/* The orientation of this band (i.e., LL, LH, HL, or HH). */
-	int orient;
+        /* The orientation of this band (i.e., LL, LH, HL, or HH). */
+        int orient;
 
-	/* The encoded quantizer step size. */
-	int stepsize;
+        /* The encoded quantizer step size. */
+        int stepsize;
 
-	/* The absolute quantizer step size. */
-	jpc_fix_t absstepsize;
+        /* The absolute quantizer step size. */
+        jpc_fix_t absstepsize;
 
-	/* The number of bit planes for this band. */
-	int numbps;
+        /* The number of bit planes for this band. */
+        int numbps;
 
-	/* The analysis gain associated with this band. */
-	int analgain;
+        /* The analysis gain associated with this band. */
+        int analgain;
 
-	/* The ROI shift value for this band. */
-	int roishift;
+        /* The ROI shift value for this band. */
+        int roishift;
 
 } jpc_dec_band_t;
 
@@ -431,60 +431,60 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of bands associated with this resolution level. */
-	int numbands;
+        /* The number of bands associated with this resolution level. */
+        int numbands;
 
-	/* The per-band information. */
-	jpc_dec_band_t *bands;
+        /* The per-band information. */
+        jpc_dec_band_t *bands;
 
-	/* The x-coordinate of the top-left corner of the tile-component
-	  at this resolution. */
-	uint_fast32_t xstart;
+        /* The x-coordinate of the top-left corner of the tile-component
+          at this resolution. */
+        uint_fast32_t xstart;
 
-	/* The y-coordinate of the top-left corner of the tile-component
-	  at this resolution. */
-	uint_fast32_t ystart;
+        /* The y-coordinate of the top-left corner of the tile-component
+          at this resolution. */
+        uint_fast32_t ystart;
 
-	/* The x-coordinate of the bottom-right corner of the tile-component
-	  at this resolution (plus one). */
-	uint_fast32_t xend;
+        /* The x-coordinate of the bottom-right corner of the tile-component
+          at this resolution (plus one). */
+        uint_fast32_t xend;
 
-	/* The y-coordinate of the bottom-right corner of the tile-component
-	  at this resolution (plus one). */
-	uint_fast32_t yend;
+        /* The y-coordinate of the bottom-right corner of the tile-component
+          at this resolution (plus one). */
+        uint_fast32_t yend;
 
-	/* The exponent value for the nominal precinct width measured
-	  relative to the associated LL band. */
-	int prcwidthexpn;
+        /* The exponent value for the nominal precinct width measured
+          relative to the associated LL band. */
+        int prcwidthexpn;
 
-	/* The exponent value for the nominal precinct height measured
-	  relative to the associated LL band. */
-	int prcheightexpn;
+        /* The exponent value for the nominal precinct height measured
+          relative to the associated LL band. */
+        int prcheightexpn;
 
-	/* The number of precincts in the horizontal direction. */
-	int numhprcs;
+        /* The number of precincts in the horizontal direction. */
+        int numhprcs;
 
-	/* The number of precincts in the vertical direction. */
-	int numvprcs;
+        /* The number of precincts in the vertical direction. */
+        int numvprcs;
 
-	/* The total number of precincts. */
-	int numprcs;
+        /* The total number of precincts. */
+        int numprcs;
 
-	/* The exponent value for the nominal code block group width.
-	  This quantity is associated with the next lower resolution level
-	  (assuming that there is one). */
-	int cbgwidthexpn;
+        /* The exponent value for the nominal code block group width.
+          This quantity is associated with the next lower resolution level
+          (assuming that there is one). */
+        int cbgwidthexpn;
 
-	/* The exponent value for the nominal code block group height
-	  This quantity is associated with the next lower resolution level
-	  (assuming that there is one). */
-	int cbgheightexpn;
+        /* The exponent value for the nominal code block group height
+          This quantity is associated with the next lower resolution level
+          (assuming that there is one). */
+        int cbgheightexpn;
 
-	/* The exponent value for the code block width. */
-	uint_fast16_t cblkwidthexpn;
+        /* The exponent value for the code block width. */
+        uint_fast16_t cblkwidthexpn;
 
-	/* The exponent value for the code block height. */
-	uint_fast16_t cblkheightexpn;
+        /* The exponent value for the code block height. */
+        uint_fast16_t cblkheightexpn;
 
 } jpc_dec_rlvl_t;
 
@@ -492,33 +492,33 @@ typedef struct {
 
 typedef struct {
 
-	/* The x-coordinate of the top-left corner of the tile-component
-	  in the coordinate system of the tile-component. */
-	uint_fast32_t xstart;
+        /* The x-coordinate of the top-left corner of the tile-component
+          in the coordinate system of the tile-component. */
+        uint_fast32_t xstart;
 
-	/* The y-coordinate of the top-left corner of the tile-component
-	  in the coordinate system of the tile-component. */
-	uint_fast32_t ystart;
+        /* The y-coordinate of the top-left corner of the tile-component
+          in the coordinate system of the tile-component. */
+        uint_fast32_t ystart;
 
-	/* The x-coordinate of the bottom-right corner of the tile-component
-	  in the coordinate system of the tile-component (plus one). */
-	uint_fast32_t xend;
+        /* The x-coordinate of the bottom-right corner of the tile-component
+          in the coordinate system of the tile-component (plus one). */
+        uint_fast32_t xend;
 
-	/* The y-coordinate of the bottom-right corner of the tile-component
-	  in the coordinate system of the tile-component (plus one). */
-	uint_fast32_t yend;
+        /* The y-coordinate of the bottom-right corner of the tile-component
+          in the coordinate system of the tile-component (plus one). */
+        uint_fast32_t yend;
 
-	/* The component data for the current tile. */
-	jas_matrix_t *data;
+        /* The component data for the current tile. */
+        jas_matrix_t *data;
 
-	/* The number of resolution levels. */
-	uint_fast16_t numrlvls;
+        /* The number of resolution levels. */
+        uint_fast16_t numrlvls;
 
-	/* The per resolution level information. */
-	jpc_dec_rlvl_t *rlvls;
+        /* The per resolution level information. */
+        jpc_dec_rlvl_t *rlvls;
 
-	/* The TSFB. */
-	jpc_tsfb_t *tsfb;
+        /* The TSFB. */
+        jpc_tsfb_t *tsfb;
 
 } jpc_dec_tcomp_t;
 
@@ -526,60 +526,60 @@ typedef struct {
  * Tile states.
  */
 
-#define	JPC_TILE_INIT	0
-#define	JPC_TILE_ACTIVE	1
-#define	JPC_TILE_ACTIVELAST	2
-#define	JPC_TILE_DONE	3
+#define JPC_TILE_INIT   0
+#define JPC_TILE_ACTIVE 1
+#define JPC_TILE_ACTIVELAST     2
+#define JPC_TILE_DONE   3
 
 /* Decoder per-tile state information. */
 
 typedef struct {
 
-	/* The processing state for this tile. */
-	int state;
+        /* The processing state for this tile. */
+        int state;
 
-	/* The x-coordinate of the top-left corner of the tile on the reference
-	  grid. */
-	uint_fast32_t xstart;
+        /* The x-coordinate of the top-left corner of the tile on the reference
+          grid. */
+        uint_fast32_t xstart;
 
-	/* The y-coordinate of the top-left corner of the tile on the reference
-	  grid. */
-	uint_fast32_t ystart;
+        /* The y-coordinate of the top-left corner of the tile on the reference
+          grid. */
+        uint_fast32_t ystart;
 
-	/* The x-coordinate of the bottom-right corner of the tile on the
-	  reference grid (plus one). */
-	uint_fast32_t xend;
+        /* The x-coordinate of the bottom-right corner of the tile on the
+          reference grid (plus one). */
+        uint_fast32_t xend;
 
-	/* The y-coordinate of the bottom-right corner of the tile on the
-	  reference grid (plus one). */
-	uint_fast32_t yend;
+        /* The y-coordinate of the bottom-right corner of the tile on the
+          reference grid (plus one). */
+        uint_fast32_t yend;
 
-	/* The packed packet header data for this tile. */
-	jpc_ppxstab_t *pptstab;
+        /* The packed packet header data for this tile. */
+        jpc_ppxstab_t *pptstab;
 
-	/* A stream containing the packed packet header data for this tile. */
-	jas_stream_t *pkthdrstream;
+        /* A stream containing the packed packet header data for this tile. */
+        jas_stream_t *pkthdrstream;
 
-	/* The current position within the packed packet header stream. */
-	long pkthdrstreampos;
+        /* The current position within the packed packet header stream. */
+        long pkthdrstreampos;
 
-	/* The coding parameters for this tile. */
-	jpc_dec_cp_t *cp;
+        /* The coding parameters for this tile. */
+        jpc_dec_cp_t *cp;
 
-	/* The per tile-component information. */
-	jpc_dec_tcomp_t *tcomps;
+        /* The per tile-component information. */
+        jpc_dec_tcomp_t *tcomps;
 
-	/* The next expected tile-part number. */
-	int partno;
+        /* The next expected tile-part number. */
+        int partno;
 
-	/* The number of tile-parts. */
-	int numparts;
+        /* The number of tile-parts. */
+        int numparts;
 
-	/* The coding mode. */
-	int realmode;
+        /* The coding mode. */
+        int realmode;
 
-	/* The packet iterator for this tile. */
-	jpc_pi_t *pi;
+        /* The packet iterator for this tile. */
+        jpc_pi_t *pi;
 
 } jpc_dec_tile_t;
 
@@ -587,29 +587,29 @@ typedef struct {
 
 typedef struct {
 
-	/* The horizontal sampling period. */
-	uint_fast32_t hstep;
+        /* The horizontal sampling period. */
+        uint_fast32_t hstep;
 
-	/* The vertical sampling period. */
-	uint_fast32_t vstep;
+        /* The vertical sampling period. */
+        uint_fast32_t vstep;
 
-	/* The number of samples in the horizontal direction. */
-	uint_fast32_t width;
+        /* The number of samples in the horizontal direction. */
+        uint_fast32_t width;
 
-	/* The number of samples in the vertical direction. */
-	uint_fast32_t height;
+        /* The number of samples in the vertical direction. */
+        uint_fast32_t height;
 
-	/* The precision of the sample data. */
-	uint_fast16_t prec;
+        /* The precision of the sample data. */
+        uint_fast16_t prec;
 
-	/* The signedness of the sample data. */
-	bool sgnd;
+        /* The signedness of the sample data. */
+        bool sgnd;
 
-	/* The sample alignment horizontal offset. */
-	uint_fast32_t hsubstep;
-	
-	/* The sample alignment vertical offset. */
-	uint_fast32_t vsubstep;
+        /* The sample alignment horizontal offset. */
+        uint_fast32_t hsubstep;
+       
+        /* The sample alignment vertical offset. */
+        uint_fast32_t vsubstep;
 
 } jpc_dec_cmpt_t;
 
@@ -617,96 +617,96 @@ typedef struct {
 
 typedef struct {
 
-	/* The decoded image. */
-	jas_image_t *image;
+        /* The decoded image. */
+        jas_image_t *image;
 
-	/* The x-coordinate of the top-left corner of the image area on
-	  the reference grid. */
-	uint_fast32_t xstart;
+        /* The x-coordinate of the top-left corner of the image area on
+          the reference grid. */
+        uint_fast32_t xstart;
 
-	/* The y-coordinate of the top-left corner of the image area on
-	  the reference grid. */
-	uint_fast32_t ystart;
+        /* The y-coordinate of the top-left corner of the image area on
+          the reference grid. */
+        uint_fast32_t ystart;
 
-	/* The x-coordinate of the bottom-right corner of the image area on
-	  the reference grid (plus one). */
-	uint_fast32_t xend;
+        /* The x-coordinate of the bottom-right corner of the image area on
+          the reference grid (plus one). */
+        uint_fast32_t xend;
 
-	/* The y-coordinate of the bottom-right corner of the image area on
-	  the reference grid (plus one). */
-	uint_fast32_t yend;
+        /* The y-coordinate of the bottom-right corner of the image area on
+          the reference grid (plus one). */
+        uint_fast32_t yend;
 
-	/* The nominal tile width in units of the image reference grid. */
-	uint_fast32_t tilewidth;
+        /* The nominal tile width in units of the image reference grid. */
+        uint_fast32_t tilewidth;
 
-	/* The nominal tile height in units of the image reference grid. */
-	uint_fast32_t tileheight;
+        /* The nominal tile height in units of the image reference grid. */
+        uint_fast32_t tileheight;
 
-	/* The horizontal offset from the origin of the reference grid to the
-	  left side of the first tile. */
-	uint_fast32_t tilexoff;
+        /* The horizontal offset from the origin of the reference grid to the
+          left side of the first tile. */
+        uint_fast32_t tilexoff;
 
-	/* The vertical offset from the origin of the reference grid to the
-	  top side of the first tile. */
-	uint_fast32_t tileyoff;
+        /* The vertical offset from the origin of the reference grid to the
+          top side of the first tile. */
+        uint_fast32_t tileyoff;
 
-	/* The number of tiles spanning the image area in the vertical
-	  direction. */
-	int numhtiles;
+        /* The number of tiles spanning the image area in the vertical
+          direction. */
+        int numhtiles;
 
-	/* The number of tiles spanning the image area in the horizontal
-	  direction. */
-	int numvtiles;
+        /* The number of tiles spanning the image area in the horizontal
+          direction. */
+        int numvtiles;
 
-	/* The total number of tiles. */
-	int numtiles;
+        /* The total number of tiles. */
+        int numtiles;
 
-	/* The per-tile information. */
-	jpc_dec_tile_t *tiles;
+        /* The per-tile information. */
+        jpc_dec_tile_t *tiles;
 
-	/* The tile currently being processed. */
-	jpc_dec_tile_t *curtile;
+        /* The tile currently being processed. */
+        jpc_dec_tile_t *curtile;
 
-	/* The number of components. */
-	int numcomps;
+        /* The number of components. */
+        int numcomps;
 
-	/* The stream containing the input JPEG-2000 code stream data. */
-	jas_stream_t *in;
+        /* The stream containing the input JPEG-2000 code stream data. */
+        jas_stream_t *in;
 
-	/* The default coding parameters for all tiles. */
-	jpc_dec_cp_t *cp;
+        /* The default coding parameters for all tiles. */
+        jpc_dec_cp_t *cp;
 
-	/* The maximum number of layers that may be decoded. */
-	int maxlyrs;
+        /* The maximum number of layers that may be decoded. */
+        int maxlyrs;
 
-	/* The maximum number of packets that may be decoded. */
-	int maxpkts;
+        /* The maximum number of packets that may be decoded. */
+        int maxpkts;
 
-	/* The number of packets decoded so far in the processing of the entire
-	  code stream. */
-	int numpkts;
+        /* The number of packets decoded so far in the processing of the entire
+          code stream. */
+        int numpkts;
 
-	/* The next expected PPM marker segment sequence number. */
-	int ppmseqno;
+        /* The next expected PPM marker segment sequence number. */
+        int ppmseqno;
 
-	/* The current state for code stream processing. */
-	int state;
+        /* The current state for code stream processing. */
+        int state;
 
-	/* The per-component information. */
-	jpc_dec_cmpt_t *cmpts;
+        /* The per-component information. */
+        jpc_dec_cmpt_t *cmpts;
 
-	/* The information from PPM marker segments. */
-	jpc_ppxstab_t *ppmstab;
+        /* The information from PPM marker segments. */
+        jpc_ppxstab_t *ppmstab;
 
-	/* A list of streams containing packet header data from PPM marker
-	  segments. */
-	jpc_streamlist_t *pkthdrstreams;
+        /* A list of streams containing packet header data from PPM marker
+          segments. */
+        jpc_streamlist_t *pkthdrstreams;
 
-	/* The expected ending offset for a tile-part. */
-	long curtileendoff;
+        /* The expected ending offset for a tile-part. */
+        long curtileendoff;
 
-	/* This is required by the tier-2 decoder. */
-	jpc_cstate_t *cstate;
+        /* This is required by the tier-2 decoder. */
+        jpc_cstate_t *cstate;
 
 } jpc_dec_t;
 
@@ -714,14 +714,14 @@ typedef struct {
 
 typedef struct {
 
-	/* The debug level for the decoder. */
-	int debug;
+        /* The debug level for the decoder. */
+        int debug;
 
-	/* The maximum number of layers to decode. */
-	int maxlyrs;
+        /* The maximum number of layers to decode. */
+        int maxlyrs;
 
-	/* The maximum number of packets to decode. */
-	int maxpkts;
+        /* The maximum number of packets to decode. */
+        int maxpkts;
 
 } jpc_dec_importopts_t;
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
index 0c77a94e..c964eeff 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
@@ -2835,14 +2835,14 @@ jpc_enc_dump(jpc_enc_t *enc) {
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -2850,22 +2850,22 @@ jpc_enc_dump(jpc_enc_t *enc) {
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -2885,17 +2885,17 @@ jpc_enc_dump(jpc_enc_t *enc) {
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -2935,7 +2935,7 @@ jpc_enc_dump(jpc_enc_t *enc) {
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h
index 86a8e59c..1e3887aa 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -136,10 +136,10 @@
 \******************************************************************************/
 
 /* The number of bits used in various lookup tables. */
-#define	JPC_NUMEXTRABITS	JPC_NMSEDEC_FRACBITS
+#define JPC_NUMEXTRABITS        JPC_NMSEDEC_FRACBITS
 
 /* An invalid R-D slope value. */
-#define	JPC_BADRDSLOPE	(-1)
+#define JPC_BADRDSLOPE  (-1)
 
 /******************************************************************************\
 * Coding parameters types.
@@ -149,29 +149,29 @@
 
 typedef struct {
 
-	/* The horizontal sampling period. */
-	uint_fast8_t sampgrdstepx;
+        /* The horizontal sampling period. */
+        uint_fast8_t sampgrdstepx;
 
-	/* The vertical sampling period. */
-	uint_fast8_t sampgrdstepy;
+        /* The vertical sampling period. */
+        uint_fast8_t sampgrdstepy;
 
-	/* The sample alignment horizontal offset. */
-	uint_fast8_t sampgrdsubstepx;
+        /* The sample alignment horizontal offset. */
+        uint_fast8_t sampgrdsubstepx;
 
-	/* The sample alignment vertical offset. */
-	uint_fast8_t sampgrdsubstepy;
+        /* The sample alignment vertical offset. */
+        uint_fast8_t sampgrdsubstepy;
 
-	/* The precision of the samples. */
-	uint_fast8_t prec;
+        /* The precision of the samples. */
+        uint_fast8_t prec;
 
-	/* The signedness of the samples. */
-	bool sgnd;
+        /* The signedness of the samples. */
+        bool sgnd;
 
-	/* The number of step sizes. */
-	uint_fast16_t numstepsizes;
+        /* The number of step sizes. */
+        uint_fast16_t numstepsizes;
 
-	/* The quantizer step sizes. */
-	uint_fast16_t stepsizes[JPC_MAXBANDS];
+        /* The quantizer step sizes. */
+        uint_fast16_t stepsizes[JPC_MAXBANDS];
 
 } jpc_enc_ccp_t;
 
@@ -179,24 +179,24 @@ typedef struct {
 
 typedef struct {
 
-	/* The coding mode. */
-	bool intmode;
+        /* The coding mode. */
+        bool intmode;
 
-	/* The coding style (i.e., SOP, EPH). */
-	uint_fast8_t csty;
+        /* The coding style (i.e., SOP, EPH). */
+        uint_fast8_t csty;
 
-	/* The progression order. */
-	uint_fast8_t prg;
+        /* The progression order. */
+        uint_fast8_t prg;
 
-	/* The multicomponent transform. */
-	uint_fast8_t mctid;
+        /* The multicomponent transform. */
+        uint_fast8_t mctid;
 
-	/* The number of layers. */
-	uint_fast16_t numlyrs;
+        /* The number of layers. */
+        uint_fast16_t numlyrs;
 
-	/* The normalized bit rates associated with the various
-	  intermediate layers. */
-	jpc_fix_t *ilyrrates;
+        /* The normalized bit rates associated with the various
+          intermediate layers. */
+        jpc_fix_t *ilyrrates;
 
 } jpc_enc_tcp_t;
 
@@ -204,33 +204,33 @@ typedef struct {
 
 typedef struct {
 
-	/* The coding style (i.e., explicit precinct sizes). */
-	uint_fast8_t csty;
+        /* The coding style (i.e., explicit precinct sizes). */
+        uint_fast8_t csty;
 
-	/* The maximum number of resolution levels allowed. */
-	uint_fast8_t maxrlvls;
+        /* The maximum number of resolution levels allowed. */
+        uint_fast8_t maxrlvls;
 
-	/* The exponent for the nominal code block width. */
-	uint_fast16_t cblkwidthexpn;
+        /* The exponent for the nominal code block width. */
+        uint_fast16_t cblkwidthexpn;
 
-	/* The exponent for the nominal code block height. */
-	uint_fast16_t cblkheightexpn;
+        /* The exponent for the nominal code block height. */
+        uint_fast16_t cblkheightexpn;
 
-	/* The code block style parameters (e.g., lazy, terminate all,
-	  segmentation symbols, causal, reset probability models). */
-	uint_fast8_t cblksty;
+        /* The code block style parameters (e.g., lazy, terminate all,
+          segmentation symbols, causal, reset probability models). */
+        uint_fast8_t cblksty;
 
-	/* The QMFB. */
-	uint_fast8_t qmfbid;
+        /* The QMFB. */
+        uint_fast8_t qmfbid;
 
-	/* The precinct width values. */
-	uint_fast16_t prcwidthexpns[JPC_MAXRLVLS];
+        /* The precinct width values. */
+        uint_fast16_t prcwidthexpns[JPC_MAXRLVLS];
 
-	/* The precinct height values. */
-	uint_fast16_t prcheightexpns[JPC_MAXRLVLS];
+        /* The precinct height values. */
+        uint_fast16_t prcheightexpns[JPC_MAXRLVLS];
 
-	/* The number of guard bits. */
-	uint_fast8_t numgbits;
+        /* The number of guard bits. */
+        uint_fast8_t numgbits;
 
 } jpc_enc_tccp_t;
 
@@ -238,67 +238,67 @@ typedef struct {
 
 typedef struct {
 
-	/* The debug level. */
-	int debug;
+        /* The debug level. */
+        int debug;
 
-	/* The horizontal offset from the origin of the reference grid to the
-	  left edge of the image area. */
-	uint_fast32_t imgareatlx;
+        /* The horizontal offset from the origin of the reference grid to the
+          left edge of the image area. */
+        uint_fast32_t imgareatlx;
 
-	/* The vertical offset from the origin of the reference grid to the
-	  top edge of the image area. */
-	uint_fast32_t imgareatly;
+        /* The vertical offset from the origin of the reference grid to the
+          top edge of the image area. */
+        uint_fast32_t imgareatly;
 
-	/* The horizontal offset from the origin of the reference grid to the
-	  right edge of the image area (plus one). */
-	uint_fast32_t refgrdwidth;
+        /* The horizontal offset from the origin of the reference grid to the
+          right edge of the image area (plus one). */
+        uint_fast32_t refgrdwidth;
 
-	/* The vertical offset from the origin of the reference grid to the
-	  bottom edge of the image area (plus one). */
-	uint_fast32_t refgrdheight;
+        /* The vertical offset from the origin of the reference grid to the
+          bottom edge of the image area (plus one). */
+        uint_fast32_t refgrdheight;
 
-	/* The horizontal offset from the origin of the tile grid to the
-	  origin of the reference grid. */
-	uint_fast32_t tilegrdoffx;
+        /* The horizontal offset from the origin of the tile grid to the
+          origin of the reference grid. */
+        uint_fast32_t tilegrdoffx;
 
-	/* The vertical offset from the origin of the tile grid to the
-	  origin of the reference grid. */
-	uint_fast32_t tilegrdoffy;
+        /* The vertical offset from the origin of the tile grid to the
+          origin of the reference grid. */
+        uint_fast32_t tilegrdoffy;
 
-	/* The nominal tile width in units of the image reference grid. */
-	uint_fast32_t tilewidth;
+        /* The nominal tile width in units of the image reference grid. */
+        uint_fast32_t tilewidth;
 
-	/* The nominal tile height in units of the image reference grid. */
-	uint_fast32_t tileheight;
+        /* The nominal tile height in units of the image reference grid. */
+        uint_fast32_t tileheight;
 
-	/* The number of tiles spanning the image area in the horizontal
-	  direction. */
-	uint_fast32_t numhtiles;
+        /* The number of tiles spanning the image area in the horizontal
+          direction. */
+        uint_fast32_t numhtiles;
 
-	/* The number of tiles spanning the image area in the vertical
-	  direction. */
-	uint_fast32_t numvtiles;
+        /* The number of tiles spanning the image area in the vertical
+          direction. */
+        uint_fast32_t numvtiles;
 
-	/* The number of tiles. */
-	uint_fast32_t numtiles;
+        /* The number of tiles. */
+        uint_fast32_t numtiles;
 
-	/* The number of components. */
-	uint_fast16_t numcmpts;
+        /* The number of components. */
+        uint_fast16_t numcmpts;
 
-	/* The per-component coding parameters. */
-	jpc_enc_ccp_t *ccps;
+        /* The per-component coding parameters. */
+        jpc_enc_ccp_t *ccps;
 
-	/* The per-tile coding parameters. */
-	jpc_enc_tcp_t tcp;
+        /* The per-tile coding parameters. */
+        jpc_enc_tcp_t tcp;
 
-	/* The per-tile-component coding parameters. */
-	jpc_enc_tccp_t tccp;
+        /* The per-tile-component coding parameters. */
+        jpc_enc_tccp_t tccp;
 
-	/* The target code stream length in bytes. */
-	uint_fast32_t totalsize;
+        /* The target code stream length in bytes. */
+        uint_fast32_t totalsize;
 
-	/* The raw (i.e., uncompressed) size of the image in bytes. */
-	uint_fast32_t rawsize;
+        /* The raw (i.e., uncompressed) size of the image in bytes. */
+        uint_fast32_t rawsize;
 
 } jpc_enc_cp_t;
 
@@ -310,35 +310,35 @@ typedef struct {
 
 typedef struct {
 
-	/* The starting offset for this pass. */
-	int start;
+        /* The starting offset for this pass. */
+        int start;
 
-	/* The ending offset for this pass. */
-	int end;
+        /* The ending offset for this pass. */
+        int end;
 
-	/* The type of data in this pass (i.e., MQ or raw). */
-	int type;
+        /* The type of data in this pass (i.e., MQ or raw). */
+        int type;
 
-	/* Flag indicating that this pass is terminated. */
-	int term;
+        /* Flag indicating that this pass is terminated. */
+        int term;
 
-	/* The entropy coder state after coding this pass. */
-	jpc_mqencstate_t mqencstate;
+        /* The entropy coder state after coding this pass. */
+        jpc_mqencstate_t mqencstate;
 
-	/* The layer to which this pass has been assigned. */
-	int lyrno;
+        /* The layer to which this pass has been assigned. */
+        int lyrno;
 
-	/* The R-D slope for this pass. */
-	jpc_flt_t rdslope;
+        /* The R-D slope for this pass. */
+        jpc_flt_t rdslope;
 
-	/* The weighted MSE reduction associated with this pass. */
-	jpc_flt_t wmsedec;
+        /* The weighted MSE reduction associated with this pass. */
+        jpc_flt_t wmsedec;
 
-	/* The cumulative weighted MSE reduction. */
-	jpc_flt_t cumwmsedec;
+        /* The cumulative weighted MSE reduction. */
+        jpc_flt_t cumwmsedec;
 
-	/* The normalized MSE reduction. */
-	long nmsedec;
+        /* The normalized MSE reduction. */
+        long nmsedec;
 
 } jpc_enc_pass_t;
 
@@ -346,53 +346,53 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of passes. */
-	int numpasses;
+        /* The number of passes. */
+        int numpasses;
 
-	/* The per-pass information. */
-	jpc_enc_pass_t *passes;
+        /* The per-pass information. */
+        jpc_enc_pass_t *passes;
 
-	/* The number of passes encoded so far. */
-	int numencpasses;
+        /* The number of passes encoded so far. */
+        int numencpasses;
 
-	/* The number of insignificant MSBs. */
-	int numimsbs;
+        /* The number of insignificant MSBs. */
+        int numimsbs;
 
-	/* The number of bits used to encode pass data lengths. */
-	int numlenbits;
+        /* The number of bits used to encode pass data lengths. */
+        int numlenbits;
 
-	/* The byte stream for this code block. */
-	jas_stream_t *stream;
+        /* The byte stream for this code block. */
+        jas_stream_t *stream;
 
-	/* The entropy encoder. */
-	jpc_mqenc_t *mqenc;
+        /* The entropy encoder. */
+        jpc_mqenc_t *mqenc;
 
-	/* The data for this code block. */
-	jas_matrix_t *data;
+        /* The data for this code block. */
+        jas_matrix_t *data;
 
-	/* The state for this code block. */
-	jas_matrix_t *flags;
+        /* The state for this code block. */
+        jas_matrix_t *flags;
 
-	/* The number of bit planes required for this code block. */
-	int numbps;
+        /* The number of bit planes required for this code block. */
+        int numbps;
 
-	/* The next pass to be encoded. */
-	jpc_enc_pass_t *curpass;
+        /* The next pass to be encoded. */
+        jpc_enc_pass_t *curpass;
 
-	/* The per-code-block-group state information. */
-	struct jpc_enc_prc_s *prc;
+        /* The per-code-block-group state information. */
+        struct jpc_enc_prc_s *prc;
 
-	/* The saved current pass. */
-	/* This is used by the rate control code. */
-	jpc_enc_pass_t *savedcurpass;
+        /* The saved current pass. */
+        /* This is used by the rate control code. */
+        jpc_enc_pass_t *savedcurpass;
 
-	/* The saved length indicator size. */
-	/* This is used by the rate control code. */
-	int savednumlenbits;
+        /* The saved length indicator size. */
+        /* This is used by the rate control code. */
+        int savednumlenbits;
 
-	/* The saved number of encoded passes. */
-	/* This is used by the rate control code. */
-	int savednumencpasses;
+        /* The saved number of encoded passes. */
+        /* This is used by the rate control code. */
+        int savednumencpasses;
 
 } jpc_enc_cblk_t;
 
@@ -400,50 +400,50 @@ typedef struct {
 
 typedef struct jpc_enc_prc_s {
 
-	/* The x-coordinate of the top-left corner of the precinct. */
-	uint_fast32_t tlx;
+        /* The x-coordinate of the top-left corner of the precinct. */
+        uint_fast32_t tlx;
 
-	/* The y-coordinate of the top-left corner of the precinct. */
-	uint_fast32_t tly;
+        /* The y-coordinate of the top-left corner of the precinct. */
+        uint_fast32_t tly;
 
-	/* The x-coordinate of the bottom-right corner of the precinct
-	  (plus one). */
-	uint_fast32_t brx;
+        /* The x-coordinate of the bottom-right corner of the precinct
+          (plus one). */
+        uint_fast32_t brx;
 
-	/* The y-coordinate of the bottom-right corner of the precinct
-	  (plus one). */
-	uint_fast32_t bry;
+        /* The y-coordinate of the bottom-right corner of the precinct
+          (plus one). */
+        uint_fast32_t bry;
 
-	/* The number of code blocks spanning the precinct in the horizontal
-	direction. */
-	int numhcblks;
+        /* The number of code blocks spanning the precinct in the horizontal
+        direction. */
+        int numhcblks;
 
-	/* The number of code blocks spanning the precinct in the vertical
-	direction. */
-	int numvcblks;
+        /* The number of code blocks spanning the precinct in the vertical
+        direction. */
+        int numvcblks;
 
-	/* The total number of code blocks. */
-	int numcblks;
+        /* The total number of code blocks. */
+        int numcblks;
 
-	/* The per-code-block information. */
-	jpc_enc_cblk_t *cblks;
+        /* The per-code-block information. */
+        jpc_enc_cblk_t *cblks;
 
-	/* The inclusion tag tree. */
-	jpc_tagtree_t *incltree;
+        /* The inclusion tag tree. */
+        jpc_tagtree_t *incltree;
 
-	/* The insignifcant MSBs tag tree. */
-	jpc_tagtree_t *nlibtree;
+        /* The insignifcant MSBs tag tree. */
+        jpc_tagtree_t *nlibtree;
 
-	/* The per-band information. */
-	struct jpc_enc_band_s *band;
+        /* The per-band information. */
+        struct jpc_enc_band_s *band;
 
-	/* The saved inclusion tag tree. */
-	/* This is used by rate control. */
-	jpc_tagtree_t *savincltree;
+        /* The saved inclusion tag tree. */
+        /* This is used by rate control. */
+        jpc_tagtree_t *savincltree;
 
-	/* The saved leading-insignificant-bit-planes tag tree. */
-	/* This is used by rate control. */
-	jpc_tagtree_t *savnlibtree;
+        /* The saved leading-insignificant-bit-planes tag tree. */
+        /* This is used by rate control. */
+        jpc_tagtree_t *savnlibtree;
 
 } jpc_enc_prc_t;
 
@@ -451,33 +451,33 @@ typedef struct jpc_enc_prc_s {
 
 typedef struct jpc_enc_band_s {
 
-	/* The per precinct information. */
-	jpc_enc_prc_t *prcs;
+        /* The per precinct information. */
+        jpc_enc_prc_t *prcs;
 
-	/* The coefficient data for this band. */
-	jas_matrix_t *data;
+        /* The coefficient data for this band. */
+        jas_matrix_t *data;
 
-	/* The orientation of this band (i.e., LL, LH, HL, or HH). */
-	int orient;
+        /* The orientation of this band (i.e., LL, LH, HL, or HH). */
+        int orient;
 
-	/* The number of bit planes associated with this band. */
-	int numbps;
+        /* The number of bit planes associated with this band. */
+        int numbps;
 
-	/* The quantizer step size. */
-	jpc_fix_t absstepsize;
+        /* The quantizer step size. */
+        jpc_fix_t absstepsize;
 
-	/* The encoded quantizer step size. */
-	int stepsize;
+        /* The encoded quantizer step size. */
+        int stepsize;
 
-	/* The L2 norm of the synthesis basis functions associated with
-	  this band.  (The MCT is not considered in this value.) */
-	jpc_fix_t synweight;
+        /* The L2 norm of the synthesis basis functions associated with
+          this band.  (The MCT is not considered in this value.) */
+        jpc_fix_t synweight;
 
-	/* The analysis gain for this band. */
-	int analgain;
+        /* The analysis gain for this band. */
+        int analgain;
 
-	/* The per-resolution-level information. */
-	struct jpc_enc_rlvl_s *rlvl;
+        /* The per-resolution-level information. */
+        struct jpc_enc_rlvl_s *rlvl;
 
 } jpc_enc_band_t;
 
@@ -485,65 +485,65 @@ typedef struct jpc_enc_band_s {
 
 typedef struct jpc_enc_rlvl_s {
 
-	/* The x-coordinate of the top-left corner of the tile-component
-	  at this resolution. */
-	uint_fast32_t tlx;
+        /* The x-coordinate of the top-left corner of the tile-component
+          at this resolution. */
+        uint_fast32_t tlx;
 
-	/* The y-coordinate of the top-left corner of the tile-component
-	  at this resolution. */
-	uint_fast32_t tly;
+        /* The y-coordinate of the top-left corner of the tile-component
+          at this resolution. */
+        uint_fast32_t tly;
 
-	/* The x-coordinate of the bottom-right corner of the tile-component
-	  at this resolution (plus one). */
-	uint_fast32_t brx;
+        /* The x-coordinate of the bottom-right corner of the tile-component
+          at this resolution (plus one). */
+        uint_fast32_t brx;
 
-	/* The y-coordinate of the bottom-right corner of the tile-component
-	  at this resolution (plus one). */
-	uint_fast32_t bry;
+        /* The y-coordinate of the bottom-right corner of the tile-component
+          at this resolution (plus one). */
+        uint_fast32_t bry;
 
-	/* The exponent value for the nominal precinct width measured
-	  relative to the associated LL band. */
-	int prcwidthexpn;
+        /* The exponent value for the nominal precinct width measured
+          relative to the associated LL band. */
+        int prcwidthexpn;
 
-	/* The exponent value for the nominal precinct height measured
-	  relative to the associated LL band. */
-	int prcheightexpn;
+        /* The exponent value for the nominal precinct height measured
+          relative to the associated LL band. */
+        int prcheightexpn;
 
-	/* The number of precincts spanning the resolution level in the
-	  horizontal direction. */
-	int numhprcs;
+        /* The number of precincts spanning the resolution level in the
+          horizontal direction. */
+        int numhprcs;
 
-	/* The number of precincts spanning the resolution level in the
-	  vertical direction. */
-	int numvprcs;
+        /* The number of precincts spanning the resolution level in the
+          vertical direction. */
+        int numvprcs;
 
-	/* The total number of precincts. */
-	int numprcs;
+        /* The total number of precincts. */
+        int numprcs;
 
-	/* The exponent value for the nominal code block group width.
-	  This quantity is associated with the next lower resolution level
-	  (assuming that there is one). */
-	int cbgwidthexpn;
+        /* The exponent value for the nominal code block group width.
+          This quantity is associated with the next lower resolution level
+          (assuming that there is one). */
+        int cbgwidthexpn;
 
-	/* The exponent value for the nominal code block group height.
-	  This quantity is associated with the next lower resolution level
-	  (assuming that there is one). */
-	int cbgheightexpn;
+        /* The exponent value for the nominal code block group height.
+          This quantity is associated with the next lower resolution level
+          (assuming that there is one). */
+        int cbgheightexpn;
 
-	/* The exponent value for the code block width. */
-	uint_fast16_t cblkwidthexpn;
+        /* The exponent value for the code block width. */
+        uint_fast16_t cblkwidthexpn;
 
-	/* The exponent value for the code block height. */
-	uint_fast16_t cblkheightexpn;
+        /* The exponent value for the code block height. */
+        uint_fast16_t cblkheightexpn;
 
-	/* The number of bands associated with this resolution level. */
-	int numbands;
+        /* The number of bands associated with this resolution level. */
+        int numbands;
 
-	/* The per-band information. */
-	jpc_enc_band_t *bands;
+        /* The per-band information. */
+        jpc_enc_band_t *bands;
 
-	/* The parent tile-component. */
-	struct jpc_enc_tcmpt_s *tcmpt;
+        /* The parent tile-component. */
+        struct jpc_enc_tcmpt_s *tcmpt;
 
 } jpc_enc_rlvl_t;
 
@@ -551,53 +551,53 @@ typedef struct jpc_enc_rlvl_s {
 
 typedef struct jpc_enc_tcmpt_s {
 
-	/* The number of resolution levels. */
-	uint_fast16_t numrlvls;
+        /* The number of resolution levels. */
+        uint_fast16_t numrlvls;
 
-	/* The per-resolution-level information. */
-	jpc_enc_rlvl_t *rlvls;
+        /* The per-resolution-level information. */
+        jpc_enc_rlvl_t *rlvls;
 
-	/* The tile-component data. */
-	jas_matrix_t *data;
+        /* The tile-component data. */
+        jas_matrix_t *data;
 
-	/* The QMFB. */
-	int qmfbid;
+        /* The QMFB. */
+        int qmfbid;
 
-	/* The number of bands. */
-	int numbands;
+        /* The number of bands. */
+        int numbands;
 
-	/* The TSFB. */
-	jpc_tsfb_t *tsfb;
+        /* The TSFB. */
+        jpc_tsfb_t *tsfb;
 
-	/* The synthesis energy weight (for the MCT). */
-	jpc_fix_t synweight;
+        /* The synthesis energy weight (for the MCT). */
+        jpc_fix_t synweight;
 
-	/* The precinct width exponents. */
-	int prcwidthexpns[JPC_MAXRLVLS];
+        /* The precinct width exponents. */
+        int prcwidthexpns[JPC_MAXRLVLS];
 
-	/* The precinct height exponents. */
-	int prcheightexpns[JPC_MAXRLVLS];
+        /* The precinct height exponents. */
+        int prcheightexpns[JPC_MAXRLVLS];
 
-	/* The code block width exponent. */
-	int cblkwidthexpn;
+        /* The code block width exponent. */
+        int cblkwidthexpn;
 
-	/* The code block height exponent. */
-	int cblkheightexpn;
+        /* The code block height exponent. */
+        int cblkheightexpn;
 
-	/* Coding style (i.e., explicit precinct sizes). */
-	int csty;
+        /* Coding style (i.e., explicit precinct sizes). */
+        int csty;
 
-	/* Code block style. */
-	int cblksty;
+        /* Code block style. */
+        int cblksty;
 
-	/* The number of quantizer step sizes. */
-	uint_fast16_t numstepsizes;
+        /* The number of quantizer step sizes. */
+        uint_fast16_t numstepsizes;
 
-	/* The encoded quantizer step sizes. */
-	uint_fast16_t stepsizes[JPC_MAXBANDS];
+        /* The encoded quantizer step sizes. */
+        uint_fast16_t stepsizes[JPC_MAXBANDS];
 
-	/* The parent tile. */
-	struct jpc_enc_tile_s *tile;
+        /* The parent tile. */
+        struct jpc_enc_tile_s *tile;
 
 } jpc_enc_tcmpt_t;
 
@@ -605,55 +605,55 @@ typedef struct jpc_enc_tcmpt_s {
 
 typedef struct jpc_enc_tile_s {
 
-	/* The tile number. */
-	uint_fast32_t tileno;
+        /* The tile number. */
+        uint_fast32_t tileno;
 
-	/* The x-coordinate of the top-left corner of the tile measured with
-	  respect to the reference grid. */
-	uint_fast32_t tlx;
+        /* The x-coordinate of the top-left corner of the tile measured with
+          respect to the reference grid. */
+        uint_fast32_t tlx;
 
-	/* The y-coordinate of the top-left corner of the tile measured with
-	  respect to the reference grid. */
-	uint_fast32_t tly;
+        /* The y-coordinate of the top-left corner of the tile measured with
+          respect to the reference grid. */
+        uint_fast32_t tly;
 
-	/* The x-coordinate of the bottom-right corner of the tile measured
-	  with respect to the reference grid (plus one). */
-	uint_fast32_t brx;
+        /* The x-coordinate of the bottom-right corner of the tile measured
+          with respect to the reference grid (plus one). */
+        uint_fast32_t brx;
 
-	/* The y-coordinate of the bottom-right corner of the tile measured
-	  with respect to the reference grid (plus one). */
-	uint_fast32_t bry;
+        /* The y-coordinate of the bottom-right corner of the tile measured
+          with respect to the reference grid (plus one). */
+        uint_fast32_t bry;
 
-	/* The coding style. */
-	uint_fast8_t csty;
+        /* The coding style. */
+        uint_fast8_t csty;
 
-	/* The progression order. */
-	uint_fast8_t prg;
+        /* The progression order. */
+        uint_fast8_t prg;
 
-	/* The number of layers. */
-	uint_fast16_t numlyrs;
+        /* The number of layers. */
+        uint_fast16_t numlyrs;
 
-	/* The MCT to employ (if any). */
-	uint_fast8_t mctid;
+        /* The MCT to employ (if any). */
+        uint_fast8_t mctid;
 
-	/* The packet iterator (used to determine the order of packet
-	  generation). */
-	jpc_pi_t *pi;
+        /* The packet iterator (used to determine the order of packet
+          generation). */
+        jpc_pi_t *pi;
 
-	/* The coding mode (i.e., integer or real). */
-	bool intmode;
+        /* The coding mode (i.e., integer or real). */
+        bool intmode;
 
-	/* The number of bytes to allocate to the various layers. */
-	uint_fast32_t *lyrsizes;
+        /* The number of bytes to allocate to the various layers. */
+        uint_fast32_t *lyrsizes;
 
-	/* The number of tile-components. */
-	int numtcmpts;
+        /* The number of tile-components. */
+        int numtcmpts;
 
-	/* The per tile-component information. */
-	jpc_enc_tcmpt_t *tcmpts;
+        /* The per tile-component information. */
+        jpc_enc_tcmpt_t *tcmpts;
 
-	/* The raw (i.e., uncompressed) size of this tile. */
-	uint_fast32_t rawsize;
+        /* The raw (i.e., uncompressed) size of this tile. */
+        uint_fast32_t rawsize;
 
 } jpc_enc_tile_t;
 
@@ -661,34 +661,34 @@ typedef struct jpc_enc_tile_s {
 
 typedef struct jpc_enc_s {
 
-	/* The image being encoded. */
-	jas_image_t *image;
+        /* The image being encoded. */
+        jas_image_t *image;
 
-	/* The output stream. */
-	jas_stream_t *out;
+        /* The output stream. */
+        jas_stream_t *out;
 
-	/* The coding parameters. */
-	jpc_enc_cp_t *cp;
+        /* The coding parameters. */
+        jpc_enc_cp_t *cp;
 
-	/* The tile currently being processed. */
-	jpc_enc_tile_t *curtile;
+        /* The tile currently being processed. */
+        jpc_enc_tile_t *curtile;
 
-	/* The code stream state. */
-	jpc_cstate_t *cstate;
+        /* The code stream state. */
+        jpc_cstate_t *cstate;
 
-	/* The number of bytes output so far. */
-	uint_fast32_t len;
+        /* The number of bytes output so far. */
+        uint_fast32_t len;
 
-	/* The number of bytes available for the main body of the code stream. */
-	/* This is used for rate allocation purposes. */
-	uint_fast32_t mainbodysize;
+        /* The number of bytes available for the main body of the code stream. */
+        /* This is used for rate allocation purposes. */
+        uint_fast32_t mainbodysize;
 
-	/* The marker segment currently being processed. */
-	/* This member is a convenience for making cleanup easier. */
-	jpc_ms_t *mrk;
+        /* The marker segment currently being processed. */
+        /* This member is a convenience for making cleanup easier. */
+        jpc_ms_t *mrk;
 
-	/* The stream used to temporarily hold tile-part data. */
-	jas_stream_t *tmpstream;
+        /* The stream used to temporarily hold tile-part data. */
+        jas_stream_t *tmpstream;
 
 } jpc_enc_t;
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h b/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h
index 5ff0c9f8..2083cdc6 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -141,7 +141,7 @@ typedef int_fast32_t jpc_fix_t;
 typedef int_fast64_t jpc_fix_big_t;
 
 /* The number of bits used for the fractional part of a fixed-point number. */
-#define JPC_FIX_FRACBITS	13
+#define JPC_FIX_FRACBITS        13
 
 /******************************************************************************\
 * Instantiations of the generic fixed-point number macros for the
@@ -150,44 +150,44 @@ typedef int_fast64_t jpc_fix_big_t;
 * corresponding macros in the jasper/jas_fix.h header file.
 \******************************************************************************/
 
-#define	JPC_FIX_ZERO	JAS_FIX_ZERO(jpc_fix_t, JPC_FIX_FRACBITS)
-#define	JPC_FIX_ONE		JAS_FIX_ONE(jpc_fix_t, JPC_FIX_FRACBITS)
-#define	JPC_FIX_HALF	JAS_FIX_HALF(jpc_fix_t, JPC_FIX_FRACBITS)
-
-#define jpc_inttofix(x)	JAS_INTTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define jpc_fixtoint(x)	JAS_FIXTOINT(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define jpc_fixtodbl(x)	JAS_FIXTODBL(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define jpc_dbltofix(x)	JAS_DBLTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x)
-
-#define	jpc_fix_add(x, y)	JAS_FIX_ADD(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
-#define	jpc_fix_sub(x, y)	JAS_FIX_SUB(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
-#define	jpc_fix_mul(x, y) \
-	JAS_FIX_MUL(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y)
-#define	jpc_fix_mulbyint(x, y) \
-	JAS_FIX_MULBYINT(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
-#define	jpc_fix_div(x, y) \
-	JAS_FIX_DIV(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y)
-#define	jpc_fix_neg(x)		JAS_FIX_NEG(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define	jpc_fix_asl(x, n)	JAS_FIX_ASL(jpc_fix_t, JPC_FIX_FRACBITS, x, n)
-#define	jpc_fix_asr(x, n)	JAS_FIX_ASR(jpc_fix_t, JPC_FIX_FRACBITS, x, n)
-
-#define jpc_fix_pluseq(x, y)	JAS_FIX_PLUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
-#define jpc_fix_minuseq(x, y)	JAS_FIX_MINUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
-#define	jpc_fix_muleq(x, y)	\
-	JAS_FIX_MULEQ(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y)
-
-#define	jpc_fix_abs(x)		JAS_FIX_ABS(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define	jpc_fix_isint(x)	JAS_FIX_ISINT(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define jpc_fix_sgn(x)		JAS_FIX_SGN(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define	jpc_fix_round(x)	JAS_FIX_ROUND(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define	jpc_fix_floor(x)	JAS_FIX_FLOOR(jpc_fix_t, JPC_FIX_FRACBITS, x)
-#define jpc_fix_trunc(x)	JAS_FIX_TRUNC(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define JPC_FIX_ZERO    JAS_FIX_ZERO(jpc_fix_t, JPC_FIX_FRACBITS)
+#define JPC_FIX_ONE             JAS_FIX_ONE(jpc_fix_t, JPC_FIX_FRACBITS)
+#define JPC_FIX_HALF    JAS_FIX_HALF(jpc_fix_t, JPC_FIX_FRACBITS)
+
+#define jpc_inttofix(x) JAS_INTTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fixtoint(x) JAS_FIXTOINT(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fixtodbl(x) JAS_FIXTODBL(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_dbltofix(x) JAS_DBLTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x)
+
+#define jpc_fix_add(x, y)       JAS_FIX_ADD(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
+#define jpc_fix_sub(x, y)       JAS_FIX_SUB(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
+#define jpc_fix_mul(x, y) \
+        JAS_FIX_MUL(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y)
+#define jpc_fix_mulbyint(x, y) \
+        JAS_FIX_MULBYINT(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
+#define jpc_fix_div(x, y) \
+        JAS_FIX_DIV(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y)
+#define jpc_fix_neg(x)          JAS_FIX_NEG(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fix_asl(x, n)       JAS_FIX_ASL(jpc_fix_t, JPC_FIX_FRACBITS, x, n)
+#define jpc_fix_asr(x, n)       JAS_FIX_ASR(jpc_fix_t, JPC_FIX_FRACBITS, x, n)
+
+#define jpc_fix_pluseq(x, y)    JAS_FIX_PLUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
+#define jpc_fix_minuseq(x, y)   JAS_FIX_MINUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y)
+#define jpc_fix_muleq(x, y)     \
+        JAS_FIX_MULEQ(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y)
+
+#define jpc_fix_abs(x)          JAS_FIX_ABS(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fix_isint(x)        JAS_FIX_ISINT(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fix_sgn(x)          JAS_FIX_SGN(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fix_round(x)        JAS_FIX_ROUND(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fix_floor(x)        JAS_FIX_FLOOR(jpc_fix_t, JPC_FIX_FRACBITS, x)
+#define jpc_fix_trunc(x)        JAS_FIX_TRUNC(jpc_fix_t, JPC_FIX_FRACBITS, x)
 
 /******************************************************************************\
 * Extra macros for convenience.
 \******************************************************************************/
 
 /* Compute the sum of three fixed-point numbers. */
-#define jpc_fix_add3(x, y, z)	jpc_fix_add(jpc_fix_add(x, y), z)
+#define jpc_fix_add3(x, y, z)   jpc_fix_add(jpc_fix_add(x, y), z)
 
 #endif
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h b/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h
index 088eb00c..dc1950e3 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_math.c b/converter/other/jpeg2000/libjasper/jpc/jpc_math.c
index a884ed4d..420e0857 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_math.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_math.c
@@ -14,18 +14,18 @@
 int
 jpc_floorlog2(int_fast32_t const arg) {
 
-	int y;
+        int y;
     int x;
 
-	assert(arg > 0);
+        assert(arg > 0);
 
-	y = 0;
+        y = 0;
     x = arg;
-	while (x > 1) {
-		x >>= 1;
-		++y;
-	}
-	return y;
+        while (x > 1) {
+                x >>= 1;
+                ++y;
+        }
+        return y;
 }
 
 
@@ -34,12 +34,12 @@ jpc_floorlog2(int_fast32_t const arg) {
   jpc_floorlog2() and jpc_firstone() do the same thing.
   The only difference is how input 0 is handled.
 
-n                  : 0 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 
-ceil(log2(n))      : x 0  1  2  2  3  3  3  3  4  4  4  4  4  4  4  4  5  5  5 
-floor(log2(n))     : x 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4 
-31-__builtin_clz(n): x 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4 
-jpc_floorlog2(n)   : x 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4 
-jpc_firstone(n)    :-1 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4 
+n                  : 0 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
+ceil(log2(n))      : x 0  1  2  2  3  3  3  3  4  4  4  4  4  4  4  4  5  5  5
+floor(log2(n))     : x 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4
+31-__builtin_clz(n): x 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4
+jpc_floorlog2(n)   : x 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4
+jpc_firstone(n)    :-1 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4
 
 */
 
@@ -47,24 +47,24 @@ jpc_firstone(n)    :-1 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4
 
 int
 jpc_firstone(int_fast32_t const arg) {
-/*---------------------------------------------------------------------------- 
+/*----------------------------------------------------------------------------
   Calculate the bit position of the first leading one in a nonnegative
   integer.
 
   LSB is bit position 0.  Iff there are no ones, return -1.
 -----------------------------------------------------------------------------*/
-	int n;
+        int n;
     int x;
 
-	assert(arg >= 0);
+        assert(arg >= 0);
 
-	n = -1;
+        n = -1;
     x = arg;
-	while (x > 0) {
-		x >>= 1;
-		++n;
-	}
-	return n;
+        while (x > 0) {
+                x >>= 1;
+                ++n;
+        }
+        return n;
 }
 
 
@@ -77,14 +77,14 @@ jpc_firstone(int_fast32_t const arg) {
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -92,22 +92,22 @@ jpc_firstone(int_fast32_t const arg) {
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -127,17 +127,17 @@ jpc_firstone(int_fast32_t const arg) {
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -177,6 +177,6 @@ jpc_firstone(int_fast32_t const arg) {
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_math.h b/converter/other/jpeg2000/libjasper/jpc/jpc_math.h
index cd24c6a6..e08db334 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_math.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_math.h
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,12 +104,12 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
-#ifndef	JPC_MATH_H
-#define	JPC_MATH_H
+#ifndef JPC_MATH_H
+#define JPC_MATH_H
 
 /******************************************************************************\
 * Includes
@@ -123,23 +123,23 @@
 \******************************************************************************/
 
 /* Compute the floor of the quotient of two integers. */
-#define	JPC_FLOORDIV(x, y)	(assert(x >= 0 && y > 0), (x) / (y))
+#define JPC_FLOORDIV(x, y)      (assert(x >= 0 && y > 0), (x) / (y))
 
 /* Compute the ceiling of the quotient of two integers. */
-#define	JPC_CEILDIV(x, y)	(assert(x >= 0 && y > 0), ((x) + (y) - 1) / (y))
+#define JPC_CEILDIV(x, y)       (assert(x >= 0 && y > 0), ((x) + (y) - 1) / (y))
 
 /* Compute the floor of (x / 2^y). */
-#define	JPC_FLOORDIVPOW2(x, y) \
-	(assert(x >= 0 && y > 0), (x) >> (y))
+#define JPC_FLOORDIVPOW2(x, y) \
+        (assert(x >= 0 && y > 0), (x) >> (y))
 
 /* Compute the ceiling of (x / 2^y). */
-#define	JPC_CEILDIVPOW2(x, y) \
-	(assert(x >= 0 && y >= 0), ((x) + (1 << (y)) - 1) >> (y))
+#define JPC_CEILDIVPOW2(x, y) \
+        (assert(x >= 0 && y >= 0), ((x) + (1 << (y)) - 1) >> (y))
 /* JPC_CEILDIVPOW2U is for unsigned arguments (JPC_CEILDIVPOW2 would generate
    compiler warnings because of its superfluous >= 0 check)
 */
-#define	JPC_CEILDIVPOW2U(x, y) \
-	(((x) + (1 << (y)) - 1) >> (y))
+#define JPC_CEILDIVPOW2U(x, y) \
+        (((x) + (1 << (y)) - 1) >> (y))
 
 /******************************************************************************\
 * Functions.
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c
index 7c16c3e5..2d7ea47c 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -135,203 +135,203 @@
 
 void jpc_rct(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2)
 {
-	int numrows;
-	int numcols;
-	int i;
-	int j;
-	jpc_fix_t *c0p;
-	jpc_fix_t *c1p;
-	jpc_fix_t *c2p;
+        int numrows;
+        int numcols;
+        int i;
+        int j;
+        jpc_fix_t *c0p;
+        jpc_fix_t *c1p;
+        jpc_fix_t *c2p;
 
-	numrows = jas_matrix_numrows(c0);
-	numcols = jas_matrix_numcols(c0);
+        numrows = jas_matrix_numrows(c0);
+        numcols = jas_matrix_numcols(c0);
 
-	/* All three matrices must have the same dimensions. */
-	assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols
-	  && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols);
+        /* All three matrices must have the same dimensions. */
+        assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols
+          && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols);
 
-	for (i = 0; i < numrows; i++) {
-		c0p = jas_matrix_getref(c0, i, 0);
-		c1p = jas_matrix_getref(c1, i, 0);
-		c2p = jas_matrix_getref(c2, i, 0);
-		for (j = numcols; j > 0; --j) {
-			int r;
-			int g;
-			int b;
-			int y;
-			int u;
-			int v;
-			r = *c0p;
-			g = *c1p;
-			b = *c2p;
-			y = (r + (g << 1) + b) >> 2;
-			u = b - g;
-			v = r - g;
-			*c0p++ = y;
-			*c1p++ = u;
-			*c2p++ = v;
-		}
-	}
+        for (i = 0; i < numrows; i++) {
+                c0p = jas_matrix_getref(c0, i, 0);
+                c1p = jas_matrix_getref(c1, i, 0);
+                c2p = jas_matrix_getref(c2, i, 0);
+                for (j = numcols; j > 0; --j) {
+                        int r;
+                        int g;
+                        int b;
+                        int y;
+                        int u;
+                        int v;
+                        r = *c0p;
+                        g = *c1p;
+                        b = *c2p;
+                        y = (r + (g << 1) + b) >> 2;
+                        u = b - g;
+                        v = r - g;
+                        *c0p++ = y;
+                        *c1p++ = u;
+                        *c2p++ = v;
+                }
+        }
 }
 
 /* Compute the inverse RCT. */
 
 void jpc_irct(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2)
 {
-	int numrows;
-	int numcols;
-	int i;
-	int j;
-	jpc_fix_t *c0p;
-	jpc_fix_t *c1p;
-	jpc_fix_t *c2p;
+        int numrows;
+        int numcols;
+        int i;
+        int j;
+        jpc_fix_t *c0p;
+        jpc_fix_t *c1p;
+        jpc_fix_t *c2p;
 
-	numrows = jas_matrix_numrows(c0);
-	numcols = jas_matrix_numcols(c0);
+        numrows = jas_matrix_numrows(c0);
+        numcols = jas_matrix_numcols(c0);
 
-	/* All three matrices must have the same dimensions. */
-	assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols
-	  && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols);
+        /* All three matrices must have the same dimensions. */
+        assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols
+          && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols);
 
-	for (i = 0; i < numrows; i++) {
-		c0p = jas_matrix_getref(c0, i, 0);
-		c1p = jas_matrix_getref(c1, i, 0);
-		c2p = jas_matrix_getref(c2, i, 0);
-		for (j = numcols; j > 0; --j) {
-			int r;
-			int g;
-			int b;
-			int y;
-			int u;
-			int v;
-			y = *c0p;
-			u = *c1p;
-			v = *c2p;
-			g = y - ((u + v) >> 2);
-			r = v + g;
-			b = u + g;
-			*c0p++ = r;
-			*c1p++ = g;
-			*c2p++ = b;
-		}
-	}
+        for (i = 0; i < numrows; i++) {
+                c0p = jas_matrix_getref(c0, i, 0);
+                c1p = jas_matrix_getref(c1, i, 0);
+                c2p = jas_matrix_getref(c2, i, 0);
+                for (j = numcols; j > 0; --j) {
+                        int r;
+                        int g;
+                        int b;
+                        int y;
+                        int u;
+                        int v;
+                        y = *c0p;
+                        u = *c1p;
+                        v = *c2p;
+                        g = y - ((u + v) >> 2);
+                        r = v + g;
+                        b = u + g;
+                        *c0p++ = r;
+                        *c1p++ = g;
+                        *c2p++ = b;
+                }
+        }
 }
 
 void jpc_ict(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2)
 {
-	int numrows;
-	int numcols;
-	int i;
-	int j;
-	jpc_fix_t r;
-	jpc_fix_t g;
-	jpc_fix_t b;
-	jpc_fix_t y;
-	jpc_fix_t u;
-	jpc_fix_t v;
-	jpc_fix_t *c0p;
-	jpc_fix_t *c1p;
-	jpc_fix_t *c2p;
+        int numrows;
+        int numcols;
+        int i;
+        int j;
+        jpc_fix_t r;
+        jpc_fix_t g;
+        jpc_fix_t b;
+        jpc_fix_t y;
+        jpc_fix_t u;
+        jpc_fix_t v;
+        jpc_fix_t *c0p;
+        jpc_fix_t *c1p;
+        jpc_fix_t *c2p;
 
-	numrows = jas_matrix_numrows(c0);
-	assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows);
-	numcols = jas_matrix_numcols(c0);
-	assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols);
-	for (i = 0; i < numrows; ++i) {
-		c0p = jas_matrix_getref(c0, i, 0);
-		c1p = jas_matrix_getref(c1, i, 0);
-		c2p = jas_matrix_getref(c2, i, 0);
-		for (j = numcols; j > 0; --j) {
-			r = *c0p;
-			g = *c1p;
-			b = *c2p;
-			y = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.299), r), jpc_fix_mul(jpc_dbltofix(0.587), g),
-			  jpc_fix_mul(jpc_dbltofix(0.114), b));
-			u = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(-0.16875), r), jpc_fix_mul(jpc_dbltofix(-0.33126), g),
-			  jpc_fix_mul(jpc_dbltofix(0.5), b));
-			v = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.5), r), jpc_fix_mul(jpc_dbltofix(-0.41869), g),
-			  jpc_fix_mul(jpc_dbltofix(-0.08131), b));
-			*c0p++ = y;
-			*c1p++ = u;
-			*c2p++ = v;
-		}
-	}
+        numrows = jas_matrix_numrows(c0);
+        assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows);
+        numcols = jas_matrix_numcols(c0);
+        assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols);
+        for (i = 0; i < numrows; ++i) {
+                c0p = jas_matrix_getref(c0, i, 0);
+                c1p = jas_matrix_getref(c1, i, 0);
+                c2p = jas_matrix_getref(c2, i, 0);
+                for (j = numcols; j > 0; --j) {
+                        r = *c0p;
+                        g = *c1p;
+                        b = *c2p;
+                        y = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.299), r), jpc_fix_mul(jpc_dbltofix(0.587), g),
+                          jpc_fix_mul(jpc_dbltofix(0.114), b));
+                        u = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(-0.16875), r), jpc_fix_mul(jpc_dbltofix(-0.33126), g),
+                          jpc_fix_mul(jpc_dbltofix(0.5), b));
+                        v = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.5), r), jpc_fix_mul(jpc_dbltofix(-0.41869), g),
+                          jpc_fix_mul(jpc_dbltofix(-0.08131), b));
+                        *c0p++ = y;
+                        *c1p++ = u;
+                        *c2p++ = v;
+                }
+        }
 }
 
 void jpc_iict(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2)
 {
-	int numrows;
-	int numcols;
-	int i;
-	int j;
-	jpc_fix_t r;
-	jpc_fix_t g;
-	jpc_fix_t b;
-	jpc_fix_t y;
-	jpc_fix_t u;
-	jpc_fix_t v;
-	jpc_fix_t *c0p;
-	jpc_fix_t *c1p;
-	jpc_fix_t *c2p;
+        int numrows;
+        int numcols;
+        int i;
+        int j;
+        jpc_fix_t r;
+        jpc_fix_t g;
+        jpc_fix_t b;
+        jpc_fix_t y;
+        jpc_fix_t u;
+        jpc_fix_t v;
+        jpc_fix_t *c0p;
+        jpc_fix_t *c1p;
+        jpc_fix_t *c2p;
 
-	numrows = jas_matrix_numrows(c0);
-	assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows);
-	numcols = jas_matrix_numcols(c0);
-	assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols);
-	for (i = 0; i < numrows; ++i) {
-		c0p = jas_matrix_getref(c0, i, 0);
-		c1p = jas_matrix_getref(c1, i, 0);
-		c2p = jas_matrix_getref(c2, i, 0);
-		for (j = numcols; j > 0; --j) {
-			y = *c0p;
-			u = *c1p;
-			v = *c2p;
-			r = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.402), v));
-			g = jpc_fix_add3(y, jpc_fix_mul(jpc_dbltofix(-0.34413), u),
-			  jpc_fix_mul(jpc_dbltofix(-0.71414), v));
-			b = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.772), u));
-			*c0p++ = r;
-			*c1p++ = g;
-			*c2p++ = b;
-		}
-	}
+        numrows = jas_matrix_numrows(c0);
+        assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows);
+        numcols = jas_matrix_numcols(c0);
+        assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols);
+        for (i = 0; i < numrows; ++i) {
+                c0p = jas_matrix_getref(c0, i, 0);
+                c1p = jas_matrix_getref(c1, i, 0);
+                c2p = jas_matrix_getref(c2, i, 0);
+                for (j = numcols; j > 0; --j) {
+                        y = *c0p;
+                        u = *c1p;
+                        v = *c2p;
+                        r = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.402), v));
+                        g = jpc_fix_add3(y, jpc_fix_mul(jpc_dbltofix(-0.34413), u),
+                          jpc_fix_mul(jpc_dbltofix(-0.71414), v));
+                        b = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.772), u));
+                        *c0p++ = r;
+                        *c1p++ = g;
+                        *c2p++ = b;
+                }
+        }
 }
 
 jpc_fix_t jpc_mct_getsynweight(int mctid, int cmptno)
 {
-	jpc_fix_t synweight;
+        jpc_fix_t synweight;
 
-	switch (mctid) {
-	case JPC_MCT_RCT:
-		switch (cmptno) {
-		case 0:
-			synweight = jpc_dbltofix(sqrt(3.0));
-			break;
-		case 1:
-			synweight = jpc_dbltofix(sqrt(0.6875));
-			break;
-		case 2:
-			synweight = jpc_dbltofix(sqrt(0.6875));
-			break;
-		}
-		break;
-	case JPC_MCT_ICT:
-		switch (cmptno) {
-		case 0:
-			synweight = jpc_dbltofix(sqrt(3.0000));
-			break;
-		case 1:
-			synweight = jpc_dbltofix(sqrt(3.2584));
-			break;
-		case 2:
-			synweight = jpc_dbltofix(sqrt(2.4755));
-			break;
-		}
-		break;
-	default:
-		synweight = JPC_FIX_ONE;
-		break;
-	}
+        switch (mctid) {
+        case JPC_MCT_RCT:
+                switch (cmptno) {
+                case 0:
+                        synweight = jpc_dbltofix(sqrt(3.0));
+                        break;
+                case 1:
+                        synweight = jpc_dbltofix(sqrt(0.6875));
+                        break;
+                case 2:
+                        synweight = jpc_dbltofix(sqrt(0.6875));
+                        break;
+                }
+                break;
+        case JPC_MCT_ICT:
+                switch (cmptno) {
+                case 0:
+                        synweight = jpc_dbltofix(sqrt(3.0000));
+                        break;
+                case 1:
+                        synweight = jpc_dbltofix(sqrt(3.2584));
+                        break;
+                case 2:
+                        synweight = jpc_dbltofix(sqrt(2.4755));
+                        break;
+                }
+                break;
+        default:
+                synweight = JPC_FIX_ONE;
+                break;
+        }
 
-	return synweight;
+        return synweight;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h
index d03d6ce1..bb424900 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -134,9 +134,9 @@
  * Multicomponent transform IDs.
  */
 
-#define JPC_MCT_NONE	0
-#define JPC_MCT_ICT		1
-#define JPC_MCT_RCT		2
+#define JPC_MCT_NONE    0
+#define JPC_MCT_ICT             1
+#define JPC_MCT_RCT             2
 
 /******************************************************************************\
 * Functions.
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c
index 535eaa2d..e19f94ad 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -131,98 +131,98 @@
 /* MQ coder per-state information. */
 
 jpc_mqstate_t jpc_mqstates[47 * 2] = {
-	{0x5601, 0, &jpc_mqstates[ 2], &jpc_mqstates[ 3]},
-	{0x5601, 1, &jpc_mqstates[ 3], &jpc_mqstates[ 2]},
-	{0x3401, 0, &jpc_mqstates[ 4], &jpc_mqstates[12]},
-	{0x3401, 1, &jpc_mqstates[ 5], &jpc_mqstates[13]},
-	{0x1801, 0, &jpc_mqstates[ 6], &jpc_mqstates[18]},
-	{0x1801, 1, &jpc_mqstates[ 7], &jpc_mqstates[19]},
-	{0x0ac1, 0, &jpc_mqstates[ 8], &jpc_mqstates[24]},
-	{0x0ac1, 1, &jpc_mqstates[ 9], &jpc_mqstates[25]},
-	{0x0521, 0, &jpc_mqstates[10], &jpc_mqstates[58]},
-	{0x0521, 1, &jpc_mqstates[11], &jpc_mqstates[59]},
-	{0x0221, 0, &jpc_mqstates[76], &jpc_mqstates[66]},
-	{0x0221, 1, &jpc_mqstates[77], &jpc_mqstates[67]},
-	{0x5601, 0, &jpc_mqstates[14], &jpc_mqstates[13]},
-	{0x5601, 1, &jpc_mqstates[15], &jpc_mqstates[12]},
-	{0x5401, 0, &jpc_mqstates[16], &jpc_mqstates[28]},
-	{0x5401, 1, &jpc_mqstates[17], &jpc_mqstates[29]},
-	{0x4801, 0, &jpc_mqstates[18], &jpc_mqstates[28]},
-	{0x4801, 1, &jpc_mqstates[19], &jpc_mqstates[29]},
-	{0x3801, 0, &jpc_mqstates[20], &jpc_mqstates[28]},
-	{0x3801, 1, &jpc_mqstates[21], &jpc_mqstates[29]},
-	{0x3001, 0, &jpc_mqstates[22], &jpc_mqstates[34]},
-	{0x3001, 1, &jpc_mqstates[23], &jpc_mqstates[35]},
-	{0x2401, 0, &jpc_mqstates[24], &jpc_mqstates[36]},
-	{0x2401, 1, &jpc_mqstates[25], &jpc_mqstates[37]},
-	{0x1c01, 0, &jpc_mqstates[26], &jpc_mqstates[40]},
-	{0x1c01, 1, &jpc_mqstates[27], &jpc_mqstates[41]},
-	{0x1601, 0, &jpc_mqstates[58], &jpc_mqstates[42]},
-	{0x1601, 1, &jpc_mqstates[59], &jpc_mqstates[43]},
-	{0x5601, 0, &jpc_mqstates[30], &jpc_mqstates[29]},
-	{0x5601, 1, &jpc_mqstates[31], &jpc_mqstates[28]},
-	{0x5401, 0, &jpc_mqstates[32], &jpc_mqstates[28]},
-	{0x5401, 1, &jpc_mqstates[33], &jpc_mqstates[29]},
-	{0x5101, 0, &jpc_mqstates[34], &jpc_mqstates[30]},
-	{0x5101, 1, &jpc_mqstates[35], &jpc_mqstates[31]},
-	{0x4801, 0, &jpc_mqstates[36], &jpc_mqstates[32]},
-	{0x4801, 1, &jpc_mqstates[37], &jpc_mqstates[33]},
-	{0x3801, 0, &jpc_mqstates[38], &jpc_mqstates[34]},
-	{0x3801, 1, &jpc_mqstates[39], &jpc_mqstates[35]},
-	{0x3401, 0, &jpc_mqstates[40], &jpc_mqstates[36]},
-	{0x3401, 1, &jpc_mqstates[41], &jpc_mqstates[37]},
-	{0x3001, 0, &jpc_mqstates[42], &jpc_mqstates[38]},
-	{0x3001, 1, &jpc_mqstates[43], &jpc_mqstates[39]},
-	{0x2801, 0, &jpc_mqstates[44], &jpc_mqstates[38]},
-	{0x2801, 1, &jpc_mqstates[45], &jpc_mqstates[39]},
-	{0x2401, 0, &jpc_mqstates[46], &jpc_mqstates[40]},
-	{0x2401, 1, &jpc_mqstates[47], &jpc_mqstates[41]},
-	{0x2201, 0, &jpc_mqstates[48], &jpc_mqstates[42]},
-	{0x2201, 1, &jpc_mqstates[49], &jpc_mqstates[43]},
-	{0x1c01, 0, &jpc_mqstates[50], &jpc_mqstates[44]},
-	{0x1c01, 1, &jpc_mqstates[51], &jpc_mqstates[45]},
-	{0x1801, 0, &jpc_mqstates[52], &jpc_mqstates[46]},
-	{0x1801, 1, &jpc_mqstates[53], &jpc_mqstates[47]},
-	{0x1601, 0, &jpc_mqstates[54], &jpc_mqstates[48]},
-	{0x1601, 1, &jpc_mqstates[55], &jpc_mqstates[49]},
-	{0x1401, 0, &jpc_mqstates[56], &jpc_mqstates[50]},
-	{0x1401, 1, &jpc_mqstates[57], &jpc_mqstates[51]},
-	{0x1201, 0, &jpc_mqstates[58], &jpc_mqstates[52]},
-	{0x1201, 1, &jpc_mqstates[59], &jpc_mqstates[53]},
-	{0x1101, 0, &jpc_mqstates[60], &jpc_mqstates[54]},
-	{0x1101, 1, &jpc_mqstates[61], &jpc_mqstates[55]},
-	{0x0ac1, 0, &jpc_mqstates[62], &jpc_mqstates[56]},
-	{0x0ac1, 1, &jpc_mqstates[63], &jpc_mqstates[57]},
-	{0x09c1, 0, &jpc_mqstates[64], &jpc_mqstates[58]},
-	{0x09c1, 1, &jpc_mqstates[65], &jpc_mqstates[59]},
-	{0x08a1, 0, &jpc_mqstates[66], &jpc_mqstates[60]},
-	{0x08a1, 1, &jpc_mqstates[67], &jpc_mqstates[61]},
-	{0x0521, 0, &jpc_mqstates[68], &jpc_mqstates[62]},
-	{0x0521, 1, &jpc_mqstates[69], &jpc_mqstates[63]},
-	{0x0441, 0, &jpc_mqstates[70], &jpc_mqstates[64]},
-	{0x0441, 1, &jpc_mqstates[71], &jpc_mqstates[65]},
-	{0x02a1, 0, &jpc_mqstates[72], &jpc_mqstates[66]},
-	{0x02a1, 1, &jpc_mqstates[73], &jpc_mqstates[67]},
-	{0x0221, 0, &jpc_mqstates[74], &jpc_mqstates[68]},
-	{0x0221, 1, &jpc_mqstates[75], &jpc_mqstates[69]},
-	{0x0141, 0, &jpc_mqstates[76], &jpc_mqstates[70]},
-	{0x0141, 1, &jpc_mqstates[77], &jpc_mqstates[71]},
-	{0x0111, 0, &jpc_mqstates[78], &jpc_mqstates[72]},
-	{0x0111, 1, &jpc_mqstates[79], &jpc_mqstates[73]},
-	{0x0085, 0, &jpc_mqstates[80], &jpc_mqstates[74]},
-	{0x0085, 1, &jpc_mqstates[81], &jpc_mqstates[75]},
-	{0x0049, 0, &jpc_mqstates[82], &jpc_mqstates[76]},
-	{0x0049, 1, &jpc_mqstates[83], &jpc_mqstates[77]},
-	{0x0025, 0, &jpc_mqstates[84], &jpc_mqstates[78]},
-	{0x0025, 1, &jpc_mqstates[85], &jpc_mqstates[79]},
-	{0x0015, 0, &jpc_mqstates[86], &jpc_mqstates[80]},
-	{0x0015, 1, &jpc_mqstates[87], &jpc_mqstates[81]},
-	{0x0009, 0, &jpc_mqstates[88], &jpc_mqstates[82]},
-	{0x0009, 1, &jpc_mqstates[89], &jpc_mqstates[83]},
-	{0x0005, 0, &jpc_mqstates[90], &jpc_mqstates[84]},
-	{0x0005, 1, &jpc_mqstates[91], &jpc_mqstates[85]},
-	{0x0001, 0, &jpc_mqstates[90], &jpc_mqstates[86]},
-	{0x0001, 1, &jpc_mqstates[91], &jpc_mqstates[87]},
-	{0x5601, 0, &jpc_mqstates[92], &jpc_mqstates[92]},
-	{0x5601, 1, &jpc_mqstates[93], &jpc_mqstates[93]},
+        {0x5601, 0, &jpc_mqstates[ 2], &jpc_mqstates[ 3]},
+        {0x5601, 1, &jpc_mqstates[ 3], &jpc_mqstates[ 2]},
+        {0x3401, 0, &jpc_mqstates[ 4], &jpc_mqstates[12]},
+        {0x3401, 1, &jpc_mqstates[ 5], &jpc_mqstates[13]},
+        {0x1801, 0, &jpc_mqstates[ 6], &jpc_mqstates[18]},
+        {0x1801, 1, &jpc_mqstates[ 7], &jpc_mqstates[19]},
+        {0x0ac1, 0, &jpc_mqstates[ 8], &jpc_mqstates[24]},
+        {0x0ac1, 1, &jpc_mqstates[ 9], &jpc_mqstates[25]},
+        {0x0521, 0, &jpc_mqstates[10], &jpc_mqstates[58]},
+        {0x0521, 1, &jpc_mqstates[11], &jpc_mqstates[59]},
+        {0x0221, 0, &jpc_mqstates[76], &jpc_mqstates[66]},
+        {0x0221, 1, &jpc_mqstates[77], &jpc_mqstates[67]},
+        {0x5601, 0, &jpc_mqstates[14], &jpc_mqstates[13]},
+        {0x5601, 1, &jpc_mqstates[15], &jpc_mqstates[12]},
+        {0x5401, 0, &jpc_mqstates[16], &jpc_mqstates[28]},
+        {0x5401, 1, &jpc_mqstates[17], &jpc_mqstates[29]},
+        {0x4801, 0, &jpc_mqstates[18], &jpc_mqstates[28]},
+        {0x4801, 1, &jpc_mqstates[19], &jpc_mqstates[29]},
+        {0x3801, 0, &jpc_mqstates[20], &jpc_mqstates[28]},
+        {0x3801, 1, &jpc_mqstates[21], &jpc_mqstates[29]},
+        {0x3001, 0, &jpc_mqstates[22], &jpc_mqstates[34]},
+        {0x3001, 1, &jpc_mqstates[23], &jpc_mqstates[35]},
+        {0x2401, 0, &jpc_mqstates[24], &jpc_mqstates[36]},
+        {0x2401, 1, &jpc_mqstates[25], &jpc_mqstates[37]},
+        {0x1c01, 0, &jpc_mqstates[26], &jpc_mqstates[40]},
+        {0x1c01, 1, &jpc_mqstates[27], &jpc_mqstates[41]},
+        {0x1601, 0, &jpc_mqstates[58], &jpc_mqstates[42]},
+        {0x1601, 1, &jpc_mqstates[59], &jpc_mqstates[43]},
+        {0x5601, 0, &jpc_mqstates[30], &jpc_mqstates[29]},
+        {0x5601, 1, &jpc_mqstates[31], &jpc_mqstates[28]},
+        {0x5401, 0, &jpc_mqstates[32], &jpc_mqstates[28]},
+        {0x5401, 1, &jpc_mqstates[33], &jpc_mqstates[29]},
+        {0x5101, 0, &jpc_mqstates[34], &jpc_mqstates[30]},
+        {0x5101, 1, &jpc_mqstates[35], &jpc_mqstates[31]},
+        {0x4801, 0, &jpc_mqstates[36], &jpc_mqstates[32]},
+        {0x4801, 1, &jpc_mqstates[37], &jpc_mqstates[33]},
+        {0x3801, 0, &jpc_mqstates[38], &jpc_mqstates[34]},
+        {0x3801, 1, &jpc_mqstates[39], &jpc_mqstates[35]},
+        {0x3401, 0, &jpc_mqstates[40], &jpc_mqstates[36]},
+        {0x3401, 1, &jpc_mqstates[41], &jpc_mqstates[37]},
+        {0x3001, 0, &jpc_mqstates[42], &jpc_mqstates[38]},
+        {0x3001, 1, &jpc_mqstates[43], &jpc_mqstates[39]},
+        {0x2801, 0, &jpc_mqstates[44], &jpc_mqstates[38]},
+        {0x2801, 1, &jpc_mqstates[45], &jpc_mqstates[39]},
+        {0x2401, 0, &jpc_mqstates[46], &jpc_mqstates[40]},
+        {0x2401, 1, &jpc_mqstates[47], &jpc_mqstates[41]},
+        {0x2201, 0, &jpc_mqstates[48], &jpc_mqstates[42]},
+        {0x2201, 1, &jpc_mqstates[49], &jpc_mqstates[43]},
+        {0x1c01, 0, &jpc_mqstates[50], &jpc_mqstates[44]},
+        {0x1c01, 1, &jpc_mqstates[51], &jpc_mqstates[45]},
+        {0x1801, 0, &jpc_mqstates[52], &jpc_mqstates[46]},
+        {0x1801, 1, &jpc_mqstates[53], &jpc_mqstates[47]},
+        {0x1601, 0, &jpc_mqstates[54], &jpc_mqstates[48]},
+        {0x1601, 1, &jpc_mqstates[55], &jpc_mqstates[49]},
+        {0x1401, 0, &jpc_mqstates[56], &jpc_mqstates[50]},
+        {0x1401, 1, &jpc_mqstates[57], &jpc_mqstates[51]},
+        {0x1201, 0, &jpc_mqstates[58], &jpc_mqstates[52]},
+        {0x1201, 1, &jpc_mqstates[59], &jpc_mqstates[53]},
+        {0x1101, 0, &jpc_mqstates[60], &jpc_mqstates[54]},
+        {0x1101, 1, &jpc_mqstates[61], &jpc_mqstates[55]},
+        {0x0ac1, 0, &jpc_mqstates[62], &jpc_mqstates[56]},
+        {0x0ac1, 1, &jpc_mqstates[63], &jpc_mqstates[57]},
+        {0x09c1, 0, &jpc_mqstates[64], &jpc_mqstates[58]},
+        {0x09c1, 1, &jpc_mqstates[65], &jpc_mqstates[59]},
+        {0x08a1, 0, &jpc_mqstates[66], &jpc_mqstates[60]},
+        {0x08a1, 1, &jpc_mqstates[67], &jpc_mqstates[61]},
+        {0x0521, 0, &jpc_mqstates[68], &jpc_mqstates[62]},
+        {0x0521, 1, &jpc_mqstates[69], &jpc_mqstates[63]},
+        {0x0441, 0, &jpc_mqstates[70], &jpc_mqstates[64]},
+        {0x0441, 1, &jpc_mqstates[71], &jpc_mqstates[65]},
+        {0x02a1, 0, &jpc_mqstates[72], &jpc_mqstates[66]},
+        {0x02a1, 1, &jpc_mqstates[73], &jpc_mqstates[67]},
+        {0x0221, 0, &jpc_mqstates[74], &jpc_mqstates[68]},
+        {0x0221, 1, &jpc_mqstates[75], &jpc_mqstates[69]},
+        {0x0141, 0, &jpc_mqstates[76], &jpc_mqstates[70]},
+        {0x0141, 1, &jpc_mqstates[77], &jpc_mqstates[71]},
+        {0x0111, 0, &jpc_mqstates[78], &jpc_mqstates[72]},
+        {0x0111, 1, &jpc_mqstates[79], &jpc_mqstates[73]},
+        {0x0085, 0, &jpc_mqstates[80], &jpc_mqstates[74]},
+        {0x0085, 1, &jpc_mqstates[81], &jpc_mqstates[75]},
+        {0x0049, 0, &jpc_mqstates[82], &jpc_mqstates[76]},
+        {0x0049, 1, &jpc_mqstates[83], &jpc_mqstates[77]},
+        {0x0025, 0, &jpc_mqstates[84], &jpc_mqstates[78]},
+        {0x0025, 1, &jpc_mqstates[85], &jpc_mqstates[79]},
+        {0x0015, 0, &jpc_mqstates[86], &jpc_mqstates[80]},
+        {0x0015, 1, &jpc_mqstates[87], &jpc_mqstates[81]},
+        {0x0009, 0, &jpc_mqstates[88], &jpc_mqstates[82]},
+        {0x0009, 1, &jpc_mqstates[89], &jpc_mqstates[83]},
+        {0x0005, 0, &jpc_mqstates[90], &jpc_mqstates[84]},
+        {0x0005, 1, &jpc_mqstates[91], &jpc_mqstates[85]},
+        {0x0001, 0, &jpc_mqstates[90], &jpc_mqstates[86]},
+        {0x0001, 1, &jpc_mqstates[91], &jpc_mqstates[87]},
+        {0x5601, 0, &jpc_mqstates[92], &jpc_mqstates[92]},
+        {0x5601, 1, &jpc_mqstates[93], &jpc_mqstates[93]},
 };
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h
index 5f99e021..f32fc7fc 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -136,11 +136,11 @@
 
 typedef struct {
 
-	/* The most probable symbol (MPS). */
-	bool mps;
+        /* The most probable symbol (MPS). */
+        bool mps;
 
-	/* The state index. */
-	int_fast16_t ind;
+        /* The state index. */
+        int_fast16_t ind;
 
 } jpc_mqctx_t;
 
@@ -150,17 +150,17 @@ typedef struct {
 
 typedef struct jpc_mqstate_s {
 
-	/* The Qe value. */
-	uint_fast16_t qeval;
+        /* The Qe value. */
+        uint_fast16_t qeval;
 
-	/* The MPS. */
-	uint_fast16_t mps;
+        /* The MPS. */
+        uint_fast16_t mps;
 
-	/* The NMPS state. */
-	struct jpc_mqstate_s *nmps;
+        /* The NMPS state. */
+        struct jpc_mqstate_s *nmps;
 
-	/* The NLPS state. */
-	struct jpc_mqstate_s *nlps;
+        /* The NLPS state. */
+        struct jpc_mqstate_s *nlps;
 
 } jpc_mqstate_t;
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c
index f58a1c7d..2d419522 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -136,10 +136,10 @@
 \******************************************************************************/
 
 #if defined(DEBUG)
-#define	MQDEC_CALL(n, x) \
-	((jas_getdbglevel() >= (n)) ? ((void)(x)) : ((void)0))
+#define MQDEC_CALL(n, x) \
+        ((jas_getdbglevel() >= (n)) ? ((void)(x)) : ((void)0))
 #else
-#define	MQDEC_CALL(n, x)
+#define MQDEC_CALL(n, x)
 #endif
 
 /******************************************************************************\
@@ -155,49 +155,49 @@ static void jpc_mqdec_bytein(jpc_mqdec_t *mqdec);
 /* Create a MQ decoder. */
 jpc_mqdec_t *jpc_mqdec_create(int maxctxs, jas_stream_t *in)
 {
-	jpc_mqdec_t *mqdec;
-
-	/* There must be at least one context. */
-	assert(maxctxs > 0);
-
-	/* Allocate memory for the MQ decoder. */
-	if (!(mqdec = jas_malloc(sizeof(jpc_mqdec_t)))) {
-		goto error;
-	}
-	mqdec->in = in;
-	mqdec->maxctxs = maxctxs;
-	/* Allocate memory for the per-context state information. */
-	if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) {
-		goto error;
-	}
-	/* Set the current context to the first context. */
-	mqdec->curctx = mqdec->ctxs;
-
-	/* If an input stream has been associated with the MQ decoder,
-	  initialize the decoder state from the stream. */
-	if (mqdec->in) {
-		jpc_mqdec_init(mqdec);
-	}
-	/* Initialize the per-context state information. */
-	jpc_mqdec_setctxs(mqdec, 0, 0);
-
-	return mqdec;
+        jpc_mqdec_t *mqdec;
+
+        /* There must be at least one context. */
+        assert(maxctxs > 0);
+
+        /* Allocate memory for the MQ decoder. */
+        if (!(mqdec = jas_malloc(sizeof(jpc_mqdec_t)))) {
+                goto error;
+        }
+        mqdec->in = in;
+        mqdec->maxctxs = maxctxs;
+        /* Allocate memory for the per-context state information. */
+        if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) {
+                goto error;
+        }
+        /* Set the current context to the first context. */
+        mqdec->curctx = mqdec->ctxs;
+
+        /* If an input stream has been associated with the MQ decoder,
+          initialize the decoder state from the stream. */
+        if (mqdec->in) {
+                jpc_mqdec_init(mqdec);
+        }
+        /* Initialize the per-context state information. */
+        jpc_mqdec_setctxs(mqdec, 0, 0);
+
+        return mqdec;
 
 error:
-	/* Oops...  Something has gone wrong. */
-	if (mqdec) {
-		jpc_mqdec_destroy(mqdec);
-	}
-	return 0;
+        /* Oops...  Something has gone wrong. */
+        if (mqdec) {
+                jpc_mqdec_destroy(mqdec);
+        }
+        return 0;
 }
 
 /* Destroy a MQ decoder. */
 void jpc_mqdec_destroy(jpc_mqdec_t *mqdec)
 {
-	if (mqdec->ctxs) {
-		jas_free(mqdec->ctxs);
-	}
-	jas_free(mqdec);
+        if (mqdec->ctxs) {
+                jas_free(mqdec->ctxs);
+        }
+        jas_free(mqdec);
 }
 
 /******************************************************************************\
@@ -208,59 +208,59 @@ void jpc_mqdec_destroy(jpc_mqdec_t *mqdec)
 
 void jpc_mqdec_init(jpc_mqdec_t *mqdec)
 {
-	int c;
-
-	mqdec->eof = 0;
-	mqdec->creg = 0;
-	/* Get the next byte from the input stream. */
-	if ((c = jas_stream_getc(mqdec->in)) == EOF) {
-		/* We have encountered an I/O error or EOF. */
-		c = 0xff;
-		mqdec->eof = 1;
-	}
-	mqdec->inbuffer = c;
-	mqdec->creg += mqdec->inbuffer << 16;
-	jpc_mqdec_bytein(mqdec);
-	mqdec->creg <<= 7;
-	mqdec->ctreg -= 7;
-	mqdec->areg = 0x8000;
+        int c;
+
+        mqdec->eof = 0;
+        mqdec->creg = 0;
+        /* Get the next byte from the input stream. */
+        if ((c = jas_stream_getc(mqdec->in)) == EOF) {
+                /* We have encountered an I/O error or EOF. */
+                c = 0xff;
+                mqdec->eof = 1;
+        }
+        mqdec->inbuffer = c;
+        mqdec->creg += mqdec->inbuffer << 16;
+        jpc_mqdec_bytein(mqdec);
+        mqdec->creg <<= 7;
+        mqdec->ctreg -= 7;
+        mqdec->areg = 0x8000;
 }
 
 /* Set the input stream for a MQ decoder. */
 
 void jpc_mqdec_setinput(jpc_mqdec_t *mqdec, jas_stream_t *in)
 {
-	mqdec->in = in;
+        mqdec->in = in;
 }
 
 /* Initialize one or more contexts. */
 
 void jpc_mqdec_setctxs(jpc_mqdec_t *mqdec, int numctxs, jpc_mqctx_t *ctxs)
 {
-	jpc_mqstate_t **ctx;
-	int n;
-
-	ctx = mqdec->ctxs;
-	n = JAS_MIN(mqdec->maxctxs, numctxs);
-	while (--n >= 0) {
-		*ctx = &jpc_mqstates[2 * ctxs->ind + ctxs->mps];
-		++ctx;
-		++ctxs;
-	}
-	n = mqdec->maxctxs - numctxs;
-	while (--n >= 0) {
-		*ctx = &jpc_mqstates[0];
-		++ctx;
-	}
+        jpc_mqstate_t **ctx;
+        int n;
+
+        ctx = mqdec->ctxs;
+        n = JAS_MIN(mqdec->maxctxs, numctxs);
+        while (--n >= 0) {
+                *ctx = &jpc_mqstates[2 * ctxs->ind + ctxs->mps];
+                ++ctx;
+                ++ctxs;
+        }
+        n = mqdec->maxctxs - numctxs;
+        while (--n >= 0) {
+                *ctx = &jpc_mqstates[0];
+                ++ctx;
+        }
 }
 
 /* Initialize a context. */
 
 void jpc_mqdec_setctx(jpc_mqdec_t *mqdec, int ctxno, jpc_mqctx_t *ctx)
 {
-	jpc_mqstate_t **ctxi;
-	ctxi = &mqdec->ctxs[ctxno];
-	*ctxi = &jpc_mqstates[2 * ctx->ind + ctx->mps];
+        jpc_mqstate_t **ctxi;
+        ctxi = &mqdec->ctxs[ctxno];
+        *ctxi = &jpc_mqstates[2 * ctx->ind + ctx->mps];
 }
 
 /******************************************************************************\
@@ -271,36 +271,36 @@ void jpc_mqdec_setctx(jpc_mqdec_t *mqdec, int ctxno, jpc_mqctx_t *ctx)
 
 int jpc_mqdec_getbit_func(register jpc_mqdec_t *mqdec)
 {
-	int bit;
-	JAS_DBGLOG(100, ("jpc_mqdec_getbit_func(%p)\n", mqdec));
-	MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr));
-	bit = jpc_mqdec_getbit_macro(mqdec);
-	MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr));
-	JAS_DBGLOG(100, ("ctx = %d, decoded %d\n", mqdec->curctx -
-	  mqdec->ctxs, bit));
-	return bit;
+        int bit;
+        JAS_DBGLOG(100, ("jpc_mqdec_getbit_func(%p)\n", mqdec));
+        MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr));
+        bit = jpc_mqdec_getbit_macro(mqdec);
+        MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr));
+        JAS_DBGLOG(100, ("ctx = %d, decoded %d\n", mqdec->curctx -
+          mqdec->ctxs, bit));
+        return bit;
 }
 
 /* Apply MPS_EXCHANGE algorithm (with RENORMD). */
 int jpc_mqdec_mpsexchrenormd(register jpc_mqdec_t *mqdec)
 {
-	int ret;
-	register jpc_mqstate_t *state = *mqdec->curctx;
-	jpc_mqdec_mpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret);
-	jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in,
-	  mqdec->eof, mqdec->inbuffer);
-	return ret;
+        int ret;
+        register jpc_mqstate_t *state = *mqdec->curctx;
+        jpc_mqdec_mpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret);
+        jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in,
+          mqdec->eof, mqdec->inbuffer);
+        return ret;
 }
 
 /* Apply LPS_EXCHANGE algorithm (with RENORMD). */
 int jpc_mqdec_lpsexchrenormd(register jpc_mqdec_t *mqdec)
 {
-	int ret;
-	register jpc_mqstate_t *state = *mqdec->curctx;
-	jpc_mqdec_lpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret);
-	jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in,
-	  mqdec->eof, mqdec->inbuffer);
-	return ret;
+        int ret;
+        register jpc_mqstate_t *state = *mqdec->curctx;
+        jpc_mqdec_lpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret);
+        jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in,
+          mqdec->eof, mqdec->inbuffer);
+        return ret;
 }
 
 /******************************************************************************\
@@ -310,30 +310,30 @@ int jpc_mqdec_lpsexchrenormd(register jpc_mqdec_t *mqdec)
 /* Apply the BYTEIN algorithm. */
 static void jpc_mqdec_bytein(jpc_mqdec_t *mqdec)
 {
-	int c;
-	unsigned char prevbuf;
-
-	if (!mqdec->eof) {
-		if ((c = jas_stream_getc(mqdec->in)) == EOF) {
-			mqdec->eof = 1;
-			c = 0xff;
-		}
-		prevbuf = mqdec->inbuffer;
-		mqdec->inbuffer = c;
-		if (prevbuf == 0xff) {
-			if (c > 0x8f) {
-				mqdec->creg += 0xff00;
-				mqdec->ctreg = 8;
-			} else {
-				mqdec->creg += c << 9;
-				mqdec->ctreg = 7;
-			}
-		} else {
-			mqdec->creg += c << 8;
-			mqdec->ctreg = 8;
-		}
-	} else {
-		mqdec->creg += 0xff00;
-		mqdec->ctreg = 8;
-	}
+        int c;
+        unsigned char prevbuf;
+
+        if (!mqdec->eof) {
+                if ((c = jas_stream_getc(mqdec->in)) == EOF) {
+                        mqdec->eof = 1;
+                        c = 0xff;
+                }
+                prevbuf = mqdec->inbuffer;
+                mqdec->inbuffer = c;
+                if (prevbuf == 0xff) {
+                        if (c > 0x8f) {
+                                mqdec->creg += 0xff00;
+                                mqdec->ctreg = 8;
+                        } else {
+                                mqdec->creg += c << 9;
+                                mqdec->ctreg = 7;
+                        }
+                } else {
+                        mqdec->creg += c << 8;
+                        mqdec->ctreg = 8;
+                }
+        } else {
+                mqdec->creg += 0xff00;
+                mqdec->ctreg = 8;
+        }
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h
index 30185506..b207c92b 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -136,32 +136,32 @@
 
 typedef struct {
 
-	/* The C register. */
-	uint_fast32_t creg;
+        /* The C register. */
+        uint_fast32_t creg;
 
-	/* The A register. */
-	uint_fast32_t areg;
+        /* The A register. */
+        uint_fast32_t areg;
 
-	/* The CT register. */
-	uint_fast32_t ctreg;
+        /* The CT register. */
+        uint_fast32_t ctreg;
 
-	/* The current context. */
-	jpc_mqstate_t **curctx;
+        /* The current context. */
+        jpc_mqstate_t **curctx;
 
-	/* The per-context information. */
-	jpc_mqstate_t **ctxs;
+        /* The per-context information. */
+        jpc_mqstate_t **ctxs;
 
-	/* The maximum number of contexts. */
-	int maxctxs;
+        /* The maximum number of contexts. */
+        int maxctxs;
 
-	/* The stream from which to read data. */
-	jas_stream_t *in;
+        /* The stream from which to read data. */
+        jas_stream_t *in;
 
-	/* The last character read. */
-	unsigned char inbuffer;
+        /* The last character read. */
+        unsigned char inbuffer;
 
-	/* The EOF indicator. */
-	int eof;
+        /* The EOF indicator. */
+        int eof;
 
 } jpc_mqdec_t;
 
@@ -190,8 +190,8 @@ void jpc_mqdec_init(jpc_mqdec_t *dec);
 \******************************************************************************/
 
 /* Set the current context for a MQ decoder. */
-#define	jpc_mqdec_setcurctx(dec, ctxno) \
-	((mqdec)->curctx = &(mqdec)->ctxs[ctxno]);
+#define jpc_mqdec_setcurctx(dec, ctxno) \
+        ((mqdec)->curctx = &(mqdec)->ctxs[ctxno]);
 
 /* Set the state information for a particular context of a MQ decoder. */
 void jpc_mqdec_setctx(jpc_mqdec_t *dec, int ctxno, jpc_mqctx_t *ctx);
@@ -205,20 +205,20 @@ void jpc_mqdec_setctxs(jpc_mqdec_t *dec, int numctxs, jpc_mqctx_t *ctxs);
 
 /* Decode a symbol. */
 #if !defined(DEBUG)
-#define	jpc_mqdec_getbit(dec) \
-	jpc_mqdec_getbit_macro(dec)
+#define jpc_mqdec_getbit(dec) \
+        jpc_mqdec_getbit_macro(dec)
 #else
-#define	jpc_mqdec_getbit(dec) \
-	jpc_mqdec_getbit_func(dec)
+#define jpc_mqdec_getbit(dec) \
+        jpc_mqdec_getbit_func(dec)
 #endif
 
 /* Decode a symbol (assuming an unskewed probability distribution). */
 #if !defined(DEBUG)
-#define	jpc_mqdec_getbitnoskew(dec) \
-	jpc_mqdec_getbit_macro(dec)
+#define jpc_mqdec_getbitnoskew(dec) \
+        jpc_mqdec_getbit_macro(dec)
 #else
-#define	jpc_mqdec_getbitnoskew(dec) \
-	jpc_mqdec_getbit_func(dec)
+#define jpc_mqdec_getbitnoskew(dec) \
+        jpc_mqdec_getbit_func(dec)
 #endif
 
 /******************************************************************************\
@@ -234,83 +234,83 @@ void mqdec_dump(jpc_mqdec_t *dec, FILE *out);
 * GIVEN BELOW.
 \******************************************************************************/
 
-#define	jpc_mqdec_getbit_macro(dec) \
-	((((dec)->areg -= (*(dec)->curctx)->qeval), \
-	  (dec)->creg >> 16 >= (*(dec)->curctx)->qeval) ? \
-	  ((((dec)->creg -= (*(dec)->curctx)->qeval << 16), \
-	  (dec)->areg & 0x8000) ?  (*(dec)->curctx)->mps : \
-	  jpc_mqdec_mpsexchrenormd(dec)) : \
-	  jpc_mqdec_lpsexchrenormd(dec))
+#define jpc_mqdec_getbit_macro(dec) \
+        ((((dec)->areg -= (*(dec)->curctx)->qeval), \
+          (dec)->creg >> 16 >= (*(dec)->curctx)->qeval) ? \
+          ((((dec)->creg -= (*(dec)->curctx)->qeval << 16), \
+          (dec)->areg & 0x8000) ?  (*(dec)->curctx)->mps : \
+          jpc_mqdec_mpsexchrenormd(dec)) : \
+          jpc_mqdec_lpsexchrenormd(dec))
 
-#define	jpc_mqdec_mpsexchange(areg, delta, curctx, bit) \
+#define jpc_mqdec_mpsexchange(areg, delta, curctx, bit) \
 { \
-	if ((areg) < (delta)) { \
-		register jpc_mqstate_t *state = *(curctx); \
-		/* LPS decoded. */ \
-		(bit) = state->mps ^ 1; \
-		*(curctx) = state->nlps; \
-	} else { \
-		register jpc_mqstate_t *state = *(curctx); \
-		/* MPS decoded. */ \
-		(bit) = state->mps; \
-		*(curctx) = state->nmps; \
-	} \
+        if ((areg) < (delta)) { \
+                register jpc_mqstate_t *state = *(curctx); \
+                /* LPS decoded. */ \
+                (bit) = state->mps ^ 1; \
+                *(curctx) = state->nlps; \
+        } else { \
+                register jpc_mqstate_t *state = *(curctx); \
+                /* MPS decoded. */ \
+                (bit) = state->mps; \
+                *(curctx) = state->nmps; \
+        } \
 }
 
-#define	jpc_mqdec_lpsexchange(areg, delta, curctx, bit) \
+#define jpc_mqdec_lpsexchange(areg, delta, curctx, bit) \
 { \
-	if ((areg) >= (delta)) { \
-		register jpc_mqstate_t *state = *(curctx); \
-		(areg) = (delta); \
-		(bit) = state->mps ^ 1; \
-		*(curctx) = state->nlps; \
-	} else { \
-		register jpc_mqstate_t *state = *(curctx); \
-		(areg) = (delta); \
-		(bit) = state->mps; \
-		*(curctx) = state->nmps; \
-	} \
+        if ((areg) >= (delta)) { \
+                register jpc_mqstate_t *state = *(curctx); \
+                (areg) = (delta); \
+                (bit) = state->mps ^ 1; \
+                *(curctx) = state->nlps; \
+        } else { \
+                register jpc_mqstate_t *state = *(curctx); \
+                (areg) = (delta); \
+                (bit) = state->mps; \
+                *(curctx) = state->nmps; \
+        } \
 }
 
-#define	jpc_mqdec_renormd(areg, creg, ctreg, in, eof, inbuf) \
+#define jpc_mqdec_renormd(areg, creg, ctreg, in, eof, inbuf) \
 { \
-	do { \
-		if (!(ctreg)) { \
-			jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf); \
-		} \
-		(areg) <<= 1; \
-		(creg) <<= 1; \
-		--(ctreg); \
-	} while (!((areg) & 0x8000)); \
+        do { \
+                if (!(ctreg)) { \
+                        jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf); \
+                } \
+                (areg) <<= 1; \
+                (creg) <<= 1; \
+                --(ctreg); \
+        } while (!((areg) & 0x8000)); \
 }
 
-#define	jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf) \
+#define jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf) \
 { \
-	int c; \
-	unsigned char prevbuf; \
-	if (!(eof)) { \
-		if ((c = jas_stream_getc(in)) == EOF) { \
-			(eof) = 1; \
-			c = 0xff; \
-		} \
-		prevbuf = (inbuf); \
-		(inbuf) = c; \
-		if (prevbuf == 0xff) { \
-			if (c > 0x8f) { \
-				(creg) += 0xff00; \
-				(ctreg) = 8; \
-			} else { \
-				(creg) += c << 9; \
-				(ctreg) = 7; \
-			} \
-		} else { \
-			(creg) += c << 8; \
-			(ctreg) = 8; \
-		} \
-	} else { \
-		(creg) += 0xff00; \
-		(ctreg) = 8; \
-	} \
+        int c; \
+        unsigned char prevbuf; \
+        if (!(eof)) { \
+                if ((c = jas_stream_getc(in)) == EOF) { \
+                        (eof) = 1; \
+                        c = 0xff; \
+                } \
+                prevbuf = (inbuf); \
+                (inbuf) = c; \
+                if (prevbuf == 0xff) { \
+                        if (c > 0x8f) { \
+                                (creg) += 0xff00; \
+                                (ctreg) = 8; \
+                        } else { \
+                                (creg) += c << 9; \
+                                (ctreg) = 7; \
+                        } \
+                } else { \
+                        (creg) += c << 8; \
+                        (ctreg) = 8; \
+                } \
+        } else { \
+                (creg) += 0xff00; \
+                (ctreg) = 8; \
+        } \
 }
 
 int jpc_mqdec_getbit_func(jpc_mqdec_t *dec);
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h
index 1421ae4d..4a1be355 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -136,8 +136,8 @@
  * Termination modes.
  */
 
-#define	JPC_MQENC_DEFTERM	0	/* default termination */
-#define	JPC_MQENC_PTERM		1	/* predictable termination */
+#define JPC_MQENC_DEFTERM       0       /* default termination */
+#define JPC_MQENC_PTERM         1       /* predictable termination */
 
 /******************************************************************************\
 * Types.
@@ -147,53 +147,53 @@
 
 typedef struct {
 
-	/* The C register. */
-	uint_fast32_t creg;
+        /* The C register. */
+        uint_fast32_t creg;
 
-	/* The A register. */
-	uint_fast32_t areg;
+        /* The A register. */
+        uint_fast32_t areg;
 
-	/* The CT register. */
-	uint_fast32_t ctreg;
+        /* The CT register. */
+        uint_fast32_t ctreg;
 
-	/* The maximum number of contexts. */
-	int maxctxs;
+        /* The maximum number of contexts. */
+        int maxctxs;
 
-	/* The per-context information. */
-	jpc_mqstate_t **ctxs;
+        /* The per-context information. */
+        jpc_mqstate_t **ctxs;
 
-	/* The current context. */
-	jpc_mqstate_t **curctx;
+        /* The current context. */
+        jpc_mqstate_t **curctx;
 
-	/* The stream for encoder output. */
-	jas_stream_t *out;
+        /* The stream for encoder output. */
+        jas_stream_t *out;
 
-	/* The byte buffer (i.e., the B variable in the standard). */
-	int_fast16_t outbuf;
+        /* The byte buffer (i.e., the B variable in the standard). */
+        int_fast16_t outbuf;
 
-	/* The last byte output. */
-	int_fast16_t lastbyte;
+        /* The last byte output. */
+        int_fast16_t lastbyte;
 
-	/* The error indicator. */
-	int err;
-	
+        /* The error indicator. */
+        int err;
+       
 } jpc_mqenc_t;
 
 /* MQ arithmetic encoder state information. */
 
 typedef struct {
 
-	/* The A register. */
-	unsigned areg;
+        /* The A register. */
+        unsigned areg;
 
-	/* The C register. */
-	unsigned creg;
+        /* The C register. */
+        unsigned creg;
 
-	/* The CT register. */
-	unsigned ctreg;
+        /* The CT register. */
+        unsigned ctreg;
 
-	/* The last byte output by the encoder. */
-	int lastbyte;
+        /* The last byte output by the encoder. */
+        int lastbyte;
 
 } jpc_mqencstate_t;
 
@@ -219,7 +219,7 @@ void jpc_mqenc_init(jpc_mqenc_t *enc);
 \******************************************************************************/
 
 /* Set the current context. */
-#define	jpc_mqenc_setcurctx(enc, ctxno) \
+#define jpc_mqenc_setcurctx(enc, ctxno) \
         ((enc)->curctx = &(enc)->ctxs[ctxno]);
 
 /* Set the state information for a particular context. */
@@ -233,8 +233,8 @@ void jpc_mqenc_setctxs(jpc_mqenc_t *enc, int numctxs, jpc_mqctx_t *ctxs);
 \******************************************************************************/
 
 /* Get the error state of a MQ encoder. */
-#define	jpc_mqenc_error(enc) \
-	((enc)->err)
+#define jpc_mqenc_error(enc) \
+        ((enc)->err)
 
 /* Get the current encoder state. */
 void jpc_mqenc_getstate(jpc_mqenc_t *enc, jpc_mqencstate_t *state);
@@ -248,9 +248,9 @@ int jpc_mqenc_flush(jpc_mqenc_t *enc, int termmode);
 
 /* Encode a bit. */
 #if !defined(DEBUG)
-#define	jpc_mqenc_putbit(enc, bit)	jpc_mqenc_putbit_macro(enc, bit)
+#define jpc_mqenc_putbit(enc, bit)      jpc_mqenc_putbit_macro(enc, bit)
 #else
-#define	jpc_mqenc_putbit(enc, bit)	jpc_mqenc_putbit_func(enc, bit)
+#define jpc_mqenc_putbit(enc, bit)      jpc_mqenc_putbit_func(enc, bit)
 #endif
 
 /******************************************************************************\
@@ -265,12 +265,12 @@ int jpc_mqenc_dump(jpc_mqenc_t *mqenc, FILE *out);
 
 /* Note: This macro is included only to satisfy the needs of
   the mqenc_putbit macro. */
-#define	jpc_mqenc_putbit_macro(enc, bit) \
-	(((*((enc)->curctx))->mps == (bit)) ? \
-	  (((enc)->areg -= (*(enc)->curctx)->qeval), \
-	  ((!((enc)->areg & 0x8000)) ? (jpc_mqenc_codemps2(enc)) : \
-	  ((enc)->creg += (*(enc)->curctx)->qeval))) : \
-	  jpc_mqenc_codelps(enc))
+#define jpc_mqenc_putbit_macro(enc, bit) \
+        (((*((enc)->curctx))->mps == (bit)) ? \
+          (((enc)->areg -= (*(enc)->curctx)->qeval), \
+          ((!((enc)->areg & 0x8000)) ? (jpc_mqenc_codemps2(enc)) : \
+          ((enc)->creg += (*(enc)->curctx)->qeval))) : \
+          jpc_mqenc_codelps(enc))
 
 /* Note: These function prototypes are included only to satisfy the
   needs of the mqenc_putbit_macro macro.  Do not call any of these
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c
index 80bc5aa5..3962f5ad 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -153,19 +153,19 @@ static void jpc_ns_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
 \******************************************************************************/
 
 jpc_qmfb1dops_t jpc_ft_ops = {
-	jpc_ft_getnumchans,
-	jpc_ft_getanalfilters,
-	jpc_ft_getsynfilters,
-	jpc_ft_analyze,
-	jpc_ft_synthesize
+        jpc_ft_getnumchans,
+        jpc_ft_getanalfilters,
+        jpc_ft_getsynfilters,
+        jpc_ft_analyze,
+        jpc_ft_synthesize
 };
 
 jpc_qmfb1dops_t jpc_ns_ops = {
-	jpc_ns_getnumchans,
-	jpc_ns_getanalfilters,
-	jpc_ns_getsynfilters,
-	jpc_ns_analyze,
-	jpc_ns_synthesize
+        jpc_ns_getnumchans,
+        jpc_ns_getanalfilters,
+        jpc_ns_getsynfilters,
+        jpc_ns_analyze,
+        jpc_ns_synthesize
 };
 
 /******************************************************************************\
@@ -176,12 +176,12 @@ static void jpc_qmfb1d_setup(jpc_fix_t *startptr, int startind, int endind,
   int intrastep, jpc_fix_t **lstartptr, int *lstartind, int *lendind,
   jpc_fix_t **hstartptr, int *hstartind, int *hendind)
 {
-	*lstartind = JPC_CEILDIVPOW2(startind, 1);
-	*lendind = JPC_CEILDIVPOW2(endind, 1);
-	*hstartind = JPC_FLOORDIVPOW2(startind, 1);
-	*hendind = JPC_FLOORDIVPOW2(endind, 1);
-	*lstartptr = startptr;
-	*hstartptr = &startptr[(*lendind - *lstartind) * intrastep];
+        *lstartind = JPC_CEILDIVPOW2(startind, 1);
+        *lendind = JPC_CEILDIVPOW2(endind, 1);
+        *hstartind = JPC_FLOORDIVPOW2(startind, 1);
+        *hendind = JPC_FLOORDIVPOW2(endind, 1);
+        *lstartptr = startptr;
+        *hstartptr = &startptr[(*lendind - *lstartind) * intrastep];
 }
 
 static void jpc_qmfb1d_split(jpc_fix_t *startptr, int startind, int endind,
@@ -189,204 +189,204 @@ static void jpc_qmfb1d_split(jpc_fix_t *startptr, int startind, int endind,
   jpc_fix_t *hstartptr, int hstartind, int hendind)
 {
 #define QMFB_SPLITBUFSIZE 4096
-	jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];
-	jpc_fix_t *buf = splitbuf;
-	int llen;
-	int hlen;
-	int twostep;
-	jpc_fix_t *tmpptr;
-	register jpc_fix_t *ptr;
-	register jpc_fix_t *hptr;
-	register jpc_fix_t *lptr;
-	register int n;
-	int state;
-
-	twostep = step << 1;
-	llen = lendind - lstartind;
-	hlen = hendind - hstartind;
-
-	if (hstartind < lstartind) {
-		/* The first sample in the input signal is to appear
-		  in the highpass subband signal. */
-		/* Copy the appropriate samples into the lowpass subband
-		  signal, saving any samples destined for the highpass subband
-		  signal as they are overwritten. */
-		tmpptr = buf;
-		ptr = &startptr[step];
-		lptr = lstartptr;
-		n = llen;
-		state = 1;
-		while (n-- > 0) {
-			if (state) {
-				*tmpptr = *lptr;
-				++tmpptr;
-			}
-			*lptr = *ptr;
-			ptr += twostep;
-			lptr += step;
-			state ^= 1;
-		}
-		/* Copy the appropriate samples into the highpass subband
-		  signal. */
-		/* Handle the nonoverwritten samples. */
-		hptr = &hstartptr[(hlen - 1) * step];
-		ptr = &startptr[(((llen + hlen - 1) >> 1) << 1) * step];
-		n = hlen - (tmpptr - buf);
-		while (n-- > 0) {
-			*hptr = *ptr;
-			hptr -= step;
-			ptr -= twostep;
-		}
-		/* Handle the overwritten samples. */
-		n = tmpptr - buf;
-		while (n-- > 0) {
-			--tmpptr;
-			*hptr = *tmpptr;
-			hptr -= step;
-		}
-	} else {
-		/* The first sample in the input signal is to appear
-		  in the lowpass subband signal. */
-		/* Copy the appropriate samples into the lowpass subband
-		  signal, saving any samples for the highpass subband
-		  signal as they are overwritten. */
-		state = 0;
-		ptr = startptr;
-		lptr = lstartptr;
-		tmpptr = buf;
-		n = llen;
-		while (n-- > 0) {
-			if (state) {
-				*tmpptr = *lptr;
-				++tmpptr;
-			}
-			*lptr = *ptr;
-			ptr += twostep;
-			lptr += step;
-			state ^= 1;
-		}
-		/* Copy the appropriate samples into the highpass subband
-		  signal. */
-		/* Handle the nonoverwritten samples. */
-		ptr = &startptr[((((llen + hlen) >> 1) << 1) - 1) * step];
-		hptr = &hstartptr[(hlen - 1) * step];
-		n = hlen - (tmpptr - buf);
-		while (n-- > 0) {
-			*hptr = *ptr;
-			ptr -= twostep;
-			hptr -= step;
-		}
-		/* Handle the overwritten samples. */
-		n = tmpptr - buf;
-		while (n-- > 0) {
-			--tmpptr;
-			*hptr = *tmpptr;
-			hptr -= step;
-		}
-	}
+        jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];
+        jpc_fix_t *buf = splitbuf;
+        int llen;
+        int hlen;
+        int twostep;
+        jpc_fix_t *tmpptr;
+        register jpc_fix_t *ptr;
+        register jpc_fix_t *hptr;
+        register jpc_fix_t *lptr;
+        register int n;
+        int state;
+
+        twostep = step << 1;
+        llen = lendind - lstartind;
+        hlen = hendind - hstartind;
+
+        if (hstartind < lstartind) {
+                /* The first sample in the input signal is to appear
+                  in the highpass subband signal. */
+                /* Copy the appropriate samples into the lowpass subband
+                  signal, saving any samples destined for the highpass subband
+                  signal as they are overwritten. */
+                tmpptr = buf;
+                ptr = &startptr[step];
+                lptr = lstartptr;
+                n = llen;
+                state = 1;
+                while (n-- > 0) {
+                        if (state) {
+                                *tmpptr = *lptr;
+                                ++tmpptr;
+                        }
+                        *lptr = *ptr;
+                        ptr += twostep;
+                        lptr += step;
+                        state ^= 1;
+                }
+                /* Copy the appropriate samples into the highpass subband
+                  signal. */
+                /* Handle the nonoverwritten samples. */
+                hptr = &hstartptr[(hlen - 1) * step];
+                ptr = &startptr[(((llen + hlen - 1) >> 1) << 1) * step];
+                n = hlen - (tmpptr - buf);
+                while (n-- > 0) {
+                        *hptr = *ptr;
+                        hptr -= step;
+                        ptr -= twostep;
+                }
+                /* Handle the overwritten samples. */
+                n = tmpptr - buf;
+                while (n-- > 0) {
+                        --tmpptr;
+                        *hptr = *tmpptr;
+                        hptr -= step;
+                }
+        } else {
+                /* The first sample in the input signal is to appear
+                  in the lowpass subband signal. */
+                /* Copy the appropriate samples into the lowpass subband
+                  signal, saving any samples for the highpass subband
+                  signal as they are overwritten. */
+                state = 0;
+                ptr = startptr;
+                lptr = lstartptr;
+                tmpptr = buf;
+                n = llen;
+                while (n-- > 0) {
+                        if (state) {
+                                *tmpptr = *lptr;
+                                ++tmpptr;
+                        }
+                        *lptr = *ptr;
+                        ptr += twostep;
+                        lptr += step;
+                        state ^= 1;
+                }
+                /* Copy the appropriate samples into the highpass subband
+                  signal. */
+                /* Handle the nonoverwritten samples. */
+                ptr = &startptr[((((llen + hlen) >> 1) << 1) - 1) * step];
+                hptr = &hstartptr[(hlen - 1) * step];
+                n = hlen - (tmpptr - buf);
+                while (n-- > 0) {
+                        *hptr = *ptr;
+                        ptr -= twostep;
+                        hptr -= step;
+                }
+                /* Handle the overwritten samples. */
+                n = tmpptr - buf;
+                while (n-- > 0) {
+                        --tmpptr;
+                        *hptr = *tmpptr;
+                        hptr -= step;
+                }
+        }
 }
 
 static void jpc_qmfb1d_join(jpc_fix_t *startptr, int startind, int endind,
   register int step, jpc_fix_t *lstartptr, int lstartind, int lendind,
   jpc_fix_t *hstartptr, int hstartind, int hendind)
 {
-#define	QMFB_JOINBUFSIZE	4096
-	jpc_fix_t joinbuf[QMFB_JOINBUFSIZE];
-	jpc_fix_t *buf = joinbuf;
-	int llen;
-	int hlen;
-	int twostep;
-	jpc_fix_t *tmpptr;
-	register jpc_fix_t *ptr;
-	register jpc_fix_t *hptr;
-	register jpc_fix_t *lptr;
-	register int n;
-	int state;
-
-	twostep = step << 1;
-	llen = lendind - lstartind;
-	hlen = hendind - hstartind;
-
-	if (hstartind < lstartind) {
-		/* The first sample in the highpass subband signal is to
-		  appear first in the output signal. */
-		/* Copy the appropriate samples into the first phase of the
-		  output signal. */
-		tmpptr = buf;
-		hptr = hstartptr;
-		ptr = startptr;
-		n = (llen + 1) >> 1;
-		while (n-- > 0) {
-			*tmpptr = *ptr;
-			*ptr = *hptr;
-			++tmpptr;
-			ptr += twostep;
-			hptr += step;
-		}
-		n = hlen - ((llen + 1) >> 1);
-		while (n-- > 0) {
-			*ptr = *hptr;
-			ptr += twostep;
-			hptr += step;
-		}
-		/* Copy the appropriate samples into the second phase of
-		  the output signal. */
-		ptr -= (lendind > hendind) ? (step) : (step + twostep);
-		state = !((llen - 1) & 1);
-		lptr = &lstartptr[(llen - 1) * step];
-		n = llen;
-		while (n-- > 0) {
-			if (state) {
-				--tmpptr;
-				*ptr = *tmpptr;
-			} else {
-				*ptr = *lptr;
-			}
-			lptr -= step;
-			ptr -= twostep;
-			state ^= 1;
-		}
-	} else {
-		/* The first sample in the lowpass subband signal is to
-		  appear first in the output signal. */
-		/* Copy the appropriate samples into the first phase of the
-		  output signal (corresponding to even indexed samples). */
-		lptr = &lstartptr[(llen - 1) * step];
-		ptr = &startptr[((llen - 1) << 1) * step];
-		n = llen >> 1;
-		tmpptr = buf;
-		while (n-- > 0) {
-			*tmpptr = *ptr;
-			*ptr = *lptr;
-			++tmpptr;
-			ptr -= twostep;
-			lptr -= step;
-		}
-		n = llen - (llen >> 1);
-		while (n-- > 0) {
-			*ptr = *lptr;
-			ptr -= twostep;
-			lptr -= step;
-		}
-		/* Copy the appropriate samples into the second phase of
-		  the output signal (corresponding to odd indexed
-		  samples). */
-		ptr = &startptr[step];
-		hptr = hstartptr;
-		state = !(llen & 1);
-		n = hlen;
-		while (n-- > 0) {
-			if (state) {
-				--tmpptr;
-				*ptr = *tmpptr;
-			} else {
-				*ptr = *hptr;
-			}
-			hptr += step;
-			ptr += twostep;
-			state ^= 1;
-		}
-	}
+#define QMFB_JOINBUFSIZE        4096
+        jpc_fix_t joinbuf[QMFB_JOINBUFSIZE];
+        jpc_fix_t *buf = joinbuf;
+        int llen;
+        int hlen;
+        int twostep;
+        jpc_fix_t *tmpptr;
+        register jpc_fix_t *ptr;
+        register jpc_fix_t *hptr;
+        register jpc_fix_t *lptr;
+        register int n;
+        int state;
+
+        twostep = step << 1;
+        llen = lendind - lstartind;
+        hlen = hendind - hstartind;
+
+        if (hstartind < lstartind) {
+                /* The first sample in the highpass subband signal is to
+                  appear first in the output signal. */
+                /* Copy the appropriate samples into the first phase of the
+                  output signal. */
+                tmpptr = buf;
+                hptr = hstartptr;
+                ptr = startptr;
+                n = (llen + 1) >> 1;
+                while (n-- > 0) {
+                        *tmpptr = *ptr;
+                        *ptr = *hptr;
+                        ++tmpptr;
+                        ptr += twostep;
+                        hptr += step;
+                }
+                n = hlen - ((llen + 1) >> 1);
+                while (n-- > 0) {
+                        *ptr = *hptr;
+                        ptr += twostep;
+                        hptr += step;
+                }
+                /* Copy the appropriate samples into the second phase of
+                  the output signal. */
+                ptr -= (lendind > hendind) ? (step) : (step + twostep);
+                state = !((llen - 1) & 1);
+                lptr = &lstartptr[(llen - 1) * step];
+                n = llen;
+                while (n-- > 0) {
+                        if (state) {
+                                --tmpptr;
+                                *ptr = *tmpptr;
+                        } else {
+                                *ptr = *lptr;
+                        }
+                        lptr -= step;
+                        ptr -= twostep;
+                        state ^= 1;
+                }
+        } else {
+                /* The first sample in the lowpass subband signal is to
+                  appear first in the output signal. */
+                /* Copy the appropriate samples into the first phase of the
+                  output signal (corresponding to even indexed samples). */
+                lptr = &lstartptr[(llen - 1) * step];
+                ptr = &startptr[((llen - 1) << 1) * step];
+                n = llen >> 1;
+                tmpptr = buf;
+                while (n-- > 0) {
+                        *tmpptr = *ptr;
+                        *ptr = *lptr;
+                        ++tmpptr;
+                        ptr -= twostep;
+                        lptr -= step;
+                }
+                n = llen - (llen >> 1);
+                while (n-- > 0) {
+                        *ptr = *lptr;
+                        ptr -= twostep;
+                        lptr -= step;
+                }
+                /* Copy the appropriate samples into the second phase of
+                  the output signal (corresponding to odd indexed
+                  samples). */
+                ptr = &startptr[step];
+                hptr = hstartptr;
+                state = !(llen & 1);
+                n = hlen;
+                while (n-- > 0) {
+                        if (state) {
+                                --tmpptr;
+                                *ptr = *tmpptr;
+                        } else {
+                                *ptr = *hptr;
+                        }
+                        hptr += step;
+                        ptr += twostep;
+                        state ^= 1;
+                }
+        }
 }
 
 /******************************************************************************\
@@ -395,310 +395,310 @@ static void jpc_qmfb1d_join(jpc_fix_t *startptr, int startind, int endind,
 
 static int jpc_ft_getnumchans(jpc_qmfb1d_t *qmfb)
 {
-	return 2;
+        return 2;
 }
 
 static int jpc_ft_getanalfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
 {
-	abort();
-	return -1;
+        abort();
+        return -1;
 }
 
 static int jpc_ft_getsynfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
 {
-	jas_seq_t *lf;
-	jas_seq_t *hf;
-
-	lf = 0;
-	hf = 0;
-
-	if (len > 1 || (!len)) {
-		if (!(lf = jas_seq_create(-1, 2))) {
-			goto error;
-		}
-		jas_seq_set(lf, -1, jpc_dbltofix(0.5));
-		jas_seq_set(lf, 0, jpc_dbltofix(1.0));
-		jas_seq_set(lf, 1, jpc_dbltofix(0.5));
-		if (!(hf = jas_seq_create(-1, 4))) {
-			goto error;
-		}
-		jas_seq_set(hf, -1, jpc_dbltofix(-0.125));
-		jas_seq_set(hf, 0, jpc_dbltofix(-0.25));
-		jas_seq_set(hf, 1, jpc_dbltofix(0.75));
-		jas_seq_set(hf, 2, jpc_dbltofix(-0.25));
-		jas_seq_set(hf, 3, jpc_dbltofix(-0.125));
-	} else if (len == 1) {
-		if (!(lf = jas_seq_create(0, 1))) {
-			goto error;
-		}
-		jas_seq_set(lf, 0, jpc_dbltofix(1.0));
-		if (!(hf = jas_seq_create(0, 1))) {
-			goto error;
-		}
-		jas_seq_set(hf, 0, jpc_dbltofix(2.0));
-	} else {
-		abort();
-	}
-
-	filters[0] = lf;
-	filters[1] = hf;
-
-	return 0;
+        jas_seq_t *lf;
+        jas_seq_t *hf;
+
+        lf = 0;
+        hf = 0;
+
+        if (len > 1 || (!len)) {
+                if (!(lf = jas_seq_create(-1, 2))) {
+                        goto error;
+                }
+                jas_seq_set(lf, -1, jpc_dbltofix(0.5));
+                jas_seq_set(lf, 0, jpc_dbltofix(1.0));
+                jas_seq_set(lf, 1, jpc_dbltofix(0.5));
+                if (!(hf = jas_seq_create(-1, 4))) {
+                        goto error;
+                }
+                jas_seq_set(hf, -1, jpc_dbltofix(-0.125));
+                jas_seq_set(hf, 0, jpc_dbltofix(-0.25));
+                jas_seq_set(hf, 1, jpc_dbltofix(0.75));
+                jas_seq_set(hf, 2, jpc_dbltofix(-0.25));
+                jas_seq_set(hf, 3, jpc_dbltofix(-0.125));
+        } else if (len == 1) {
+                if (!(lf = jas_seq_create(0, 1))) {
+                        goto error;
+                }
+                jas_seq_set(lf, 0, jpc_dbltofix(1.0));
+                if (!(hf = jas_seq_create(0, 1))) {
+                        goto error;
+                }
+                jas_seq_set(hf, 0, jpc_dbltofix(2.0));
+        } else {
+                abort();
+        }
+
+        filters[0] = lf;
+        filters[1] = hf;
+
+        return 0;
 
 error:
-	if (lf) {
-		jas_seq_destroy(lf);
-	}
-	if (hf) {
-		jas_seq_destroy(hf);
-	}
-	return -1;
+        if (lf) {
+                jas_seq_destroy(lf);
+        }
+        if (hf) {
+                jas_seq_destroy(hf);
+        }
+        return -1;
 }
 
-#define	NFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \
+#define NFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \
 { \
-	register jpc_fix_t *lptr = (lstartptr); \
-	register jpc_fix_t *hptr = (hstartptr); \
-	register int n = (hendind) - (hstartind); \
-	if ((hstartind) < (lstartind)) { \
-		pluseq(*hptr, *lptr); \
-		hptr += (step); \
-		--n; \
-	} \
-	if ((hendind) >= (lendind)) { \
-		--n; \
-	} \
-	while (n-- > 0) { \
-		pluseq(*hptr, jpc_fix_asr(jpc_fix_add(*lptr, lptr[(step)]), 1)); \
-		hptr += (step); \
-		lptr += (step); \
-	} \
-	if ((hendind) >= (lendind)) { \
-		pluseq(*hptr, *lptr); \
-	} \
+        register jpc_fix_t *lptr = (lstartptr); \
+        register jpc_fix_t *hptr = (hstartptr); \
+        register int n = (hendind) - (hstartind); \
+        if ((hstartind) < (lstartind)) { \
+                pluseq(*hptr, *lptr); \
+                hptr += (step); \
+                --n; \
+        } \
+        if ((hendind) >= (lendind)) { \
+                --n; \
+        } \
+        while (n-- > 0) { \
+                pluseq(*hptr, jpc_fix_asr(jpc_fix_add(*lptr, lptr[(step)]), 1)); \
+                hptr += (step); \
+                lptr += (step); \
+        } \
+        if ((hendind) >= (lendind)) { \
+                pluseq(*hptr, *lptr); \
+        } \
 }
 
-#define	NFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \
+#define NFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \
 { \
-	register jpc_fix_t *lptr = (lstartptr); \
-	register jpc_fix_t *hptr = (hstartptr); \
-	register int n = (lendind) - (lstartind); \
-	if ((hstartind) >= (lstartind)) { \
-		pluseq(*lptr, *hptr); \
-		lptr += (step); \
-		--n; \
-	} \
-	if ((lendind) > (hendind)) { \
-		--n; \
-	} \
-	while (n-- > 0) { \
-		pluseq(*lptr, jpc_fix_asr(jpc_fix_add(*hptr, hptr[(step)]), 2)); \
-		lptr += (step); \
-		hptr += (step); \
-	} \
-	if ((lendind) > (hendind)) { \
-		pluseq(*lptr, *hptr); \
-	} \
+        register jpc_fix_t *lptr = (lstartptr); \
+        register jpc_fix_t *hptr = (hstartptr); \
+        register int n = (lendind) - (lstartind); \
+        if ((hstartind) >= (lstartind)) { \
+                pluseq(*lptr, *hptr); \
+                lptr += (step); \
+                --n; \
+        } \
+        if ((lendind) > (hendind)) { \
+                --n; \
+        } \
+        while (n-- > 0) { \
+                pluseq(*lptr, jpc_fix_asr(jpc_fix_add(*hptr, hptr[(step)]), 2)); \
+                lptr += (step); \
+                hptr += (step); \
+        } \
+        if ((lendind) > (hendind)) { \
+                pluseq(*lptr, *hptr); \
+        } \
 }
 
-#define	RFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \
+#define RFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \
 { \
-	register jpc_fix_t *lptr = (lstartptr); \
-	register jpc_fix_t *hptr = (hstartptr); \
-	register int n = (hendind) - (hstartind); \
-	if ((hstartind) < (lstartind)) { \
-		*hptr pmeqop *lptr; \
-		hptr += (step); \
-		--n; \
-	} \
-	if ((hendind) >= (lendind)) { \
-		--n; \
-	} \
-	while (n-- > 0) { \
-		*hptr pmeqop (*lptr + lptr[(step)]) >> 1; \
-		hptr += (step); \
-		lptr += (step); \
-	} \
-	if ((hendind) >= (lendind)) { \
-		*hptr pmeqop *lptr; \
-	} \
+        register jpc_fix_t *lptr = (lstartptr); \
+        register jpc_fix_t *hptr = (hstartptr); \
+        register int n = (hendind) - (hstartind); \
+        if ((hstartind) < (lstartind)) { \
+                *hptr pmeqop *lptr; \
+                hptr += (step); \
+                --n; \
+        } \
+        if ((hendind) >= (lendind)) { \
+                --n; \
+        } \
+        while (n-- > 0) { \
+                *hptr pmeqop (*lptr + lptr[(step)]) >> 1; \
+                hptr += (step); \
+                lptr += (step); \
+        } \
+        if ((hendind) >= (lendind)) { \
+                *hptr pmeqop *lptr; \
+        } \
 }
 
-#define	RFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \
+#define RFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \
 { \
-	register jpc_fix_t *lptr = (lstartptr); \
-	register jpc_fix_t *hptr = (hstartptr); \
-	register int n = (lendind) - (lstartind); \
-	if ((hstartind) >= (lstartind)) { \
-		*lptr pmeqop ((*hptr << 1) + 2) >> 2; \
-		lptr += (step); \
-		--n; \
-	} \
-	if ((lendind) > (hendind)) { \
-		--n; \
-	} \
-	while (n-- > 0) { \
-		*lptr pmeqop ((*hptr + hptr[(step)]) + 2) >> 2; \
-		lptr += (step); \
-		hptr += (step); \
-	} \
-	if ((lendind) > (hendind)) { \
-		*lptr pmeqop ((*hptr << 1) + 2) >> 2; \
-	} \
+        register jpc_fix_t *lptr = (lstartptr); \
+        register jpc_fix_t *hptr = (hstartptr); \
+        register int n = (lendind) - (lstartind); \
+        if ((hstartind) >= (lstartind)) { \
+                *lptr pmeqop ((*hptr << 1) + 2) >> 2; \
+                lptr += (step); \
+                --n; \
+        } \
+        if ((lendind) > (hendind)) { \
+                --n; \
+        } \
+        while (n-- > 0) { \
+                *lptr pmeqop ((*hptr + hptr[(step)]) + 2) >> 2; \
+                lptr += (step); \
+                hptr += (step); \
+        } \
+        if ((lendind) > (hendind)) { \
+                *lptr pmeqop ((*hptr << 1) + 2) >> 2; \
+        } \
 }
 
 static void jpc_ft_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 {
-	jpc_fix_t *startptr;
-	int startind;
-	int endind;
-	jpc_fix_t *  lstartptr;
-	int   lstartind;
-	int   lendind;
-	jpc_fix_t *  hstartptr;
-	int   hstartind;
-	int   hendind;
-	int interstep;
-	int intrastep;
-	int numseq;
-
-	if (flags & JPC_QMFB1D_VERT) {
-		interstep = 1;
-		intrastep = jas_seq2d_rowstep(x);
-		numseq = jas_seq2d_width(x);
-		startind = jas_seq2d_ystart(x);
-		endind = jas_seq2d_yend(x);
-	} else {
-		interstep = jas_seq2d_rowstep(x);
-		intrastep = 1;
-		numseq = jas_seq2d_height(x);
-		startind = jas_seq2d_xstart(x);
-		endind = jas_seq2d_xend(x);
-	}
-
-	assert(startind < endind);
-
-	startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
-	if (flags & JPC_QMFB1D_RITIMODE) {
-		while (numseq-- > 0) {
-			jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
-			  &lstartptr, &lstartind, &lendind, &hstartptr,
-			  &hstartind, &hendind);
-			if (endind - startind > 1) {
-				jpc_qmfb1d_split(startptr, startind, endind,
-				  intrastep, lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind);
-				RFT_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep, -=);
-				RFT_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep, +=);
-			} else {
-				if (lstartind == lendind) {
-					*startptr <<= 1;
-				}
-			}
-			startptr += interstep;
-		}
-	} else {
-		while (numseq-- > 0) {
-			jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
-			  &lstartptr, &lstartind, &lendind, &hstartptr,
-			  &hstartind, &hendind);
-			if (endind - startind > 1) {
-				jpc_qmfb1d_split(startptr, startind, endind,
-				  intrastep, lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind);
-				NFT_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_fix_minuseq);
-				NFT_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_fix_pluseq);
-			} else {
-				if (lstartind == lendind) {
-					*startptr = jpc_fix_asl(*startptr, 1);
-				}
-			}
-			startptr += interstep;
-		}
-	}
+        jpc_fix_t *startptr;
+        int startind;
+        int endind;
+        jpc_fix_t *  lstartptr;
+        int   lstartind;
+        int   lendind;
+        jpc_fix_t *  hstartptr;
+        int   hstartind;
+        int   hendind;
+        int interstep;
+        int intrastep;
+        int numseq;
+
+        if (flags & JPC_QMFB1D_VERT) {
+                interstep = 1;
+                intrastep = jas_seq2d_rowstep(x);
+                numseq = jas_seq2d_width(x);
+                startind = jas_seq2d_ystart(x);
+                endind = jas_seq2d_yend(x);
+        } else {
+                interstep = jas_seq2d_rowstep(x);
+                intrastep = 1;
+                numseq = jas_seq2d_height(x);
+                startind = jas_seq2d_xstart(x);
+                endind = jas_seq2d_xend(x);
+        }
+
+        assert(startind < endind);
+
+        startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
+        if (flags & JPC_QMFB1D_RITIMODE) {
+                while (numseq-- > 0) {
+                        jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
+                          &lstartptr, &lstartind, &lendind, &hstartptr,
+                          &hstartind, &hendind);
+                        if (endind - startind > 1) {
+                                jpc_qmfb1d_split(startptr, startind, endind,
+                                  intrastep, lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind);
+                                RFT_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep, -=);
+                                RFT_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep, +=);
+                        } else {
+                                if (lstartind == lendind) {
+                                        *startptr <<= 1;
+                                }
+                        }
+                        startptr += interstep;
+                }
+        } else {
+                while (numseq-- > 0) {
+                        jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
+                          &lstartptr, &lstartind, &lendind, &hstartptr,
+                          &hstartind, &hendind);
+                        if (endind - startind > 1) {
+                                jpc_qmfb1d_split(startptr, startind, endind,
+                                  intrastep, lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind);
+                                NFT_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_fix_minuseq);
+                                NFT_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_fix_pluseq);
+                        } else {
+                                if (lstartind == lendind) {
+                                        *startptr = jpc_fix_asl(*startptr, 1);
+                                }
+                        }
+                        startptr += interstep;
+                }
+        }
 }
 
 static void jpc_ft_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 {
-	jpc_fix_t *startptr;
-	int startind;
-	int endind;
-	jpc_fix_t *lstartptr;
-	int lstartind;
-	int lendind;
-	jpc_fix_t *hstartptr;
-	int hstartind;
-	int hendind;
-	int interstep;
-	int intrastep;
-	int numseq;
-
-	if (flags & JPC_QMFB1D_VERT) {
-		interstep = 1;
-		intrastep = jas_seq2d_rowstep(x);
-		numseq = jas_seq2d_width(x);
-		startind = jas_seq2d_ystart(x);
-		endind = jas_seq2d_yend(x);
-	} else {
-		interstep = jas_seq2d_rowstep(x);
-		intrastep = 1;
-		numseq = jas_seq2d_height(x);
-		startind = jas_seq2d_xstart(x);
-		endind = jas_seq2d_xend(x);
-	}
-
-	assert(startind < endind);
-
-	startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
-	if (flags & JPC_QMFB1D_RITIMODE) {
-		while (numseq-- > 0) {
-			jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
-			  &lstartptr, &lstartind, &lendind, &hstartptr,
-			  &hstartind, &hendind);
-			if (endind - startind > 1) {
-				RFT_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep, -=);
-				RFT_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep, +=);
-				jpc_qmfb1d_join(startptr, startind, endind,
-				  intrastep, lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind);
-			} else {
-				if (lstartind == lendind) {
-					*startptr >>= 1;
-				}
-			}
-			startptr += interstep;
-		}
-	} else {
-		while (numseq-- > 0) {
-			jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
-			  &lstartptr, &lstartind, &lendind, &hstartptr,
-			  &hstartind, &hendind);
-			if (endind - startind > 1) {
-				NFT_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_fix_minuseq);
-				NFT_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_fix_pluseq);
-				jpc_qmfb1d_join(startptr, startind, endind,
-				  intrastep, lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind);
-			} else {
-				if (lstartind == lendind) {
-					*startptr = jpc_fix_asr(*startptr, 1);
-				}
-			}
-			startptr += interstep;
-		}
-	}
+        jpc_fix_t *startptr;
+        int startind;
+        int endind;
+        jpc_fix_t *lstartptr;
+        int lstartind;
+        int lendind;
+        jpc_fix_t *hstartptr;
+        int hstartind;
+        int hendind;
+        int interstep;
+        int intrastep;
+        int numseq;
+
+        if (flags & JPC_QMFB1D_VERT) {
+                interstep = 1;
+                intrastep = jas_seq2d_rowstep(x);
+                numseq = jas_seq2d_width(x);
+                startind = jas_seq2d_ystart(x);
+                endind = jas_seq2d_yend(x);
+        } else {
+                interstep = jas_seq2d_rowstep(x);
+                intrastep = 1;
+                numseq = jas_seq2d_height(x);
+                startind = jas_seq2d_xstart(x);
+                endind = jas_seq2d_xend(x);
+        }
+
+        assert(startind < endind);
+
+        startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
+        if (flags & JPC_QMFB1D_RITIMODE) {
+                while (numseq-- > 0) {
+                        jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
+                          &lstartptr, &lstartind, &lendind, &hstartptr,
+                          &hstartind, &hendind);
+                        if (endind - startind > 1) {
+                                RFT_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep, -=);
+                                RFT_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep, +=);
+                                jpc_qmfb1d_join(startptr, startind, endind,
+                                  intrastep, lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind);
+                        } else {
+                                if (lstartind == lendind) {
+                                        *startptr >>= 1;
+                                }
+                        }
+                        startptr += interstep;
+                }
+        } else {
+                while (numseq-- > 0) {
+                        jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
+                          &lstartptr, &lstartind, &lendind, &hstartptr,
+                          &hstartind, &hendind);
+                        if (endind - startind > 1) {
+                                NFT_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_fix_minuseq);
+                                NFT_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_fix_pluseq);
+                                jpc_qmfb1d_join(startptr, startind, endind,
+                                  intrastep, lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind);
+                        } else {
+                                if (lstartind == lendind) {
+                                        *startptr = jpc_fix_asr(*startptr, 1);
+                                }
+                        }
+                        startptr += interstep;
+                }
+        }
 }
 
 /******************************************************************************\
@@ -707,276 +707,276 @@ static void jpc_ft_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 
 static int jpc_ns_getnumchans(jpc_qmfb1d_t *qmfb)
 {
-	return 2;
+        return 2;
 }
 
 static int jpc_ns_getanalfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
 {
-	abort();
-	return -1;
+        abort();
+        return -1;
 }
 
 static int jpc_ns_getsynfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
 {
-	jas_seq_t *lf;
-	jas_seq_t *hf;
-
-	lf = 0;
-	hf = 0;
-
-	if (len > 1 || (!len)) {
-		if (!(lf = jas_seq_create(-3, 4))) {
-			goto error;
-		}
-		jas_seq_set(lf, -3, jpc_dbltofix(-0.09127176311424948));
-		jas_seq_set(lf, -2, jpc_dbltofix(-0.05754352622849957));
-		jas_seq_set(lf, -1, jpc_dbltofix(0.5912717631142470));
-		jas_seq_set(lf, 0, jpc_dbltofix(1.115087052456994));
-		jas_seq_set(lf, 1, jpc_dbltofix(0.5912717631142470));
-		jas_seq_set(lf, 2, jpc_dbltofix(-0.05754352622849957));
-		jas_seq_set(lf, 3, jpc_dbltofix(-0.09127176311424948));
-		if (!(hf = jas_seq_create(-3, 6))) {
-			goto error;
-		}
-		jas_seq_set(hf, -3, jpc_dbltofix(-0.02674875741080976 * 2.0));
-		jas_seq_set(hf, -2, jpc_dbltofix(-0.01686411844287495 * 2.0));
-		jas_seq_set(hf, -1, jpc_dbltofix(0.07822326652898785 * 2.0));
-		jas_seq_set(hf, 0, jpc_dbltofix(0.2668641184428723 * 2.0));
-		jas_seq_set(hf, 1, jpc_dbltofix(-0.6029490182363579 * 2.0));
-		jas_seq_set(hf, 2, jpc_dbltofix(0.2668641184428723 * 2.0));
-		jas_seq_set(hf, 3, jpc_dbltofix(0.07822326652898785 * 2.0));
-		jas_seq_set(hf, 4, jpc_dbltofix(-0.01686411844287495 * 2.0));
-		jas_seq_set(hf, 5, jpc_dbltofix(-0.02674875741080976 * 2.0));
-	} else if (len == 1) {
-		if (!(lf = jas_seq_create(0, 1))) {
-			goto error;
-		}
-		jas_seq_set(lf, 0, jpc_dbltofix(1.0));
-		if (!(hf = jas_seq_create(0, 1))) {
-			goto error;
-		}
-		jas_seq_set(hf, 0, jpc_dbltofix(2.0));
-	} else {
-		abort();
-	}
-
-	filters[0] = lf;
-	filters[1] = hf;
-
-	return 0;
+        jas_seq_t *lf;
+        jas_seq_t *hf;
+
+        lf = 0;
+        hf = 0;
+
+        if (len > 1 || (!len)) {
+                if (!(lf = jas_seq_create(-3, 4))) {
+                        goto error;
+                }
+                jas_seq_set(lf, -3, jpc_dbltofix(-0.09127176311424948));
+                jas_seq_set(lf, -2, jpc_dbltofix(-0.05754352622849957));
+                jas_seq_set(lf, -1, jpc_dbltofix(0.5912717631142470));
+                jas_seq_set(lf, 0, jpc_dbltofix(1.115087052456994));
+                jas_seq_set(lf, 1, jpc_dbltofix(0.5912717631142470));
+                jas_seq_set(lf, 2, jpc_dbltofix(-0.05754352622849957));
+                jas_seq_set(lf, 3, jpc_dbltofix(-0.09127176311424948));
+                if (!(hf = jas_seq_create(-3, 6))) {
+                        goto error;
+                }
+                jas_seq_set(hf, -3, jpc_dbltofix(-0.02674875741080976 * 2.0));
+                jas_seq_set(hf, -2, jpc_dbltofix(-0.01686411844287495 * 2.0));
+                jas_seq_set(hf, -1, jpc_dbltofix(0.07822326652898785 * 2.0));
+                jas_seq_set(hf, 0, jpc_dbltofix(0.2668641184428723 * 2.0));
+                jas_seq_set(hf, 1, jpc_dbltofix(-0.6029490182363579 * 2.0));
+                jas_seq_set(hf, 2, jpc_dbltofix(0.2668641184428723 * 2.0));
+                jas_seq_set(hf, 3, jpc_dbltofix(0.07822326652898785 * 2.0));
+                jas_seq_set(hf, 4, jpc_dbltofix(-0.01686411844287495 * 2.0));
+                jas_seq_set(hf, 5, jpc_dbltofix(-0.02674875741080976 * 2.0));
+        } else if (len == 1) {
+                if (!(lf = jas_seq_create(0, 1))) {
+                        goto error;
+                }
+                jas_seq_set(lf, 0, jpc_dbltofix(1.0));
+                if (!(hf = jas_seq_create(0, 1))) {
+                        goto error;
+                }
+                jas_seq_set(hf, 0, jpc_dbltofix(2.0));
+        } else {
+                abort();
+        }
+
+        filters[0] = lf;
+        filters[1] = hf;
+
+        return 0;
 
 error:
-	if (lf) {
-		jas_seq_destroy(lf);
-	}
-	if (hf) {
-		jas_seq_destroy(hf);
-	}
-	return -1;
+        if (lf) {
+                jas_seq_destroy(lf);
+        }
+        if (hf) {
+                jas_seq_destroy(hf);
+        }
+        return -1;
 }
 
-#define	NNS_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \
+#define NNS_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \
 { \
-	register jpc_fix_t *lptr = (lstartptr); \
-	register jpc_fix_t *hptr = (hstartptr); \
-	register int n = (hendind) - (hstartind); \
-	jpc_fix_t twoalpha = jpc_fix_mulbyint(alpha, 2); \
-	if ((hstartind) < (lstartind)) { \
-		jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \
-		hptr += (step); \
-		--n; \
-	} \
-	if ((hendind) >= (lendind)) { \
-		--n; \
-	} \
-	while (n-- > 0) { \
-		jpc_fix_pluseq(*hptr, jpc_fix_mul(jpc_fix_add(*lptr, lptr[(step)]), (alpha))); \
-		hptr += (step); \
-		lptr += (step); \
-	} \
-	if ((hendind) >= (lendind)) { \
-		jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \
-	} \
+        register jpc_fix_t *lptr = (lstartptr); \
+        register jpc_fix_t *hptr = (hstartptr); \
+        register int n = (hendind) - (hstartind); \
+        jpc_fix_t twoalpha = jpc_fix_mulbyint(alpha, 2); \
+        if ((hstartind) < (lstartind)) { \
+                jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \
+                hptr += (step); \
+                --n; \
+        } \
+        if ((hendind) >= (lendind)) { \
+                --n; \
+        } \
+        while (n-- > 0) { \
+                jpc_fix_pluseq(*hptr, jpc_fix_mul(jpc_fix_add(*lptr, lptr[(step)]), (alpha))); \
+                hptr += (step); \
+                lptr += (step); \
+        } \
+        if ((hendind) >= (lendind)) { \
+                jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \
+        } \
 }
 
-#define	NNS_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \
+#define NNS_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \
 { \
-	register jpc_fix_t *lptr = (lstartptr); \
-	register jpc_fix_t *hptr = (hstartptr); \
-	register int n = (lendind) - (lstartind); \
-	int twoalpha = jpc_fix_mulbyint(alpha, 2); \
-	if ((hstartind) >= (lstartind)) { \
-		jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \
-		lptr += (step); \
-		--n; \
-	} \
-	if ((lendind) > (hendind)) { \
-		--n; \
-	} \
-	while (n-- > 0) { \
-		jpc_fix_pluseq(*lptr, jpc_fix_mul(jpc_fix_add(*hptr, hptr[(step)]), (alpha))); \
-		lptr += (step); \
-		hptr += (step); \
-	} \
-	if ((lendind) > (hendind)) { \
-		jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \
-	} \
+        register jpc_fix_t *lptr = (lstartptr); \
+        register jpc_fix_t *hptr = (hstartptr); \
+        register int n = (lendind) - (lstartind); \
+        int twoalpha = jpc_fix_mulbyint(alpha, 2); \
+        if ((hstartind) >= (lstartind)) { \
+                jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \
+                lptr += (step); \
+                --n; \
+        } \
+        if ((lendind) > (hendind)) { \
+                --n; \
+        } \
+        while (n-- > 0) { \
+                jpc_fix_pluseq(*lptr, jpc_fix_mul(jpc_fix_add(*hptr, hptr[(step)]), (alpha))); \
+                lptr += (step); \
+                hptr += (step); \
+        } \
+        if ((lendind) > (hendind)) { \
+                jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \
+        } \
 }
 
-#define	NNS_SCALE(startptr, startind, endind, step, alpha) \
+#define NNS_SCALE(startptr, startind, endind, step, alpha) \
 { \
-	register jpc_fix_t *ptr = (startptr); \
-	register int n = (endind) - (startind); \
-	while (n-- > 0) { \
-		jpc_fix_muleq(*ptr, alpha); \
-		ptr += (step); \
-	} \
+        register jpc_fix_t *ptr = (startptr); \
+        register int n = (endind) - (startind); \
+        while (n-- > 0) { \
+                jpc_fix_muleq(*ptr, alpha); \
+                ptr += (step); \
+        } \
 }
 
 static void jpc_ns_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 {
-	jpc_fix_t *startptr;
-	int startind;
-	int endind;
-	jpc_fix_t *lstartptr;
-	int lstartind;
-	int lendind;
-	jpc_fix_t *hstartptr;
-	int hstartind;
-	int hendind;
-	int interstep;
-	int intrastep;
-	int numseq;
-
-	if (flags & JPC_QMFB1D_VERT) {
-		interstep = 1;
-		intrastep = jas_seq2d_rowstep(x);
-		numseq = jas_seq2d_width(x);
-		startind = jas_seq2d_ystart(x);
-		endind = jas_seq2d_yend(x);
-	} else {
-		interstep = jas_seq2d_rowstep(x);
-		intrastep = 1;
-		numseq = jas_seq2d_height(x);
-		startind = jas_seq2d_xstart(x);
-		endind = jas_seq2d_xend(x);
-	}
-
-	assert(startind < endind);
-
-	startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
-	if (!(flags & JPC_QMFB1D_RITIMODE)) {
-		while (numseq-- > 0) {
-			jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
-			  &lstartptr, &lstartind, &lendind, &hstartptr,
-			  &hstartind, &hendind);
-			if (endind - startind > 1) {
-				jpc_qmfb1d_split(startptr, startind, endind,
-				  intrastep, lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind);
-				NNS_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(-1.586134342));
-				NNS_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(-0.052980118));
-				NNS_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(0.882911075));
-				NNS_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(0.443506852));
-				NNS_SCALE(lstartptr, lstartind, lendind,
-				  intrastep, jpc_dbltofix(1.0/1.23017410558578));
-				NNS_SCALE(hstartptr, hstartind, hendind,
-				  intrastep, jpc_dbltofix(1.0/1.62578613134411));
-			} else {
+        jpc_fix_t *startptr;
+        int startind;
+        int endind;
+        jpc_fix_t *lstartptr;
+        int lstartind;
+        int lendind;
+        jpc_fix_t *hstartptr;
+        int hstartind;
+        int hendind;
+        int interstep;
+        int intrastep;
+        int numseq;
+
+        if (flags & JPC_QMFB1D_VERT) {
+                interstep = 1;
+                intrastep = jas_seq2d_rowstep(x);
+                numseq = jas_seq2d_width(x);
+                startind = jas_seq2d_ystart(x);
+                endind = jas_seq2d_yend(x);
+        } else {
+                interstep = jas_seq2d_rowstep(x);
+                intrastep = 1;
+                numseq = jas_seq2d_height(x);
+                startind = jas_seq2d_xstart(x);
+                endind = jas_seq2d_xend(x);
+        }
+
+        assert(startind < endind);
+
+        startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
+        if (!(flags & JPC_QMFB1D_RITIMODE)) {
+                while (numseq-- > 0) {
+                        jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
+                          &lstartptr, &lstartind, &lendind, &hstartptr,
+                          &hstartind, &hendind);
+                        if (endind - startind > 1) {
+                                jpc_qmfb1d_split(startptr, startind, endind,
+                                  intrastep, lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind);
+                                NNS_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(-1.586134342));
+                                NNS_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(-0.052980118));
+                                NNS_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(0.882911075));
+                                NNS_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(0.443506852));
+                                NNS_SCALE(lstartptr, lstartind, lendind,
+                                  intrastep, jpc_dbltofix(1.0/1.23017410558578));
+                                NNS_SCALE(hstartptr, hstartind, hendind,
+                                  intrastep, jpc_dbltofix(1.0/1.62578613134411));
+                        } else {
 #if 0
-				if (lstartind == lendind) {
-					*startptr = jpc_fix_asl(*startptr, 1);
-				}
+                                if (lstartind == lendind) {
+                                        *startptr = jpc_fix_asl(*startptr, 1);
+                                }
 #endif
-			}
-			startptr += interstep;
-		}
-	} else {
-		/* The reversible integer-to-integer mode is not valid for this
-		  transform. */
-		abort();
-	}
+                        }
+                        startptr += interstep;
+                }
+        } else {
+                /* The reversible integer-to-integer mode is not valid for this
+                  transform. */
+                abort();
+        }
 }
 
 static void jpc_ns_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 {
-	jpc_fix_t *startptr;
-	int startind;
-	int endind;
-	jpc_fix_t *lstartptr;
-	int lstartind;
-	int lendind;
-	jpc_fix_t *hstartptr;
-	int hstartind;
-	int hendind;
-	int interstep;
-	int intrastep;
-	int numseq;
-
-	if (flags & JPC_QMFB1D_VERT) {
-		interstep = 1;
-		intrastep = jas_seq2d_rowstep(x);
-		numseq = jas_seq2d_width(x);
-		startind = jas_seq2d_ystart(x);
-		endind = jas_seq2d_yend(x);
-	} else {
-		interstep = jas_seq2d_rowstep(x);
-		intrastep = 1;
-		numseq = jas_seq2d_height(x);
-		startind = jas_seq2d_xstart(x);
-		endind = jas_seq2d_xend(x);
-	}
-
-	assert(startind < endind);
-
-	startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
-	if (!(flags & JPC_QMFB1D_RITIMODE)) {
-		while (numseq-- > 0) {
-			jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
-			  &lstartptr, &lstartind, &lendind, &hstartptr,
-			  &hstartind, &hendind);
-			if (endind - startind > 1) {
-				NNS_SCALE(lstartptr, lstartind, lendind,
-				  intrastep, jpc_dbltofix(1.23017410558578));
-				NNS_SCALE(hstartptr, hstartind, hendind,
-				  intrastep, jpc_dbltofix(1.62578613134411));
-				NNS_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(-0.443506852));
-				NNS_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(-0.882911075));
-				NNS_LIFT1(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(0.052980118));
-				NNS_LIFT0(lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind, intrastep,
-				  jpc_dbltofix(1.586134342));
-				jpc_qmfb1d_join(startptr, startind, endind,
-				  intrastep, lstartptr, lstartind, lendind,
-				  hstartptr, hstartind, hendind);
-			} else {
+        jpc_fix_t *startptr;
+        int startind;
+        int endind;
+        jpc_fix_t *lstartptr;
+        int lstartind;
+        int lendind;
+        jpc_fix_t *hstartptr;
+        int hstartind;
+        int hendind;
+        int interstep;
+        int intrastep;
+        int numseq;
+
+        if (flags & JPC_QMFB1D_VERT) {
+                interstep = 1;
+                intrastep = jas_seq2d_rowstep(x);
+                numseq = jas_seq2d_width(x);
+                startind = jas_seq2d_ystart(x);
+                endind = jas_seq2d_yend(x);
+        } else {
+                interstep = jas_seq2d_rowstep(x);
+                intrastep = 1;
+                numseq = jas_seq2d_height(x);
+                startind = jas_seq2d_xstart(x);
+                endind = jas_seq2d_xend(x);
+        }
+
+        assert(startind < endind);
+
+        startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));
+        if (!(flags & JPC_QMFB1D_RITIMODE)) {
+                while (numseq-- > 0) {
+                        jpc_qmfb1d_setup(startptr, startind, endind, intrastep,
+                          &lstartptr, &lstartind, &lendind, &hstartptr,
+                          &hstartind, &hendind);
+                        if (endind - startind > 1) {
+                                NNS_SCALE(lstartptr, lstartind, lendind,
+                                  intrastep, jpc_dbltofix(1.23017410558578));
+                                NNS_SCALE(hstartptr, hstartind, hendind,
+                                  intrastep, jpc_dbltofix(1.62578613134411));
+                                NNS_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(-0.443506852));
+                                NNS_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(-0.882911075));
+                                NNS_LIFT1(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(0.052980118));
+                                NNS_LIFT0(lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind, intrastep,
+                                  jpc_dbltofix(1.586134342));
+                                jpc_qmfb1d_join(startptr, startind, endind,
+                                  intrastep, lstartptr, lstartind, lendind,
+                                  hstartptr, hstartind, hendind);
+                        } else {
 #if 0
-				if (lstartind == lendind) {
-					*startptr = jpc_fix_asr(*startptr, 1);
-				}
+                                if (lstartind == lendind) {
+                                        *startptr = jpc_fix_asr(*startptr, 1);
+                                }
 #endif
-			}
-			startptr += interstep;
-		}
-	} else {
-		/* The reversible integer-to-integer mode is not valid
+                        }
+                        startptr += interstep;
+                }
+        } else {
+                /* The reversible integer-to-integer mode is not valid
            for this transform. */
-		abort();
-	}
+                abort();
+        }
 }
 
 /******************************************************************************\
@@ -985,49 +985,49 @@ static void jpc_ns_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 
 jpc_qmfb1d_t *jpc_qmfb1d_make(int qmfbid)
 {
-	jpc_qmfb1d_t *qmfb;
-	if (!(qmfb = jpc_qmfb1d_create())) {
-		return 0;
-	}
-	switch (qmfbid) {
-	case JPC_QMFB1D_FT:
-		qmfb->ops = &jpc_ft_ops;
-		break;
-	case JPC_QMFB1D_NS:
-		qmfb->ops = &jpc_ns_ops;
-		break;
-	default:
-		jpc_qmfb1d_destroy(qmfb);
-		return 0;
-		break;
-	}
-	return qmfb;
+        jpc_qmfb1d_t *qmfb;
+        if (!(qmfb = jpc_qmfb1d_create())) {
+                return 0;
+        }
+        switch (qmfbid) {
+        case JPC_QMFB1D_FT:
+                qmfb->ops = &jpc_ft_ops;
+                break;
+        case JPC_QMFB1D_NS:
+                qmfb->ops = &jpc_ns_ops;
+                break;
+        default:
+                jpc_qmfb1d_destroy(qmfb);
+                return 0;
+                break;
+        }
+        return qmfb;
 }
 
 static jpc_qmfb1d_t *jpc_qmfb1d_create()
 {
-	jpc_qmfb1d_t *qmfb;
-	if (!(qmfb = jas_malloc(sizeof(jpc_qmfb1d_t)))) {
-		return 0;
-	}
-	qmfb->ops = 0;
-	return qmfb;
+        jpc_qmfb1d_t *qmfb;
+        if (!(qmfb = jas_malloc(sizeof(jpc_qmfb1d_t)))) {
+                return 0;
+        }
+        qmfb->ops = 0;
+        return qmfb;
 }
 
 jpc_qmfb1d_t *jpc_qmfb1d_copy(jpc_qmfb1d_t *qmfb)
 {
-	jpc_qmfb1d_t *newqmfb;
+        jpc_qmfb1d_t *newqmfb;
 
-	if (!(newqmfb = jpc_qmfb1d_create())) {
-		return 0;
-	}
-	newqmfb->ops = qmfb->ops;
-	return newqmfb;
+        if (!(newqmfb = jpc_qmfb1d_create())) {
+                return 0;
+        }
+        newqmfb->ops = qmfb->ops;
+        return newqmfb;
 }
 
 void jpc_qmfb1d_destroy(jpc_qmfb1d_t *qmfb)
 {
-	jas_free(qmfb);
+        jas_free(qmfb);
 }
 
 /******************************************************************************\
@@ -1038,27 +1038,27 @@ void jpc_qmfb1d_getbands(jpc_qmfb1d_t *qmfb, int flags, uint_fast32_t xstart,
   uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, int maxbands,
   int *numbandsptr, jpc_qmfb1dband_t *bands)
 {
-	int start;
-	int end;
-	if (flags & JPC_QMFB1D_VERT) {
-		start = ystart;
-		end = yend;
-	} else {
-		start = xstart;
-		end = xend;
-	}
-	assert(jpc_qmfb1d_getnumchans(qmfb) == 2);
-	assert(start <= end);
-	bands[0].start = JPC_CEILDIVPOW2(start, 1);
-	bands[0].end = JPC_CEILDIVPOW2(end, 1);
-	bands[0].locstart = start;
-	bands[0].locend = start + bands[0].end - bands[0].start;
-	bands[1].start = JPC_FLOORDIVPOW2(start, 1);
-	bands[1].end = JPC_FLOORDIVPOW2(end, 1);
-	bands[1].locstart = bands[0].locend;
-	bands[1].locend = bands[1].locstart + bands[1].end - bands[1].start;
-	assert(bands[1].locend == end);
-	*numbandsptr = 2;
+        int start;
+        int end;
+        if (flags & JPC_QMFB1D_VERT) {
+                start = ystart;
+                end = yend;
+        } else {
+                start = xstart;
+                end = xend;
+        }
+        assert(jpc_qmfb1d_getnumchans(qmfb) == 2);
+        assert(start <= end);
+        bands[0].start = JPC_CEILDIVPOW2(start, 1);
+        bands[0].end = JPC_CEILDIVPOW2(end, 1);
+        bands[0].locstart = start;
+        bands[0].locend = start + bands[0].end - bands[0].start;
+        bands[1].start = JPC_FLOORDIVPOW2(start, 1);
+        bands[1].end = JPC_FLOORDIVPOW2(end, 1);
+        bands[1].locstart = bands[0].locend;
+        bands[1].locend = bands[1].locstart + bands[1].end - bands[1].start;
+        assert(bands[1].locend == end);
+        *numbandsptr = 2;
 }
 
 /******************************************************************************\
@@ -1067,25 +1067,25 @@ void jpc_qmfb1d_getbands(jpc_qmfb1d_t *qmfb, int flags, uint_fast32_t xstart,
 
 int jpc_qmfb1d_getnumchans(jpc_qmfb1d_t *qmfb)
 {
-	return (*qmfb->ops->getnumchans)(qmfb);
+        return (*qmfb->ops->getnumchans)(qmfb);
 }
 
 int jpc_qmfb1d_getanalfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
 {
-	return (*qmfb->ops->getanalfilters)(qmfb, len, filters);
+        return (*qmfb->ops->getanalfilters)(qmfb, len, filters);
 }
 
 int jpc_qmfb1d_getsynfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
 {
-	return (*qmfb->ops->getsynfilters)(qmfb, len, filters);
+        return (*qmfb->ops->getsynfilters)(qmfb, len, filters);
 }
 
 void jpc_qmfb1d_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 {
-	(*qmfb->ops->analyze)(qmfb, flags, x);
+        (*qmfb->ops->analyze)(qmfb, flags, x);
 }
 
 void jpc_qmfb1d_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
 {
-	(*qmfb->ops->synthesize)(qmfb, flags, x);
+        (*qmfb->ops->synthesize)(qmfb, flags, x);
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h
index e10b6c13..fb46965b 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -130,17 +130,17 @@
 \******************************************************************************/
 
 /* The maximum number of channels for a QMF bank. */
-#define	JPC_QMFB1D_MAXCHANS	2
+#define JPC_QMFB1D_MAXCHANS     2
 
 /* Select reversible integer-to-integer mode. */
-#define	JPC_QMFB1D_RITIMODE	1
+#define JPC_QMFB1D_RITIMODE     1
 
 /* Vertical filtering. */
-#define	JPC_QMFB1D_VERT	0x10000
+#define JPC_QMFB1D_VERT 0x10000
 
 /* QMFB IDs. */
-#define	JPC_QMFB1D_FT	1	/* 5/3 */
-#define	JPC_QMFB1D_NS	2	/* 9/7 */
+#define JPC_QMFB1D_FT   1       /* 5/3 */
+#define JPC_QMFB1D_NS   2       /* 9/7 */
 
 /******************************************************************************\
 * Types.
@@ -153,17 +153,17 @@ struct jpc_qmfb1dops_s;
 
 typedef struct {
 
-	/* The starting index for the band in the downsampled domain. */
-	int start;
+        /* The starting index for the band in the downsampled domain. */
+        int start;
 
-	/* The ending index for the band in the downsampled domain. */
-	int end;
+        /* The ending index for the band in the downsampled domain. */
+        int end;
 
-	/* The location of the start of the band. */
-	int locstart;
+        /* The location of the start of the band. */
+        int locstart;
 
-	/* The location of the end of the band. */
-	int locend;
+        /* The location of the end of the band. */
+        int locend;
 
 } jpc_qmfb1dband_t;
 
@@ -171,8 +171,8 @@ typedef struct {
 
 typedef struct {
 
-	/* The operations for this QMFB. */
-	struct jpc_qmfb1dops_s *ops;
+        /* The operations for this QMFB. */
+        struct jpc_qmfb1dops_s *ops;
 
 } jpc_qmfb1d_t;
 
@@ -180,20 +180,20 @@ typedef struct {
 
 typedef struct jpc_qmfb1dops_s {
 
-	/* The number of channels in the QMFB. */
-	int (*getnumchans)(jpc_qmfb1d_t *qmfb);
+        /* The number of channels in the QMFB. */
+        int (*getnumchans)(jpc_qmfb1d_t *qmfb);
 
-	/* Get the analysis filters for this QMFB. */
-	int (*getanalfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters);
+        /* Get the analysis filters for this QMFB. */
+        int (*getanalfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters);
 
-	/* Get the synthesis filters for this QMFB. */
-	int (*getsynfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters);
+        /* Get the synthesis filters for this QMFB. */
+        int (*getsynfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters);
 
-	/* Do analysis. */
-	void (*analyze)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
+        /* Do analysis. */
+        void (*analyze)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
 
-	/* Do synthesis. */
-	void (*synthesize)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
+        /* Do synthesis. */
+        void (*synthesize)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
 
 } jpc_qmfb1dops_t;
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c
index 650cb854..ed188154 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -157,46 +157,46 @@ jpc_mqctx_t jpc_mqctxs[JPC_NUMCTXS];
 
 int JPC_PASSTYPE(int passno)
 {
-	int passtype;
-	switch (passno % 3) {
-	case 0:
-		passtype = JPC_CLNPASS;
-		break;
-	case 1:
-		passtype = JPC_SIGPASS;
-		break;
-	case 2:
-		passtype = JPC_REFPASS;
-		break;
-	default:
-		passtype = -1;
-		assert(0);
-		break;
-	}
-	return passtype;
+        int passtype;
+        switch (passno % 3) {
+        case 0:
+                passtype = JPC_CLNPASS;
+                break;
+        case 1:
+                passtype = JPC_SIGPASS;
+                break;
+        case 2:
+                passtype = JPC_REFPASS;
+                break;
+        default:
+                passtype = -1;
+                assert(0);
+                break;
+        }
+        return passtype;
 }
 
 int JPC_NOMINALGAIN(int qmfbid, int numlvls, int lvlno, int orient)
 {
 if (qmfbid == JPC_COX_INS) {
-	return 0;
+        return 0;
 }
-	assert(qmfbid == JPC_COX_RFT);
-	if (lvlno == 0) {
-		assert(orient == JPC_TSFB_LL);
-		return 0;
-	} else {
-		switch (orient) {
-		case JPC_TSFB_LH:
-		case JPC_TSFB_HL:
-			return 1;
-			break;
-		case JPC_TSFB_HH:
-			return 2;
-			break;
-		}
-	}
-	abort();
+        assert(qmfbid == JPC_COX_RFT);
+        if (lvlno == 0) {
+                assert(orient == JPC_TSFB_LL);
+                return 0;
+        } else {
+                switch (orient) {
+                case JPC_TSFB_LH:
+                case JPC_TSFB_HL:
+                        return 1;
+                        break;
+                case JPC_TSFB_HH:
+                        return 2;
+                        break;
+                }
+        }
+        abort();
 }
 
 /******************************************************************************\
@@ -205,66 +205,66 @@ if (qmfbid == JPC_COX_INS) {
 
 int JPC_SEGTYPE(int passno, int firstpassno, int bypass)
 {
-	int passtype;
-	if (bypass) {
-		passtype = JPC_PASSTYPE(passno);
-		if (passtype == JPC_CLNPASS) {
-			return JPC_SEG_MQ;
-		}
-		return ((passno < firstpassno + 10) ? JPC_SEG_MQ : JPC_SEG_RAW);
-	} else {
-		return JPC_SEG_MQ;
-	}
+        int passtype;
+        if (bypass) {
+                passtype = JPC_PASSTYPE(passno);
+                if (passtype == JPC_CLNPASS) {
+                        return JPC_SEG_MQ;
+                }
+                return ((passno < firstpassno + 10) ? JPC_SEG_MQ : JPC_SEG_RAW);
+        } else {
+                return JPC_SEG_MQ;
+        }
 }
 
 int JPC_SEGPASSCNT(int passno, int firstpassno, int numpasses, int bypass, int termall)
 {
-	int ret;
-	int passtype;
-
-	if (termall) {
-		ret = 1;
-	} else if (bypass) {
-		if (passno < firstpassno + 10) {
-			ret = 10 - (passno - firstpassno);
-		} else {
-			passtype = JPC_PASSTYPE(passno);
-			switch (passtype) {
-			case JPC_SIGPASS:
-				ret = 2;
-				break;
-			case JPC_REFPASS:
-				ret = 1;
-				break;
-			case JPC_CLNPASS:
-				ret = 1;
-				break;
-			default:
-				ret = -1;
-				assert(0);
-				break;
-			}
-		}
-	} else {
-		ret = JPC_PREC * 3 - 2;
-	}
-	ret = JAS_MIN(ret, numpasses - passno);
-	return ret;
+        int ret;
+        int passtype;
+
+        if (termall) {
+                ret = 1;
+        } else if (bypass) {
+                if (passno < firstpassno + 10) {
+                        ret = 10 - (passno - firstpassno);
+                } else {
+                        passtype = JPC_PASSTYPE(passno);
+                        switch (passtype) {
+                        case JPC_SIGPASS:
+                                ret = 2;
+                                break;
+                        case JPC_REFPASS:
+                                ret = 1;
+                                break;
+                        case JPC_CLNPASS:
+                                ret = 1;
+                                break;
+                        default:
+                                ret = -1;
+                                assert(0);
+                                break;
+                        }
+                }
+        } else {
+                ret = JPC_PREC * 3 - 2;
+        }
+        ret = JAS_MIN(ret, numpasses - passno);
+        return ret;
 }
 
 int JPC_ISTERMINATED(int passno, int firstpassno, int numpasses, int termall,
   int lazy)
 {
-	int ret;
-	int n;
-	if (passno - firstpassno == numpasses - 1) {
-		ret = 1;
-	} else {
-		n = JPC_SEGPASSCNT(passno, firstpassno, numpasses, lazy, termall);
-		ret = (n <= 1) ? 1 : 0;
-	}
-
-	return ret;
+        int ret;
+        int n;
+        if (passno - firstpassno == numpasses - 1) {
+                ret = 1;
+        } else {
+                n = JPC_SEGPASSCNT(passno, firstpassno, numpasses, lazy, termall);
+                ret = (n <= 1) ? 1 : 0;
+        }
+
+        return ret;
 }
 
 /******************************************************************************\
@@ -273,265 +273,265 @@ int JPC_ISTERMINATED(int passno, int firstpassno, int numpasses, int termall,
 
 static void jpc_initmqctxs(void)
 {
-	jpc_initctxs(jpc_mqctxs);
+        jpc_initctxs(jpc_mqctxs);
 }
 
 void jpc_initluts()
 {
-	int i;
-	int orient;
-	int refine;
-	float u;
-	float v;
-	float t;
+        int i;
+        int orient;
+        int refine;
+        float u;
+        float v;
+        float t;
 
 /* XXX - hack */
 jpc_initmqctxs();
 
-	for (orient = 0; orient < 4; ++orient) {
-		for (i = 0; i < 256; ++i) {
-			jpc_zcctxnolut[(orient << 8) | i] = jpc_getzcctxno(i, orient);
-		}
-	}
-
-	for (i = 0; i < 256; ++i) {
-		jpc_spblut[i] = jpc_getspb(i << 4);
-	}
-
-	for (i = 0; i < 256; ++i) {
-		jpc_scctxnolut[i] = jpc_getscctxno(i << 4);
-	}
-
-	for (refine = 0; refine < 2; ++refine) {
-		for (i = 0; i < 2048; ++i) {
-			jpc_magctxnolut[(refine << 11) + i] = jpc_getmagctxno((refine ? JPC_REFINE : 0) | i);
-		}
-	}
-
-	for (i = 0; i < (1 << JPC_NMSEDEC_BITS); ++i) {
-		t = i * jpc_pow2i(-JPC_NMSEDEC_FRACBITS);
-		u = t;
-		v = t - 1.5;
-		jpc_signmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
+        for (orient = 0; orient < 4; ++orient) {
+                for (i = 0; i < 256; ++i) {
+                        jpc_zcctxnolut[(orient << 8) | i] = jpc_getzcctxno(i, orient);
+                }
+        }
+
+        for (i = 0; i < 256; ++i) {
+                jpc_spblut[i] = jpc_getspb(i << 4);
+        }
+
+        for (i = 0; i < 256; ++i) {
+                jpc_scctxnolut[i] = jpc_getscctxno(i << 4);
+        }
+
+        for (refine = 0; refine < 2; ++refine) {
+                for (i = 0; i < 2048; ++i) {
+                        jpc_magctxnolut[(refine << 11) + i] = jpc_getmagctxno((refine ? JPC_REFINE : 0) | i);
+                }
+        }
+
+        for (i = 0; i < (1 << JPC_NMSEDEC_BITS); ++i) {
+                t = i * jpc_pow2i(-JPC_NMSEDEC_FRACBITS);
+                u = t;
+                v = t - 1.5;
+                jpc_signmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
 /* XXX - this calc is not correct */
-		jpc_signmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
-		u = t - 1.0;
-		if (i & (1 << (JPC_NMSEDEC_BITS - 1))) {
-			v = t - 1.5;
-		} else {
-			v = t - 0.5;
-		}
-		jpc_refnmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
+                jpc_signmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
+                u = t - 1.0;
+                if (i & (1 << (JPC_NMSEDEC_BITS - 1))) {
+                        v = t - 1.5;
+                } else {
+                        v = t - 0.5;
+                }
+                jpc_refnmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
 /* XXX - this calc is not correct */
-		jpc_refnmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
-	}
+                jpc_refnmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS));
+        }
 }
 
 jpc_fix_t jpc_getsignmsedec_func(jpc_fix_t x, int bitpos)
 {
-	jpc_fix_t y;
-	assert(!(x & (~JAS_ONES(bitpos + 1))));
-	y = jpc_getsignmsedec_macro(x, bitpos);
-	return y;
+        jpc_fix_t y;
+        assert(!(x & (~JAS_ONES(bitpos + 1))));
+        y = jpc_getsignmsedec_macro(x, bitpos);
+        return y;
 }
 
 int jpc_getzcctxno(int f, int orient)
 {
-	int h;
-	int v;
-	int d;
-	int n;
-	int t;
-	int hv;
-
-	/* Avoid compiler warning. */
-	n = 0;
-
-	h = ((f & JPC_WSIG) != 0) + ((f & JPC_ESIG) != 0);
-	v = ((f & JPC_NSIG) != 0) + ((f & JPC_SSIG) != 0);
-	d = ((f & JPC_NWSIG) != 0) + ((f & JPC_NESIG) != 0) + ((f & JPC_SESIG) != 0) + ((f & JPC_SWSIG) != 0);
-	switch (orient) {
-	case JPC_TSFB_HL:
-		t = h;
-		h = v;
-		v = t;
-	case JPC_TSFB_LL:
-	case JPC_TSFB_LH:
-		if (!h) {
-			if (!v) {
-				if (!d) {
-					n = 0;
-				} else if (d == 1) {
-					n = 1;
-				} else {
-					n = 2;
-				}
-			} else if (v == 1) {
-				n = 3;
-			} else {
-				n = 4;
-			}
-		} else if (h == 1) {
-			if (!v) {
-				if (!d) {
-					n = 5;
-				} else {
-					n = 6;
-				}
-			} else {
-				n = 7;
-			}
-		} else {
-			n = 8;
-		}
-		break;
-	case JPC_TSFB_HH:
-		hv = h + v;
-		if (!d) {
-			if (!hv) {
-				n = 0;
-			} else if (hv == 1) {
-				n = 1;
-			} else {
-				n = 2;
-			}
-		} else if (d == 1) {
-			if (!hv) {
-				n = 3;
-			} else if (hv == 1) {
-				n = 4;
-			} else {
-				n = 5;
-			}
-		} else if (d == 2) {
-			if (!hv) {
-				n = 6;
-			} else {
-				n = 7;
-			}
-		} else {
-			n = 8;
-		}
-		break;
-	}
-	assert(n < JPC_NUMZCCTXS);
-	return JPC_ZCCTXNO + n;
+        int h;
+        int v;
+        int d;
+        int n;
+        int t;
+        int hv;
+
+        /* Avoid compiler warning. */
+        n = 0;
+
+        h = ((f & JPC_WSIG) != 0) + ((f & JPC_ESIG) != 0);
+        v = ((f & JPC_NSIG) != 0) + ((f & JPC_SSIG) != 0);
+        d = ((f & JPC_NWSIG) != 0) + ((f & JPC_NESIG) != 0) + ((f & JPC_SESIG) != 0) + ((f & JPC_SWSIG) != 0);
+        switch (orient) {
+        case JPC_TSFB_HL:
+                t = h;
+                h = v;
+                v = t;
+        case JPC_TSFB_LL:
+        case JPC_TSFB_LH:
+                if (!h) {
+                        if (!v) {
+                                if (!d) {
+                                        n = 0;
+                                } else if (d == 1) {
+                                        n = 1;
+                                } else {
+                                        n = 2;
+                                }
+                        } else if (v == 1) {
+                                n = 3;
+                        } else {
+                                n = 4;
+                        }
+                } else if (h == 1) {
+                        if (!v) {
+                                if (!d) {
+                                        n = 5;
+                                } else {
+                                        n = 6;
+                                }
+                        } else {
+                                n = 7;
+                        }
+                } else {
+                        n = 8;
+                }
+                break;
+        case JPC_TSFB_HH:
+                hv = h + v;
+                if (!d) {
+                        if (!hv) {
+                                n = 0;
+                        } else if (hv == 1) {
+                                n = 1;
+                        } else {
+                                n = 2;
+                        }
+                } else if (d == 1) {
+                        if (!hv) {
+                                n = 3;
+                        } else if (hv == 1) {
+                                n = 4;
+                        } else {
+                                n = 5;
+                        }
+                } else if (d == 2) {
+                        if (!hv) {
+                                n = 6;
+                        } else {
+                                n = 7;
+                        }
+                } else {
+                        n = 8;
+                }
+                break;
+        }
+        assert(n < JPC_NUMZCCTXS);
+        return JPC_ZCCTXNO + n;
 }
 
 int jpc_getspb(int f)
 {
-	int hc;
-	int vc;
-	int n;
-
-	hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG), 1) -
-	  JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) + ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1);
-	vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG), 1) -
-	  JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) + ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1);
-	if (!hc && !vc) {
-		n = 0;
-	} else {
-		n = (!(hc > 0 || (!hc && vc > 0)));
-	}
-	return n;
+        int hc;
+        int vc;
+        int n;
+
+        hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG), 1) -
+          JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) + ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1);
+        vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG), 1) -
+          JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) + ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1);
+        if (!hc && !vc) {
+                n = 0;
+        } else {
+                n = (!(hc > 0 || (!hc && vc > 0)));
+        }
+        return n;
 }
 
 int jpc_getscctxno(int f)
 {
-	int hc;
-	int vc;
-	int n;
-
-	/* Avoid compiler warning. */
-	n = 0;
-
-	hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG),
-	  1) - JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) +
-	  ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1);
-	vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG),
-	  1) - JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) +
-	  ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1);
-	assert(hc >= -1 && hc <= 1 && vc >= -1 && vc <= 1);
-	if (hc < 0) {
-		hc = -hc;
-		vc = -vc;
-	}
-	if (!hc) {
-		if (vc == -1) {
-			n = 1;
-		} else if (!vc) {
-			n = 0;
-		} else {
-			n = 1;
-		}
-	} else if (hc == 1) {
-		if (vc == -1) {
-			n = 2;
-		} else if (!vc) {
-			n = 3;
-		} else {
-			n = 4;
-		}
-	}
-	assert(n < JPC_NUMSCCTXS);
-	return JPC_SCCTXNO + n;
+        int hc;
+        int vc;
+        int n;
+
+        /* Avoid compiler warning. */
+        n = 0;
+
+        hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG),
+          1) - JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) +
+          ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1);
+        vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG),
+          1) - JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) +
+          ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1);
+        assert(hc >= -1 && hc <= 1 && vc >= -1 && vc <= 1);
+        if (hc < 0) {
+                hc = -hc;
+                vc = -vc;
+        }
+        if (!hc) {
+                if (vc == -1) {
+                        n = 1;
+                } else if (!vc) {
+                        n = 0;
+                } else {
+                        n = 1;
+                }
+        } else if (hc == 1) {
+                if (vc == -1) {
+                        n = 2;
+                } else if (!vc) {
+                        n = 3;
+                } else {
+                        n = 4;
+                }
+        }
+        assert(n < JPC_NUMSCCTXS);
+        return JPC_SCCTXNO + n;
 }
 
 int jpc_getmagctxno(int f)
 {
-	int n;
+        int n;
 
-	if (!(f & JPC_REFINE)) {
-		n = (f & (JPC_OTHSIGMSK)) ? 1 : 0;
-	} else {
-		n = 2;
-	}
+        if (!(f & JPC_REFINE)) {
+                n = (f & (JPC_OTHSIGMSK)) ? 1 : 0;
+        } else {
+                n = 2;
+        }
 
-	assert(n < JPC_NUMMAGCTXS);
-	return JPC_MAGCTXNO + n;
+        assert(n < JPC_NUMMAGCTXS);
+        return JPC_MAGCTXNO + n;
 }
 
 void jpc_initctxs(jpc_mqctx_t *ctxs)
 {
-	jpc_mqctx_t *ctx;
-	int i;
-
-	ctx = ctxs;
-	for (i = 0; i < JPC_NUMCTXS; ++i) {
-		ctx->mps = 0;
-		switch (i) {
-		case JPC_UCTXNO:
-			ctx->ind = 46;
-			break;
-		case JPC_ZCCTXNO:
-			ctx->ind = 4;
-			break;
-		case JPC_AGGCTXNO:
-			ctx->ind = 3;
-			break;
-		default:
-			ctx->ind = 0;
-			break;
-		}
-		++ctx;
-	}
+        jpc_mqctx_t *ctx;
+        int i;
+
+        ctx = ctxs;
+        for (i = 0; i < JPC_NUMCTXS; ++i) {
+                ctx->mps = 0;
+                switch (i) {
+                case JPC_UCTXNO:
+                        ctx->ind = 46;
+                        break;
+                case JPC_ZCCTXNO:
+                        ctx->ind = 4;
+                        break;
+                case JPC_AGGCTXNO:
+                        ctx->ind = 3;
+                        break;
+                default:
+                        ctx->ind = 0;
+                        break;
+                }
+                ++ctx;
+        }
 }
 
 /* Calculate the real quantity exp2(n), where x is an integer. */
 double jpc_pow2i(int n)
 {
-	double x;
-	double a;
-
-	x = 1.0;
-	if (n < 0) {
-		a = 0.5;
-		n = -n;
-	} else {
-		a = 2.0;
-	}
-	while (--n >= 0) {
-		x *= a;
-	}
-	return x;
+        double x;
+        double a;
+
+        x = 1.0;
+        if (n < 0) {
+                a = 0.5;
+                n = -n;
+        } else {
+                a = 2.0;
+        }
+        while (--n >= 0) {
+                x *= a;
+        }
+        return x;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h
index 3e061d20..771464ec 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -132,95 +132,95 @@
 \******************************************************************************/
 
 /* The number of bits used to index into various lookup tables. */
-#define JPC_NMSEDEC_BITS	7
-#define JPC_NMSEDEC_FRACBITS	(JPC_NMSEDEC_BITS - 1)
+#define JPC_NMSEDEC_BITS        7
+#define JPC_NMSEDEC_FRACBITS    (JPC_NMSEDEC_BITS - 1)
 
 /*
  * Segment types.
  */
 
 /* Invalid. */
-#define JPC_SEG_INVALID	0
+#define JPC_SEG_INVALID 0
 /* MQ. */
-#define JPC_SEG_MQ		1
+#define JPC_SEG_MQ              1
 /* Raw. */
-#define JPC_SEG_RAW		2
+#define JPC_SEG_RAW             2
 
 /* The nominal word size. */
-#define	JPC_PREC	32
+#define JPC_PREC        32
 
 /* Tier-1 coding pass types. */
-#define	JPC_SIGPASS	0	/* significance */
-#define	JPC_REFPASS	1	/* refinement */
-#define	JPC_CLNPASS	2	/* cleanup */
+#define JPC_SIGPASS     0       /* significance */
+#define JPC_REFPASS     1       /* refinement */
+#define JPC_CLNPASS     2       /* cleanup */
 
 /*
  * Per-sample state information for tier-1 coding.
  */
 
 /* The northeast neighbour has been found to be significant. */
-#define	JPC_NESIG	0x0001
+#define JPC_NESIG       0x0001
 /* The southeast neighbour has been found to be significant. */
-#define	JPC_SESIG	0x0002
+#define JPC_SESIG       0x0002
 /* The southwest neighbour has been found to be significant. */
-#define	JPC_SWSIG	0x0004
+#define JPC_SWSIG       0x0004
 /* The northwest neighbour has been found to be significant. */
-#define	JPC_NWSIG	0x0008
+#define JPC_NWSIG       0x0008
 /* The north neighbour has been found to be significant. */
-#define	JPC_NSIG	0x0010
+#define JPC_NSIG        0x0010
 /* The east neighbour has been found to be significant. */
-#define	JPC_ESIG	0x0020
+#define JPC_ESIG        0x0020
 /* The south neighbour has been found to be significant. */
-#define	JPC_SSIG	0x0040
+#define JPC_SSIG        0x0040
 /* The west neighbour has been found to be significant. */
-#define	JPC_WSIG	0x0080
+#define JPC_WSIG        0x0080
 /* The significance mask for 8-connected neighbours. */
-#define	JPC_OTHSIGMSK \
-	(JPC_NSIG | JPC_NESIG | JPC_ESIG | JPC_SESIG | JPC_SSIG | JPC_SWSIG | JPC_WSIG | JPC_NWSIG)
+#define JPC_OTHSIGMSK \
+        (JPC_NSIG | JPC_NESIG | JPC_ESIG | JPC_SESIG | JPC_SSIG | JPC_SWSIG | JPC_WSIG | JPC_NWSIG)
 /* The significance mask for 4-connected neighbours. */
-#define	JPC_PRIMSIGMSK	(JPC_NSIG | JPC_ESIG | JPC_SSIG | JPC_WSIG)
+#define JPC_PRIMSIGMSK  (JPC_NSIG | JPC_ESIG | JPC_SSIG | JPC_WSIG)
 
 /* The north neighbour is negative in value. */
-#define	JPC_NSGN	0x0100
+#define JPC_NSGN        0x0100
 /* The east neighbour is negative in value. */
-#define	JPC_ESGN	0x0200
+#define JPC_ESGN        0x0200
 /* The south neighbour is negative in value. */
-#define	JPC_SSGN	0x0400
+#define JPC_SSGN        0x0400
 /* The west neighbour is negative in value. */
-#define	JPC_WSGN	0x0800
+#define JPC_WSGN        0x0800
 /* The sign mask for 4-connected neighbours. */
-#define	JPC_SGNMSK	(JPC_NSGN | JPC_ESGN | JPC_SSGN | JPC_WSGN)
+#define JPC_SGNMSK      (JPC_NSGN | JPC_ESGN | JPC_SSGN | JPC_WSGN)
 
 /* This sample has been found to be significant. */
-#define JPC_SIG		0x1000
+#define JPC_SIG         0x1000
 /* The sample has been refined. */
-#define	JPC_REFINE	0x2000
+#define JPC_REFINE      0x2000
 /* This sample has been processed during the significance pass. */
-#define	JPC_VISIT	0x4000
+#define JPC_VISIT       0x4000
 
 /* The number of aggregation contexts. */
-#define	JPC_NUMAGGCTXS	1
+#define JPC_NUMAGGCTXS  1
 /* The number of zero coding contexts. */
-#define	JPC_NUMZCCTXS	9
+#define JPC_NUMZCCTXS   9
 /* The number of magnitude contexts. */
-#define	JPC_NUMMAGCTXS	3
+#define JPC_NUMMAGCTXS  3
 /* The number of sign coding contexts. */
-#define	JPC_NUMSCCTXS	5
+#define JPC_NUMSCCTXS   5
 /* The number of uniform contexts. */
-#define	JPC_NUMUCTXS	1
+#define JPC_NUMUCTXS    1
 
 /* The context ID for the first aggregation context. */
-#define	JPC_AGGCTXNO	0
+#define JPC_AGGCTXNO    0
 /* The context ID for the first zero coding context. */
-#define	JPC_ZCCTXNO		(JPC_AGGCTXNO + JPC_NUMAGGCTXS)
+#define JPC_ZCCTXNO             (JPC_AGGCTXNO + JPC_NUMAGGCTXS)
 /* The context ID for the first magnitude context. */
-#define	JPC_MAGCTXNO	(JPC_ZCCTXNO + JPC_NUMZCCTXS)
+#define JPC_MAGCTXNO    (JPC_ZCCTXNO + JPC_NUMZCCTXS)
 /* The context ID for the first sign coding context. */
-#define	JPC_SCCTXNO		(JPC_MAGCTXNO + JPC_NUMMAGCTXS)
+#define JPC_SCCTXNO             (JPC_MAGCTXNO + JPC_NUMMAGCTXS)
 /* The context ID for the first uniform context. */
-#define	JPC_UCTXNO		(JPC_SCCTXNO + JPC_NUMSCCTXS)
+#define JPC_UCTXNO              (JPC_SCCTXNO + JPC_NUMSCCTXS)
 /* The total number of contexts. */
-#define	JPC_NUMCTXS		(JPC_UCTXNO + JPC_NUMUCTXS)
+#define JPC_NUMCTXS             (JPC_UCTXNO + JPC_NUMUCTXS)
 
 /******************************************************************************\
 * External data.
@@ -249,76 +249,76 @@ void jpc_initctxs(jpc_mqctx_t *ctxs);
 
 /* Get the zero coding context. */
 int jpc_getzcctxno(int f, int orient);
-#define	JPC_GETZCCTXNO(f, orient) \
-	(jpc_zcctxnolut[((orient) << 8) | ((f) & JPC_OTHSIGMSK)])
+#define JPC_GETZCCTXNO(f, orient) \
+        (jpc_zcctxnolut[((orient) << 8) | ((f) & JPC_OTHSIGMSK)])
 
 /* Get the sign prediction bit. */
 int jpc_getspb(int f);
-#define	JPC_GETSPB(f) \
-	(jpc_spblut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4])
+#define JPC_GETSPB(f) \
+        (jpc_spblut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4])
 
 /* Get the sign coding context. */
 int jpc_getscctxno(int f);
-#define	JPC_GETSCCTXNO(f) \
-	(jpc_scctxnolut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4])
+#define JPC_GETSCCTXNO(f) \
+        (jpc_scctxnolut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4])
 
 /* Get the magnitude context. */
 int jpc_getmagctxno(int f);
-#define	JPC_GETMAGCTXNO(f) \
-	(jpc_magctxnolut[((f) & JPC_OTHSIGMSK) | ((((f) & JPC_REFINE) != 0) << 11)])
+#define JPC_GETMAGCTXNO(f) \
+        (jpc_magctxnolut[((f) & JPC_OTHSIGMSK) | ((((f) & JPC_REFINE) != 0) << 11)])
 
 /* Get the normalized MSE reduction for significance passes. */
-#define	JPC_GETSIGNMSEDEC(x, bitpos)	jpc_getsignmsedec_macro(x, bitpos)
+#define JPC_GETSIGNMSEDEC(x, bitpos)    jpc_getsignmsedec_macro(x, bitpos)
 jpc_fix_t jpc_getsignmsedec_func(jpc_fix_t x, int bitpos);
-#define	jpc_getsignmsedec_macro(x, bitpos) \
-	((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_signmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \
-	  (jpc_signmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]))
+#define jpc_getsignmsedec_macro(x, bitpos) \
+        ((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_signmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \
+          (jpc_signmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]))
 
 /* Get the normalized MSE reduction for refinement passes. */
-#define	JPC_GETREFNMSEDEC(x, bitpos)	jpc_getrefnmsedec_macro(x, bitpos)
+#define JPC_GETREFNMSEDEC(x, bitpos)    jpc_getrefnmsedec_macro(x, bitpos)
 jpc_fix_t jpc_refsignmsedec_func(jpc_fix_t x, int bitpos);
-#define	jpc_getrefnmsedec_macro(x, bitpos) \
-	((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_refnmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \
-	  (jpc_refnmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]))
+#define jpc_getrefnmsedec_macro(x, bitpos) \
+        ((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_refnmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \
+          (jpc_refnmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]))
 
 /* Arithmetic shift right (with ability to shift left also). */
-#define	JPC_ASR(x, n) \
-	(((n) >= 0) ? ((x) >> (n)) : ((x) << (-(n))))
+#define JPC_ASR(x, n) \
+        (((n) >= 0) ? ((x) >> (n)) : ((x) << (-(n))))
 
 /* Update the per-sample state information. */
-#define	JPC_UPDATEFLAGS4(fp, rowstep, s, vcausalflag) \
+#define JPC_UPDATEFLAGS4(fp, rowstep, s, vcausalflag) \
 { \
-	register jpc_fix_t *np = (fp) - (rowstep); \
-	register jpc_fix_t *sp = (fp) + (rowstep); \
-	if ((vcausalflag)) { \
-		sp[-1] |= JPC_NESIG; \
-		sp[1] |= JPC_NWSIG; \
-		if (s) { \
-			*sp |= JPC_NSIG | JPC_NSGN; \
-			(fp)[-1] |= JPC_ESIG | JPC_ESGN; \
-			(fp)[1] |= JPC_WSIG | JPC_WSGN; \
-		} else { \
-			*sp |= JPC_NSIG; \
-			(fp)[-1] |= JPC_ESIG; \
-			(fp)[1] |= JPC_WSIG; \
-		} \
-	} else { \
-		np[-1] |= JPC_SESIG; \
-		np[1] |= JPC_SWSIG; \
-		sp[-1] |= JPC_NESIG; \
-		sp[1] |= JPC_NWSIG; \
-		if (s) { \
-			*np |= JPC_SSIG | JPC_SSGN; \
-			*sp |= JPC_NSIG | JPC_NSGN; \
-			(fp)[-1] |= JPC_ESIG | JPC_ESGN; \
-			(fp)[1] |= JPC_WSIG | JPC_WSGN; \
-		} else { \
-			*np |= JPC_SSIG; \
-			*sp |= JPC_NSIG; \
-			(fp)[-1] |= JPC_ESIG; \
-			(fp)[1] |= JPC_WSIG; \
-		} \
-	} \
+        register jpc_fix_t *np = (fp) - (rowstep); \
+        register jpc_fix_t *sp = (fp) + (rowstep); \
+        if ((vcausalflag)) { \
+                sp[-1] |= JPC_NESIG; \
+                sp[1] |= JPC_NWSIG; \
+                if (s) { \
+                        *sp |= JPC_NSIG | JPC_NSGN; \
+                        (fp)[-1] |= JPC_ESIG | JPC_ESGN; \
+                        (fp)[1] |= JPC_WSIG | JPC_WSGN; \
+                } else { \
+                        *sp |= JPC_NSIG; \
+                        (fp)[-1] |= JPC_ESIG; \
+                        (fp)[1] |= JPC_WSIG; \
+                } \
+        } else { \
+                np[-1] |= JPC_SESIG; \
+                np[1] |= JPC_SWSIG; \
+                sp[-1] |= JPC_NESIG; \
+                sp[1] |= JPC_NWSIG; \
+                if (s) { \
+                        *np |= JPC_SSIG | JPC_SSGN; \
+                        *sp |= JPC_NSIG | JPC_NSGN; \
+                        (fp)[-1] |= JPC_ESIG | JPC_ESGN; \
+                        (fp)[1] |= JPC_WSIG | JPC_WSGN; \
+                } else { \
+                        *np |= JPC_SSIG; \
+                        *sp |= JPC_NSIG; \
+                        (fp)[-1] |= JPC_ESIG; \
+                        (fp)[1] |= JPC_WSIG; \
+                } \
+        } \
 }
 
 /* Initialize the lookup tables used by the codec. */
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c
index b6c5e14f..437e9dd6 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h
index f8b3b342..35ff549a 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c
index 34b9738c..e9ec12d4 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -433,7 +433,7 @@ assert(jas_stream_tell(cblk->stream) == jas_stream_getrwcount(cblk->stream));
 #if 0
     /* XXX - This assertion fails sometimes when various coding modes are used.
        This seems to be harmless, but why does it happen at all? */
-        assert(jas_stream_tell(cblk->stream) == 
+        assert(jas_stream_tell(cblk->stream) ==
                jas_stream_getrwcount(cblk->stream));
 #endif
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h
index 9ce5ed27..08b4811f 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c
index a9ca0dc1..9a635285 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -132,602 +132,602 @@ static int jpc_pi_nextcprl(jpc_pi_t *pi);
 
 int jpc_pi_next(jpc_pi_t *pi)
 {
-	jpc_pchg_t *pchg;
-	int ret;
-
-
-	for (;;) {
-
-		pi->valid = false;
-
-		if (!pi->pchg) {
-			++pi->pchgno;
-			pi->compno = 0;
-			pi->rlvlno = 0;
-			pi->prcno = 0;
-			pi->lyrno = 0;
-			pi->prgvolfirst = true;
-			if (pi->pchgno < jpc_pchglist_numpchgs(pi->pchglist)) {
-				pi->pchg = jpc_pchglist_get(pi->pchglist, pi->pchgno);
-			} else if (pi->pchgno == jpc_pchglist_numpchgs(pi->pchglist)) {
-				pi->pchg = &pi->defaultpchg;
-			} else {
-				return 1;
-			}
-		}
-
-		pchg = pi->pchg;
-		switch (pchg->prgord) {
-		case JPC_COD_LRCPPRG:
-			ret = jpc_pi_nextlrcp(pi);
-			break;
-		case JPC_COD_RLCPPRG:
-			ret = jpc_pi_nextrlcp(pi);
-			break;
-		case JPC_COD_RPCLPRG:
-			ret = jpc_pi_nextrpcl(pi);
-			break;
-		case JPC_COD_PCRLPRG:
-			ret = jpc_pi_nextpcrl(pi);
-			break;
-		case JPC_COD_CPRLPRG:
-			ret = jpc_pi_nextcprl(pi);
-			break;
-		default:
-			ret = -1;
-			break;
-		}
-		if (!ret) {
-			pi->valid = true;
-			++pi->pktno;
-			return 0;
-		}
-		pi->pchg = 0;
-	}
+        jpc_pchg_t *pchg;
+        int ret;
+
+
+        for (;;) {
+
+                pi->valid = false;
+
+                if (!pi->pchg) {
+                        ++pi->pchgno;
+                        pi->compno = 0;
+                        pi->rlvlno = 0;
+                        pi->prcno = 0;
+                        pi->lyrno = 0;
+                        pi->prgvolfirst = true;
+                        if (pi->pchgno < jpc_pchglist_numpchgs(pi->pchglist)) {
+                                pi->pchg = jpc_pchglist_get(pi->pchglist, pi->pchgno);
+                        } else if (pi->pchgno == jpc_pchglist_numpchgs(pi->pchglist)) {
+                                pi->pchg = &pi->defaultpchg;
+                        } else {
+                                return 1;
+                        }
+                }
+
+                pchg = pi->pchg;
+                switch (pchg->prgord) {
+                case JPC_COD_LRCPPRG:
+                        ret = jpc_pi_nextlrcp(pi);
+                        break;
+                case JPC_COD_RLCPPRG:
+                        ret = jpc_pi_nextrlcp(pi);
+                        break;
+                case JPC_COD_RPCLPRG:
+                        ret = jpc_pi_nextrpcl(pi);
+                        break;
+                case JPC_COD_PCRLPRG:
+                        ret = jpc_pi_nextpcrl(pi);
+                        break;
+                case JPC_COD_CPRLPRG:
+                        ret = jpc_pi_nextcprl(pi);
+                        break;
+                default:
+                        ret = -1;
+                        break;
+                }
+                if (!ret) {
+                        pi->valid = true;
+                        ++pi->pktno;
+                        return 0;
+                }
+                pi->pchg = 0;
+        }
 }
 
 static int jpc_pi_nextlrcp(register jpc_pi_t *pi)
 {
-	jpc_pchg_t *pchg;
-	int *prclyrno;
-
-	pchg = pi->pchg;
-	if (!pi->prgvolfirst) {
-		prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
-		goto skip;
-	} else {
-		pi->prgvolfirst = false;
-	}
-
-	for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno <
-	  pchg->lyrnoend; ++pi->lyrno) {
-		for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls &&
-		  pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) {
-			for (pi->compno = pchg->compnostart, pi->picomp =
-			  &pi->picomps[pi->compno]; pi->compno < pi->numcomps
-			  && pi->compno < pchg->compnoend; ++pi->compno,
-			  ++pi->picomp) {
-				if (pi->rlvlno >= pi->picomp->numrlvls) {
-					continue;
-				}
-				pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
-				for (pi->prcno = 0, prclyrno =
-				  pi->pirlvl->prclyrnos; pi->prcno <
-				  pi->pirlvl->numprcs; ++pi->prcno,
-				  ++prclyrno) {
-					if (pi->lyrno >= *prclyrno) {
-						*prclyrno = pi->lyrno;
-						++(*prclyrno);
-						return 0;
-					}
+        jpc_pchg_t *pchg;
+        int *prclyrno;
+
+        pchg = pi->pchg;
+        if (!pi->prgvolfirst) {
+                prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
+                goto skip;
+        } else {
+                pi->prgvolfirst = false;
+        }
+
+        for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno <
+          pchg->lyrnoend; ++pi->lyrno) {
+                for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls &&
+                  pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) {
+                        for (pi->compno = pchg->compnostart, pi->picomp =
+                          &pi->picomps[pi->compno]; pi->compno < pi->numcomps
+                          && pi->compno < pchg->compnoend; ++pi->compno,
+                          ++pi->picomp) {
+                                if (pi->rlvlno >= pi->picomp->numrlvls) {
+                                        continue;
+                                }
+                                pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
+                                for (pi->prcno = 0, prclyrno =
+                                  pi->pirlvl->prclyrnos; pi->prcno <
+                                  pi->pirlvl->numprcs; ++pi->prcno,
+                                  ++prclyrno) {
+                                        if (pi->lyrno >= *prclyrno) {
+                                                *prclyrno = pi->lyrno;
+                                                ++(*prclyrno);
+                                                return 0;
+                                        }
 skip:
-					;
-				}
-			}
-		}
-	}
-	return 1;
+                                        ;
+                                }
+                        }
+                }
+        }
+        return 1;
 }
 
 static int jpc_pi_nextrlcp(register jpc_pi_t *pi)
 {
-	jpc_pchg_t *pchg;
-	int *prclyrno;
-
-	pchg = pi->pchg;
-	if (!pi->prgvolfirst) {
-		assert(pi->prcno < pi->pirlvl->numprcs);
-		prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
-		goto skip;
-	} else {
-		pi->prgvolfirst = 0;
-	}
-
-	for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls &&
-	  pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) {
-		for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno <
-		  pchg->lyrnoend; ++pi->lyrno) {
-			for (pi->compno = pchg->compnostart, pi->picomp =
-			  &pi->picomps[pi->compno]; pi->compno < pi->numcomps &&
-			  pi->compno < pchg->compnoend; ++pi->compno, ++pi->picomp) {
-				if (pi->rlvlno >= pi->picomp->numrlvls) {
-					continue;
-				}
-				pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
-				for (pi->prcno = 0, prclyrno = pi->pirlvl->prclyrnos;
-				  pi->prcno < pi->pirlvl->numprcs; ++pi->prcno, ++prclyrno) {
-					if (pi->lyrno >= *prclyrno) {
-						*prclyrno = pi->lyrno;
-						++(*prclyrno);
-						return 0;
-					}
+        jpc_pchg_t *pchg;
+        int *prclyrno;
+
+        pchg = pi->pchg;
+        if (!pi->prgvolfirst) {
+                assert(pi->prcno < pi->pirlvl->numprcs);
+                prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
+                goto skip;
+        } else {
+                pi->prgvolfirst = 0;
+        }
+
+        for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls &&
+          pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) {
+                for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno <
+                  pchg->lyrnoend; ++pi->lyrno) {
+                        for (pi->compno = pchg->compnostart, pi->picomp =
+                          &pi->picomps[pi->compno]; pi->compno < pi->numcomps &&
+                          pi->compno < pchg->compnoend; ++pi->compno, ++pi->picomp) {
+                                if (pi->rlvlno >= pi->picomp->numrlvls) {
+                                        continue;
+                                }
+                                pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
+                                for (pi->prcno = 0, prclyrno = pi->pirlvl->prclyrnos;
+                                  pi->prcno < pi->pirlvl->numprcs; ++pi->prcno, ++prclyrno) {
+                                        if (pi->lyrno >= *prclyrno) {
+                                                *prclyrno = pi->lyrno;
+                                                ++(*prclyrno);
+                                                return 0;
+                                        }
 skip:
-					;
-				}
-			}
-		}
-	}
-	return 1;
+                                        ;
+                                }
+                        }
+                }
+        }
+        return 1;
 }
 
 static int jpc_pi_nextrpcl(register jpc_pi_t *pi)
 {
-	int rlvlno;
-	jpc_pirlvl_t *pirlvl;
-	jpc_pchg_t *pchg;
-	int prchind;
-	int prcvind;
-	int *prclyrno;
-	int compno;
-	jpc_picomp_t *picomp;
-	int xstep;
-	int ystep;
-	uint_fast32_t r;
-	uint_fast32_t rpx;
-	uint_fast32_t rpy;
-	uint_fast32_t trx0;
-	uint_fast32_t try0;
-
-	pchg = pi->pchg;
-	if (!pi->prgvolfirst) {
-		goto skip;
-	} else {
-		pi->xstep = 0;
-		pi->ystep = 0;
-		for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
-		  ++compno, ++picomp) {
-			for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
-			  picomp->numrlvls; ++rlvlno, ++pirlvl) {
-				xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn +
-				  picomp->numrlvls - rlvlno - 1));
-				ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn +
-				  picomp->numrlvls - rlvlno - 1));
-				pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep);
-				pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep);
-			}
-		}
-		pi->prgvolfirst = 0;
-	}
-
-	for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend &&
-	  pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) {
-		for (pi->y = pi->ystart; pi->y < pi->yend; pi->y +=
-		  pi->ystep - (pi->y % pi->ystep)) {
-			for (pi->x = pi->xstart; pi->x < pi->xend; pi->x +=
-			  pi->xstep - (pi->x % pi->xstep)) {
-				for (pi->compno = pchg->compnostart,
-				  pi->picomp = &pi->picomps[pi->compno];
-				  pi->compno < pchg->compnoend && pi->compno <
-				  pi->numcomps; ++pi->compno, ++pi->picomp) {
-					if (pi->rlvlno >= pi->picomp->numrlvls) {
-						continue;
-					}
-					pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
-					if (pi->pirlvl->numprcs == 0) {
-						continue;
-					}
-					r = pi->picomp->numrlvls - 1 - pi->rlvlno;
-					rpx = r + pi->pirlvl->prcwidthexpn;
-					rpy = r + pi->pirlvl->prcheightexpn;
-					trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);
-					try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);
-					if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx)))
-					  || !(pi->x % (1 << rpx))) &&
-					  ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy)))
-					  || !(pi->y % (1 << rpy)))) {
-						prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp
-						  << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,
-						  pi->pirlvl->prcwidthexpn);
-						prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp
-						  << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,
-						  pi->pirlvl->prcheightexpn);
-						pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind;
-
-						assert(pi->prcno < pi->pirlvl->numprcs);
-						for (pi->lyrno = 0; pi->lyrno <
-						  pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) {
-							prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
-							if (pi->lyrno >= *prclyrno) {
-								++(*prclyrno);
-								return 0;
-							}
+        int rlvlno;
+        jpc_pirlvl_t *pirlvl;
+        jpc_pchg_t *pchg;
+        int prchind;
+        int prcvind;
+        int *prclyrno;
+        int compno;
+        jpc_picomp_t *picomp;
+        int xstep;
+        int ystep;
+        uint_fast32_t r;
+        uint_fast32_t rpx;
+        uint_fast32_t rpy;
+        uint_fast32_t trx0;
+        uint_fast32_t try0;
+
+        pchg = pi->pchg;
+        if (!pi->prgvolfirst) {
+                goto skip;
+        } else {
+                pi->xstep = 0;
+                pi->ystep = 0;
+                for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
+                  ++compno, ++picomp) {
+                        for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
+                          picomp->numrlvls; ++rlvlno, ++pirlvl) {
+                                xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn +
+                                  picomp->numrlvls - rlvlno - 1));
+                                ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn +
+                                  picomp->numrlvls - rlvlno - 1));
+                                pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep);
+                                pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep);
+                        }
+                }
+                pi->prgvolfirst = 0;
+        }
+
+        for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend &&
+          pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) {
+                for (pi->y = pi->ystart; pi->y < pi->yend; pi->y +=
+                  pi->ystep - (pi->y % pi->ystep)) {
+                        for (pi->x = pi->xstart; pi->x < pi->xend; pi->x +=
+                          pi->xstep - (pi->x % pi->xstep)) {
+                                for (pi->compno = pchg->compnostart,
+                                  pi->picomp = &pi->picomps[pi->compno];
+                                  pi->compno < pchg->compnoend && pi->compno <
+                                  pi->numcomps; ++pi->compno, ++pi->picomp) {
+                                        if (pi->rlvlno >= pi->picomp->numrlvls) {
+                                                continue;
+                                        }
+                                        pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
+                                        if (pi->pirlvl->numprcs == 0) {
+                                                continue;
+                                        }
+                                        r = pi->picomp->numrlvls - 1 - pi->rlvlno;
+                                        rpx = r + pi->pirlvl->prcwidthexpn;
+                                        rpy = r + pi->pirlvl->prcheightexpn;
+                                        trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);
+                                        try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);
+                                        if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx)))
+                                          || !(pi->x % (1 << rpx))) &&
+                                          ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy)))
+                                          || !(pi->y % (1 << rpy)))) {
+                                                prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp
+                                                  << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,
+                                                  pi->pirlvl->prcwidthexpn);
+                                                prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp
+                                                  << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,
+                                                  pi->pirlvl->prcheightexpn);
+                                                pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind;
+
+                                                assert(pi->prcno < pi->pirlvl->numprcs);
+                                                for (pi->lyrno = 0; pi->lyrno <
+                                                  pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) {
+                                                        prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
+                                                        if (pi->lyrno >= *prclyrno) {
+                                                                ++(*prclyrno);
+                                                                return 0;
+                                                        }
 skip:
-							;
-						}
-					}
-				}
-			}
-		}
-	}
-	return 1;
+                                                        ;
+                                                }
+                                        }
+                                }
+                        }
+                }
+        }
+        return 1;
 }
 
 static int jpc_pi_nextpcrl(register jpc_pi_t *pi)
 {
-	int rlvlno;
-	jpc_pirlvl_t *pirlvl;
-	jpc_pchg_t *pchg;
-	int prchind;
-	int prcvind;
-	int *prclyrno;
-	int compno;
-	jpc_picomp_t *picomp;
-	int xstep;
-	int ystep;
-	uint_fast32_t trx0;
-	uint_fast32_t try0;
-	uint_fast32_t r;
-	uint_fast32_t rpx;
-	uint_fast32_t rpy;
-
-	pchg = pi->pchg;
-	if (!pi->prgvolfirst) {
-		goto skip;
-	} else {
-		pi->xstep = 0;
-		pi->ystep = 0;
-		for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
-		  ++compno, ++picomp) {
-			for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
-			  picomp->numrlvls; ++rlvlno, ++pirlvl) {
-				xstep = picomp->hsamp * (1 <<
-				  (pirlvl->prcwidthexpn + picomp->numrlvls -
-				  rlvlno - 1));
-				ystep = picomp->vsamp * (1 <<
-				  (pirlvl->prcheightexpn + picomp->numrlvls -
-				  rlvlno - 1));
-				pi->xstep = (!pi->xstep) ? xstep :
-				  JAS_MIN(pi->xstep, xstep);
-				pi->ystep = (!pi->ystep) ? ystep :
-				  JAS_MIN(pi->ystep, ystep);
-			}
-		}
-		pi->prgvolfirst = 0;
-	}
-
-	for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += pi->ystep -
-	  (pi->y % pi->ystep)) {
-		for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += pi->xstep -
-		  (pi->x % pi->xstep)) {
-			for (pi->compno = pchg->compnostart, pi->picomp =
-			  &pi->picomps[pi->compno]; pi->compno < pi->numcomps
-			  && pi->compno < pchg->compnoend; ++pi->compno,
-			  ++pi->picomp) {
-				for (pi->rlvlno = pchg->rlvlnostart,
-				  pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
-				  pi->rlvlno < pi->picomp->numrlvls &&
-				  pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno,
-				  ++pi->pirlvl) {
-					if (pi->pirlvl->numprcs == 0) {
-						continue;
-					}
-					r = pi->picomp->numrlvls - 1 - pi->rlvlno;
-					trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);
-					try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);
-					rpx = r + pi->pirlvl->prcwidthexpn;
-					rpy = r + pi->pirlvl->prcheightexpn;
-					if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) ||
-					  !(pi->x % (pi->picomp->hsamp << rpx))) &&
-					  ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) ||
-					  !(pi->y % (pi->picomp->vsamp << rpy)))) {
-						prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp
-						  << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,
-						  pi->pirlvl->prcwidthexpn);
-						prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp
-						  << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,
-						  pi->pirlvl->prcheightexpn);
-						pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind;
-						assert(pi->prcno < pi->pirlvl->numprcs);
-						for (pi->lyrno = 0; pi->lyrno < pi->numlyrs &&
-						  pi->lyrno < pchg->lyrnoend; ++pi->lyrno) {
-							prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
-							if (pi->lyrno >= *prclyrno) {
-								++(*prclyrno);
-								return 0;
-							}
+        int rlvlno;
+        jpc_pirlvl_t *pirlvl;
+        jpc_pchg_t *pchg;
+        int prchind;
+        int prcvind;
+        int *prclyrno;
+        int compno;
+        jpc_picomp_t *picomp;
+        int xstep;
+        int ystep;
+        uint_fast32_t trx0;
+        uint_fast32_t try0;
+        uint_fast32_t r;
+        uint_fast32_t rpx;
+        uint_fast32_t rpy;
+
+        pchg = pi->pchg;
+        if (!pi->prgvolfirst) {
+                goto skip;
+        } else {
+                pi->xstep = 0;
+                pi->ystep = 0;
+                for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
+                  ++compno, ++picomp) {
+                        for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
+                          picomp->numrlvls; ++rlvlno, ++pirlvl) {
+                                xstep = picomp->hsamp * (1 <<
+                                  (pirlvl->prcwidthexpn + picomp->numrlvls -
+                                  rlvlno - 1));
+                                ystep = picomp->vsamp * (1 <<
+                                  (pirlvl->prcheightexpn + picomp->numrlvls -
+                                  rlvlno - 1));
+                                pi->xstep = (!pi->xstep) ? xstep :
+                                  JAS_MIN(pi->xstep, xstep);
+                                pi->ystep = (!pi->ystep) ? ystep :
+                                  JAS_MIN(pi->ystep, ystep);
+                        }
+                }
+                pi->prgvolfirst = 0;
+        }
+
+        for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += pi->ystep -
+          (pi->y % pi->ystep)) {
+                for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += pi->xstep -
+                  (pi->x % pi->xstep)) {
+                        for (pi->compno = pchg->compnostart, pi->picomp =
+                          &pi->picomps[pi->compno]; pi->compno < pi->numcomps
+                          && pi->compno < pchg->compnoend; ++pi->compno,
+                          ++pi->picomp) {
+                                for (pi->rlvlno = pchg->rlvlnostart,
+                                  pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
+                                  pi->rlvlno < pi->picomp->numrlvls &&
+                                  pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno,
+                                  ++pi->pirlvl) {
+                                        if (pi->pirlvl->numprcs == 0) {
+                                                continue;
+                                        }
+                                        r = pi->picomp->numrlvls - 1 - pi->rlvlno;
+                                        trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);
+                                        try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);
+                                        rpx = r + pi->pirlvl->prcwidthexpn;
+                                        rpy = r + pi->pirlvl->prcheightexpn;
+                                        if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) ||
+                                          !(pi->x % (pi->picomp->hsamp << rpx))) &&
+                                          ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) ||
+                                          !(pi->y % (pi->picomp->vsamp << rpy)))) {
+                                                prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp
+                                                  << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,
+                                                  pi->pirlvl->prcwidthexpn);
+                                                prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp
+                                                  << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,
+                                                  pi->pirlvl->prcheightexpn);
+                                                pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind;
+                                                assert(pi->prcno < pi->pirlvl->numprcs);
+                                                for (pi->lyrno = 0; pi->lyrno < pi->numlyrs &&
+                                                  pi->lyrno < pchg->lyrnoend; ++pi->lyrno) {
+                                                        prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
+                                                        if (pi->lyrno >= *prclyrno) {
+                                                                ++(*prclyrno);
+                                                                return 0;
+                                                        }
 skip:
-							;
-						}
-					}
-				}
-			}
-		}
-	}
-	return 1;
+                                                        ;
+                                                }
+                                        }
+                                }
+                        }
+                }
+        }
+        return 1;
 }
 
 static int jpc_pi_nextcprl(register jpc_pi_t *pi)
 {
-	int rlvlno;
-	jpc_pirlvl_t *pirlvl;
-	jpc_pchg_t *pchg;
-	int prchind;
-	int prcvind;
-	int *prclyrno;
-	uint_fast32_t trx0;
-	uint_fast32_t try0;
-	uint_fast32_t r;
-	uint_fast32_t rpx;
-	uint_fast32_t rpy;
-
-	pchg = pi->pchg;
-	if (!pi->prgvolfirst) {
-		goto skip;
-	} else {
-		pi->prgvolfirst = 0;
-	}
-
-	for (pi->compno = pchg->compnostart, pi->picomp =
-	  &pi->picomps[pi->compno]; pi->compno < pchg->compnoend; ++pi->compno,
-	  ++pi->picomp) {
-		pirlvl = pi->picomp->pirlvls;
-		pi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn +
-		  pi->picomp->numrlvls - 1));
-		pi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn +
-		  pi->picomp->numrlvls - 1));
-		for (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1];
-		  rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) {
-			pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 <<
-			  (pirlvl->prcwidthexpn + pi->picomp->numrlvls -
-			  rlvlno - 1)));
-			pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 <<
-			  (pirlvl->prcheightexpn + pi->picomp->numrlvls -
-			  rlvlno - 1)));
-		}
-		for (pi->y = pi->ystart; pi->y < pi->yend;
-		  pi->y += pi->ystep - (pi->y % pi->ystep)) {
-			for (pi->x = pi->xstart; pi->x < pi->xend;
-			  pi->x += pi->xstep - (pi->x % pi->xstep)) {
-				for (pi->rlvlno = pchg->rlvlnostart,
-				  pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
-				  pi->rlvlno < pi->picomp->numrlvls && pi->rlvlno <
-				  pchg->rlvlnoend; ++pi->rlvlno, ++pi->pirlvl) {
-					if (pi->pirlvl->numprcs == 0) {
-						continue;
-					}
-					r = pi->picomp->numrlvls - 1 - pi->rlvlno;
-					trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);
-					try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);
-					rpx = r + pi->pirlvl->prcwidthexpn;
-					rpy = r + pi->pirlvl->prcheightexpn;
-					if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) ||
-					  !(pi->x % (pi->picomp->hsamp << rpx))) &&
-					  ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) ||
-					  !(pi->y % (pi->picomp->vsamp << rpy)))) {
-						prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp
-						  << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,
-						  pi->pirlvl->prcwidthexpn);
-						prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp
-						  << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,
-						  pi->pirlvl->prcheightexpn);
-						pi->prcno = prcvind *
-						  pi->pirlvl->numhprcs +
-						  prchind;
-						assert(pi->prcno <
-						  pi->pirlvl->numprcs);
-						for (pi->lyrno = 0; pi->lyrno <
-						  pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) {
-							prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
-							if (pi->lyrno >= *prclyrno) {
-								++(*prclyrno);
-								return 0;
-							}
+        int rlvlno;
+        jpc_pirlvl_t *pirlvl;
+        jpc_pchg_t *pchg;
+        int prchind;
+        int prcvind;
+        int *prclyrno;
+        uint_fast32_t trx0;
+        uint_fast32_t try0;
+        uint_fast32_t r;
+        uint_fast32_t rpx;
+        uint_fast32_t rpy;
+
+        pchg = pi->pchg;
+        if (!pi->prgvolfirst) {
+                goto skip;
+        } else {
+                pi->prgvolfirst = 0;
+        }
+
+        for (pi->compno = pchg->compnostart, pi->picomp =
+          &pi->picomps[pi->compno]; pi->compno < pchg->compnoend; ++pi->compno,
+          ++pi->picomp) {
+                pirlvl = pi->picomp->pirlvls;
+                pi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn +
+                  pi->picomp->numrlvls - 1));
+                pi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn +
+                  pi->picomp->numrlvls - 1));
+                for (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1];
+                  rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) {
+                        pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 <<
+                          (pirlvl->prcwidthexpn + pi->picomp->numrlvls -
+                          rlvlno - 1)));
+                        pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 <<
+                          (pirlvl->prcheightexpn + pi->picomp->numrlvls -
+                          rlvlno - 1)));
+                }
+                for (pi->y = pi->ystart; pi->y < pi->yend;
+                  pi->y += pi->ystep - (pi->y % pi->ystep)) {
+                        for (pi->x = pi->xstart; pi->x < pi->xend;
+                          pi->x += pi->xstep - (pi->x % pi->xstep)) {
+                                for (pi->rlvlno = pchg->rlvlnostart,
+                                  pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];
+                                  pi->rlvlno < pi->picomp->numrlvls && pi->rlvlno <
+                                  pchg->rlvlnoend; ++pi->rlvlno, ++pi->pirlvl) {
+                                        if (pi->pirlvl->numprcs == 0) {
+                                                continue;
+                                        }
+                                        r = pi->picomp->numrlvls - 1 - pi->rlvlno;
+                                        trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);
+                                        try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);
+                                        rpx = r + pi->pirlvl->prcwidthexpn;
+                                        rpy = r + pi->pirlvl->prcheightexpn;
+                                        if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) ||
+                                          !(pi->x % (pi->picomp->hsamp << rpx))) &&
+                                          ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) ||
+                                          !(pi->y % (pi->picomp->vsamp << rpy)))) {
+                                                prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp
+                                                  << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,
+                                                  pi->pirlvl->prcwidthexpn);
+                                                prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp
+                                                  << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,
+                                                  pi->pirlvl->prcheightexpn);
+                                                pi->prcno = prcvind *
+                                                  pi->pirlvl->numhprcs +
+                                                  prchind;
+                                                assert(pi->prcno <
+                                                  pi->pirlvl->numprcs);
+                                                for (pi->lyrno = 0; pi->lyrno <
+                                                  pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) {
+                                                        prclyrno = &pi->pirlvl->prclyrnos[pi->prcno];
+                                                        if (pi->lyrno >= *prclyrno) {
+                                                                ++(*prclyrno);
+                                                                return 0;
+                                                        }
 skip:
-							;
-						}
-					}
-				}
-			}
-		}
-	}
-	return 1;
+                                                        ;
+                                                }
+                                        }
+                                }
+                        }
+                }
+        }
+        return 1;
 }
 
 static void pirlvl_destroy(jpc_pirlvl_t *rlvl)
 {
-	if (rlvl->prclyrnos) {
-		jas_free(rlvl->prclyrnos);
-	}
+        if (rlvl->prclyrnos) {
+                jas_free(rlvl->prclyrnos);
+        }
 }
 
 static void jpc_picomp_destroy(jpc_picomp_t *picomp)
 {
-	int rlvlno;
-	jpc_pirlvl_t *pirlvl;
-	if (picomp->pirlvls) {
-		for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
-		  picomp->numrlvls; ++rlvlno, ++pirlvl) {
-			pirlvl_destroy(pirlvl);
-		}
-		jas_free(picomp->pirlvls);
-	}
+        int rlvlno;
+        jpc_pirlvl_t *pirlvl;
+        if (picomp->pirlvls) {
+                for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
+                  picomp->numrlvls; ++rlvlno, ++pirlvl) {
+                        pirlvl_destroy(pirlvl);
+                }
+                jas_free(picomp->pirlvls);
+        }
 }
 
 void jpc_pi_destroy(jpc_pi_t *pi)
 {
-	jpc_picomp_t *picomp;
-	int compno;
-	if (pi->picomps) {
-		for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
-		  ++compno, ++picomp) {
-			jpc_picomp_destroy(picomp);
-		}
-		jas_free(pi->picomps);
-	}
-	if (pi->pchglist) {
-		jpc_pchglist_destroy(pi->pchglist);
-	}
-	jas_free(pi);
+        jpc_picomp_t *picomp;
+        int compno;
+        if (pi->picomps) {
+                for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
+                  ++compno, ++picomp) {
+                        jpc_picomp_destroy(picomp);
+                }
+                jas_free(pi->picomps);
+        }
+        if (pi->pchglist) {
+                jpc_pchglist_destroy(pi->pchglist);
+        }
+        jas_free(pi);
 }
 
 jpc_pi_t *jpc_pi_create0(void)
 {
-	jpc_pi_t *pi;
-	if (!(pi = jas_malloc(sizeof(jpc_pi_t)))) {
-		return 0;
-	}
-	pi->picomps = 0;
-	pi->pchgno = 0;
-	if (!(pi->pchglist = jpc_pchglist_create())) {
-		jas_free(pi);
-		return 0;
-	}
-	return pi;
+        jpc_pi_t *pi;
+        if (!(pi = jas_malloc(sizeof(jpc_pi_t)))) {
+                return 0;
+        }
+        pi->picomps = 0;
+        pi->pchgno = 0;
+        if (!(pi->pchglist = jpc_pchglist_create())) {
+                jas_free(pi);
+                return 0;
+        }
+        return pi;
 }
 
 int jpc_pi_addpchg(jpc_pi_t *pi, jpc_pocpchg_t *pchg)
 {
-	return jpc_pchglist_insert(pi->pchglist, -1, pchg);
+        return jpc_pchglist_insert(pi->pchglist, -1, pchg);
 }
 
 jpc_pchglist_t *jpc_pchglist_create(void)
 {
-	jpc_pchglist_t *pchglist;
-	if (!(pchglist = jas_malloc(sizeof(jpc_pchglist_t)))) {
-		return 0;
-	}
-	pchglist->numpchgs = 0;
-	pchglist->maxpchgs = 0;
-	pchglist->pchgs = 0;
-	return pchglist;
+        jpc_pchglist_t *pchglist;
+        if (!(pchglist = jas_malloc(sizeof(jpc_pchglist_t)))) {
+                return 0;
+        }
+        pchglist->numpchgs = 0;
+        pchglist->maxpchgs = 0;
+        pchglist->pchgs = 0;
+        return pchglist;
 }
 
 int jpc_pchglist_insert(jpc_pchglist_t *pchglist, int pchgno, jpc_pchg_t *pchg)
 {
-	int i;
-	int newmaxpchgs;
-	jpc_pchg_t **newpchgs;
-	if (pchgno < 0) {
-		pchgno = pchglist->numpchgs;
-	}
-	if (pchglist->numpchgs >= pchglist->maxpchgs) {
-		newmaxpchgs = pchglist->maxpchgs + 128;
-		if (!(newpchgs = jas_realloc(pchglist->pchgs, newmaxpchgs * sizeof(jpc_pchg_t *)))) {
-			return -1;
-		}
-		pchglist->maxpchgs = newmaxpchgs;
-		pchglist->pchgs = newpchgs;
-	}
-	for (i = pchglist->numpchgs; i > pchgno; --i) {
-		pchglist->pchgs[i] = pchglist->pchgs[i - 1];
-	}
-	pchglist->pchgs[pchgno] = pchg;
-	++pchglist->numpchgs;
-	return 0;
+        int i;
+        int newmaxpchgs;
+        jpc_pchg_t **newpchgs;
+        if (pchgno < 0) {
+                pchgno = pchglist->numpchgs;
+        }
+        if (pchglist->numpchgs >= pchglist->maxpchgs) {
+                newmaxpchgs = pchglist->maxpchgs + 128;
+                if (!(newpchgs = jas_realloc(pchglist->pchgs, newmaxpchgs * sizeof(jpc_pchg_t *)))) {
+                        return -1;
+                }
+                pchglist->maxpchgs = newmaxpchgs;
+                pchglist->pchgs = newpchgs;
+        }
+        for (i = pchglist->numpchgs; i > pchgno; --i) {
+                pchglist->pchgs[i] = pchglist->pchgs[i - 1];
+        }
+        pchglist->pchgs[pchgno] = pchg;
+        ++pchglist->numpchgs;
+        return 0;
 }
 
 jpc_pchg_t *jpc_pchglist_remove(jpc_pchglist_t *pchglist, int pchgno)
 {
-	int i;
-	jpc_pchg_t *pchg;
-	assert(pchgno < pchglist->numpchgs);
-	pchg = pchglist->pchgs[pchgno];
-	for (i = pchgno + 1; i < pchglist->numpchgs; ++i) {
-		pchglist->pchgs[i - 1] = pchglist->pchgs[i];
-	}
-	--pchglist->numpchgs;
-	return pchg;
+        int i;
+        jpc_pchg_t *pchg;
+        assert(pchgno < pchglist->numpchgs);
+        pchg = pchglist->pchgs[pchgno];
+        for (i = pchgno + 1; i < pchglist->numpchgs; ++i) {
+                pchglist->pchgs[i - 1] = pchglist->pchgs[i];
+        }
+        --pchglist->numpchgs;
+        return pchg;
 }
 
 jpc_pchg_t *jpc_pchg_copy(jpc_pchg_t *pchg)
 {
-	jpc_pchg_t *newpchg;
-	if (!(newpchg = jas_malloc(sizeof(jpc_pchg_t)))) {
-		return 0;
-	}
-	*newpchg = *pchg;
-	return newpchg;
+        jpc_pchg_t *newpchg;
+        if (!(newpchg = jas_malloc(sizeof(jpc_pchg_t)))) {
+                return 0;
+        }
+        *newpchg = *pchg;
+        return newpchg;
 }
 
 jpc_pchglist_t *jpc_pchglist_copy(jpc_pchglist_t *pchglist)
 {
-	jpc_pchglist_t *newpchglist;
-	jpc_pchg_t *newpchg;
-	int pchgno;
-	if (!(newpchglist = jpc_pchglist_create())) {
-		return 0;
-	}
-	for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) {
-		if (!(newpchg = jpc_pchg_copy(pchglist->pchgs[pchgno])) ||
-		  jpc_pchglist_insert(newpchglist, -1, newpchg)) {
-			jpc_pchglist_destroy(newpchglist);
-			return 0;
-		}
-	}
-	return newpchglist;
+        jpc_pchglist_t *newpchglist;
+        jpc_pchg_t *newpchg;
+        int pchgno;
+        if (!(newpchglist = jpc_pchglist_create())) {
+                return 0;
+        }
+        for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) {
+                if (!(newpchg = jpc_pchg_copy(pchglist->pchgs[pchgno])) ||
+                  jpc_pchglist_insert(newpchglist, -1, newpchg)) {
+                        jpc_pchglist_destroy(newpchglist);
+                        return 0;
+                }
+        }
+        return newpchglist;
 }
 
 void jpc_pchglist_destroy(jpc_pchglist_t *pchglist)
 {
-	int pchgno;
-	if (pchglist->pchgs) {
-		for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) {
-			jpc_pchg_destroy(pchglist->pchgs[pchgno]);
-		}
-		jas_free(pchglist->pchgs);
-	}
-	jas_free(pchglist);
+        int pchgno;
+        if (pchglist->pchgs) {
+                for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) {
+                        jpc_pchg_destroy(pchglist->pchgs[pchgno]);
+                }
+                jas_free(pchglist->pchgs);
+        }
+        jas_free(pchglist);
 }
 
 void jpc_pchg_destroy(jpc_pchg_t *pchg)
 {
-	jas_free(pchg);
+        jas_free(pchg);
 }
 
 jpc_pchg_t *jpc_pchglist_get(jpc_pchglist_t *pchglist, int pchgno)
 {
-	return pchglist->pchgs[pchgno];
+        return pchglist->pchgs[pchgno];
 }
 
 int jpc_pchglist_numpchgs(jpc_pchglist_t *pchglist)
 {
-	return pchglist->numpchgs;
+        return pchglist->numpchgs;
 }
 
 int jpc_pi_init(jpc_pi_t *pi)
 {
-	int compno;
-	int rlvlno;
-	int prcno;
-	jpc_picomp_t *picomp;
-	jpc_pirlvl_t *pirlvl;
-	int *prclyrno;
-
-	pi->prgvolfirst = 0;
-	pi->valid = 0;
-	pi->pktno = -1;
-	pi->pchgno = -1;
-	pi->pchg = 0;
-
-	for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
-	  ++compno, ++picomp) {
-		for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
-		  picomp->numrlvls; ++rlvlno, ++pirlvl) {
-			for (prcno = 0, prclyrno = pirlvl->prclyrnos;
-			  prcno < pirlvl->numprcs; ++prcno, ++prclyrno) {
-				*prclyrno = 0;
-			}
-		}
-	}
-	return 0;
+        int compno;
+        int rlvlno;
+        int prcno;
+        jpc_picomp_t *picomp;
+        jpc_pirlvl_t *pirlvl;
+        int *prclyrno;
+
+        pi->prgvolfirst = 0;
+        pi->valid = 0;
+        pi->pktno = -1;
+        pi->pchgno = -1;
+        pi->pchg = 0;
+
+        for (compno = 0, picomp = pi->picomps; compno < pi->numcomps;
+          ++compno, ++picomp) {
+                for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
+                  picomp->numrlvls; ++rlvlno, ++pirlvl) {
+                        for (prcno = 0, prclyrno = pirlvl->prclyrnos;
+                          prcno < pirlvl->numprcs; ++prcno, ++prclyrno) {
+                                *prclyrno = 0;
+                        }
+                }
+        }
+        return 0;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h
index 82dafcce..8e9b6b15 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -117,7 +117,7 @@
  */
 
 #ifndef JPC_T2COD_H
-#define	JPC_T2COD_H
+#define JPC_T2COD_H
 
 /******************************************************************************\
 * Includes.
@@ -133,15 +133,15 @@
 
 typedef struct {
 
-	/* The number of progression changes. */
-	int numpchgs;
+        /* The number of progression changes. */
+        int numpchgs;
 
-	/* The maximum number of progression changes that can be accommodated
-	  without growing the progression change array. */
-	int maxpchgs;
+        /* The maximum number of progression changes that can be accommodated
+          without growing the progression change array. */
+        int maxpchgs;
 
-	/* The progression changes. */
-	jpc_pchg_t **pchgs;
+        /* The progression changes. */
+        jpc_pchg_t **pchgs;
 
 } jpc_pchglist_t;
 
@@ -149,21 +149,21 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of precincts. */
-	int numprcs;
+        /* The number of precincts. */
+        int numprcs;
 
-	/* The last layer processed for each precinct. */
-	int *prclyrnos;
+        /* The last layer processed for each precinct. */
+        int *prclyrnos;
 
-	/* The precinct width exponent. */
-	int prcwidthexpn;
+        /* The precinct width exponent. */
+        int prcwidthexpn;
 
-	/* The precinct height exponent. */
-	int prcheightexpn;
+        /* The precinct height exponent. */
+        int prcheightexpn;
 
-	/* The number of precincts spanning the resolution level in the horizontal
-	  direction. */
-	int numhprcs;
+        /* The number of precincts spanning the resolution level in the horizontal
+          direction. */
+        int numhprcs;
 
 } jpc_pirlvl_t;
 
@@ -171,17 +171,17 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of resolution levels. */
-	int numrlvls;
+        /* The number of resolution levels. */
+        int numrlvls;
 
-	/* The per-resolution-level information. */
-	jpc_pirlvl_t *pirlvls;
+        /* The per-resolution-level information. */
+        jpc_pirlvl_t *pirlvls;
 
-	/* The horizontal sampling period. */
-	int hsamp;
+        /* The horizontal sampling period. */
+        int hsamp;
 
-	/* The vertical sampling period. */
-	int vsamp;
+        /* The vertical sampling period. */
+        int vsamp;
 
 } jpc_picomp_t;
 
@@ -189,84 +189,84 @@ typedef struct {
 
 typedef struct {
 
-	/* The number of layers. */
-	int numlyrs;
+        /* The number of layers. */
+        int numlyrs;
 
-	/* The number of resolution levels. */
-	int maxrlvls;
+        /* The number of resolution levels. */
+        int maxrlvls;
 
-	/* The number of components. */
-	int numcomps;
+        /* The number of components. */
+        int numcomps;
 
-	/* The per-component information. */
-	jpc_picomp_t *picomps;
+        /* The per-component information. */
+        jpc_picomp_t *picomps;
 
-	/* The current component. */
-	jpc_picomp_t *picomp;
+        /* The current component. */
+        jpc_picomp_t *picomp;
 
-	/* The current resolution level. */
-	jpc_pirlvl_t *pirlvl;
+        /* The current resolution level. */
+        jpc_pirlvl_t *pirlvl;
 
-	/* The number of the current component. */
-	int compno;
+        /* The number of the current component. */
+        int compno;
 
-	/* The number of the current resolution level. */
-	int rlvlno;
+        /* The number of the current resolution level. */
+        int rlvlno;
 
-	/* The number of the current precinct. */
-	int prcno;
+        /* The number of the current precinct. */
+        int prcno;
 
-	/* The number of the current layer. */
-	int lyrno;
+        /* The number of the current layer. */
+        int lyrno;
 
-	/* The x-coordinate of the current position. */
-	int x;
+        /* The x-coordinate of the current position. */
+        int x;
 
-	/* The y-coordinate of the current position. */
-	int y;
+        /* The y-coordinate of the current position. */
+        int y;
 
-	/* The horizontal step size. */
-	int xstep;
+        /* The horizontal step size. */
+        int xstep;
 
-	/* The vertical step size. */
-	int ystep;
+        /* The vertical step size. */
+        int ystep;
 
-	/* The x-coordinate of the top-left corner of the tile on the reference
-	  grid. */
-	int xstart;
+        /* The x-coordinate of the top-left corner of the tile on the reference
+          grid. */
+        int xstart;
 
-	/* The y-coordinate of the top-left corner of the tile on the reference
-	  grid. */
-	int ystart;
+        /* The y-coordinate of the top-left corner of the tile on the reference
+          grid. */
+        int ystart;
 
-	/* The x-coordinate of the bottom-right corner of the tile on the
-	  reference grid (plus one). */
-	int xend;
+        /* The x-coordinate of the bottom-right corner of the tile on the
+          reference grid (plus one). */
+        int xend;
 
-	/* The y-coordinate of the bottom-right corner of the tile on the
-	  reference grid (plus one). */
-	int yend;
+        /* The y-coordinate of the bottom-right corner of the tile on the
+          reference grid (plus one). */
+        int yend;
 
-	/* The current progression change. */
-	jpc_pchg_t *pchg;
+        /* The current progression change. */
+        jpc_pchg_t *pchg;
 
-	/* The progression change list. */
-	jpc_pchglist_t *pchglist;
+        /* The progression change list. */
+        jpc_pchglist_t *pchglist;
 
-	/* The progression to use in the absence of explicit specification. */
-	jpc_pchg_t defaultpchg;
+        /* The progression to use in the absence of explicit specification. */
+        jpc_pchg_t defaultpchg;
 
-	/* The current progression change number. */
-	int pchgno;
+        /* The current progression change number. */
+        int pchgno;
 
-	/* Is this the first time in the current progression volume? */
-	bool prgvolfirst;
+        /* Is this the first time in the current progression volume? */
+        bool prgvolfirst;
 
-	/* Is the current iterator value valid? */
-	bool valid;
+        /* Is the current iterator value valid? */
+        bool valid;
 
-	/* The current packet number. */
-	int pktno;
+        /* The current packet number. */
+        int pktno;
 
 } jpc_pi_t;
 
@@ -293,22 +293,22 @@ int jpc_pi_begin(jpc_pi_t *pi);
 int jpc_pi_next(jpc_pi_t *pi);
 
 /* Get the index of the current packet. */
-#define	jpc_pi_getind(pi)	((pi)->pktno)
+#define jpc_pi_getind(pi)       ((pi)->pktno)
 
 /* Get the component number of the current packet. */
-#define jpc_pi_cmptno(pi)	(assert(pi->valid), (pi)->compno)
+#define jpc_pi_cmptno(pi)       (assert(pi->valid), (pi)->compno)
 
 /* Get the resolution level of the current packet. */
-#define jpc_pi_rlvlno(pi)	(assert(pi->valid), (pi)->rlvlno)
+#define jpc_pi_rlvlno(pi)       (assert(pi->valid), (pi)->rlvlno)
 
 /* Get the layer number of the current packet. */
-#define jpc_pi_lyrno(pi)	(assert(pi->valid), (pi)->lyrno)
+#define jpc_pi_lyrno(pi)        (assert(pi->valid), (pi)->lyrno)
 
 /* Get the precinct number of the current packet. */
-#define jpc_pi_prcno(pi)	(assert(pi->valid), (pi)->prcno)
+#define jpc_pi_prcno(pi)        (assert(pi->valid), (pi)->prcno)
 
 /* Get the progression order for the current packet. */
-#define jpc_pi_prg(pi)	(assert(pi->valid), (pi)->pchg->prgord)
+#define jpc_pi_prg(pi)  (assert(pi->valid), (pi)->pchg->prgord)
 
 /******************************************************************************\
 * Functions/macros for progression change lists.
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c
index 9aaaa55c..a05e1c10 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -155,305 +155,305 @@ static int jpc_dec_decodepkt(jpc_dec_t *dec, jas_stream_t *pkthdrstream, jas_str
 
 static int jpc_getcommacode(jpc_bitstream_t *in)
 {
-	int n;
-	int v;
-
-	n = 0;
-	for (;;) {
-		if ((v = jpc_bitstream_getbit(in)) < 0) {
-			return -1;
-		}
-		if (jpc_bitstream_eof(in)) {
-			return -1;
-		}
-		if (!v) {
-			break;
-		}
-		++n;
-	}
-
-	return n;
+        int n;
+        int v;
+
+        n = 0;
+        for (;;) {
+                if ((v = jpc_bitstream_getbit(in)) < 0) {
+                        return -1;
+                }
+                if (jpc_bitstream_eof(in)) {
+                        return -1;
+                }
+                if (!v) {
+                        break;
+                }
+                ++n;
+        }
+
+        return n;
 }
 
 static int jpc_getnumnewpasses(jpc_bitstream_t *in)
 {
-	int n;
-
-	if ((n = jpc_bitstream_getbit(in)) > 0) {
-		if ((n = jpc_bitstream_getbit(in)) > 0) {
-			if ((n = jpc_bitstream_getbits(in, 2)) == 3) {
-				if ((n = jpc_bitstream_getbits(in, 5)) == 31) {
-					if ((n = jpc_bitstream_getbits(in, 7)) >= 0) {
-						n += 36 + 1;
-					}
-				} else if (n >= 0) {
-					n += 5 + 1;
-				}
-			} else if (n >= 0) {
-				n += 2 + 1;
-			}
-		} else if (!n) {
-			n += 2;
-		}
-	} else if (!n) {
-		++n;
-	}
-
-	return n;
+        int n;
+
+        if ((n = jpc_bitstream_getbit(in)) > 0) {
+                if ((n = jpc_bitstream_getbit(in)) > 0) {
+                        if ((n = jpc_bitstream_getbits(in, 2)) == 3) {
+                                if ((n = jpc_bitstream_getbits(in, 5)) == 31) {
+                                        if ((n = jpc_bitstream_getbits(in, 7)) >= 0) {
+                                                n += 36 + 1;
+                                        }
+                                } else if (n >= 0) {
+                                        n += 5 + 1;
+                                }
+                        } else if (n >= 0) {
+                                n += 2 + 1;
+                        }
+                } else if (!n) {
+                        n += 2;
+                }
+        } else if (!n) {
+                ++n;
+        }
+
+        return n;
 }
 
 static int jpc_dec_decodepkt(jpc_dec_t *dec, jas_stream_t *pkthdrstream, jas_stream_t *in, int compno, int rlvlno,
   int prcno, int lyrno)
 {
-	jpc_bitstream_t *inb;
-	jpc_dec_tcomp_t *tcomp;
-	jpc_dec_rlvl_t *rlvl;
-	jpc_dec_band_t *band;
-	jpc_dec_cblk_t *cblk;
-	int n;
-	int m;
-	int i;
-	jpc_tagtreenode_t *leaf;
-	int included;
-	int ret;
-	int numnewpasses;
-	jpc_dec_seg_t *seg;
-	int len;
-	int present;
-	int savenumnewpasses;
-	int mycounter;
-	jpc_ms_t *ms;
-	jpc_dec_tile_t *tile;
-	jpc_dec_ccp_t *ccp;
-	jpc_dec_cp_t *cp;
-	int bandno;
-	jpc_dec_prc_t *prc;
-	int usedcblkcnt;
-	int cblkno;
-	uint_fast32_t bodylen;
-	bool discard;
-	int passno;
-	int maxpasses;
-	int hdrlen;
-	int hdroffstart;
-	int hdroffend;
-
-	discard = (lyrno >= dec->maxlyrs);
-
-	tile = dec->curtile;
-	cp = tile->cp;
-	ccp = &cp->ccps[compno];
-
-	/*
-	 * Decode the packet header.
-	 */
-
-	/* Decode the SOP marker segment if present. */
-	if (cp->csty & JPC_COD_SOP) {
-		if (jpc_dec_lookahead(in) == JPC_MS_SOP) {
-			if (!(ms = jpc_getms(in, dec->cstate))) {
-				return -1;
-			}
-			if (jpc_ms_gettype(ms) != JPC_MS_SOP) {
-				jpc_ms_destroy(ms);
-				fprintf(stderr, "missing SOP marker segment\n");
-				return -1;
-			}
-			jpc_ms_destroy(ms);
-		}
-	}
+        jpc_bitstream_t *inb;
+        jpc_dec_tcomp_t *tcomp;
+        jpc_dec_rlvl_t *rlvl;
+        jpc_dec_band_t *band;
+        jpc_dec_cblk_t *cblk;
+        int n;
+        int m;
+        int i;
+        jpc_tagtreenode_t *leaf;
+        int included;
+        int ret;
+        int numnewpasses;
+        jpc_dec_seg_t *seg;
+        int len;
+        int present;
+        int savenumnewpasses;
+        int mycounter;
+        jpc_ms_t *ms;
+        jpc_dec_tile_t *tile;
+        jpc_dec_ccp_t *ccp;
+        jpc_dec_cp_t *cp;
+        int bandno;
+        jpc_dec_prc_t *prc;
+        int usedcblkcnt;
+        int cblkno;
+        uint_fast32_t bodylen;
+        bool discard;
+        int passno;
+        int maxpasses;
+        int hdrlen;
+        int hdroffstart;
+        int hdroffend;
+
+        discard = (lyrno >= dec->maxlyrs);
+
+        tile = dec->curtile;
+        cp = tile->cp;
+        ccp = &cp->ccps[compno];
+
+        /*
+         * Decode the packet header.
+         */
+
+        /* Decode the SOP marker segment if present. */
+        if (cp->csty & JPC_COD_SOP) {
+                if (jpc_dec_lookahead(in) == JPC_MS_SOP) {
+                        if (!(ms = jpc_getms(in, dec->cstate))) {
+                                return -1;
+                        }
+                        if (jpc_ms_gettype(ms) != JPC_MS_SOP) {
+                                jpc_ms_destroy(ms);
+                                fprintf(stderr, "missing SOP marker segment\n");
+                                return -1;
+                        }
+                        jpc_ms_destroy(ms);
+                }
+        }
 
 hdroffstart = jas_stream_getrwcount(pkthdrstream);
 
-	if (!(inb = jpc_bitstream_sopen(pkthdrstream, "r"))) {
-		return -1;
-	}
-
-	if ((present = jpc_bitstream_getbit(inb)) < 0) {
-		return 1;
-	}
-	JAS_DBGLOG(10, ("\n", present));
-	JAS_DBGLOG(10, ("present=%d ", present));
-
-	/* Is the packet non-empty? */
-	if (present) {
-		/* The packet is non-empty. */
-		tcomp = &tile->tcomps[compno];
-		rlvl = &tcomp->rlvls[rlvlno];
-		bodylen = 0;
-		for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
-		  ++bandno, ++band) {
-			if (!band->data) {
-				continue;
-			}
-			prc = &band->prcs[prcno];
-			if (!prc->cblks) {
-				continue;
-			}
-			usedcblkcnt = 0;
-			for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;
-			  ++cblkno, ++cblk) {
-				++usedcblkcnt;
-				if (!cblk->numpasses) {
-					leaf = jpc_tagtree_getleaf(prc->incltagtree, usedcblkcnt - 1);
-					if ((included = jpc_tagtree_decode(prc->incltagtree, leaf, lyrno + 1, inb)) < 0) {
-						return -1;
-					}
-				} else {
-					if ((included = jpc_bitstream_getbit(inb)) < 0) {
-						return -1;
-					}
-				}
-				JAS_DBGLOG(10, ("\n"));
-				JAS_DBGLOG(10, ("included=%d ", included));
-				if (!included) {
-					continue;
-				}
-				if (!cblk->numpasses) {
-					i = 1;
-					leaf = jpc_tagtree_getleaf(prc->numimsbstagtree, usedcblkcnt - 1);
-					for (;;) {
-						if ((ret = jpc_tagtree_decode(prc->numimsbstagtree, leaf, i, inb)) < 0) {
-							return -1;
-						}
-						if (ret) {
-							break;
-						}
-						++i;
-					}
-					cblk->numimsbs = i - 1;
-					cblk->firstpassno = cblk->numimsbs * 3;
-				}
-				if ((numnewpasses = jpc_getnumnewpasses(inb)) < 0) {
-					return -1;
-				}
-				JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses));
-				seg = cblk->curseg;
-				savenumnewpasses = numnewpasses;
-				mycounter = 0;
-				if (numnewpasses > 0) {
-					if ((m = jpc_getcommacode(inb)) < 0) {
-						return -1;
-					}
-					cblk->numlenbits += m;
-					JAS_DBGLOG(10, ("increment=%d ", m));
-					while (numnewpasses > 0) {
-						passno = cblk->firstpassno + cblk->numpasses + mycounter;
-	/* XXX - the maxpasses is not set precisely but this doesn't matter... */
-						maxpasses = JPC_SEGPASSCNT(passno, cblk->firstpassno, 10000, (ccp->cblkctx & JPC_COX_LAZY) != 0, (ccp->cblkctx & JPC_COX_TERMALL) != 0);
-						if (!discard && !seg) {
-							if (!(seg = jpc_seg_alloc())) {
-								return -1;
-							}
-							jpc_seglist_insert(&cblk->segs, cblk->segs.tail, seg);
-							if (!cblk->curseg) {
-								cblk->curseg = seg;
-							}
-							seg->passno = passno;
-							seg->type = JPC_SEGTYPE(seg->passno, cblk->firstpassno, (ccp->cblkctx & JPC_COX_LAZY) != 0);
-							seg->maxpasses = maxpasses;
-						}
-						n = JAS_MIN(numnewpasses, maxpasses);
-						mycounter += n;
-						numnewpasses -= n;
-						if ((len = jpc_bitstream_getbits(inb, cblk->numlenbits + jpc_floorlog2(n))) < 0) {
-							return -1;
-						}
-						JAS_DBGLOG(10, ("len=%d ", len));
-						if (!discard) {
-							seg->lyrno = lyrno;
-							seg->numpasses += n;
-							seg->cnt = len;
-							seg = seg->next;
-						}
-						bodylen += len;
-					}
-				}
-				cblk->numpasses += savenumnewpasses;
-			}
-		}
-
-		jpc_bitstream_inalign(inb, 0, 0);
-
-	} else {
-		if (jpc_bitstream_inalign(inb, 0x7f, 0)) {
-			fprintf(stderr, "alignment failed\n");
-			return -1;
-		}
-	}
-	jpc_bitstream_close(inb);
-
-	hdroffend = jas_stream_getrwcount(pkthdrstream);
-	hdrlen = hdroffend - hdroffstart;
-	if (jas_getdbglevel() >= 5) {
-		fprintf(stderr, "hdrlen=%lu bodylen=%lu \n", (unsigned long) hdrlen,
-		  (unsigned long) bodylen);
-	}
-
-	if (cp->csty & JPC_COD_EPH) {
-		if (jpc_dec_lookahead(pkthdrstream) == JPC_MS_EPH) {
-			if (!(ms = jpc_getms(pkthdrstream, dec->cstate))) {
-				fprintf(stderr, "cannot get (EPH) marker segment\n");
-				return -1;
-			}
-			if (jpc_ms_gettype(ms) != JPC_MS_EPH) {
-				jpc_ms_destroy(ms);
-				fprintf(stderr, "missing EPH marker segment\n");
-				return -1;
-			}
-			jpc_ms_destroy(ms);
-		}
-	}
-
-	/* decode the packet body. */
-
-	if (jas_getdbglevel() >= 1) {
-		fprintf(stderr, "packet body offset=%06ld\n", (long) jas_stream_getrwcount(in));
-	}
-
-	if (!discard) {
-		tcomp = &tile->tcomps[compno];
-		rlvl = &tcomp->rlvls[rlvlno];
-		for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
-		  ++bandno, ++band) {
-			if (!band->data) {
-				continue;
-			}
-			prc = &band->prcs[prcno];
-			if (!prc->cblks) {
-				continue;
-			}
-			for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;
-			  ++cblkno, ++cblk) {
-				seg = cblk->curseg;
-				while (seg) {
-					if (!seg->stream) {
-						if (!(seg->stream = jas_stream_memopen(0, 0))) {
-							return -1;
-						}
-					}
+        if (!(inb = jpc_bitstream_sopen(pkthdrstream, "r"))) {
+                return -1;
+        }
+
+        if ((present = jpc_bitstream_getbit(inb)) < 0) {
+                return 1;
+        }
+        JAS_DBGLOG(10, ("\n", present));
+        JAS_DBGLOG(10, ("present=%d ", present));
+
+        /* Is the packet non-empty? */
+        if (present) {
+                /* The packet is non-empty. */
+                tcomp = &tile->tcomps[compno];
+                rlvl = &tcomp->rlvls[rlvlno];
+                bodylen = 0;
+                for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
+                  ++bandno, ++band) {
+                        if (!band->data) {
+                                continue;
+                        }
+                        prc = &band->prcs[prcno];
+                        if (!prc->cblks) {
+                                continue;
+                        }
+                        usedcblkcnt = 0;
+                        for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;
+                          ++cblkno, ++cblk) {
+                                ++usedcblkcnt;
+                                if (!cblk->numpasses) {
+                                        leaf = jpc_tagtree_getleaf(prc->incltagtree, usedcblkcnt - 1);
+                                        if ((included = jpc_tagtree_decode(prc->incltagtree, leaf, lyrno + 1, inb)) < 0) {
+                                                return -1;
+                                        }
+                                } else {
+                                        if ((included = jpc_bitstream_getbit(inb)) < 0) {
+                                                return -1;
+                                        }
+                                }
+                                JAS_DBGLOG(10, ("\n"));
+                                JAS_DBGLOG(10, ("included=%d ", included));
+                                if (!included) {
+                                        continue;
+                                }
+                                if (!cblk->numpasses) {
+                                        i = 1;
+                                        leaf = jpc_tagtree_getleaf(prc->numimsbstagtree, usedcblkcnt - 1);
+                                        for (;;) {
+                                                if ((ret = jpc_tagtree_decode(prc->numimsbstagtree, leaf, i, inb)) < 0) {
+                                                        return -1;
+                                                }
+                                                if (ret) {
+                                                        break;
+                                                }
+                                                ++i;
+                                        }
+                                        cblk->numimsbs = i - 1;
+                                        cblk->firstpassno = cblk->numimsbs * 3;
+                                }
+                                if ((numnewpasses = jpc_getnumnewpasses(inb)) < 0) {
+                                        return -1;
+                                }
+                                JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses));
+                                seg = cblk->curseg;
+                                savenumnewpasses = numnewpasses;
+                                mycounter = 0;
+                                if (numnewpasses > 0) {
+                                        if ((m = jpc_getcommacode(inb)) < 0) {
+                                                return -1;
+                                        }
+                                        cblk->numlenbits += m;
+                                        JAS_DBGLOG(10, ("increment=%d ", m));
+                                        while (numnewpasses > 0) {
+                                                passno = cblk->firstpassno + cblk->numpasses + mycounter;
+        /* XXX - the maxpasses is not set precisely but this doesn't matter... */
+                                                maxpasses = JPC_SEGPASSCNT(passno, cblk->firstpassno, 10000, (ccp->cblkctx & JPC_COX_LAZY) != 0, (ccp->cblkctx & JPC_COX_TERMALL) != 0);
+                                                if (!discard && !seg) {
+                                                        if (!(seg = jpc_seg_alloc())) {
+                                                                return -1;
+                                                        }
+                                                        jpc_seglist_insert(&cblk->segs, cblk->segs.tail, seg);
+                                                        if (!cblk->curseg) {
+                                                                cblk->curseg = seg;
+                                                        }
+                                                        seg->passno = passno;
+                                                        seg->type = JPC_SEGTYPE(seg->passno, cblk->firstpassno, (ccp->cblkctx & JPC_COX_LAZY) != 0);
+                                                        seg->maxpasses = maxpasses;
+                                                }
+                                                n = JAS_MIN(numnewpasses, maxpasses);
+                                                mycounter += n;
+                                                numnewpasses -= n;
+                                                if ((len = jpc_bitstream_getbits(inb, cblk->numlenbits + jpc_floorlog2(n))) < 0) {
+                                                        return -1;
+                                                }
+                                                JAS_DBGLOG(10, ("len=%d ", len));
+                                                if (!discard) {
+                                                        seg->lyrno = lyrno;
+                                                        seg->numpasses += n;
+                                                        seg->cnt = len;
+                                                        seg = seg->next;
+                                                }
+                                                bodylen += len;
+                                        }
+                                }
+                                cblk->numpasses += savenumnewpasses;
+                        }
+                }
+
+                jpc_bitstream_inalign(inb, 0, 0);
+
+        } else {
+                if (jpc_bitstream_inalign(inb, 0x7f, 0)) {
+                        fprintf(stderr, "alignment failed\n");
+                        return -1;
+                }
+        }
+        jpc_bitstream_close(inb);
+
+        hdroffend = jas_stream_getrwcount(pkthdrstream);
+        hdrlen = hdroffend - hdroffstart;
+        if (jas_getdbglevel() >= 5) {
+                fprintf(stderr, "hdrlen=%lu bodylen=%lu \n", (unsigned long) hdrlen,
+                  (unsigned long) bodylen);
+        }
+
+        if (cp->csty & JPC_COD_EPH) {
+                if (jpc_dec_lookahead(pkthdrstream) == JPC_MS_EPH) {
+                        if (!(ms = jpc_getms(pkthdrstream, dec->cstate))) {
+                                fprintf(stderr, "cannot get (EPH) marker segment\n");
+                                return -1;
+                        }
+                        if (jpc_ms_gettype(ms) != JPC_MS_EPH) {
+                                jpc_ms_destroy(ms);
+                                fprintf(stderr, "missing EPH marker segment\n");
+                                return -1;
+                        }
+                        jpc_ms_destroy(ms);
+                }
+        }
+
+        /* decode the packet body. */
+
+        if (jas_getdbglevel() >= 1) {
+                fprintf(stderr, "packet body offset=%06ld\n", (long) jas_stream_getrwcount(in));
+        }
+
+        if (!discard) {
+                tcomp = &tile->tcomps[compno];
+                rlvl = &tcomp->rlvls[rlvlno];
+                for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
+                  ++bandno, ++band) {
+                        if (!band->data) {
+                                continue;
+                        }
+                        prc = &band->prcs[prcno];
+                        if (!prc->cblks) {
+                                continue;
+                        }
+                        for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;
+                          ++cblkno, ++cblk) {
+                                seg = cblk->curseg;
+                                while (seg) {
+                                        if (!seg->stream) {
+                                                if (!(seg->stream = jas_stream_memopen(0, 0))) {
+                                                        return -1;
+                                                }
+                                        }
 #if 0
 fprintf(stderr, "lyrno=%02d, compno=%02d, lvlno=%02d, prcno=%02d, bandno=%02d, cblkno=%02d, passno=%02d numpasses=%02d cnt=%d numbps=%d, numimsbs=%d\n", lyrno, compno, rlvlno, prcno, band - rlvl->bands, cblk - prc->cblks, seg->passno, seg->numpasses, seg->cnt, band->numbps, cblk->numimsbs);
 #endif
-					if (seg->cnt > 0) {
-						if (jpc_getdata(in, seg->stream, seg->cnt) < 0) {
-							return -1;
-						}
-						seg->cnt = 0;
-					}
-					if (seg->numpasses >= seg->maxpasses) {
-						cblk->curseg = seg->next;
-					}
-					seg = seg->next;
-				}
-			}
-		}
-	} else {
-		if (jas_stream_gobble(in, bodylen) != bodylen) {
-			return -1;
-		}
-	}
-	return 0;
+                                        if (seg->cnt > 0) {
+                                                if (jpc_getdata(in, seg->stream, seg->cnt) < 0) {
+                                                        return -1;
+                                                }
+                                                seg->cnt = 0;
+                                        }
+                                        if (seg->numpasses >= seg->maxpasses) {
+                                                cblk->curseg = seg->next;
+                                        }
+                                        seg = seg->next;
+                                }
+                        }
+                }
+        } else {
+                if (jas_stream_gobble(in, bodylen) != bodylen) {
+                        return -1;
+                }
+        }
+        return 0;
 }
 
 /********************************************************************************************/
@@ -461,166 +461,166 @@ fprintf(stderr, "lyrno=%02d, compno=%02d, lvlno=%02d, prcno=%02d, bandno=%02d, c
 
 int jpc_dec_decodepkts(jpc_dec_t *dec, jas_stream_t *pkthdrstream, jas_stream_t *in)
 {
-	jpc_dec_tile_t *tile;
-	jpc_pi_t *pi;
-	int ret;
+        jpc_dec_tile_t *tile;
+        jpc_pi_t *pi;
+        int ret;
 
-	tile = dec->curtile;
-	pi = tile->pi;
-	for (;;) {
+        tile = dec->curtile;
+        pi = tile->pi;
+        for (;;) {
 if (!tile->pkthdrstream || jas_stream_peekc(tile->pkthdrstream) == EOF) {
-		switch (jpc_dec_lookahead(in)) {
-		case JPC_MS_EOC:
-		case JPC_MS_SOT:
-			return 0;
-			break;
-		case JPC_MS_SOP:
-		case JPC_MS_EPH:
-		case 0:
-			break;
-		default:
-			return -1;
-			break;
-		}
+                switch (jpc_dec_lookahead(in)) {
+                case JPC_MS_EOC:
+                case JPC_MS_SOT:
+                        return 0;
+                        break;
+                case JPC_MS_SOP:
+                case JPC_MS_EPH:
+                case 0:
+                        break;
+                default:
+                        return -1;
+                        break;
+                }
 }
-		if ((ret = jpc_pi_next(pi))) {
-			return ret;
-		}
+                if ((ret = jpc_pi_next(pi))) {
+                        return ret;
+                }
 if (dec->maxpkts >= 0 && dec->numpkts >= dec->maxpkts) {
-	fprintf(stderr, "warning: stopping decode prematurely as requested\n");
-	return 0;
+        fprintf(stderr, "warning: stopping decode prematurely as requested\n");
+        return 0;
 }
-		if (jas_getdbglevel() >= 1) {
-			fprintf(stderr, "packet offset=%08ld prg=%d cmptno=%02d "
-			  "rlvlno=%02d prcno=%03d lyrno=%02d\n", (long)
-			  jas_stream_getrwcount(in), jpc_pi_prg(pi), jpc_pi_cmptno(pi),
-			  jpc_pi_rlvlno(pi), jpc_pi_prcno(pi), jpc_pi_lyrno(pi));
-		}
-		if (jpc_dec_decodepkt(dec, pkthdrstream, in, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi),
-		  jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) {
-			return -1;
-		}
+                if (jas_getdbglevel() >= 1) {
+                        fprintf(stderr, "packet offset=%08ld prg=%d cmptno=%02d "
+                          "rlvlno=%02d prcno=%03d lyrno=%02d\n", (long)
+                          jas_stream_getrwcount(in), jpc_pi_prg(pi), jpc_pi_cmptno(pi),
+                          jpc_pi_rlvlno(pi), jpc_pi_prcno(pi), jpc_pi_lyrno(pi));
+                }
+                if (jpc_dec_decodepkt(dec, pkthdrstream, in, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi),
+                  jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) {
+                        return -1;
+                }
 ++dec->numpkts;
-	}
+        }
 
-	return 0;
+        return 0;
 }
 
 jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *dec, jpc_dec_tile_t *tile)
 {
-	jpc_pi_t *pi;
-	int compno;
-	jpc_picomp_t *picomp;
-	jpc_pirlvl_t *pirlvl;
-	jpc_dec_tcomp_t *tcomp;
-	int rlvlno;
-	jpc_dec_rlvl_t *rlvl;
-	int prcno;
-	int *prclyrno;
-	jpc_dec_cmpt_t *cmpt;
-
-	if (!(pi = jpc_pi_create0())) {
-		return 0;
-	}
-	pi->numcomps = dec->numcomps;
-	if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
-		jpc_pi_destroy(pi);
-		return 0;
-	}
-	for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno,
-	  ++picomp) {
-		picomp->pirlvls = 0;
-	}
-
-	for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps;
-	  compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
-		picomp->numrlvls = tcomp->numrlvls;
-		if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
-		  sizeof(jpc_pirlvl_t)))) {
-			jpc_pi_destroy(pi);
-			return 0;
-		}
-		for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
-		  picomp->numrlvls; ++rlvlno, ++pirlvl) {
-			pirlvl->prclyrnos = 0;
-		}
-		for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
-		  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
+        jpc_pi_t *pi;
+        int compno;
+        jpc_picomp_t *picomp;
+        jpc_pirlvl_t *pirlvl;
+        jpc_dec_tcomp_t *tcomp;
+        int rlvlno;
+        jpc_dec_rlvl_t *rlvl;
+        int prcno;
+        int *prclyrno;
+        jpc_dec_cmpt_t *cmpt;
+
+        if (!(pi = jpc_pi_create0())) {
+                return 0;
+        }
+        pi->numcomps = dec->numcomps;
+        if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
+                jpc_pi_destroy(pi);
+                return 0;
+        }
+        for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno,
+          ++picomp) {
+                picomp->pirlvls = 0;
+        }
+
+        for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps;
+          compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
+                picomp->numrlvls = tcomp->numrlvls;
+                if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
+                  sizeof(jpc_pirlvl_t)))) {
+                        jpc_pi_destroy(pi);
+                        return 0;
+                }
+                for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
+                  picomp->numrlvls; ++rlvlno, ++pirlvl) {
+                        pirlvl->prclyrnos = 0;
+                }
+                for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
+                  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
 /* XXX sizeof(long) should be sizeof different type */
-			pirlvl->numprcs = rlvl->numprcs;
-			if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
-			  sizeof(long)))) {
-				jpc_pi_destroy(pi);
-				return 0;
-			}
-		}
-	}
-
-	pi->maxrlvls = 0;
-	for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps, cmpt =
-	  dec->cmpts; compno < pi->numcomps; ++compno, ++tcomp, ++picomp,
-	  ++cmpt) {
-		picomp->hsamp = cmpt->hstep;
-		picomp->vsamp = cmpt->vstep;
-		for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
-		  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
-			pirlvl->prcwidthexpn = rlvl->prcwidthexpn;
-			pirlvl->prcheightexpn = rlvl->prcheightexpn;
-			for (prcno = 0, prclyrno = pirlvl->prclyrnos;
-			  prcno < pirlvl->numprcs; ++prcno, ++prclyrno) {
-				*prclyrno = 0;
-			}
-			pirlvl->numhprcs = rlvl->numhprcs;
-		}
-		if (pi->maxrlvls < tcomp->numrlvls) {
-			pi->maxrlvls = tcomp->numrlvls;
-		}
-	}
-
-	pi->numlyrs = tile->cp->numlyrs;
-	pi->xstart = tile->xstart;
-	pi->ystart = tile->ystart;
-	pi->xend = tile->xend;
-	pi->yend = tile->yend;
-
-	pi->picomp = 0;
-	pi->pirlvl = 0;
-	pi->x = 0;
-	pi->y = 0;
-	pi->compno = 0;
-	pi->rlvlno = 0;
-	pi->prcno = 0;
-	pi->lyrno = 0;
-	pi->xstep = 0;
-	pi->ystep = 0;
-
-	pi->pchgno = -1;
-
-	pi->defaultpchg.prgord = tile->cp->prgord;
-	pi->defaultpchg.compnostart = 0;
-	pi->defaultpchg.compnoend = pi->numcomps;
-	pi->defaultpchg.rlvlnostart = 0;
-	pi->defaultpchg.rlvlnoend = pi->maxrlvls;
-	pi->defaultpchg.lyrnoend = pi->numlyrs;
-	pi->pchg = 0;
-
-	pi->valid = 0;
-
-	return pi;
+                        pirlvl->numprcs = rlvl->numprcs;
+                        if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
+                          sizeof(long)))) {
+                                jpc_pi_destroy(pi);
+                                return 0;
+                        }
+                }
+        }
+
+        pi->maxrlvls = 0;
+        for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps, cmpt =
+          dec->cmpts; compno < pi->numcomps; ++compno, ++tcomp, ++picomp,
+          ++cmpt) {
+                picomp->hsamp = cmpt->hstep;
+                picomp->vsamp = cmpt->vstep;
+                for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
+                  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
+                        pirlvl->prcwidthexpn = rlvl->prcwidthexpn;
+                        pirlvl->prcheightexpn = rlvl->prcheightexpn;
+                        for (prcno = 0, prclyrno = pirlvl->prclyrnos;
+                          prcno < pirlvl->numprcs; ++prcno, ++prclyrno) {
+                                *prclyrno = 0;
+                        }
+                        pirlvl->numhprcs = rlvl->numhprcs;
+                }
+                if (pi->maxrlvls < tcomp->numrlvls) {
+                        pi->maxrlvls = tcomp->numrlvls;
+                }
+        }
+
+        pi->numlyrs = tile->cp->numlyrs;
+        pi->xstart = tile->xstart;
+        pi->ystart = tile->ystart;
+        pi->xend = tile->xend;
+        pi->yend = tile->yend;
+
+        pi->picomp = 0;
+        pi->pirlvl = 0;
+        pi->x = 0;
+        pi->y = 0;
+        pi->compno = 0;
+        pi->rlvlno = 0;
+        pi->prcno = 0;
+        pi->lyrno = 0;
+        pi->xstep = 0;
+        pi->ystep = 0;
+
+        pi->pchgno = -1;
+
+        pi->defaultpchg.prgord = tile->cp->prgord;
+        pi->defaultpchg.compnostart = 0;
+        pi->defaultpchg.compnoend = pi->numcomps;
+        pi->defaultpchg.rlvlnostart = 0;
+        pi->defaultpchg.rlvlnoend = pi->maxrlvls;
+        pi->defaultpchg.lyrnoend = pi->numlyrs;
+        pi->pchg = 0;
+
+        pi->valid = 0;
+
+        return pi;
 }
 
 long jpc_dec_lookahead(jas_stream_t *in)
 {
-	uint_fast16_t x;
-	if (jpc_getuint16(in, &x)) {
-		return -1;
-	}
-	if (jas_stream_ungetc(in, x & 0xff) == EOF ||
-	  jas_stream_ungetc(in, x >> 8) == EOF) {
-		return -1;
-	}
-	if (x >= JPC_MS_INMIN && x <= JPC_MS_INMAX) {
-		return x;
-	}
-	return 0;
+        uint_fast16_t x;
+        if (jpc_getuint16(in, &x)) {
+                return -1;
+        }
+        if (jas_stream_ungetc(in, x & 0xff) == EOF ||
+          jas_stream_ungetc(in, x >> 8) == EOF) {
+                return -1;
+        }
+        if (x >= JPC_MS_INMIN && x <= JPC_MS_INMAX) {
+                return x;
+        }
+        return 0;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h
index 923d7c1a..8e94232a 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c
index 1444dc7b..2d03cb29 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -142,563 +142,563 @@
 
 static int jpc_putcommacode(jpc_bitstream_t *out, int n)
 {
-	assert(n >= 0);
-
-	while (--n >= 0) {
-		if (jpc_bitstream_putbit(out, 1) == EOF) {
-			return -1;
-		}
-	}
-	if (jpc_bitstream_putbit(out, 0) == EOF) {
-		return -1;
-	}
-	return 0;
+        assert(n >= 0);
+
+        while (--n >= 0) {
+                if (jpc_bitstream_putbit(out, 1) == EOF) {
+                        return -1;
+                }
+        }
+        if (jpc_bitstream_putbit(out, 0) == EOF) {
+                return -1;
+        }
+        return 0;
 }
 
 static int jpc_putnumnewpasses(jpc_bitstream_t *out, int n)
 {
-	int ret;
-
-	if (n <= 0) {
-		return -1;
-	} else if (n == 1) {
-		ret = jpc_bitstream_putbit(out, 0);
-	} else if (n == 2) {
-		ret = jpc_bitstream_putbits(out, 2, 2);
-	} else if (n <= 5) {
-		ret = jpc_bitstream_putbits(out, 4, 0xc | (n - 3));
-	} else if (n <= 36) {
-		ret = jpc_bitstream_putbits(out, 9, 0x1e0 | (n - 6));
-	} else if (n <= 164) {
-		ret = jpc_bitstream_putbits(out, 16, 0xff80 | (n - 37));
-	} else {
-		/* The standard has no provision for encoding a larger value.
-		In practice, however, it is highly unlikely that this
-		limitation will ever be encountered. */
-		return -1;
-	}
-
-	return (ret != EOF) ? 0 : (-1);
+        int ret;
+
+        if (n <= 0) {
+                return -1;
+        } else if (n == 1) {
+                ret = jpc_bitstream_putbit(out, 0);
+        } else if (n == 2) {
+                ret = jpc_bitstream_putbits(out, 2, 2);
+        } else if (n <= 5) {
+                ret = jpc_bitstream_putbits(out, 4, 0xc | (n - 3));
+        } else if (n <= 36) {
+                ret = jpc_bitstream_putbits(out, 9, 0x1e0 | (n - 6));
+        } else if (n <= 164) {
+                ret = jpc_bitstream_putbits(out, 16, 0xff80 | (n - 37));
+        } else {
+                /* The standard has no provision for encoding a larger value.
+                In practice, however, it is highly unlikely that this
+                limitation will ever be encountered. */
+                return -1;
+        }
+
+        return (ret != EOF) ? 0 : (-1);
 }
 
 int jpc_enc_encpkts(jpc_enc_t *enc, jas_stream_t *out)
 {
-	jpc_enc_tile_t *tile;
-	jpc_pi_t *pi;
-
-	tile = enc->curtile;
-
-	jpc_init_t2state(enc, 0);
-	pi = tile->pi;
-	jpc_pi_init(pi);
-
-	if (!jpc_pi_next(pi)) {
-		for (;;) {
-			if (jpc_enc_encpkt(enc, out, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi),
-			  jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) {
-				return -1;
-			}
-			if (jpc_pi_next(pi)) {
-				break;
-			}
-		}
-	}
-	
-	return 0;
+        jpc_enc_tile_t *tile;
+        jpc_pi_t *pi;
+
+        tile = enc->curtile;
+
+        jpc_init_t2state(enc, 0);
+        pi = tile->pi;
+        jpc_pi_init(pi);
+
+        if (!jpc_pi_next(pi)) {
+                for (;;) {
+                        if (jpc_enc_encpkt(enc, out, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi),
+                          jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) {
+                                return -1;
+                        }
+                        if (jpc_pi_next(pi)) {
+                                break;
+                        }
+                }
+        }
+       
+        return 0;
 }
 
 int jpc_enc_encpkt(jpc_enc_t *enc, jas_stream_t *out, int compno, int lvlno, int prcno, int lyrno)
 {
-	jpc_enc_tcmpt_t *comp;
-	jpc_enc_rlvl_t *lvl;
-	jpc_enc_band_t *band;
-	jpc_enc_band_t *endbands;
-	jpc_enc_cblk_t *cblk;
-	jpc_enc_cblk_t *endcblks;
-	jpc_bitstream_t *outb;
-	jpc_enc_pass_t *pass;
-	jpc_enc_pass_t *startpass;
-	jpc_enc_pass_t *lastpass;
-	jpc_enc_pass_t *endpass;
-	jpc_enc_pass_t *endpasses;
-	int i;
-	int included;
-	int ret;
-	jpc_tagtreenode_t *leaf;
-	int n;
-	int t1;
-	int t2;
-	int adjust;
-	int maxadjust;
-	int datalen;
-	int numnewpasses;
-	int passcount;
-	jpc_enc_tile_t *tile;
-	jpc_enc_prc_t *prc;
-	jpc_enc_cp_t *cp;
-	jpc_ms_t *ms;
-
-	tile = enc->curtile;
-	cp = enc->cp;
-
-	if (cp->tcp.csty & JPC_COD_SOP) {
-		if (!(ms = jpc_ms_create(JPC_MS_SOP))) {
-			return -1;
-		}
-		ms->parms.sop.seqno = jpc_pi_getind(tile->pi);
-		if (jpc_putms(out, enc->cstate, ms)) {
-			return -1;
-		}
-		jpc_ms_destroy(ms);
-	}
-
-	outb = jpc_bitstream_sopen(out, "w+");
-	assert(outb);
-
-	if (jpc_bitstream_putbit(outb, 1) == EOF) {
-		return -1;
-	}
-	JAS_DBGLOG(10, ("\n"));
-	JAS_DBGLOG(10, ("present. "));
-
-	comp = &tile->tcmpts[compno];
-	lvl = &comp->rlvls[lvlno];
-	endbands = &lvl->bands[lvl->numbands];
-	for (band = lvl->bands; band != endbands; ++band) {
-		if (!band->data) {
-			continue;
-		}
-		prc = &band->prcs[prcno];
-		if (!prc->cblks) {
-			continue;
-		}
-
-		endcblks = &prc->cblks[prc->numcblks];
-		for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
-			if (!lyrno) {
-				leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks);
-				jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs);
-			}
-			pass = cblk->curpass;
-			included = (pass && pass->lyrno == lyrno);
-			if (included && (!cblk->numencpasses)) {
-				assert(pass->lyrno == lyrno);
-				leaf = jpc_tagtree_getleaf(prc->incltree,
-				  cblk - prc->cblks);
-				jpc_tagtree_setvalue(prc->incltree, leaf, pass->lyrno);
-			}
-		}
-
-		endcblks = &prc->cblks[prc->numcblks];
-		for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
-			pass = cblk->curpass;
-			included = (pass && pass->lyrno == lyrno);
-			if (!cblk->numencpasses) {
-				leaf = jpc_tagtree_getleaf(prc->incltree,
-				  cblk - prc->cblks);
-				if (jpc_tagtree_encode(prc->incltree, leaf, lyrno
-				  + 1, outb) < 0) {
-					return -1;
-				}
-			} else {
-				if (jpc_bitstream_putbit(outb, included) == EOF) {
-					return -1;
-				}
-			}
-			JAS_DBGLOG(10, ("included=%d ", included));
-			if (!included) {
-				continue;
-			}
-			if (!cblk->numencpasses) {
-				i = 1;
-				leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks);
-				for (;;) {
-					if ((ret = jpc_tagtree_encode(prc->nlibtree, leaf, i, outb)) < 0) {
-						return -1;
-					}
-					if (ret) {
-						break;
-					}
-					++i;
-				}
-				assert(leaf->known_ && i == leaf->value_ + 1);
-			}
-
-			endpasses = &cblk->passes[cblk->numpasses];
-			startpass = pass;
-			endpass = startpass;
-			while (endpass != endpasses && endpass->lyrno == lyrno){
-				++endpass;
-			}
-			numnewpasses = endpass - startpass;
-			if (jpc_putnumnewpasses(outb, numnewpasses)) {
-				return -1;
-			}
-			JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses));
-
-			lastpass = endpass - 1;
-			n = startpass->start;
-			passcount = 1;
-			maxadjust = 0;
-			for (pass = startpass; pass != endpass; ++pass) {
-				if (pass->term || pass == lastpass) {
-					datalen = pass->end - n;
-					t1 = jpc_firstone(datalen) + 1;
-					t2 = cblk->numlenbits + jpc_floorlog2(passcount);
-					adjust = JAS_MAX(t1 - t2, 0);
-					maxadjust = JAS_MAX(adjust, maxadjust);
-					n += datalen;
-					passcount = 1;
-				} else {
-					++passcount;
-				}
-			}
-			if (jpc_putcommacode(outb, maxadjust)) {
-				return -1;
-			}
-			cblk->numlenbits += maxadjust;
-
-			lastpass = endpass - 1;
-			n = startpass->start;
-			passcount = 1;
-			for (pass = startpass; pass != endpass; ++pass) {
-				if (pass->term || pass == lastpass) {
-					datalen = pass->end - n;
+        jpc_enc_tcmpt_t *comp;
+        jpc_enc_rlvl_t *lvl;
+        jpc_enc_band_t *band;
+        jpc_enc_band_t *endbands;
+        jpc_enc_cblk_t *cblk;
+        jpc_enc_cblk_t *endcblks;
+        jpc_bitstream_t *outb;
+        jpc_enc_pass_t *pass;
+        jpc_enc_pass_t *startpass;
+        jpc_enc_pass_t *lastpass;
+        jpc_enc_pass_t *endpass;
+        jpc_enc_pass_t *endpasses;
+        int i;
+        int included;
+        int ret;
+        jpc_tagtreenode_t *leaf;
+        int n;
+        int t1;
+        int t2;
+        int adjust;
+        int maxadjust;
+        int datalen;
+        int numnewpasses;
+        int passcount;
+        jpc_enc_tile_t *tile;
+        jpc_enc_prc_t *prc;
+        jpc_enc_cp_t *cp;
+        jpc_ms_t *ms;
+
+        tile = enc->curtile;
+        cp = enc->cp;
+
+        if (cp->tcp.csty & JPC_COD_SOP) {
+                if (!(ms = jpc_ms_create(JPC_MS_SOP))) {
+                        return -1;
+                }
+                ms->parms.sop.seqno = jpc_pi_getind(tile->pi);
+                if (jpc_putms(out, enc->cstate, ms)) {
+                        return -1;
+                }
+                jpc_ms_destroy(ms);
+        }
+
+        outb = jpc_bitstream_sopen(out, "w+");
+        assert(outb);
+
+        if (jpc_bitstream_putbit(outb, 1) == EOF) {
+                return -1;
+        }
+        JAS_DBGLOG(10, ("\n"));
+        JAS_DBGLOG(10, ("present. "));
+
+        comp = &tile->tcmpts[compno];
+        lvl = &comp->rlvls[lvlno];
+        endbands = &lvl->bands[lvl->numbands];
+        for (band = lvl->bands; band != endbands; ++band) {
+                if (!band->data) {
+                        continue;
+                }
+                prc = &band->prcs[prcno];
+                if (!prc->cblks) {
+                        continue;
+                }
+
+                endcblks = &prc->cblks[prc->numcblks];
+                for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
+                        if (!lyrno) {
+                                leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks);
+                                jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs);
+                        }
+                        pass = cblk->curpass;
+                        included = (pass && pass->lyrno == lyrno);
+                        if (included && (!cblk->numencpasses)) {
+                                assert(pass->lyrno == lyrno);
+                                leaf = jpc_tagtree_getleaf(prc->incltree,
+                                  cblk - prc->cblks);
+                                jpc_tagtree_setvalue(prc->incltree, leaf, pass->lyrno);
+                        }
+                }
+
+                endcblks = &prc->cblks[prc->numcblks];
+                for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
+                        pass = cblk->curpass;
+                        included = (pass && pass->lyrno == lyrno);
+                        if (!cblk->numencpasses) {
+                                leaf = jpc_tagtree_getleaf(prc->incltree,
+                                  cblk - prc->cblks);
+                                if (jpc_tagtree_encode(prc->incltree, leaf, lyrno
+                                  + 1, outb) < 0) {
+                                        return -1;
+                                }
+                        } else {
+                                if (jpc_bitstream_putbit(outb, included) == EOF) {
+                                        return -1;
+                                }
+                        }
+                        JAS_DBGLOG(10, ("included=%d ", included));
+                        if (!included) {
+                                continue;
+                        }
+                        if (!cblk->numencpasses) {
+                                i = 1;
+                                leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks);
+                                for (;;) {
+                                        if ((ret = jpc_tagtree_encode(prc->nlibtree, leaf, i, outb)) < 0) {
+                                                return -1;
+                                        }
+                                        if (ret) {
+                                                break;
+                                        }
+                                        ++i;
+                                }
+                                assert(leaf->known_ && i == leaf->value_ + 1);
+                        }
+
+                        endpasses = &cblk->passes[cblk->numpasses];
+                        startpass = pass;
+                        endpass = startpass;
+                        while (endpass != endpasses && endpass->lyrno == lyrno){
+                                ++endpass;
+                        }
+                        numnewpasses = endpass - startpass;
+                        if (jpc_putnumnewpasses(outb, numnewpasses)) {
+                                return -1;
+                        }
+                        JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses));
+
+                        lastpass = endpass - 1;
+                        n = startpass->start;
+                        passcount = 1;
+                        maxadjust = 0;
+                        for (pass = startpass; pass != endpass; ++pass) {
+                                if (pass->term || pass == lastpass) {
+                                        datalen = pass->end - n;
+                                        t1 = jpc_firstone(datalen) + 1;
+                                        t2 = cblk->numlenbits + jpc_floorlog2(passcount);
+                                        adjust = JAS_MAX(t1 - t2, 0);
+                                        maxadjust = JAS_MAX(adjust, maxadjust);
+                                        n += datalen;
+                                        passcount = 1;
+                                } else {
+                                        ++passcount;
+                                }
+                        }
+                        if (jpc_putcommacode(outb, maxadjust)) {
+                                return -1;
+                        }
+                        cblk->numlenbits += maxadjust;
+
+                        lastpass = endpass - 1;
+                        n = startpass->start;
+                        passcount = 1;
+                        for (pass = startpass; pass != endpass; ++pass) {
+                                if (pass->term || pass == lastpass) {
+                                        datalen = pass->end - n;
 assert(jpc_firstone(datalen) < cblk->numlenbits + jpc_floorlog2(passcount));
-					if (jpc_bitstream_putbits(outb, cblk->numlenbits + jpc_floorlog2(passcount), datalen) == EOF) {
-						return -1;
-					}
-					n += datalen;
-					passcount = 1;
-				} else {
-					++passcount;
-				}
-			}
-		}
-	}
-
-	jpc_bitstream_outalign(outb, 0);
-	jpc_bitstream_close(outb);
-
-	if (cp->tcp.csty & JPC_COD_EPH) {
-		if (!(ms = jpc_ms_create(JPC_MS_EPH))) {
-			return -1;
-		}
-		jpc_putms(out, enc->cstate, ms);
-		jpc_ms_destroy(ms);
-	}
-
-	comp = &tile->tcmpts[compno];
-	lvl = &comp->rlvls[lvlno];
-	endbands = &lvl->bands[lvl->numbands];
-	for (band = lvl->bands; band != endbands; ++band) {
-		if (!band->data) {
-			continue;
-		}
-		prc = &band->prcs[prcno];
-		if (!prc->cblks) {
-			continue;
-		}
-		endcblks = &prc->cblks[prc->numcblks];
-		for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
-			pass = cblk->curpass;
-
-			if (!pass) {
-				continue;
-			}
-			if (pass->lyrno != lyrno) {
-				assert(pass->lyrno < 0 || pass->lyrno > lyrno);
-				continue;
-			}
-
-			endpasses = &cblk->passes[cblk->numpasses];
-			startpass = pass;
-			endpass = startpass;
-			while (endpass != endpasses && endpass->lyrno == lyrno){
-				++endpass;
-			}
-			lastpass = endpass - 1;
-			numnewpasses = endpass - startpass;
-
-			jas_stream_seek(cblk->stream, startpass->start, SEEK_SET);
-			assert(jas_stream_tell(cblk->stream) == startpass->start);
-			if (jas_stream_copy(out, cblk->stream, lastpass->end - startpass->start)) {
-				return -1;
-			}
-			cblk->curpass = (endpass != endpasses) ? endpass : 0;
-			cblk->numencpasses += numnewpasses;
-
-		}
-	}
-
-	return 0;
+                                        if (jpc_bitstream_putbits(outb, cblk->numlenbits + jpc_floorlog2(passcount), datalen) == EOF) {
+                                                return -1;
+                                        }
+                                        n += datalen;
+                                        passcount = 1;
+                                } else {
+                                        ++passcount;
+                                }
+                        }
+                }
+        }
+
+        jpc_bitstream_outalign(outb, 0);
+        jpc_bitstream_close(outb);
+
+        if (cp->tcp.csty & JPC_COD_EPH) {
+                if (!(ms = jpc_ms_create(JPC_MS_EPH))) {
+                        return -1;
+                }
+                jpc_putms(out, enc->cstate, ms);
+                jpc_ms_destroy(ms);
+        }
+
+        comp = &tile->tcmpts[compno];
+        lvl = &comp->rlvls[lvlno];
+        endbands = &lvl->bands[lvl->numbands];
+        for (band = lvl->bands; band != endbands; ++band) {
+                if (!band->data) {
+                        continue;
+                }
+                prc = &band->prcs[prcno];
+                if (!prc->cblks) {
+                        continue;
+                }
+                endcblks = &prc->cblks[prc->numcblks];
+                for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
+                        pass = cblk->curpass;
+
+                        if (!pass) {
+                                continue;
+                        }
+                        if (pass->lyrno != lyrno) {
+                                assert(pass->lyrno < 0 || pass->lyrno > lyrno);
+                                continue;
+                        }
+
+                        endpasses = &cblk->passes[cblk->numpasses];
+                        startpass = pass;
+                        endpass = startpass;
+                        while (endpass != endpasses && endpass->lyrno == lyrno){
+                                ++endpass;
+                        }
+                        lastpass = endpass - 1;
+                        numnewpasses = endpass - startpass;
+
+                        jas_stream_seek(cblk->stream, startpass->start, SEEK_SET);
+                        assert(jas_stream_tell(cblk->stream) == startpass->start);
+                        if (jas_stream_copy(out, cblk->stream, lastpass->end - startpass->start)) {
+                                return -1;
+                        }
+                        cblk->curpass = (endpass != endpasses) ? endpass : 0;
+                        cblk->numencpasses += numnewpasses;
+
+                }
+        }
+
+        return 0;
 }
 
 void jpc_save_t2state(jpc_enc_t *enc)
 {
 /* stream pos in embedded T1 stream may be wrong since not saved/restored! */
 
-	jpc_enc_tcmpt_t *comp;
-	jpc_enc_tcmpt_t *endcomps;
-	jpc_enc_rlvl_t *lvl;
-	jpc_enc_rlvl_t *endlvls;
-	jpc_enc_band_t *band;
-	jpc_enc_band_t *endbands;
-	jpc_enc_cblk_t *cblk;
-	jpc_enc_cblk_t *endcblks;
-	jpc_enc_tile_t *tile;
-	uint_fast32_t prcno;
-	jpc_enc_prc_t *prc;
-
-	tile = enc->curtile;
-
-	endcomps = &tile->tcmpts[tile->numtcmpts];
-	for (comp = tile->tcmpts; comp != endcomps; ++comp) {
-		endlvls = &comp->rlvls[comp->numrlvls];
-		for (lvl = comp->rlvls; lvl != endlvls; ++lvl) {
-			if (!lvl->bands) {
-				continue;
-			}
-			endbands = &lvl->bands[lvl->numbands];
-			for (band = lvl->bands; band != endbands; ++band) {
-				if (!band->data) {
-					continue;
-				}
-				for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) {
-					if (!prc->cblks) {
-						continue;
-					}
-					jpc_tagtree_copy(prc->savincltree, prc->incltree);
-					jpc_tagtree_copy(prc->savnlibtree, prc->nlibtree);
-					endcblks = &prc->cblks[prc->numcblks];
-					for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
-						cblk->savedcurpass = cblk->curpass;
-						cblk->savednumencpasses = cblk->numencpasses;
-						cblk->savednumlenbits = cblk->numlenbits;
-					}
-				}
-			}
-		}
-	}
+        jpc_enc_tcmpt_t *comp;
+        jpc_enc_tcmpt_t *endcomps;
+        jpc_enc_rlvl_t *lvl;
+        jpc_enc_rlvl_t *endlvls;
+        jpc_enc_band_t *band;
+        jpc_enc_band_t *endbands;
+        jpc_enc_cblk_t *cblk;
+        jpc_enc_cblk_t *endcblks;
+        jpc_enc_tile_t *tile;
+        uint_fast32_t prcno;
+        jpc_enc_prc_t *prc;
+
+        tile = enc->curtile;
+
+        endcomps = &tile->tcmpts[tile->numtcmpts];
+        for (comp = tile->tcmpts; comp != endcomps; ++comp) {
+                endlvls = &comp->rlvls[comp->numrlvls];
+                for (lvl = comp->rlvls; lvl != endlvls; ++lvl) {
+                        if (!lvl->bands) {
+                                continue;
+                        }
+                        endbands = &lvl->bands[lvl->numbands];
+                        for (band = lvl->bands; band != endbands; ++band) {
+                                if (!band->data) {
+                                        continue;
+                                }
+                                for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) {
+                                        if (!prc->cblks) {
+                                                continue;
+                                        }
+                                        jpc_tagtree_copy(prc->savincltree, prc->incltree);
+                                        jpc_tagtree_copy(prc->savnlibtree, prc->nlibtree);
+                                        endcblks = &prc->cblks[prc->numcblks];
+                                        for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
+                                                cblk->savedcurpass = cblk->curpass;
+                                                cblk->savednumencpasses = cblk->numencpasses;
+                                                cblk->savednumlenbits = cblk->numlenbits;
+                                        }
+                                }
+                        }
+                }
+        }
 
 }
 
 void jpc_restore_t2state(jpc_enc_t *enc)
 {
 
-	jpc_enc_tcmpt_t *comp;
-	jpc_enc_tcmpt_t *endcomps;
-	jpc_enc_rlvl_t *lvl;
-	jpc_enc_rlvl_t *endlvls;
-	jpc_enc_band_t *band;
-	jpc_enc_band_t *endbands;
-	jpc_enc_cblk_t *cblk;
-	jpc_enc_cblk_t *endcblks;
-	jpc_enc_tile_t *tile;
-	uint_fast32_t prcno;
-	jpc_enc_prc_t *prc;
-
-	tile = enc->curtile;
-
-	endcomps = &tile->tcmpts[tile->numtcmpts];
-	for (comp = tile->tcmpts; comp != endcomps; ++comp) {
-		endlvls = &comp->rlvls[comp->numrlvls];
-		for (lvl = comp->rlvls; lvl != endlvls; ++lvl) {
-			if (!lvl->bands) {
-				continue;
-			}
-			endbands = &lvl->bands[lvl->numbands];
-			for (band = lvl->bands; band != endbands; ++band) {
-				if (!band->data) {
-					continue;
-				}
-				for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) {
-					if (!prc->cblks) {
-						continue;
-					}
-					jpc_tagtree_copy(prc->incltree, prc->savincltree);
-					jpc_tagtree_copy(prc->nlibtree, prc->savnlibtree);
-					endcblks = &prc->cblks[prc->numcblks];
-					for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
-						cblk->curpass = cblk->savedcurpass;
-						cblk->numencpasses = cblk->savednumencpasses;
-						cblk->numlenbits = cblk->savednumlenbits;
-					}
-				}
-			}
-		}
-	}
+        jpc_enc_tcmpt_t *comp;
+        jpc_enc_tcmpt_t *endcomps;
+        jpc_enc_rlvl_t *lvl;
+        jpc_enc_rlvl_t *endlvls;
+        jpc_enc_band_t *band;
+        jpc_enc_band_t *endbands;
+        jpc_enc_cblk_t *cblk;
+        jpc_enc_cblk_t *endcblks;
+        jpc_enc_tile_t *tile;
+        uint_fast32_t prcno;
+        jpc_enc_prc_t *prc;
+
+        tile = enc->curtile;
+
+        endcomps = &tile->tcmpts[tile->numtcmpts];
+        for (comp = tile->tcmpts; comp != endcomps; ++comp) {
+                endlvls = &comp->rlvls[comp->numrlvls];
+                for (lvl = comp->rlvls; lvl != endlvls; ++lvl) {
+                        if (!lvl->bands) {
+                                continue;
+                        }
+                        endbands = &lvl->bands[lvl->numbands];
+                        for (band = lvl->bands; band != endbands; ++band) {
+                                if (!band->data) {
+                                        continue;
+                                }
+                                for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) {
+                                        if (!prc->cblks) {
+                                                continue;
+                                        }
+                                        jpc_tagtree_copy(prc->incltree, prc->savincltree);
+                                        jpc_tagtree_copy(prc->nlibtree, prc->savnlibtree);
+                                        endcblks = &prc->cblks[prc->numcblks];
+                                        for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
+                                                cblk->curpass = cblk->savedcurpass;
+                                                cblk->numencpasses = cblk->savednumencpasses;
+                                                cblk->numlenbits = cblk->savednumlenbits;
+                                        }
+                                }
+                        }
+                }
+        }
 }
 
 void jpc_init_t2state(jpc_enc_t *enc, int raflag)
 {
 /* It is assumed that band->numbps and cblk->numbps precomputed */
 
-	jpc_enc_tcmpt_t *comp;
-	jpc_enc_tcmpt_t *endcomps;
-	jpc_enc_rlvl_t *lvl;
-	jpc_enc_rlvl_t *endlvls;
-	jpc_enc_band_t *band;
-	jpc_enc_band_t *endbands;
-	jpc_enc_cblk_t *cblk;
-	jpc_enc_cblk_t *endcblks;
-	jpc_enc_pass_t *pass;
-	jpc_enc_pass_t *endpasses;
-	jpc_tagtreenode_t *leaf;
-	jpc_enc_tile_t *tile;
-	uint_fast32_t prcno;
-	jpc_enc_prc_t *prc;
-
-	tile = enc->curtile;
-
-	endcomps = &tile->tcmpts[tile->numtcmpts];
-	for (comp = tile->tcmpts; comp != endcomps; ++comp) {
-		endlvls = &comp->rlvls[comp->numrlvls];
-		for (lvl = comp->rlvls; lvl != endlvls; ++lvl) {
-			if (!lvl->bands) {
-				continue;
-			}
-			endbands = &lvl->bands[lvl->numbands];
-			for (band = lvl->bands; band != endbands; ++band) {
-				if (!band->data) {
-					continue;
-				}
-				for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) {
-					if (!prc->cblks) {
-						continue;
-					}
-					jpc_tagtree_reset(prc->incltree);
-					jpc_tagtree_reset(prc->nlibtree);
-					endcblks = &prc->cblks[prc->numcblks];
-					for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
-						if (jas_stream_rewind(cblk->stream)) {
-							assert(0);
-						}
-						cblk->curpass = (cblk->numpasses > 0) ? cblk->passes : 0;
-						cblk->numencpasses = 0;
-						cblk->numlenbits = 3;
-						cblk->numimsbs = band->numbps - cblk->numbps;
-						assert(cblk->numimsbs >= 0);
-						leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks);
-						jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs);
-
-						if (raflag) {
-							endpasses = &cblk->passes[cblk->numpasses];
-							for (pass = cblk->passes; pass != endpasses; ++pass) {
-								pass->lyrno = -1;
-								pass->lyrno = 0;
-							}
-						}
-					}
-				}
-			}
-		}
-	}
+        jpc_enc_tcmpt_t *comp;
+        jpc_enc_tcmpt_t *endcomps;
+        jpc_enc_rlvl_t *lvl;
+        jpc_enc_rlvl_t *endlvls;
+        jpc_enc_band_t *band;
+        jpc_enc_band_t *endbands;
+        jpc_enc_cblk_t *cblk;
+        jpc_enc_cblk_t *endcblks;
+        jpc_enc_pass_t *pass;
+        jpc_enc_pass_t *endpasses;
+        jpc_tagtreenode_t *leaf;
+        jpc_enc_tile_t *tile;
+        uint_fast32_t prcno;
+        jpc_enc_prc_t *prc;
+
+        tile = enc->curtile;
+
+        endcomps = &tile->tcmpts[tile->numtcmpts];
+        for (comp = tile->tcmpts; comp != endcomps; ++comp) {
+                endlvls = &comp->rlvls[comp->numrlvls];
+                for (lvl = comp->rlvls; lvl != endlvls; ++lvl) {
+                        if (!lvl->bands) {
+                                continue;
+                        }
+                        endbands = &lvl->bands[lvl->numbands];
+                        for (band = lvl->bands; band != endbands; ++band) {
+                                if (!band->data) {
+                                        continue;
+                                }
+                                for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) {
+                                        if (!prc->cblks) {
+                                                continue;
+                                        }
+                                        jpc_tagtree_reset(prc->incltree);
+                                        jpc_tagtree_reset(prc->nlibtree);
+                                        endcblks = &prc->cblks[prc->numcblks];
+                                        for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
+                                                if (jas_stream_rewind(cblk->stream)) {
+                                                        assert(0);
+                                                }
+                                                cblk->curpass = (cblk->numpasses > 0) ? cblk->passes : 0;
+                                                cblk->numencpasses = 0;
+                                                cblk->numlenbits = 3;
+                                                cblk->numimsbs = band->numbps - cblk->numbps;
+                                                assert(cblk->numimsbs >= 0);
+                                                leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks);
+                                                jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs);
+
+                                                if (raflag) {
+                                                        endpasses = &cblk->passes[cblk->numpasses];
+                                                        for (pass = cblk->passes; pass != endpasses; ++pass) {
+                                                                pass->lyrno = -1;
+                                                                pass->lyrno = 0;
+                                                        }
+                                                }
+                                        }
+                                }
+                        }
+                }
+        }
 
 }
 
 jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t *cp, jpc_enc_tile_t *tile)
 {
-	jpc_pi_t *pi;
-	int compno;
-	jpc_picomp_t *picomp;
-	jpc_pirlvl_t *pirlvl;
-	jpc_enc_tcmpt_t *tcomp;
-	int rlvlno;
-	jpc_enc_rlvl_t *rlvl;
-	int prcno;
-	int *prclyrno;
-
-	if (!(pi = jpc_pi_create0())) {
-		return 0;
-	}
-	pi->pktno = -1;
-	pi->numcomps = cp->numcmpts;
-	if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
-		jpc_pi_destroy(pi);
-		return 0;
-	}
-	for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno,
-	  ++picomp) {
-		picomp->pirlvls = 0;
-	}
-
-	for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps;
-	  compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
-		picomp->numrlvls = tcomp->numrlvls;
-		if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
-		  sizeof(jpc_pirlvl_t)))) {
-			jpc_pi_destroy(pi);
-			return 0;
-		}
-		for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
-		  picomp->numrlvls; ++rlvlno, ++pirlvl) {
-			pirlvl->prclyrnos = 0;
-		}
-		for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
-		  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
+        jpc_pi_t *pi;
+        int compno;
+        jpc_picomp_t *picomp;
+        jpc_pirlvl_t *pirlvl;
+        jpc_enc_tcmpt_t *tcomp;
+        int rlvlno;
+        jpc_enc_rlvl_t *rlvl;
+        int prcno;
+        int *prclyrno;
+
+        if (!(pi = jpc_pi_create0())) {
+                return 0;
+        }
+        pi->pktno = -1;
+        pi->numcomps = cp->numcmpts;
+        if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
+                jpc_pi_destroy(pi);
+                return 0;
+        }
+        for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno,
+          ++picomp) {
+                picomp->pirlvls = 0;
+        }
+
+        for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps;
+          compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
+                picomp->numrlvls = tcomp->numrlvls;
+                if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
+                  sizeof(jpc_pirlvl_t)))) {
+                        jpc_pi_destroy(pi);
+                        return 0;
+                }
+                for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <
+                  picomp->numrlvls; ++rlvlno, ++pirlvl) {
+                        pirlvl->prclyrnos = 0;
+                }
+                for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
+                  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
 /* XXX sizeof(long) should be sizeof different type */
-			pirlvl->numprcs = rlvl->numprcs;
-			if (rlvl->numprcs) {
-				if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
-				  sizeof(long)))) {
-					jpc_pi_destroy(pi);
-					return 0;
-				}
-			} else {
-				pirlvl->prclyrnos = 0;
-			}
-		}
-	}
-
-	pi->maxrlvls = 0;
-	for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps;
-	  compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
-		picomp->hsamp = cp->ccps[compno].sampgrdstepx;
-		picomp->vsamp = cp->ccps[compno].sampgrdstepy;
-		for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
-		  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
-			pirlvl->prcwidthexpn = rlvl->prcwidthexpn;
-			pirlvl->prcheightexpn = rlvl->prcheightexpn;
-			for (prcno = 0, prclyrno = pirlvl->prclyrnos;
-			  prcno < pirlvl->numprcs; ++prcno, ++prclyrno) {
-				*prclyrno = 0;
-			}
-			pirlvl->numhprcs = rlvl->numhprcs;
-		}
-		if (pi->maxrlvls < tcomp->numrlvls) {
-			pi->maxrlvls = tcomp->numrlvls;
-		}
-	}
-
-	pi->numlyrs = tile->numlyrs;
-	pi->xstart = tile->tlx;
-	pi->ystart = tile->tly;
-	pi->xend = tile->brx;
-	pi->yend = tile->bry;
-
-	pi->picomp = 0;
-	pi->pirlvl = 0;
-	pi->x = 0;
-	pi->y = 0;
-	pi->compno = 0;
-	pi->rlvlno = 0;
-	pi->prcno = 0;
-	pi->lyrno = 0;
-	pi->xstep = 0;
-	pi->ystep = 0;
-
-	pi->pchgno = -1;
-
-	pi->defaultpchg.prgord = tile->prg;
-	pi->defaultpchg.compnostart = 0;
-	pi->defaultpchg.compnoend = pi->numcomps;
-	pi->defaultpchg.rlvlnostart = 0;
-	pi->defaultpchg.rlvlnoend = pi->maxrlvls;
-	pi->defaultpchg.lyrnoend = pi->numlyrs;
-	pi->pchg = 0;
-
-	pi->valid = 0;
-
-	return pi;
+                        pirlvl->numprcs = rlvl->numprcs;
+                        if (rlvl->numprcs) {
+                                if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
+                                  sizeof(long)))) {
+                                        jpc_pi_destroy(pi);
+                                        return 0;
+                                }
+                        } else {
+                                pirlvl->prclyrnos = 0;
+                        }
+                }
+        }
+
+        pi->maxrlvls = 0;
+        for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps;
+          compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
+                picomp->hsamp = cp->ccps[compno].sampgrdstepx;
+                picomp->vsamp = cp->ccps[compno].sampgrdstepy;
+                for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls;
+                  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
+                        pirlvl->prcwidthexpn = rlvl->prcwidthexpn;
+                        pirlvl->prcheightexpn = rlvl->prcheightexpn;
+                        for (prcno = 0, prclyrno = pirlvl->prclyrnos;
+                          prcno < pirlvl->numprcs; ++prcno, ++prclyrno) {
+                                *prclyrno = 0;
+                        }
+                        pirlvl->numhprcs = rlvl->numhprcs;
+                }
+                if (pi->maxrlvls < tcomp->numrlvls) {
+                        pi->maxrlvls = tcomp->numrlvls;
+                }
+        }
+
+        pi->numlyrs = tile->numlyrs;
+        pi->xstart = tile->tlx;
+        pi->ystart = tile->tly;
+        pi->xend = tile->brx;
+        pi->yend = tile->bry;
+
+        pi->picomp = 0;
+        pi->pirlvl = 0;
+        pi->x = 0;
+        pi->y = 0;
+        pi->compno = 0;
+        pi->rlvlno = 0;
+        pi->prcno = 0;
+        pi->lyrno = 0;
+        pi->xstep = 0;
+        pi->ystep = 0;
+
+        pi->pchgno = -1;
+
+        pi->defaultpchg.prgord = tile->prg;
+        pi->defaultpchg.compnostart = 0;
+        pi->defaultpchg.compnoend = pi->numcomps;
+        pi->defaultpchg.rlvlnostart = 0;
+        pi->defaultpchg.rlvlnoend = pi->maxrlvls;
+        pi->defaultpchg.lyrnoend = pi->numlyrs;
+        pi->pchg = 0;
+
+        pi->valid = 0;
+
+        return pi;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h
index e97f8c06..8b5979de 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c
index 2b13fcf1..1d026b85 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -135,101 +135,101 @@
 
 static jpc_tagtree_t *jpc_tagtree_alloc(void)
 {
-	jpc_tagtree_t *tree;
+        jpc_tagtree_t *tree;
 
-	if (!(tree = jas_malloc(sizeof(jpc_tagtree_t)))) {
-		return 0;
-	}
-	tree->numleafsh_ = 0;
-	tree->numleafsv_ = 0;
-	tree->numnodes_ = 0;
-	tree->nodes_ = 0;
+        if (!(tree = jas_malloc(sizeof(jpc_tagtree_t)))) {
+                return 0;
+        }
+        tree->numleafsh_ = 0;
+        tree->numleafsv_ = 0;
+        tree->numnodes_ = 0;
+        tree->nodes_ = 0;
 
-	return tree;
+        return tree;
 }
 
 /* Create a tag tree. */
 
 jpc_tagtree_t *jpc_tagtree_create(int numleafsh, int numleafsv)
 {
-	int nplh[JPC_TAGTREE_MAXDEPTH];
-	int nplv[JPC_TAGTREE_MAXDEPTH];
-	jpc_tagtreenode_t *node;
-	jpc_tagtreenode_t *parentnode;
-	jpc_tagtreenode_t *parentnode0;
-	jpc_tagtree_t *tree;
-	int i;
-	int j;
-	int k;
-	int numlvls;
-	int n;
-
-	assert(numleafsh > 0 && numleafsv > 0);
-
-	if (!(tree = jpc_tagtree_alloc())) {
-		return 0;
-	}
-	tree->numleafsh_ = numleafsh;
-	tree->numleafsv_ = numleafsv;
-
-	numlvls = 0;
-	nplh[0] = numleafsh;
-	nplv[0] = numleafsv;
-	do {
-		n = nplh[numlvls] * nplv[numlvls];
-		nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
-		nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
-		tree->numnodes_ += n;
-		++numlvls;
-	} while (n > 1);
-
-	if (!(tree->nodes_ = jas_malloc(tree->numnodes_ * sizeof(jpc_tagtreenode_t)))) {
-		return 0;
-	}
-
-	/* Initialize the parent links for all nodes in the tree. */
-
-	node = tree->nodes_;
-	parentnode = &tree->nodes_[tree->numleafsh_ * tree->numleafsv_];
-	parentnode0 = parentnode;
-
-	for (i = 0; i < numlvls - 1; ++i) {
-		for (j = 0; j < nplv[i]; ++j) {
-			k = nplh[i];
-			while (--k >= 0) {
-				node->parent_ = parentnode;
-				++node;
-				if (--k >= 0) {
-					node->parent_ = parentnode;
-					++node;
-				}
-				++parentnode;
-			}
-			if ((j & 1) || j == nplv[i] - 1) {
-				parentnode0 = parentnode;
-			} else {
-				parentnode = parentnode0;
-				parentnode0 += nplh[i];
-			}
-		}
-	}
-	node->parent_ = 0;
-
-	/* Initialize the data values to something sane. */
-
-	jpc_tagtree_reset(tree);
-
-	return tree;
+        int nplh[JPC_TAGTREE_MAXDEPTH];
+        int nplv[JPC_TAGTREE_MAXDEPTH];
+        jpc_tagtreenode_t *node;
+        jpc_tagtreenode_t *parentnode;
+        jpc_tagtreenode_t *parentnode0;
+        jpc_tagtree_t *tree;
+        int i;
+        int j;
+        int k;
+        int numlvls;
+        int n;
+
+        assert(numleafsh > 0 && numleafsv > 0);
+
+        if (!(tree = jpc_tagtree_alloc())) {
+                return 0;
+        }
+        tree->numleafsh_ = numleafsh;
+        tree->numleafsv_ = numleafsv;
+
+        numlvls = 0;
+        nplh[0] = numleafsh;
+        nplv[0] = numleafsv;
+        do {
+                n = nplh[numlvls] * nplv[numlvls];
+                nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
+                nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
+                tree->numnodes_ += n;
+                ++numlvls;
+        } while (n > 1);
+
+        if (!(tree->nodes_ = jas_malloc(tree->numnodes_ * sizeof(jpc_tagtreenode_t)))) {
+                return 0;
+        }
+
+        /* Initialize the parent links for all nodes in the tree. */
+
+        node = tree->nodes_;
+        parentnode = &tree->nodes_[tree->numleafsh_ * tree->numleafsv_];
+        parentnode0 = parentnode;
+
+        for (i = 0; i < numlvls - 1; ++i) {
+                for (j = 0; j < nplv[i]; ++j) {
+                        k = nplh[i];
+                        while (--k >= 0) {
+                                node->parent_ = parentnode;
+                                ++node;
+                                if (--k >= 0) {
+                                        node->parent_ = parentnode;
+                                        ++node;
+                                }
+                                ++parentnode;
+                        }
+                        if ((j & 1) || j == nplv[i] - 1) {
+                                parentnode0 = parentnode;
+                        } else {
+                                parentnode = parentnode0;
+                                parentnode0 += nplh[i];
+                        }
+                }
+        }
+        node->parent_ = 0;
+
+        /* Initialize the data values to something sane. */
+
+        jpc_tagtree_reset(tree);
+
+        return tree;
 }
 
 /* Destroy a tag tree. */
 
 void jpc_tagtree_destroy(jpc_tagtree_t *tree)
 {
-	if (tree->nodes_) {
-		jas_free(tree->nodes_);
-	}
-	jas_free(tree);
+        if (tree->nodes_) {
+                jas_free(tree->nodes_);
+        }
+        jas_free(tree);
 }
 
 /******************************************************************************\
@@ -240,42 +240,42 @@ void jpc_tagtree_destroy(jpc_tagtree_t *tree)
 
 void jpc_tagtree_copy(jpc_tagtree_t *dsttree, jpc_tagtree_t *srctree)
 {
-	int n;
-	jpc_tagtreenode_t *srcnode;
-	jpc_tagtreenode_t *dstnode;
-
-	/* The two tag trees must have similar sizes. */
-	assert(srctree->numleafsh_ == dsttree->numleafsh_ &&
-	  srctree->numleafsv_ == dsttree->numleafsv_);
-
-	n = srctree->numnodes_;
-	srcnode = srctree->nodes_;
-	dstnode = dsttree->nodes_;
-	while (--n >= 0) {
-		dstnode->value_ = srcnode->value_;
-		dstnode->low_ = srcnode->low_;
-		dstnode->known_ = srcnode->known_;
-		++dstnode;
-		++srcnode;
-	}
+        int n;
+        jpc_tagtreenode_t *srcnode;
+        jpc_tagtreenode_t *dstnode;
+
+        /* The two tag trees must have similar sizes. */
+        assert(srctree->numleafsh_ == dsttree->numleafsh_ &&
+          srctree->numleafsv_ == dsttree->numleafsv_);
+
+        n = srctree->numnodes_;
+        srcnode = srctree->nodes_;
+        dstnode = dsttree->nodes_;
+        while (--n >= 0) {
+                dstnode->value_ = srcnode->value_;
+                dstnode->low_ = srcnode->low_;
+                dstnode->known_ = srcnode->known_;
+                ++dstnode;
+                ++srcnode;
+        }
 }
 
 /* Reset all of the state information associated with a tag tree. */
 
 void jpc_tagtree_reset(jpc_tagtree_t *tree)
 {
-	int n;
-	jpc_tagtreenode_t *node;
-
-	n = tree->numnodes_;
-	node = tree->nodes_;
-
-	while (--n >= 0) {
-		node->value_ = INT_MAX;
-		node->low_ = 0;
-		node->known_ = 0;
-		++node;
-	}
+        int n;
+        jpc_tagtreenode_t *node;
+
+        n = tree->numnodes_;
+        node = tree->nodes_;
+
+        while (--n >= 0) {
+                node->value_ = INT_MAX;
+                node->low_ = 0;
+                node->known_ = 0;
+                ++node;
+        }
 }
 
 /* Set the value associated with the specified leaf node, updating
@@ -283,22 +283,22 @@ the other nodes as necessary. */
 
 void jpc_tagtree_setvalue(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int value)
 {
-	jpc_tagtreenode_t *node;
+        jpc_tagtreenode_t *node;
 
-	assert(value >= 0);
+        assert(value >= 0);
 
-	node = leaf;
-	while (node && node->value_ > value) {
-		node->value_ = value;
-		node = node->parent_;
-	}
+        node = leaf;
+        while (node && node->value_ > value) {
+                node->value_ = value;
+                node = node->parent_;
+        }
 }
 
 /* Get a particular leaf node. */
 
 jpc_tagtreenode_t *jpc_tagtree_getleaf(jpc_tagtree_t *tree, int n)
 {
-	return &tree->nodes_[n];
+        return &tree->nodes_[n];
 }
 
 /* Invoke the tag tree encoding procedure. */
@@ -306,55 +306,55 @@ jpc_tagtreenode_t *jpc_tagtree_getleaf(jpc_tagtree_t *tree, int n)
 int jpc_tagtree_encode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int threshold,
   jpc_bitstream_t *out)
 {
-	jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1];
-	jpc_tagtreenode_t **stkptr;
-	jpc_tagtreenode_t *node;
-	int low;
-
-	assert(leaf);
-	assert(threshold >= 0);
-
-	/* Traverse to the root of the tree, recording the path taken. */
-	stkptr = stk;
-	node = leaf;
-	while (node->parent_) {
-		*stkptr++ = node;
-		node = node->parent_;
-	}
-
-	low = 0;
-	for (;;) {
-		if (low > node->low_) {
-			/* Deferred propagation of the lower bound downward in
-			  the tree. */
-			node->low_ = low;
-		} else {
-			low = node->low_;
-		}
-
-		while (low < threshold) {
-			if (low >= node->value_) {
-				if (!node->known_) {
-					if (jpc_bitstream_putbit(out, 1) == EOF) {
-						return -1;
-					}
-					node->known_ = 1;
-				}
-				break;
-			}
-			if (jpc_bitstream_putbit(out, 0) == EOF) {
-				return -1;
-			}
-			++low;
-		}
-		node->low_ = low;
-		if (stkptr == stk) {
-			break;
-		}
-		node = *--stkptr;
-
-	}
-	return (leaf->low_ < threshold) ? 1 : 0;
+        jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1];
+        jpc_tagtreenode_t **stkptr;
+        jpc_tagtreenode_t *node;
+        int low;
+
+        assert(leaf);
+        assert(threshold >= 0);
+
+        /* Traverse to the root of the tree, recording the path taken. */
+        stkptr = stk;
+        node = leaf;
+        while (node->parent_) {
+                *stkptr++ = node;
+                node = node->parent_;
+        }
+
+        low = 0;
+        for (;;) {
+                if (low > node->low_) {
+                        /* Deferred propagation of the lower bound downward in
+                          the tree. */
+                        node->low_ = low;
+                } else {
+                        low = node->low_;
+                }
+
+                while (low < threshold) {
+                        if (low >= node->value_) {
+                                if (!node->known_) {
+                                        if (jpc_bitstream_putbit(out, 1) == EOF) {
+                                                return -1;
+                                        }
+                                        node->known_ = 1;
+                                }
+                                break;
+                        }
+                        if (jpc_bitstream_putbit(out, 0) == EOF) {
+                                return -1;
+                        }
+                        ++low;
+                }
+                node->low_ = low;
+                if (stkptr == stk) {
+                        break;
+                }
+                node = *--stkptr;
+
+        }
+        return (leaf->low_ < threshold) ? 1 : 0;
 
 }
 
@@ -363,47 +363,47 @@ int jpc_tagtree_encode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int thresho
 int jpc_tagtree_decode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int threshold,
   jpc_bitstream_t *in)
 {
-	jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1];
-	jpc_tagtreenode_t **stkptr;
-	jpc_tagtreenode_t *node;
-	int low;
-	int ret;
-
-	assert(threshold >= 0);
-
-	/* Traverse to the root of the tree, recording the path taken. */
-	stkptr = stk;
-	node = leaf;
-	while (node->parent_) {
-		*stkptr++ = node;
-		node = node->parent_;
-	}
-
-	low = 0;
-	for (;;) {
-		if (low > node->low_) {
-			node->low_ = low;
-		} else {
-			low = node->low_;
-		}
-		while (low < threshold && low < node->value_) {
-			if ((ret = jpc_bitstream_getbit(in)) < 0) {
-				return -1;
-			}
-			if (ret) {
-				node->value_ = low;
-			} else {
-				++low;
-			}
-		}
-		node->low_ = low;
-		if (stkptr == stk) {
-			break;
-		}
-		node = *--stkptr;
-	}
-
-	return (node->value_ < threshold) ? 1 : 0;
+        jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1];
+        jpc_tagtreenode_t **stkptr;
+        jpc_tagtreenode_t *node;
+        int low;
+        int ret;
+
+        assert(threshold >= 0);
+
+        /* Traverse to the root of the tree, recording the path taken. */
+        stkptr = stk;
+        node = leaf;
+        while (node->parent_) {
+                *stkptr++ = node;
+                node = node->parent_;
+        }
+
+        low = 0;
+        for (;;) {
+                if (low > node->low_) {
+                        node->low_ = low;
+                } else {
+                        low = node->low_;
+                }
+                while (low < threshold && low < node->value_) {
+                        if ((ret = jpc_bitstream_getbit(in)) < 0) {
+                                return -1;
+                        }
+                        if (ret) {
+                                node->value_ = low;
+                        } else {
+                                ++low;
+                        }
+                }
+                node->low_ = low;
+                if (stkptr == stk) {
+                        break;
+                }
+                node = *--stkptr;
+        }
+
+        return (node->value_ < threshold) ? 1 : 0;
 }
 
 /******************************************************************************\
@@ -412,15 +412,15 @@ int jpc_tagtree_decode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int thresho
 
 void jpc_tagtree_dump(jpc_tagtree_t *tree, FILE *out)
 {
-	jpc_tagtreenode_t *node;
-	int n;
-
-	node = tree->nodes_;
-	n = tree->numnodes_;
-	while (--n >= 0) {
-		fprintf(out, "node %p, parent %p, value %d, lower %d, known %d\n",
-		  (void *) node, (void *) node->parent_, node->value_, node->low_,
-		  node->known_);
-		++node;
-	}
+        jpc_tagtreenode_t *node;
+        int n;
+
+        node = tree->nodes_;
+        n = tree->numnodes_;
+        while (--n >= 0) {
+                fprintf(out, "node %p, parent %p, value %d, lower %d, known %d\n",
+                  (void *) node, (void *) node->parent_, node->value_, node->low_,
+                  node->known_);
+                ++node;
+        }
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h
index 1892b13f..cf1dc652 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -133,7 +133,7 @@
 \******************************************************************************/
 
 /* The maximum allowable depth for a tag tree. */
-#define JPC_TAGTREE_MAXDEPTH	32
+#define JPC_TAGTREE_MAXDEPTH    32
 
 /******************************************************************************\
 * Types
@@ -145,17 +145,17 @@
 
 typedef struct jpc_tagtreenode_ {
 
-	/* The parent of this node. */
-	struct jpc_tagtreenode_ *parent_;
+        /* The parent of this node. */
+        struct jpc_tagtreenode_ *parent_;
 
-	/* The value associated with this node. */
-	int value_;
+        /* The value associated with this node. */
+        int value_;
 
-	/* The lower bound on the value associated with this node. */
-	int low_;
+        /* The lower bound on the value associated with this node. */
+        int low_;
 
-	/* A flag indicating if the value is known exactly. */
-	int known_;
+        /* A flag indicating if the value is known exactly. */
+        int known_;
 
 } jpc_tagtreenode_t;
 
@@ -165,17 +165,17 @@ typedef struct jpc_tagtreenode_ {
 
 typedef struct {
 
-	/* The number of leaves in the horizontal direction. */
-	int numleafsh_;
+        /* The number of leaves in the horizontal direction. */
+        int numleafsh_;
 
-	/* The number of leaves in the vertical direction. */
-	int numleafsv_;
+        /* The number of leaves in the vertical direction. */
+        int numleafsv_;
 
-	/* The total number of nodes in the tree. */
-	int numnodes_;
+        /* The total number of nodes in the tree. */
+        int numnodes_;
 
-	/* The nodes. */
-	jpc_tagtreenode_t *nodes_;
+        /* The nodes. */
+        jpc_tagtreenode_t *nodes_;
 
 } jpc_tagtree_t;
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c
index f7d66b57..a5772c53 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -134,8 +134,8 @@
 *
 \******************************************************************************/
 
-#define	bandnotovind(tsfbnode, x)	((x) / (tsfbnode)->numhchans)
-#define	bandnotohind(tsfbnode, x)	((x) % (tsfbnode)->numhchans)
+#define bandnotovind(tsfbnode, x)       ((x) / (tsfbnode)->numhchans)
+#define bandnotohind(tsfbnode, x)       ((x) % (tsfbnode)->numhchans)
 
 static jpc_tsfb_t *jpc_tsfb_create(void);
 static jpc_tsfbnode_t *jpc_tsfbnode_create(void);
@@ -158,74 +158,74 @@ static int jpc_tsfbnode_getequivfilters(jpc_tsfbnode_t *tsfbnode, int cldind,
 
 jpc_tsfb_t *jpc_tsfb_wavelet(jpc_qmfb1d_t *hqmfb, jpc_qmfb1d_t *vqmfb, int numdlvls)
 {
-	jpc_tsfb_t *tsfb;
-	int dlvlno;
-	jpc_tsfbnode_t *curnode;
-	jpc_tsfbnode_t *prevnode;
-	int childno;
-	if (!(tsfb = jpc_tsfb_create())) {
-		return 0;
-	}
-	prevnode = 0;
-	for (dlvlno = 0; dlvlno < numdlvls; ++dlvlno) {
-		if (!(curnode = jpc_tsfbnode_create())) {
-			jpc_tsfb_destroy(tsfb);
-			return 0;
-		}
-		if (prevnode) {
-			prevnode->children[0] = curnode;
-			++prevnode->numchildren;
-			curnode->parent = prevnode;
-		} else {
-			tsfb->root = curnode;
-			curnode->parent = 0;
-		}
-		if (hqmfb) {
-			curnode->numhchans = jpc_qmfb1d_getnumchans(hqmfb);
-			if (!(curnode->hqmfb = jpc_qmfb1d_copy(hqmfb))) {
-				jpc_tsfb_destroy(tsfb);
-				return 0;
-			}
-		} else {
-			curnode->hqmfb = 0;
-			curnode->numhchans = 1;
-		}
-		if (vqmfb) {
-			curnode->numvchans = jpc_qmfb1d_getnumchans(vqmfb);
-			if (!(curnode->vqmfb = jpc_qmfb1d_copy(vqmfb))) {
-				jpc_tsfb_destroy(tsfb);
-				return 0;
-			}
-		} else {
-			curnode->vqmfb = 0;
-			curnode->numvchans = 1;
-		}
-		curnode->maxchildren = curnode->numhchans * curnode->numvchans;
-		for (childno = 0; childno < curnode->maxchildren;
-		  ++childno) {
-			curnode->children[childno] = 0;
-		}
-		prevnode = curnode;
-	}
-	return tsfb;
+        jpc_tsfb_t *tsfb;
+        int dlvlno;
+        jpc_tsfbnode_t *curnode;
+        jpc_tsfbnode_t *prevnode;
+        int childno;
+        if (!(tsfb = jpc_tsfb_create())) {
+                return 0;
+        }
+        prevnode = 0;
+        for (dlvlno = 0; dlvlno < numdlvls; ++dlvlno) {
+                if (!(curnode = jpc_tsfbnode_create())) {
+                        jpc_tsfb_destroy(tsfb);
+                        return 0;
+                }
+                if (prevnode) {
+                        prevnode->children[0] = curnode;
+                        ++prevnode->numchildren;
+                        curnode->parent = prevnode;
+                } else {
+                        tsfb->root = curnode;
+                        curnode->parent = 0;
+                }
+                if (hqmfb) {
+                        curnode->numhchans = jpc_qmfb1d_getnumchans(hqmfb);
+                        if (!(curnode->hqmfb = jpc_qmfb1d_copy(hqmfb))) {
+                                jpc_tsfb_destroy(tsfb);
+                                return 0;
+                        }
+                } else {
+                        curnode->hqmfb = 0;
+                        curnode->numhchans = 1;
+                }
+                if (vqmfb) {
+                        curnode->numvchans = jpc_qmfb1d_getnumchans(vqmfb);
+                        if (!(curnode->vqmfb = jpc_qmfb1d_copy(vqmfb))) {
+                                jpc_tsfb_destroy(tsfb);
+                                return 0;
+                        }
+                } else {
+                        curnode->vqmfb = 0;
+                        curnode->numvchans = 1;
+                }
+                curnode->maxchildren = curnode->numhchans * curnode->numvchans;
+                for (childno = 0; childno < curnode->maxchildren;
+                  ++childno) {
+                        curnode->children[childno] = 0;
+                }
+                prevnode = curnode;
+        }
+        return tsfb;
 }
 
 static jpc_tsfb_t *jpc_tsfb_create()
 {
-	jpc_tsfb_t *tsfb;
-	if (!(tsfb = jas_malloc(sizeof(jpc_tsfb_t)))) {
-		return 0;
-	}
-	tsfb->root = 0;
-	return tsfb;
+        jpc_tsfb_t *tsfb;
+        if (!(tsfb = jas_malloc(sizeof(jpc_tsfb_t)))) {
+                return 0;
+        }
+        tsfb->root = 0;
+        return tsfb;
 }
 
 void jpc_tsfb_destroy(jpc_tsfb_t *tsfb)
 {
-	if (tsfb->root) {
-		jpc_tsfbnode_destroy(tsfb->root);
-	}
-	jas_free(tsfb);
+        if (tsfb->root) {
+                jpc_tsfbnode_destroy(tsfb->root);
+        }
+        jas_free(tsfb);
 }
 
 /******************************************************************************\
@@ -234,83 +234,83 @@ void jpc_tsfb_destroy(jpc_tsfb_t *tsfb)
 
 void jpc_tsfb_analyze(jpc_tsfb_t *tsfb, int flags, jas_seq2d_t *x)
 {
-	if (tsfb->root) {
-		jpc_tsfbnode_analyze(tsfb->root, flags, x);
-	}
+        if (tsfb->root) {
+                jpc_tsfbnode_analyze(tsfb->root, flags, x);
+        }
 }
 
 static void jpc_tsfbnode_analyze(jpc_tsfbnode_t *node, int flags, jas_seq2d_t *x)
 {
-	jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE];
-	int numbands;
-	jas_seq2d_t *y;
-	int bandno;
-	jpc_tsfbnodeband_t *band;
-
-	if (node->vqmfb) {
-		jpc_qmfb1d_analyze(node->vqmfb, flags | JPC_QMFB1D_VERT, x);
-	}
-	if (node->hqmfb) {
-		jpc_qmfb1d_analyze(node->hqmfb, flags, x);
-	}
-	if (node->numchildren > 0) {
-		qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x),
-		  jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x),
-		  JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands);
-		y = jas_seq2d_create(0, 0, 0, 0);
-		assert(y);
-		for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) {
-			if (node->children[bandno]) {
-				if (band->xstart != band->xend && band->ystart != band->yend) {
-					jas_seq2d_bindsub(y, x, band->locxstart, band->locystart,
-					  band->locxend, band->locyend);
-					jas_seq2d_setshift(y, band->xstart, band->ystart);
-					jpc_tsfbnode_analyze(node->children[bandno], flags, y);
-				}
-			}
-		}
-		jas_matrix_destroy(y);
-	}
+        jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE];
+        int numbands;
+        jas_seq2d_t *y;
+        int bandno;
+        jpc_tsfbnodeband_t *band;
+
+        if (node->vqmfb) {
+                jpc_qmfb1d_analyze(node->vqmfb, flags | JPC_QMFB1D_VERT, x);
+        }
+        if (node->hqmfb) {
+                jpc_qmfb1d_analyze(node->hqmfb, flags, x);
+        }
+        if (node->numchildren > 0) {
+                qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x),
+                  jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x),
+                  JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands);
+                y = jas_seq2d_create(0, 0, 0, 0);
+                assert(y);
+                for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) {
+                        if (node->children[bandno]) {
+                                if (band->xstart != band->xend && band->ystart != band->yend) {
+                                        jas_seq2d_bindsub(y, x, band->locxstart, band->locystart,
+                                          band->locxend, band->locyend);
+                                        jas_seq2d_setshift(y, band->xstart, band->ystart);
+                                        jpc_tsfbnode_analyze(node->children[bandno], flags, y);
+                                }
+                        }
+                }
+                jas_matrix_destroy(y);
+        }
 }
 
 void jpc_tsfb_synthesize(jpc_tsfb_t *tsfb, int flags, jas_seq2d_t *x)
 {
-	if (tsfb->root) {
-		jpc_tsfbnode_synthesize(tsfb->root, flags, x);
-	}
+        if (tsfb->root) {
+                jpc_tsfbnode_synthesize(tsfb->root, flags, x);
+        }
 }
 
 static void jpc_tsfbnode_synthesize(jpc_tsfbnode_t *node, int flags, jas_seq2d_t *x)
 {
-	jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE];
-	int numbands;
-	jas_seq2d_t *y;
-	int bandno;
-	jpc_tsfbnodeband_t *band;
-
-	if (node->numchildren > 0) {
-		qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x),
-		  jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x),
-		  JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands);
-		y = jas_seq2d_create(0, 0, 0, 0);
-		for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) {
-			if (node->children[bandno]) {
-				if (band->xstart != band->xend && band->ystart != band->yend) {
-					jas_seq2d_bindsub(y, x, band->locxstart, band->locystart,
-					  band->locxend, band->locyend);
-					jas_seq2d_setshift(y, band->xstart, band->ystart);
-					jpc_tsfbnode_synthesize(node->children[bandno], flags, y);
-				}
-			}
-		}
-		jas_seq2d_destroy(y);
-	}
-	if (node->hqmfb) {
-		jpc_qmfb1d_synthesize(node->hqmfb, flags, x);
-	}
-	if (node->vqmfb) {
-		jpc_qmfb1d_synthesize(node->vqmfb, flags | JPC_QMFB1D_VERT, x);
-	}
+        jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE];
+        int numbands;
+        jas_seq2d_t *y;
+        int bandno;
+        jpc_tsfbnodeband_t *band;
+
+        if (node->numchildren > 0) {
+                qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x),
+                  jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x),
+                  JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands);
+                y = jas_seq2d_create(0, 0, 0, 0);
+                for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) {
+                        if (node->children[bandno]) {
+                                if (band->xstart != band->xend && band->ystart != band->yend) {
+                                        jas_seq2d_bindsub(y, x, band->locxstart, band->locystart,
+                                          band->locxend, band->locyend);
+                                        jas_seq2d_setshift(y, band->xstart, band->ystart);
+                                        jpc_tsfbnode_synthesize(node->children[bandno], flags, y);
+                                }
+                        }
+                }
+                jas_seq2d_destroy(y);
+        }
+        if (node->hqmfb) {
+                jpc_qmfb1d_synthesize(node->hqmfb, flags, x);
+        }
+        if (node->vqmfb) {
+                jpc_qmfb1d_synthesize(node->vqmfb, flags | JPC_QMFB1D_VERT, x);
+        }
 }
 
 /******************************************************************************\
@@ -321,114 +321,114 @@ static void jpc_tsfbnode_synthesize(jpc_tsfbnode_t *node, int flags, jas_seq2d_t
 int jpc_tsfb_getbands(jpc_tsfb_t *tsfb, uint_fast32_t xstart, uint_fast32_t ystart,
   uint_fast32_t xend, uint_fast32_t yend, jpc_tsfb_band_t *bands)
 {
-	jpc_tsfb_band_t *savbands;
-	savbands = bands;
-	if (!tsfb->root) {
-		bands[0].xstart = xstart;
-		bands[0].ystart = ystart;
-		bands[0].xend = xend;
-		bands[0].yend = yend;
-		bands[0].locxstart = xstart;
-		bands[0].locystart = ystart;
-		bands[0].locxend = xend;
-		bands[0].locyend = yend;
-		bands[0].orient = JPC_TSFB_LL;
-		bands[0].synenergywt = JPC_FIX_ONE;
-		++bands;
-	} else {
-		jpc_tsfbnode_getbandstree(tsfb->root, xstart, ystart,
-		  xstart, ystart, xend, yend, &bands);
-	}
-	return bands - savbands;
+        jpc_tsfb_band_t *savbands;
+        savbands = bands;
+        if (!tsfb->root) {
+                bands[0].xstart = xstart;
+                bands[0].ystart = ystart;
+                bands[0].xend = xend;
+                bands[0].yend = yend;
+                bands[0].locxstart = xstart;
+                bands[0].locystart = ystart;
+                bands[0].locxend = xend;
+                bands[0].locyend = yend;
+                bands[0].orient = JPC_TSFB_LL;
+                bands[0].synenergywt = JPC_FIX_ONE;
+                ++bands;
+        } else {
+                jpc_tsfbnode_getbandstree(tsfb->root, xstart, ystart,
+                  xstart, ystart, xend, yend, &bands);
+        }
+        return bands - savbands;
 }
 
 static void jpc_tsfbnode_getbandstree(jpc_tsfbnode_t *node, uint_fast32_t posxstart,
   uint_fast32_t posystart, uint_fast32_t xstart, uint_fast32_t ystart,
   uint_fast32_t xend, uint_fast32_t yend, jpc_tsfb_band_t **bands)
 {
-	jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE];
-	jpc_tsfbnodeband_t *nodeband;
-	int nodebandno;
-	int numnodebands;
-	jpc_tsfb_band_t *band;
-	jas_seq_t *hfilter;
-	jas_seq_t *vfilter;
-
-	qmfb2d_getbands(node->hqmfb, node->vqmfb, xstart, ystart, xend, yend,
-	  JPC_TSFB_MAXBANDSPERNODE, &numnodebands, nodebands);
-	if (node->numchildren > 0) {
-		for (nodebandno = 0, nodeband = nodebands;
-		  nodebandno < numnodebands; ++nodebandno, ++nodeband) {
-			if (node->children[nodebandno]) {
-				jpc_tsfbnode_getbandstree(node->children[
-				  nodebandno], posxstart +
-				  nodeband->locxstart - xstart, posystart +
-				  nodeband->locystart - ystart, nodeband->xstart,
-				  nodeband->ystart, nodeband->xend,
-				  nodeband->yend, bands);
-
-			}
-		}
-	}
+        jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE];
+        jpc_tsfbnodeband_t *nodeband;
+        int nodebandno;
+        int numnodebands;
+        jpc_tsfb_band_t *band;
+        jas_seq_t *hfilter;
+        jas_seq_t *vfilter;
+
+        qmfb2d_getbands(node->hqmfb, node->vqmfb, xstart, ystart, xend, yend,
+          JPC_TSFB_MAXBANDSPERNODE, &numnodebands, nodebands);
+        if (node->numchildren > 0) {
+                for (nodebandno = 0, nodeband = nodebands;
+                  nodebandno < numnodebands; ++nodebandno, ++nodeband) {
+                        if (node->children[nodebandno]) {
+                                jpc_tsfbnode_getbandstree(node->children[
+                                  nodebandno], posxstart +
+                                  nodeband->locxstart - xstart, posystart +
+                                  nodeband->locystart - ystart, nodeband->xstart,
+                                  nodeband->ystart, nodeband->xend,
+                                  nodeband->yend, bands);
+
+                        }
+                }
+        }
 assert(numnodebands == 4 || numnodebands == 3);
-	for (nodebandno = 0, nodeband = nodebands; nodebandno < numnodebands;
-	  ++nodebandno, ++nodeband) {
-		if (!node->children[nodebandno]) {
-			band = *bands;
-			band->xstart = nodeband->xstart;
-			band->ystart = nodeband->ystart;
-			band->xend = nodeband->xend;
-			band->yend = nodeband->yend;
-			band->locxstart = posxstart + nodeband->locxstart -
-			  xstart;
-			band->locystart = posystart + nodeband->locystart -
-			  ystart;
-			band->locxend = band->locxstart + band->xend -
-			  band->xstart;
-			band->locyend = band->locystart + band->yend -
-			  band->ystart;
-			if (numnodebands == 4) {
-				switch (nodebandno) {
-				case 0:
-					band->orient = JPC_TSFB_LL;
-					break;
-				case 1:
-					band->orient = JPC_TSFB_HL;
-					break;
-				case 2:
-					band->orient = JPC_TSFB_LH;
-					break;
-				case 3:
-					band->orient = JPC_TSFB_HH;
-					break;
-				default:
-					abort();
-					break;
-				}
-			} else {
-				switch (nodebandno) {
-				case 0:
-					band->orient = JPC_TSFB_HL;
-					break;
-				case 1:
-					band->orient = JPC_TSFB_LH;
-					break;
-				case 2:
-					band->orient = JPC_TSFB_HH;
-					break;
-				default:
-					abort();
-					break;
-				}
-			}
-			jpc_tsfbnode_getequivfilters(node, nodebandno, band->xend - band->xstart, band->yend - band->ystart, &hfilter, &vfilter);
-			band->synenergywt = jpc_fix_mul(jpc_seq_norm(hfilter),
-			  jpc_seq_norm(vfilter));
-			jas_seq_destroy(hfilter);
-			jas_seq_destroy(vfilter);
-			++(*bands);
-		}
-	}
+        for (nodebandno = 0, nodeband = nodebands; nodebandno < numnodebands;
+          ++nodebandno, ++nodeband) {
+                if (!node->children[nodebandno]) {
+                        band = *bands;
+                        band->xstart = nodeband->xstart;
+                        band->ystart = nodeband->ystart;
+                        band->xend = nodeband->xend;
+                        band->yend = nodeband->yend;
+                        band->locxstart = posxstart + nodeband->locxstart -
+                          xstart;
+                        band->locystart = posystart + nodeband->locystart -
+                          ystart;
+                        band->locxend = band->locxstart + band->xend -
+                          band->xstart;
+                        band->locyend = band->locystart + band->yend -
+                          band->ystart;
+                        if (numnodebands == 4) {
+                                switch (nodebandno) {
+                                case 0:
+                                        band->orient = JPC_TSFB_LL;
+                                        break;
+                                case 1:
+                                        band->orient = JPC_TSFB_HL;
+                                        break;
+                                case 2:
+                                        band->orient = JPC_TSFB_LH;
+                                        break;
+                                case 3:
+                                        band->orient = JPC_TSFB_HH;
+                                        break;
+                                default:
+                                        abort();
+                                        break;
+                                }
+                        } else {
+                                switch (nodebandno) {
+                                case 0:
+                                        band->orient = JPC_TSFB_HL;
+                                        break;
+                                case 1:
+                                        band->orient = JPC_TSFB_LH;
+                                        break;
+                                case 2:
+                                        band->orient = JPC_TSFB_HH;
+                                        break;
+                                default:
+                                        abort();
+                                        break;
+                                }
+                        }
+                        jpc_tsfbnode_getequivfilters(node, nodebandno, band->xend - band->xstart, band->yend - band->ystart, &hfilter, &vfilter);
+                        band->synenergywt = jpc_fix_mul(jpc_seq_norm(hfilter),
+                          jpc_seq_norm(vfilter));
+                        jas_seq_destroy(hfilter);
+                        jas_seq_destroy(vfilter);
+                        ++(*bands);
+                }
+        }
 }
 
 /******************************************************************************\
@@ -437,37 +437,37 @@ assert(numnodebands == 4 || numnodebands == 3);
 
 static jpc_tsfbnode_t *jpc_tsfbnode_create()
 {
-	jpc_tsfbnode_t *node;
-	if (!(node = jas_malloc(sizeof(jpc_tsfbnode_t)))) {
-		return 0;
-	}
-	node->numhchans = 0;
-	node->numvchans = 0;
-	node->numchildren = 0;
-	node->maxchildren = 0;
-	node->hqmfb = 0;
-	node->vqmfb = 0;
-	node->parent = 0;
-	return node;
+        jpc_tsfbnode_t *node;
+        if (!(node = jas_malloc(sizeof(jpc_tsfbnode_t)))) {
+                return 0;
+        }
+        node->numhchans = 0;
+        node->numvchans = 0;
+        node->numchildren = 0;
+        node->maxchildren = 0;
+        node->hqmfb = 0;
+        node->vqmfb = 0;
+        node->parent = 0;
+        return node;
 }
 
 static void jpc_tsfbnode_destroy(jpc_tsfbnode_t *node)
 {
-	jpc_tsfbnode_t **child;
-	int childno;
-	for (childno = 0, child = node->children; childno < node->maxchildren;
-	  ++childno, ++child) {
-		if (*child) {
-			jpc_tsfbnode_destroy(*child);
-		}
-	}
-	if (node->hqmfb) {
-		jpc_qmfb1d_destroy(node->hqmfb);
-	}
-	if (node->vqmfb) {
-		jpc_qmfb1d_destroy(node->vqmfb);
-	}
-	jas_free(node);
+        jpc_tsfbnode_t **child;
+        int childno;
+        for (childno = 0, child = node->children; childno < node->maxchildren;
+          ++childno, ++child) {
+                if (*child) {
+                        jpc_tsfbnode_destroy(*child);
+                }
+        }
+        if (node->hqmfb) {
+                jpc_qmfb1d_destroy(node->hqmfb);
+        }
+        if (node->vqmfb) {
+                jpc_qmfb1d_destroy(node->vqmfb);
+        }
+        jas_free(node);
 }
 
 
@@ -481,182 +481,182 @@ static void qmfb2d_getbands(jpc_qmfb1d_t *hqmfb, jpc_qmfb1d_t *vqmfb,
   uint_fast32_t xstart, uint_fast32_t ystart, uint_fast32_t xend,
   uint_fast32_t yend, int maxbands, int *numbandsptr, jpc_tsfbnodeband_t *bands)
 {
-	jpc_qmfb1dband_t hbands[JPC_QMFB1D_MAXCHANS];
-	jpc_qmfb1dband_t vbands[JPC_QMFB1D_MAXCHANS];
-	int numhbands;
-	int numvbands;
-	int numbands;
-	int bandno;
-	int hbandno;
-	int vbandno;
-	jpc_tsfbnodeband_t *band;
-
-	if (hqmfb) {
-		jpc_qmfb1d_getbands(hqmfb, 0, xstart, ystart, xend, yend,
-		  JPC_QMFB1D_MAXCHANS, &numhbands, hbands);
-	} else {
-		numhbands = 1;
-		hbands[0].start = xstart;
-		hbands[0].end = xend;
-		hbands[0].locstart = xstart;
-		hbands[0].locend = xend;
-	}
-	if (vqmfb) {
-		jpc_qmfb1d_getbands(vqmfb, JPC_QMFB1D_VERT, xstart, ystart, xend,
-		  yend, JPC_QMFB1D_MAXCHANS, &numvbands, vbands);
-	} else {
-		numvbands = 1;
-		vbands[0].start = ystart;
-		vbands[0].end = yend;
-		vbands[0].locstart = ystart;
-		vbands[0].locend = yend;
-	}
-	numbands = numhbands * numvbands;
-	*numbandsptr = numbands;
-	for (bandno = 0, band = bands; bandno < numbands; ++bandno, ++band) {
-		hbandno = bandno % numhbands;
-		vbandno = bandno / numhbands;
-		band->xstart = hbands[hbandno].start;
-		band->ystart = vbands[vbandno].start;
-		band->xend = hbands[hbandno].end;
-		band->yend = vbands[vbandno].end;
-		band->locxstart = hbands[hbandno].locstart;
-		band->locystart = vbands[vbandno].locstart;
-		band->locxend = hbands[hbandno].locend;
-		band->locyend = vbands[vbandno].locend;
-		assert(band->xstart <= band->xend &&
-		  band->ystart <= band->yend);
-		if (band->xstart == band->xend) {
-			band->yend = band->ystart;
-			band->locyend = band->locystart;
-		} else if (band->ystart == band->yend) {
-			band->xend = band->xstart;
-			band->locxend = band->locxstart;
-		}
-	}
+        jpc_qmfb1dband_t hbands[JPC_QMFB1D_MAXCHANS];
+        jpc_qmfb1dband_t vbands[JPC_QMFB1D_MAXCHANS];
+        int numhbands;
+        int numvbands;
+        int numbands;
+        int bandno;
+        int hbandno;
+        int vbandno;
+        jpc_tsfbnodeband_t *band;
+
+        if (hqmfb) {
+                jpc_qmfb1d_getbands(hqmfb, 0, xstart, ystart, xend, yend,
+                  JPC_QMFB1D_MAXCHANS, &numhbands, hbands);
+        } else {
+                numhbands = 1;
+                hbands[0].start = xstart;
+                hbands[0].end = xend;
+                hbands[0].locstart = xstart;
+                hbands[0].locend = xend;
+        }
+        if (vqmfb) {
+                jpc_qmfb1d_getbands(vqmfb, JPC_QMFB1D_VERT, xstart, ystart, xend,
+                  yend, JPC_QMFB1D_MAXCHANS, &numvbands, vbands);
+        } else {
+                numvbands = 1;
+                vbands[0].start = ystart;
+                vbands[0].end = yend;
+                vbands[0].locstart = ystart;
+                vbands[0].locend = yend;
+        }
+        numbands = numhbands * numvbands;
+        *numbandsptr = numbands;
+        for (bandno = 0, band = bands; bandno < numbands; ++bandno, ++band) {
+                hbandno = bandno % numhbands;
+                vbandno = bandno / numhbands;
+                band->xstart = hbands[hbandno].start;
+                band->ystart = vbands[vbandno].start;
+                band->xend = hbands[hbandno].end;
+                band->yend = vbands[vbandno].end;
+                band->locxstart = hbands[hbandno].locstart;
+                band->locystart = vbands[vbandno].locstart;
+                band->locxend = hbands[hbandno].locend;
+                band->locyend = vbands[vbandno].locend;
+                assert(band->xstart <= band->xend &&
+                  band->ystart <= band->yend);
+                if (band->xstart == band->xend) {
+                        band->yend = band->ystart;
+                        band->locyend = band->locystart;
+                } else if (band->ystart == band->yend) {
+                        band->xend = band->xstart;
+                        band->locxend = band->locxstart;
+                }
+        }
 }
 
 static int jpc_tsfbnode_getequivfilters(jpc_tsfbnode_t *tsfbnode, int cldind,
   int width, int height, jas_seq_t **hfilter, jas_seq_t **vfilter)
 {
-	jas_seq_t *hseq;
-	jas_seq_t *vseq;
-	jpc_tsfbnode_t *node;
-	jas_seq2d_t *hfilters[JPC_QMFB1D_MAXCHANS];
-	jas_seq2d_t *vfilters[JPC_QMFB1D_MAXCHANS];
-	int numhchans;
-	int numvchans;
-	jas_seq_t *tmpseq;
-
-	hseq = 0;
-	vseq = 0;
-
-	if (!(hseq = jas_seq_create(0, 1))) {
-		goto error;
-	}
-	jas_seq_set(hseq, 0, jpc_inttofix(1));
-	if (!(vseq = jas_seq_create(0, 1))) {
-		goto error;
-	}
-	jas_seq_set(vseq, 0, jpc_inttofix(1));
-
-	node = tsfbnode;
-	while (node) {
-		if (node->hqmfb) {
-			numhchans = jpc_qmfb1d_getnumchans(node->hqmfb);
-			if (jpc_qmfb1d_getsynfilters(node->hqmfb, width, hfilters)) {
-				goto error;
-			}
-			if (!(tmpseq = jpc_seq_upsample(hseq, numhchans))) {
-				goto error;
-			}
-			jas_seq_destroy(hseq);
-			hseq = tmpseq;
-			if (!(tmpseq = jpc_seq_conv(hseq, hfilters[bandnotohind(node, cldind)]))) {
-				goto error;
-			}
-			jas_seq_destroy(hfilters[0]);
-			jas_seq_destroy(hfilters[1]);
-			jas_seq_destroy(hseq);
-			hseq = tmpseq;
-		}
-		if (node->vqmfb) {
-			numvchans = jpc_qmfb1d_getnumchans(node->vqmfb);
-			if (jpc_qmfb1d_getsynfilters(node->vqmfb, height, vfilters)) {
-				abort();
-			}
-			if (!(tmpseq = jpc_seq_upsample(vseq, numvchans))) {
-				goto error;
-			}
-			jas_seq_destroy(vseq);
-			vseq = tmpseq;
-			if (!(tmpseq = jpc_seq_conv(vseq, vfilters[bandnotovind(node, cldind)]))) {
-				goto error;
-			}
-			jas_seq_destroy(vfilters[0]);
-			jas_seq_destroy(vfilters[1]);
-			jas_seq_destroy(vseq);
-			vseq = tmpseq;
-		}
-		if (node->parent) {
-			cldind = jpc_tsfbnode_findchild(node->parent, node);
-		}
-		node = node->parent;
-	}
-
-	*hfilter = hseq;
-	*vfilter = vseq;
-
-	return 0;
+        jas_seq_t *hseq;
+        jas_seq_t *vseq;
+        jpc_tsfbnode_t *node;
+        jas_seq2d_t *hfilters[JPC_QMFB1D_MAXCHANS];
+        jas_seq2d_t *vfilters[JPC_QMFB1D_MAXCHANS];
+        int numhchans;
+        int numvchans;
+        jas_seq_t *tmpseq;
+
+        hseq = 0;
+        vseq = 0;
+
+        if (!(hseq = jas_seq_create(0, 1))) {
+                goto error;
+        }
+        jas_seq_set(hseq, 0, jpc_inttofix(1));
+        if (!(vseq = jas_seq_create(0, 1))) {
+                goto error;
+        }
+        jas_seq_set(vseq, 0, jpc_inttofix(1));
+
+        node = tsfbnode;
+        while (node) {
+                if (node->hqmfb) {
+                        numhchans = jpc_qmfb1d_getnumchans(node->hqmfb);
+                        if (jpc_qmfb1d_getsynfilters(node->hqmfb, width, hfilters)) {
+                                goto error;
+                        }
+                        if (!(tmpseq = jpc_seq_upsample(hseq, numhchans))) {
+                                goto error;
+                        }
+                        jas_seq_destroy(hseq);
+                        hseq = tmpseq;
+                        if (!(tmpseq = jpc_seq_conv(hseq, hfilters[bandnotohind(node, cldind)]))) {
+                                goto error;
+                        }
+                        jas_seq_destroy(hfilters[0]);
+                        jas_seq_destroy(hfilters[1]);
+                        jas_seq_destroy(hseq);
+                        hseq = tmpseq;
+                }
+                if (node->vqmfb) {
+                        numvchans = jpc_qmfb1d_getnumchans(node->vqmfb);
+                        if (jpc_qmfb1d_getsynfilters(node->vqmfb, height, vfilters)) {
+                                abort();
+                        }
+                        if (!(tmpseq = jpc_seq_upsample(vseq, numvchans))) {
+                                goto error;
+                        }
+                        jas_seq_destroy(vseq);
+                        vseq = tmpseq;
+                        if (!(tmpseq = jpc_seq_conv(vseq, vfilters[bandnotovind(node, cldind)]))) {
+                                goto error;
+                        }
+                        jas_seq_destroy(vfilters[0]);
+                        jas_seq_destroy(vfilters[1]);
+                        jas_seq_destroy(vseq);
+                        vseq = tmpseq;
+                }
+                if (node->parent) {
+                        cldind = jpc_tsfbnode_findchild(node->parent, node);
+                }
+                node = node->parent;
+        }
+
+        *hfilter = hseq;
+        *vfilter = vseq;
+
+        return 0;
 
 error:
-	if (hseq) {
-		jas_seq_destroy(hseq);
-	}
-	if (vseq) {
-		jas_seq_destroy(vseq);
-	}
-	return -1;
+        if (hseq) {
+                jas_seq_destroy(hseq);
+        }
+        if (vseq) {
+                jas_seq_destroy(vseq);
+        }
+        return -1;
 
 }
 
 static int jpc_tsfbnode_findchild(jpc_tsfbnode_t *parnode, jpc_tsfbnode_t *cldnode)
 {
-	int i;
-
-	for (i = 0; i < parnode->maxchildren; i++) {
-		if (parnode->children[i] == cldnode)
-			return i;
-	}
-	assert(0);
-	return -1;
+        int i;
+
+        for (i = 0; i < parnode->maxchildren; i++) {
+                if (parnode->children[i] == cldnode)
+                        return i;
+        }
+        assert(0);
+        return -1;
 }
 
 jpc_tsfb_t *jpc_cod_gettsfb(int qmfbid, int numlevels)
 {
-	jpc_tsfb_t *tsfb;
-
-	switch (qmfbid) {
-	case JPC_COX_RFT:
-		qmfbid = JPC_QMFB1D_FT;
-		break;
-	case JPC_COX_INS:
-		qmfbid = JPC_QMFB1D_NS;
-		break;
-	default:
-		assert(0);
-		qmfbid = 10;
-		break;
-	}
+        jpc_tsfb_t *tsfb;
+
+        switch (qmfbid) {
+        case JPC_COX_RFT:
+                qmfbid = JPC_QMFB1D_FT;
+                break;
+        case JPC_COX_INS:
+                qmfbid = JPC_QMFB1D_NS;
+                break;
+        default:
+                assert(0);
+                qmfbid = 10;
+                break;
+        }
 
 {
-	jpc_qmfb1d_t *hqmfb;
-	hqmfb = jpc_qmfb1d_make(qmfbid);
-	assert(hqmfb);
-	tsfb = jpc_tsfb_wavelet(hqmfb, hqmfb, numlevels);
-	assert(tsfb);
-	jpc_qmfb1d_destroy(hqmfb);
+        jpc_qmfb1d_t *hqmfb;
+        hqmfb = jpc_qmfb1d_make(qmfbid);
+        assert(hqmfb);
+        tsfb = jpc_tsfb_wavelet(hqmfb, hqmfb, numlevels);
+        assert(tsfb);
+        jpc_qmfb1d_destroy(hqmfb);
 }
 
-	return tsfb;
+        return tsfb;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h
index 8670c22e..3558cadb 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h
@@ -6,14 +6,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -21,22 +21,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -56,17 +56,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -106,7 +106,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
@@ -132,19 +132,19 @@
 * Constants.
 \******************************************************************************/
 
-#define	JPC_TSFB_MAXBANDS	(JPC_TSFB_MAXDEPTH * 3 + 1)
-#define	JPC_TSFB_MAXDEPTH	32
-#define	JPC_TSFB_RITIMODE	JPC_QMFB1D_RITIMODE
+#define JPC_TSFB_MAXBANDS       (JPC_TSFB_MAXDEPTH * 3 + 1)
+#define JPC_TSFB_MAXDEPTH       32
+#define JPC_TSFB_RITIMODE       JPC_QMFB1D_RITIMODE
 
-#define	JPC_TSFB_MAXBANDSPERNODE	(JPC_QMFB1D_MAXCHANS * JPC_QMFB1D_MAXCHANS)
+#define JPC_TSFB_MAXBANDSPERNODE        (JPC_QMFB1D_MAXCHANS * JPC_QMFB1D_MAXCHANS)
 
-#define	JPC_TSFB_PRUNEVERT	0x01
-#define	JPC_TSFB_PRUNEHORZ	0x02
+#define JPC_TSFB_PRUNEVERT      0x01
+#define JPC_TSFB_PRUNEHORZ      0x02
 
-#define JPC_TSFB_LL	0
-#define JPC_TSFB_LH	1
-#define JPC_TSFB_HL	2
-#define JPC_TSFB_HH	3
+#define JPC_TSFB_LL     0
+#define JPC_TSFB_LH     1
+#define JPC_TSFB_HL     2
+#define JPC_TSFB_HH     3
 
 /******************************************************************************\
 * Types.
@@ -152,45 +152,45 @@
 
 typedef struct {
 
-	int xstart;
-	int ystart;
-	int xend;
-	int yend;
-	int locxstart;
-	int locystart;
-	int locxend;
-	int locyend;
+        int xstart;
+        int ystart;
+        int xend;
+        int yend;
+        int locxstart;
+        int locystart;
+        int locxend;
+        int locyend;
 
 } jpc_tsfbnodeband_t;
 
 typedef struct jpc_tsfbnode_s {
 
-	int numhchans;
-	int numvchans;
-	jpc_qmfb1d_t *hqmfb;
-	jpc_qmfb1d_t *vqmfb;
-	int maxchildren;
-	int numchildren;
-	struct jpc_tsfbnode_s *children[JPC_TSFB_MAXBANDSPERNODE];
-	struct jpc_tsfbnode_s *parent;
+        int numhchans;
+        int numvchans;
+        jpc_qmfb1d_t *hqmfb;
+        jpc_qmfb1d_t *vqmfb;
+        int maxchildren;
+        int numchildren;
+        struct jpc_tsfbnode_s *children[JPC_TSFB_MAXBANDSPERNODE];
+        struct jpc_tsfbnode_s *parent;
 
 } jpc_tsfbnode_t;
 
 typedef struct {
-	jpc_tsfbnode_t *root;
+        jpc_tsfbnode_t *root;
 } jpc_tsfb_t;
 
 typedef struct {
-	int xstart;
-	int ystart;
-	int xend;
-	int yend;
-	int orient;
-	int locxstart;
-	int locystart;
-	int locxend;
-	int locyend;
-	jpc_fix_t synenergywt;
+        int xstart;
+        int ystart;
+        int xend;
+        int yend;
+        int orient;
+        int locxstart;
+        int locystart;
+        int locxend;
+        int locyend;
+        jpc_fix_t synenergywt;
 } jpc_tsfb_band_t;
 
 /******************************************************************************\
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c
index e6e3942a..12a41c3f 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c
@@ -139,32 +139,32 @@
 
 static unsigned int
 countOfTokens(const char * const s,
-			  const char * const delim) {
+                          const char * const delim) {
 
-	unsigned int n;
-	char buf[4096];
-	const char * cp;
+        unsigned int n;
+        char buf[4096];
+        const char * cp;
 
-	strncpy(buf, s, sizeof(buf));
-	buf[sizeof(buf) - 1] = '\0';
-	n = 0;  /* initial value */
-	if ((cp = strtok(buf, delim))) {
-		++n;
-		while ((cp = strtok(0, delim))) {
-			if (cp[0] != '\0') {
-				++n;
-			}
-		}
-	}
-	return n;
+        strncpy(buf, s, sizeof(buf));
+        buf[sizeof(buf) - 1] = '\0';
+        n = 0;  /* initial value */
+        if ((cp = strtok(buf, delim))) {
+                ++n;
+                while ((cp = strtok(0, delim))) {
+                        if (cp[0] != '\0') {
+                                ++n;
+                        }
+                }
+        }
+        return n;
 }
 
 
 
 int
 jpc_atoaf(const char * const s,
-		  int *        const numvaluesP,
-		  double **    const valuesP) {
+                  int *        const numvaluesP,
+                  double **    const valuesP) {
 /*----------------------------------------------------------------------------
    Parse a string like "3.2,9,-5".  Return as *numvaluesP the number of
    values in the string and as *valuesP a malloced array of the values.
@@ -173,96 +173,96 @@ jpc_atoaf(const char * const s,
 
    Delimiters can be comma as in the example or space, tab, or newline.
 -----------------------------------------------------------------------------*/
-	char const delim[] = ", \t\n";
+        char const delim[] = ", \t\n";
 
-	unsigned int const valueCt = countOfTokens(s, delim);
+        unsigned int const valueCt = countOfTokens(s, delim);
 
-	if (valueCt > 0) {
-		unsigned int i;
-		double * vs;
-		const char * cp;
-		char buf[4096];
+        if (valueCt > 0) {
+                unsigned int i;
+                double * vs;
+                const char * cp;
+                char buf[4096];
 
-		if (!(vs = jas_malloc(valueCt * sizeof(double)))) {
-			return -1;
-		}
+                if (!(vs = jas_malloc(valueCt * sizeof(double)))) {
+                        return -1;
+                }
 
-		strncpy(buf, s, sizeof(buf));
-		buf[sizeof(buf) - 1] = '\0';
-		i = 0;
-		if ((cp = strtok(buf, delim))) {
-			vs[i] = atof(cp);
-			++i;
-			while ((cp = strtok(0, delim))) {
-				if (cp[0] != '\0') {
-					vs[i] = atof(cp);
-					++i;
-				}
-			}
-		}
-		assert(i == valueCt);
-		*numvaluesP = valueCt;
-		*valuesP    = vs;
-	} else {
-		*valuesP    = NULL;
-		*numvaluesP = 0;
-	}
-	return 0;
+                strncpy(buf, s, sizeof(buf));
+                buf[sizeof(buf) - 1] = '\0';
+                i = 0;
+                if ((cp = strtok(buf, delim))) {
+                        vs[i] = atof(cp);
+                        ++i;
+                        while ((cp = strtok(0, delim))) {
+                                if (cp[0] != '\0') {
+                                        vs[i] = atof(cp);
+                                        ++i;
+                                }
+                        }
+                }
+                assert(i == valueCt);
+                *numvaluesP = valueCt;
+                *valuesP    = vs;
+        } else {
+                *valuesP    = NULL;
+                *numvaluesP = 0;
+        }
+        return 0;
 }
 
 jas_seq_t *jpc_seq_upsample(jas_seq_t *x, int m)
 {
-	jas_seq_t *z;
-	int i;
+        jas_seq_t *z;
+        int i;
 
-	if (!(z = jas_seq_create(jas_seq_start(x) * m, (jas_seq_end(x) - 1) * m + 1)))
-		return 0;
-	for (i = jas_seq_start(z); i < jas_seq_end(z); i++) {
-		*jas_seq_getref(z, i) = (!JAS_MOD(i, m)) ? jas_seq_get(x, i / m) :
-		  jpc_inttofix(0);
-	}
+        if (!(z = jas_seq_create(jas_seq_start(x) * m, (jas_seq_end(x) - 1) * m + 1)))
+                return 0;
+        for (i = jas_seq_start(z); i < jas_seq_end(z); i++) {
+                *jas_seq_getref(z, i) = (!JAS_MOD(i, m)) ? jas_seq_get(x, i / m) :
+                  jpc_inttofix(0);
+        }
 
-	return z;
+        return z;
 }
 
 jpc_fix_t jpc_seq_norm(jas_seq_t *x)
 {
-	jpc_fix_t s;
-	int i;
+        jpc_fix_t s;
+        int i;
 
-	s = jpc_inttofix(0);
-	for (i = jas_seq_start(x); i < jas_seq_end(x); i++) {
-		s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(x, i), jas_seq_get(x, i)));
-	}
+        s = jpc_inttofix(0);
+        for (i = jas_seq_start(x); i < jas_seq_end(x); i++) {
+                s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(x, i), jas_seq_get(x, i)));
+        }
 
-	return jpc_dbltofix(sqrt(jpc_fixtodbl(s)));
+        return jpc_dbltofix(sqrt(jpc_fixtodbl(s)));
 }
 
 jas_seq_t *jpc_seq_conv(jas_seq_t *x, jas_seq_t *y)
 {
-	int i;
-	int j;
-	int k;
-	jas_seq_t *z;
-	jpc_fix_t s;
-	jpc_fix_t v;
+        int i;
+        int j;
+        int k;
+        jas_seq_t *z;
+        jpc_fix_t s;
+        jpc_fix_t v;
 
-	z = jas_seq_create(jas_seq_start(x) + jas_seq_start(y),
-	  jas_seq_end(x) + jas_seq_end(y) - 1);
-	assert(z);
-	for (i = jas_seq_start(z); i < jas_seq_end(z); i++) {
-		s = jpc_inttofix(0);
-		for (j = jas_seq_start(y); j < jas_seq_end(y); j++) {
-			k = i - j;
-			if (k < jas_seq_start(x) || k >= jas_seq_end(x)) {
-				v = JPC_FIX_ZERO;
-			} else {
-				v = jas_seq_get(x, k);
-			}
-			s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(y, j), v));
-		}
-		*jas_seq_getref(z, i) = s;
-	}
+        z = jas_seq_create(jas_seq_start(x) + jas_seq_start(y),
+          jas_seq_end(x) + jas_seq_end(y) - 1);
+        assert(z);
+        for (i = jas_seq_start(z); i < jas_seq_end(z); i++) {
+                s = jpc_inttofix(0);
+                for (j = jas_seq_start(y); j < jas_seq_end(y); j++) {
+                        k = i - j;
+                        if (k < jas_seq_start(x) || k >= jas_seq_end(x)) {
+                                v = JPC_FIX_ZERO;
+                        } else {
+                                v = jas_seq_get(x, k);
+                        }
+                        s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(y, j), v));
+                }
+                *jas_seq_getref(z, i) = s;
+        }
 
-	return z;
+        return z;
 }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_util.h b/converter/other/jpeg2000/libjasper/jpc/jpc_util.h
index c23fc33b..f1d90385 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_util.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_util.h
@@ -4,14 +4,14 @@
  */
 
 /* __START_OF_JASPER_LICENSE__
- * 
+ *
  * JasPer Software License
- * 
+ *
  * IMAGE POWER JPEG-2000 PUBLIC LICENSE
  * ************************************
- * 
+ *
  * GRANT:
- * 
+ *
  * Permission is hereby granted, free of charge, to any person (the "User")
  * obtaining a copy of this software and associated documentation, to deal
  * in the JasPer Software without restriction, including without limitation
@@ -19,22 +19,22 @@
  * and/or sell copies of the JasPer Software (in source and binary forms),
  * and to permit persons to whom the JasPer Software is furnished to do so,
  * provided further that the License Conditions below are met.
- * 
+ *
  * License Conditions
  * ******************
- * 
+ *
  * A.  Redistributions of source code must retain the above copyright notice,
  * and this list of conditions, and the following disclaimer.
- * 
+ *
  * B.  Redistributions in binary form must reproduce the above copyright
  * notice, and this list of conditions, and the following disclaimer in
  * the documentation and/or other materials provided with the distribution.
- * 
+ *
  * C.  Neither the name of Image Power, Inc. nor any other contributor
  * (including, but not limited to, the University of British Columbia and
  * Michael David Adams) may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * D.  User agrees that it shall not commence any action against Image Power,
  * Inc., the University of British Columbia, Michael David Adams, or any
  * other contributors (collectively "Licensors") for infringement of any
@@ -54,17 +54,17 @@
  * trade dress, or service mark rights); and (v) divisions, continuations,
  * renewals, reissues and extensions of the foregoing (as and to the extent
  * applicable) now existing, hereafter filed, issued or acquired.
- * 
+ *
  * E.  If User commences an infringement action against any Licensor(s) then
  * such Licensor(s) shall have the right to terminate User's license and
  * all sublicenses that have been granted hereunder by User to other parties.
- * 
+ *
  * F.  This software is for use only in hardware or software products that
  * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
  * or right to this Software is granted for products that do not comply
  * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
  * from the ISO.
- * 
+ *
  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
  * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
@@ -104,7 +104,7 @@
  * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
  * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
  * NOTICE SPECIFIED IN THIS SECTION.
- * 
+ *
  * __END_OF_JASPER_LICENSE__
  */
 
diff --git a/converter/other/jpeg2000/pamtojpeg2k.c b/converter/other/jpeg2000/pamtojpeg2k.c
index 8f7409c0..ea9ad492 100644
--- a/converter/other/jpeg2000/pamtojpeg2k.c
+++ b/converter/other/jpeg2000/pamtojpeg2k.c
@@ -314,7 +314,7 @@ static void
 createJasperImage(struct pam *   const inpamP,
                   jas_image_t ** const jasperPP) {
 
-	jas_image_cmptparm_t * cmptparms;
+        jas_image_cmptparm_t * cmptparms;
     unsigned int plane;
 
     MALLOCARRAY_NOFAIL(cmptparms, inpamP->depth);
@@ -489,7 +489,7 @@ writeJpc(jas_image_t *      const jasperP,
             pm_error("jas_image_encode() failed to encode the JPEG 2000 "
                      "image.  Rc=%d", rc);
     }
-	jas_stream_flush(outStreamP);
+        jas_stream_flush(outStreamP);
 
     {
         int rc;
@@ -501,7 +501,7 @@ writeJpc(jas_image_t *      const jasperP,
                      "jas_stream_close() rc = %d", rc);
     }
 
-	jas_image_clearfmts();
+        jas_image_clearfmts();
 
     pm_strfree(options);
 }
@@ -539,7 +539,7 @@ main(int argc, char **argv)
 
     writeJpc(jasperP, cmdline, fileno(stdout));
 
-	jas_image_destroy(jasperP);
+        jas_image_destroy(jasperP);
 
     pm_close(ifP);
 
diff --git a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c
index 7d1750a7..518d80ac 100644
--- a/converter/other/jpegtopnm.c
+++ b/converter/other/jpegtopnm.c
@@ -827,11 +827,17 @@ convertRaster(struct jpeg_decompress_struct * const cinfoP,
 
     xel * pnmbuffer;      /* Output buffer */
 
-    jpegbuffer = ((*cinfoP->mem->alloc_sarray)
-                  ((j_common_ptr) cinfoP, JPOOL_IMAGE,
-                   cinfoP->output_width * cinfoP->output_components,
-                   (JDIMENSION) 1)
-        )[0];
+    if (cinfoP->output_width > UINT_MAX/cinfoP->output_components)
+        pm_error("Image is too wide (%u columns) for computations",
+                 cinfoP->output_width);
+
+    MALLOCARRAY(jpegbuffer,
+                cinfoP->output_width * cinfoP->output_components);
+
+    if (!jpegbuffer)
+        pm_error("Failed to allocated a buffer for a row of %u columns "
+                 "of %u samples each",
+                 cinfoP->output_width, cinfoP->output_components);
 
     pnmbuffer = pnm_allocrow(cinfoP->output_width);
 
@@ -846,6 +852,8 @@ convertRaster(struct jpeg_decompress_struct * const cinfoP,
                             maxval, format, false);
         }
     }
+
+    free(jpegbuffer);
     pnm_freerow(pnmbuffer);
 }
 
diff --git a/converter/other/pamtosvg/Makefile b/converter/other/pamtosvg/Makefile
index 83f150d0..d67281d5 100644
--- a/converter/other/pamtosvg/Makefile
+++ b/converter/other/pamtosvg/Makefile
@@ -18,8 +18,9 @@ ADDL_OBJECTS = \
 	fit.o \
 	spline.o \
 	curve.o \
+	point.o \
 	vector.o \
-	epsilon-equal.o \
+	epsilon.o \
 	autotrace.o \
 	pxl-outline.o \
 	bitmap.o \
diff --git a/converter/other/pamtosvg/autotrace.c b/converter/other/pamtosvg/autotrace.c
index e9902669..fa5b7e15 100644
--- a/converter/other/pamtosvg/autotrace.c
+++ b/converter/other/pamtosvg/autotrace.c
@@ -56,7 +56,7 @@ at_fitting_opts_copy (at_fitting_opts_type * original)
   return new_opts;
 }
 
-void 
+void
 at_fitting_opts_free(at_fitting_opts_type * opts)
 {
   free(opts);
@@ -88,10 +88,10 @@ at_output_opts_free(at_output_opts_type * opts)
 /* at_splines_new_full modifies its 'bitmap' argument
    when it does the thin_image thing.
 */
-at_spline_list_array_type * 
+at_spline_list_array_type *
 at_splines_new_full(at_bitmap_type *       const bitmap,
                     at_fitting_opts_type * const opts,
-                    at_msg_func                  msg_func, 
+                    at_msg_func                  msg_func,
                     void *                 const msg_data,
                     at_progress_func             notify_progress,
                     void *                 const progress_data,
@@ -128,20 +128,20 @@ at_splines_new_full(at_bitmap_type *       const bitmap,
         if (opts->centerline) {
             pixel background_color;
 
-            if (opts->backgroundSpec) 
+            if (opts->backgroundSpec)
                 background_color = opts->background_color;
             else
                 PPM_ASSIGN(background_color, 255, 255, 255);
-            
+
             pixelOutlineList =
-                find_centerline_pixels(*bitmap, background_color, 
+                find_centerline_pixels(*bitmap, background_color,
                                        notify_progress, progress_data,
                                        test_cancel, testcancel_data, &exp);
         } else
             pixelOutlineList =
                 find_outline_pixels(*bitmap,
                                     opts->backgroundSpec,
-                                    opts->background_color, 
+                                    opts->background_color,
                                     notify_progress, progress_data,
                                     test_cancel, testcancel_data, &exp);
 
@@ -150,8 +150,8 @@ at_splines_new_full(at_bitmap_type *       const bitmap,
             retval = NULL;
         else {
             at_spline_list_array_type * splinesP;
-        
-            MALLOCVAR_NOFAIL(splinesP); 
+
+            MALLOCVAR_NOFAIL(splinesP);
             fit_outlines_to_splines(pixelOutlineList, opts,
                                     haveDistMap ? &distanceMap : NULL,
                                     image_header.width,
@@ -180,7 +180,7 @@ at_splines_new_full(at_bitmap_type *       const bitmap,
 
 
 
-void 
+void
 at_splines_write(at_output_write_func                  outputWriter,
                  FILE *                          const writeto,
                  at_output_opts_type *           const optsArg,
@@ -195,7 +195,7 @@ at_splines_write(at_output_write_func                  outputWriter,
     lly = 0;
     urx = splinesP->width;
     ury = splinesP->height;
-    
+
     if (optsArg == NULL) {
         newOpts = true;
         optsP   = at_output_opts_new();
@@ -212,9 +212,12 @@ at_splines_write(at_output_write_func                  outputWriter,
 
 
 
-void 
+void
 at_splines_free(at_spline_list_array_type * const splines) {
 
     free_spline_list_array(splines);
     free(splines);
 }
+
+
+
diff --git a/converter/other/pamtosvg/autotrace.h b/converter/other/pamtosvg/autotrace.h
index 2ac81a08..e30105a2 100644
--- a/converter/other/pamtosvg/autotrace.h
+++ b/converter/other/pamtosvg/autotrace.h
@@ -46,12 +46,12 @@ typedef struct _at_spline_list_array_type at_spline_list_array_type;
 /* Third degree is the highest we deal with.  */
 typedef enum _at_polynomial_degree
 {
-  AT_LINEARTYPE = 1, 
-  AT_QUADRATICTYPE = 2, 
-  AT_CUBICTYPE = 3, 
+  AT_LINEARTYPE = 1,
+  AT_QUADRATICTYPE = 2,
+  AT_CUBICTYPE = 3,
   AT_PARALLELELLIPSETYPE = 4,
-  AT_ELLIPSETYPE = 5, 
-  AT_CIRCLETYPE = 6 
+  AT_ELLIPSETYPE = 5,
+  AT_CIRCLETYPE = 6
   /* not the real number of points to define a
      circle but to distinguish between a cubic spline */
 } at_polynomial_degree;
@@ -63,7 +63,7 @@ typedef enum _at_polynomial_degree
    straight line defined by the endpoints.  */
 struct _at_spline_type
 {
-  float_coord v[4];	/* The control points.  */
+  Point v[4];   /* The control points.  */
   at_polynomial_degree degree;
   float linearity;
 };
@@ -88,8 +88,8 @@ struct _at_spline_list_array_type
 
   /* splines bbox */
   unsigned short height, width;
-  
-  /* the values for following members are inherited from 
+
+  /* the values for following members are inherited from
      at_fitting_opts_type */
   bool backgroundSpec;
   pixel background_color;
@@ -101,7 +101,7 @@ struct _at_spline_list_array_type
 
 
 /* Fitting option.
-   With using at_fitting_opts_doc macro, the description of 
+   With using at_fitting_opts_doc macro, the description of
    each option could be get. e.g. at_fitting_opts_doc(background_color) */
 struct _at_fitting_opts_type {
     bool backgroundSpec;
@@ -122,7 +122,7 @@ struct _at_fitting_opts_type {
 
 struct _at_output_opts_type
 {
-  int dpi;			/* DPI is used only in MIF output.*/
+  int dpi;          /* DPI is used only in MIF output.*/
 };
 
 struct _at_bitmap_type
@@ -144,16 +144,16 @@ void (* at_msg_func) (const char * const msg,
                       at_msg_type  const msg_type,
                       void *       const client_data);
 
-typedef 
+typedef
 int (*at_output_write_func) (FILE *                          const file,
                              const char *                    const name,
                              int                             const llx,
-                             int                             const lly, 
+                             int                             const lly,
                              int                             const urx,
                              int                             const ury,
                              at_output_opts_type *           const opts,
                              at_spline_list_array_type       const shape,
-                             at_msg_func                           msg_func, 
+                             at_msg_func                           msg_func,
                              void *                          const msg_data);
 
 /*
@@ -181,7 +181,7 @@ bool (*at_testcancel_func) (void * const client_data);
  * TODO: internal data access, copy
  * --------------------------------------------------------------------- */
 at_fitting_opts_type * at_fitting_opts_new(void);
-at_fitting_opts_type * at_fitting_opts_copy (at_fitting_opts_type * original); 
+at_fitting_opts_type * at_fitting_opts_copy (at_fitting_opts_type * original);
 void at_fitting_opts_free(at_fitting_opts_type * opts);
 
 /* TODO: Gettextize */
@@ -206,8 +206,8 @@ void at_output_opts_free(at_output_opts_type * opts);
    args:
 
    NOTIFY_PROGRESS is called repeatedly inside at_splines_new_full
-   to notify the progress of the execution. This might be useful for 
-   interactive applications. NOTIFY_PROGRESS is called following 
+   to notify the progress of the execution. This might be useful for
+   interactive applications. NOTIFY_PROGRESS is called following
    format:
 
    NOTIFY_PROGRESS (percentage, progress_data);
@@ -215,27 +215,27 @@ void at_output_opts_free(at_output_opts_type * opts);
    test_cancel is called repeatedly inside at_splines_new_full
    to test whether the execution is canceled or not.
    If test_cancel returns TRUE, execution of at_splines_new_full
-   is stopped as soon as possible and returns NULL. If test_cancel 
+   is stopped as soon as possible and returns NULL. If test_cancel
    returns FALSE, nothing happens. test_cancel  is called following
    format:
 
    TEST_CANCEL (testcancel_data);
-   
-   NULL is valid value for notify_progress and/or test_cancel if 
-   you don't need to know the progress of the execution and/or 
-   cancel the execution */ 
 
-at_spline_list_array_type * 
+   NULL is valid value for notify_progress and/or test_cancel if
+   you don't need to know the progress of the execution and/or
+   cancel the execution */
+
+at_spline_list_array_type *
 at_splines_new_full(at_bitmap_type *       const bitmap,
                     at_fitting_opts_type * const opts,
-                    at_msg_func                  msg_func, 
+                    at_msg_func                  msg_func,
                     void *                 const msg_data,
                     at_progress_func             notify_progress,
                     void *                 const progress_data,
                     at_testcancel_func           test_cancel,
                     void *                 const testcancel_data);
 
-void 
+void
 at_splines_write(at_output_write_func                  output_writer,
                  FILE *                          const writeto,
                  at_output_opts_type *           const opts,
diff --git a/converter/other/pamtosvg/curve.c b/converter/other/pamtosvg/curve.c
index 369a0cd3..d7fff87d 100644
--- a/converter/other/pamtosvg/curve.c
+++ b/converter/other/pamtosvg/curve.c
@@ -18,71 +18,75 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
+#include <assert.h>
+
 #include "mallocvar.h"
 
 #include "logreport.h"
 #include "curve.h"
 
 
-static float_coord
-int_to_real_coord(pm_pixelcoord const int_coord) {
+static Point
+realCoordFromInt(pm_pixelcoord const int_coord) {
 /*----------------------------------------------------------------------------
   Turn an integer point into a real one.
 -----------------------------------------------------------------------------*/
-    float_coord real_coord;
+    Point real_coord;
 
     real_coord.x = int_coord.col;
     real_coord.y = int_coord.row;
     real_coord.z = 0.0;
-    
+
     return real_coord;
 }
 
 
 
-/* Return an entirely empty curve.  */
-
-curve *
-new_curve(void) {
-  curve * curveP;
+Curve *
+curve_new(void) {
+/*----------------------------------------------------------------------------
+  A new, entirely empty curve.
+-----------------------------------------------------------------------------*/
+    Curve * curveP;
 
-  MALLOCVAR_NOFAIL(curveP);
+    MALLOCVAR_NOFAIL(curveP);
 
-  curveP->point_list = NULL;
-  CURVE_LENGTH(curveP) = 0;
-  CURVE_CYCLIC(curveP) = false;
-  PREVIOUS_CURVE(curveP)  = NULL;
-  NEXT_CURVE(curveP)      = NULL;
+    curveP->pointList       = NULL;
+    CURVE_LENGTH(curveP)    = 0;
+    CURVE_CYCLIC(curveP)    = false;
+    PREVIOUS_CURVE(curveP)  = NULL;
+    NEXT_CURVE(curveP)      = NULL;
 
-  return curveP;
+    return curveP;
 }
 
 
-/* Don't copy the points or tangents, but copy everything else.  */
+Curve *
+curve_copyMost(Curve * const oldCurveP) {
+/*----------------------------------------------------------------------------
+  New curve that is the same as *curveP, except without any points.
 
-curve_type
-copy_most_of_curve (curve_type old_curve)
-{
-  curve_type curve = new_curve ();
+  Don't copy the points or tangents, but copy everything else.
+-----------------------------------------------------------------------------*/
+    Curve * curveP = curve_new();
 
-  CURVE_CYCLIC (curve) = CURVE_CYCLIC (old_curve);
-  PREVIOUS_CURVE (curve) = PREVIOUS_CURVE (old_curve);
-  NEXT_CURVE (curve) = NEXT_CURVE (old_curve);
+    CURVE_CYCLIC(curveP)   = CURVE_CYCLIC(oldCurveP);
+    PREVIOUS_CURVE(curveP) = PREVIOUS_CURVE(oldCurveP);
+    NEXT_CURVE(curveP)     = NEXT_CURVE(oldCurveP);
 
-  return curve;
+    return curveP;
 }
 
 void
-move_curve(curve * const dstP,
-           curve * const srcP) {
-
-    /* Move ownership of dynamically allocated memory from source 
-       to destination; destroy source.
-    */
-
+curve_move(Curve * const dstP,
+           Curve * const srcP) {
+/*----------------------------------------------------------------------------
+  Move ownership of dynamically allocated memory from source to destination;
+  destroy source.
+-----------------------------------------------------------------------------*/
    if (CURVE_LENGTH(dstP) > 0)
-       free(dstP->point_list);
-    
+       free(dstP->pointList);
+
    *dstP = *srcP;
 
    free(srcP);
@@ -90,62 +94,124 @@ move_curve(curve * const dstP,
 
 
 
-/* The length of CURVE will be zero if we ended up not being able to fit
-   it (which in turn implies a problem elsewhere in the program, but at
-   any rate, we shouldn't try here to free the nonexistent curve).  */
-
 void
-free_curve(curve * const curveP) {
+curve_free(Curve * const curveP) {
+
+    /* The length of CURVE will be zero if we ended up not being able to fit
+       it (which in turn implies a problem elsewhere in the program, but at
+       any rate, we shouldn't try here to free the nonexistent curve).
+    */
 
-   if (CURVE_LENGTH(curveP) > 0)
-       free(curveP->point_list);
+     if (CURVE_LENGTH(curveP) > 0)
+         free(curveP->pointList);
 
-   free(curveP);
+     free(curveP);
 }
 
 
 
 void
-append_point(curve_type  const curve,
-             float_coord const coord) {
-
-    CURVE_LENGTH(curve)++;
-    REALLOCARRAY_NOFAIL(curve->point_list, CURVE_LENGTH(curve));
-    LAST_CURVE_POINT(curve) = coord;
+curve_appendPoint(Curve * const curveP,
+                  Point   const coord) {
+/*----------------------------------------------------------------------------
+  Like `append_pixel', for a point in real coordinates.
+-----------------------------------------------------------------------------*/
+    CURVE_LENGTH(curveP)++;
+    REALLOCARRAY_NOFAIL(curveP->pointList, CURVE_LENGTH(curveP));
+    LAST_CURVE_POINT(curveP) = coord;
     /* The t value does not need to be set.  */
 }
 
 
+
 void
-append_pixel(curve_type    const curve,
-             pm_pixelcoord const coord) {
+curve_appendPixel(Curve *       const curveP,
+                  pm_pixelcoord const coord) {
+/*----------------------------------------------------------------------------
+  Append the point 'coord' to the end of *curveP's list.
+-----------------------------------------------------------------------------*/
+    curve_appendPoint(curveP, realCoordFromInt(coord));
+}
+
+
+
+void
+curve_setDistance(Curve * const curveP) {
+/*----------------------------------------------------------------------------
+   Fill in the distance values in *curveP.
+
+   The distance value for point P on a curve is the distance P is along the
+   curve from the initial point, normalized so the entire curve is length 1.0
+   (i.e. t of the initial point is 0.0; t of the final point is 1.0).
+
+   There are a lot of curves that pass through the points indicated by
+   *curveP, but for practical computation of t, we just take the piecewise
+   linear locus that runs through all of them.  That means we can just step
+   through *curveP, adding up the distance from one point to the next to get
+   the t value for each point.
+
+   This is the "chord-length parameterization" method, which is described in
+   Plass & Stone.
+-----------------------------------------------------------------------------*/
+    unsigned int p;
+
+    LOG("\nAssigning initial t values:\n  ");
+
+    /* Algorithm: We do a pass through the curve establishing how far each
+       point is along the curve in absolute terms, and then another pass
+       to normalize those distances to the fraction of the curve (i.e.
+       if the curve is 5 units long and Point P is 2 units in, we record
+       2 units for Point P in the first pass, and then compute 0.2 as the
+       fraction of the curve length in the second pass.
 
-    append_point(curve, int_to_real_coord(coord));
+       In the first pass, we abuse the distance property of the CurvePoint
+       object to remember the unnormalized distances.
+    */
+
+    CURVE_DIST(curveP, 0) = 0.0;
+
+    for (p = 1; p < CURVE_LENGTH(curveP); ++p) {
+        Point const point      = CURVE_POINT(curveP, p);
+        Point const previous_p = CURVE_POINT(curveP, p - 1);
+        float const d          = point_distance(point, previous_p);
+        CURVE_DIST(curveP, p)  = CURVE_DIST(curveP, p - 1) + d;
+    }
+
+    assert(LAST_CURVE_DIST(curveP) != 0.0);
+
+    /* Normalize to a curve length of 1.0 */
+
+    for (p = 1; p < CURVE_LENGTH(curveP); ++p)
+        CURVE_DIST(curveP, p) =
+            CURVE_DIST(curveP, p) / LAST_CURVE_DIST(curveP);
+
+    curve_logEntire(curveP);
 }
 
 
-/* Print a curve in human-readable form.  It turns out we never care
-   about most of the points on the curve, and so it is pointless to
-   print them all out umpteen times.  What matters is that we have some
-   from the end and some from the beginning.  */
 
 #define NUM_TO_PRINT 3
 
-#define LOG_CURVE_POINT(c, p, print_t)					\
-  do									\
-    {									\
-      LOG2 ("(%.3f,%.3f)", CURVE_POINT (c, p).x, CURVE_POINT (c, p).y);	\
-      if (print_t)							\
-        LOG1 ("/%.2f", CURVE_T (c, p));					\
-    }									\
+#define LOG_CURVE_POINT(c, p, printDistance) \
+    do  \
+    {                                   \
+      LOG2 ("(%.3f,%.3f)", CURVE_POINT (c, p).x, CURVE_POINT (c, p).y); \
+      if (printDistance) \
+        LOG1 ("/%.2f", CURVE_DIST(c, p)); \
+    } \
   while (0)
 
 
 
 void
-log_curve(curve * const curveP,
-          bool    const print_t) {
-
+curve_log(Curve * const curveP,
+          bool    const printDistance) {
+/*----------------------------------------------------------------------------
+  Print a curve in human-readable form.  It turns out we never care
+  about most of the points on the curve, and so it is pointless to
+  print them all out umpteen times.  What matters is that we have some
+  from the end and some from the beginning.
+-----------------------------------------------------------------------------*/
     if (!log_file)
         return;
 
@@ -159,9 +225,9 @@ log_curve(curve * const curveP,
     /* If the curve is short enough, don't use ellipses.  */
     if (CURVE_LENGTH(curveP) <= NUM_TO_PRINT * 2) {
         unsigned int thisPoint;
-    
+
         for (thisPoint = 0; thisPoint < CURVE_LENGTH(curveP); ++thisPoint) {
-            LOG_CURVE_POINT(curveP, thisPoint, print_t);
+            LOG_CURVE_POINT(curveP, thisPoint, printDistance);
             LOG(" ");
 
             if (thisPoint != CURVE_LENGTH(curveP) - 1
@@ -173,7 +239,7 @@ log_curve(curve * const curveP,
         for (thisPoint = 0;
              thisPoint < NUM_TO_PRINT && thisPoint < CURVE_LENGTH(curveP);
              ++thisPoint) {
-            LOG_CURVE_POINT(curveP, thisPoint, print_t);
+            LOG_CURVE_POINT(curveP, thisPoint, printDistance);
             LOG(" ");
         }
 
@@ -183,18 +249,19 @@ log_curve(curve * const curveP,
              thisPoint < CURVE_LENGTH(curveP);
              ++thisPoint) {
             LOG(" ");
-            LOG_CURVE_POINT(curveP, thisPoint, print_t);
+            LOG_CURVE_POINT(curveP, thisPoint, printDistance);
         }
     }
     LOG(".\n");
 }
 
 
-/* Like `log_curve', but write the whole thing.  */
 
 void
-log_entire_curve(curve * const curveP) {
-
+curve_logEntire(Curve * const curveP) {
+/*----------------------------------------------------------------------------
+  Like `log_curve', but write the whole thing.
+-----------------------------------------------------------------------------*/
     unsigned int thisPoint;
 
     if (!log_file)
@@ -218,95 +285,105 @@ log_entire_curve(curve * const curveP) {
 
 
 
-/* Return an initialized but empty curve list.  */
 
-curve_list_type
-new_curve_list (void)
-{
-  curve_list_type curve_list;
+CurveList
+curve_newList(void) {
+/*----------------------------------------------------------------------------
+  A new initialized but empty curve list.
+-----------------------------------------------------------------------------*/
+    CurveList curveList;
 
-  curve_list.length = 0;
-  curve_list.data = NULL;
+    curveList.length = 0;
+    curveList.data   = NULL;
 
-  return curve_list;
+    return curveList;
 }
 
 
-/* Free a curve list and all the curves it contains.  */
 
 void
-free_curve_list(curve_list_type * const curveListP) {
-
+curve_freeList(CurveList * const curveListP) {
+/*----------------------------------------------------------------------------
+  Free curve list and all the curves it contains.
+-----------------------------------------------------------------------------*/
     unsigned int thisCurve;
 
     for (thisCurve = 0; thisCurve < curveListP->length; ++thisCurve)
-        free_curve(curveListP->data[thisCurve]);
+        curve_free(curveListP->data[thisCurve]);
 
     /* If the character was empty, it won't have any curves.  */
     if (curveListP->data != NULL)
-        free (curveListP->data);
+        free(curveListP->data);
 }
 
 
-/* Add an element to a curve list.  */
 
 void
-append_curve (curve_list_type *curve_list, curve_type curve)
-{
-  curve_list->length++;
-  REALLOCARRAY_NOFAIL(curve_list->data, curve_list->length);
-  curve_list->data[curve_list->length - 1] = curve; }
+curve_appendList(CurveList * const curveListP,
+                 Curve *     const curveP) {
+/*----------------------------------------------------------------------------
+  Add an element to a curve list.
+-----------------------------------------------------------------------------*/
+    ++curveListP->length;
+    REALLOCARRAY_NOFAIL(curveListP->data, curveListP->length);
+    curveListP->data[curveListP->length - 1] = curveP;
+}
 
 
-/* Return an initialized but empty curve list array.  */
 
-curve_list_array_type
-new_curve_list_array (void)
-{
-  curve_list_array_type curve_list_array;
+CurveListArray
+curve_newListArray(void) {
+/*----------------------------------------------------------------------------
+    An initialized but empty curve list array.
+-----------------------------------------------------------------------------*/
+    CurveListArray curveListArray;
 
-  CURVE_LIST_ARRAY_LENGTH (curve_list_array) = 0;
-  curve_list_array.data = NULL;
+    CURVE_LIST_ARRAY_LENGTH(curveListArray) = 0;
+    curveListArray.data = NULL;
 
-  return curve_list_array;
+    return curveListArray;
 }
 
 
-/* Free a curve list array and all the curve lists it contains.  */
 
 void
-free_curve_list_array(const curve_list_array_type * const curve_list_array,
-                      at_progress_func                    notify_progress, 
-                      void *                        const client_data) {
+curve_freeListArray(const CurveListArray * const curveListArrayP,
+                    at_progress_func             notify_progress,
+                    void *                 const clientData) {
+/*----------------------------------------------------------------------------
+  Free all the curve lists curveListArray contains.
+-----------------------------------------------------------------------------*/
+    unsigned int thisList;
 
-  unsigned this_list;
+    for (thisList = 0;
+         thisList < CURVE_LIST_ARRAY_LENGTH(*curveListArrayP);
+         ++thisList) {
 
-  for (this_list = 0; this_list < CURVE_LIST_ARRAY_LENGTH(*curve_list_array);
-       this_list++) {
       if (notify_progress)
-          notify_progress(((float)this_list)/
-                          (CURVE_LIST_ARRAY_LENGTH(*curve_list_array) *
+          notify_progress(((float)thisList)/
+                          (CURVE_LIST_ARRAY_LENGTH(*curveListArrayP) *
                            (float)3.0)+(float)0.666 ,
-                          client_data);
-      free_curve_list(&CURVE_LIST_ARRAY_ELT (*curve_list_array, this_list));
-  }
-  
-  /* If the character was empty, it won't have any curves.  */
-  if (curve_list_array->data != NULL)
-      free(curve_list_array->data);
+                          clientData);
+      curve_freeList(&CURVE_LIST_ARRAY_ELT(*curveListArrayP, thisList));
+    }
+
+    /* If the character was empty, it won't have any curves.  */
+    if (curveListArrayP->data)
+        free(curveListArrayP->data);
 }
 
 
-/* Add an element to a curve list array.  */
 
 void
-append_curve_list(curve_list_array_type * const curve_list_array,
-                  curve_list_type         const curve_list) {
-
-  CURVE_LIST_ARRAY_LENGTH (*curve_list_array)++;
-  REALLOCARRAY_NOFAIL(curve_list_array->data,
-                      CURVE_LIST_ARRAY_LENGTH(*curve_list_array));
-  LAST_CURVE_LIST_ARRAY_ELT (*curve_list_array) = curve_list;
+curve_appendArray(CurveListArray * const curveListArrayP,
+                  CurveList        const curveList) {
+/*----------------------------------------------------------------------------
+  Add an element to *curveListArrayP.
+-----------------------------------------------------------------------------*/
+    CURVE_LIST_ARRAY_LENGTH(*curveListArrayP)++;
+    REALLOCARRAY_NOFAIL(curveListArrayP->data,
+                        CURVE_LIST_ARRAY_LENGTH(*curveListArrayP));
+    LAST_CURVE_LIST_ARRAY_ELT(*curveListArrayP) = curveList;
 }
 
 
diff --git a/converter/other/pamtosvg/curve.h b/converter/other/pamtosvg/curve.h
index ba5f1833..65d4e26b 100644
--- a/converter/other/pamtosvg/curve.h
+++ b/converter/other/pamtosvg/curve.h
@@ -5,56 +5,60 @@
 
 #include "autotrace.h"
 #include "point.h"
-#include "vector.h"
 
 /* We are simultaneously manipulating two different representations of
    the same outline: one based on (x,y) positions in the plane, and one
    based on parametric splines.  (We are trying to match the latter to
    the former.)  Although the original (x,y)'s are pixel positions,
-   i.e., integers, after filtering they are reals.  */
+   i.e., integers, after filtering they are reals.
+*/
 
 typedef struct {
-    float_coord coord;
-    float       t;
-} point_type;
+/*----------------------------------------------------------------------------
+   A point in a curve (i.e. a component of a curve).
+-----------------------------------------------------------------------------*/
+    Point coord;
+        /* Location in space of the point */
+    float distance;
+        /* Distance point is along the curve, as a fraction of the
+           curve length.  This is invalid until after someone has called
+           curve_updateDistance() on the curve.
+        */
+} CurvePoint;
 
 
 
-typedef struct curve {
+typedef struct Curve {
 /*----------------------------------------------------------------------------
   An ordered list of contiguous points in the raster, with no corners
   in it.  I.e. something that could reasonably be fit to a spline.
 -----------------------------------------------------------------------------*/
-    point_type *   point_list;
+    CurvePoint *   pointList;
         /* Array of the points in the curve.  Malloc'ed.  Size is 'length'.
            if 'length' is zero, this is meaningless and no memory is
            allocated.
         */
-    unsigned       length;
+    unsigned int   length;
         /* Number of points in the curve */
     bool           cyclic;
+       /* The curve is cyclic, i.e. it didn't have any corners, after all, so
+          the last point is adjacent to the first.
+       */
 
     /* 'previous' and 'next' links are for the doubly linked list which is
        a chain of all curves in an outline.  The chain is a cycle for a
        closed outline and linear for an open outline.
     */
-    struct curve * previous;
-    struct curve * next;
-} curve;
-
-typedef struct curve * curve_type;
-
-/* Get at the coordinates and the t values.  */
-#define CURVE_POINT(c, n) ((c)->point_list[n].coord)
-#define LAST_CURVE_POINT(c) ((c)->point_list[(c)->length-1].coord)
-#define CURVE_T(c, n) ((c)->point_list[n].t)
-#define LAST_CURVE_T(c) ((c)->point_list[(c)->length-1].t)
-
-/* This is the length of `point_list'.  */
+    struct Curve * previous;
+    struct Curve * next;
+} Curve;
+
+#define CURVE_POINT(c, n) ((c)->pointList[n].coord)
+#define LAST_CURVE_POINT(c) ((c)->pointList[(c)->length-1].coord)
+#define CURVE_DIST(c, n) ((c)->pointList[n].distance)
+#define LAST_CURVE_DIST(c) ((c)->pointList[(c)->length-1].distance)
 #define CURVE_LENGTH(c)  ((c)->length)
 
-/* A curve is ``cyclic'' if it didn't have any corners, after all, so
-   the last point is adjacent to the first.  */
 #define CURVE_CYCLIC(c)  ((c)->cyclic)
 
 /* If the curve is cyclic, the next and previous points should wrap
@@ -73,44 +77,41 @@ typedef struct curve * curve_type;
 #define NEXT_CURVE(c) ((c)->next)
 
 
-/* Return an entirely empty curve.  */
-extern curve_type new_curve (void);
+Curve *
+curve_new(void);
 
-/* Return a curve the same as C, except without any points.  */
-extern curve_type copy_most_of_curve (curve_type c);
+Curve *
+curve_copyMost(Curve * const curveP);
 
 void
-move_curve(curve * const dstP,
-           curve * const srcP);
+curve_move(Curve * const dstP,
+           Curve * const srcP);
 
 void
-free_curve(curve * const curveP);
+curve_free(Curve * const curveP);
 
-/* Like `append_pixel', for a point in real coordinates.  */
 void
-append_point(curve_type  const curve,
-             float_coord const coord);
+curve_appendPoint(Curve * const curveP,
+                  Point   const coord);
 
-/* Append the point P to the end of C's list.  */
 void
-append_pixel(curve_type    const c,
-             pm_pixelcoord const p);
-
-/* Write some or all, respectively, of the curve C in human-readable
-   form to the log file, if logging is enabled.  */
-extern void log_curve (curve_type c, bool print_t);
-extern void log_entire_curve (curve_type c);
-
-/* Display the curve C online, if displaying is enabled.  */
-extern void display_curve (curve_type);
+curve_appendPixel(Curve *       const curveP,
+                  pm_pixelcoord const p);
 
+void
+curve_setDistance(Curve * const curveP);
 
+void
+curve_log(Curve * const curveP,
+          bool    const print_t);
+void
+curve_logEntire(Curve * const curveP);
 
 typedef struct {
 /*----------------------------------------------------------------------------
    An ordered list of contiguous curves of a particular color.
 -----------------------------------------------------------------------------*/
-    curve ** data;
+    Curve ** data;
         /* data[i] is the handle of the ith curve in the list */
     unsigned length;
     bool     clockwise;
@@ -119,7 +120,7 @@ typedef struct {
         /* The curve list does not form a closed shape;  i.e. the last
            curve doesn't end where the first one starts.
         */
-} curve_list_type;
+} CurveList;
 
 /* Number of curves in the list.  */
 #define CURVE_LIST_LENGTH(c_l)  ((c_l).length)
@@ -134,21 +135,23 @@ typedef struct {
 #define CURVE_LIST_CLOCKWISE(c_l) ((c_l).clockwise)
 
 
-extern curve_list_type new_curve_list (void);
+CurveList
+curve_newList(void);
 
 void
-free_curve_list(curve_list_type * const curve_list);
+curve_freeList(CurveList * const curveListP);
 
-extern void append_curve (curve_list_type *, curve_type);
+void
+curve_appendList(CurveList * const curveListP,
+                 Curve *     const curveP);
 
 /* And a character is a list of outlines.  I named this
    `curve_list_array_type' because `curve_list_list_type' seemed pretty
    monstrous.  */
-typedef struct
-{
-  curve_list_type *data;
-  unsigned length;
-} curve_list_array_type;
+typedef struct {
+  CurveList * data;
+  unsigned    length;
+} CurveListArray;
 
 /* Turns out we can use the same definitions for lists of lists as for
    just lists.  But we define the usual names, just in case.  */
@@ -156,17 +159,16 @@ typedef struct
 #define CURVE_LIST_ARRAY_ELT CURVE_LIST_ELT
 #define LAST_CURVE_LIST_ARRAY_ELT LAST_CURVE_LIST_ELT
 
-curve_list_array_type
-new_curve_list_array(void);
+CurveListArray
+curve_newListArray(void);
 
 void
-free_curve_list_array(const curve_list_array_type * const curve_list_array,
-                      at_progress_func                    notify_progress, 
-                      void *                        const client_data);
+curve_freeListArray(const CurveListArray * const curveListArrayP,
+                    at_progress_func             notify_progress,
+                    void *                 const client_data);
 
 void
-append_curve_list(curve_list_array_type * const curve_list_array,
-                  curve_list_type         const curve_list);
+curve_appendArray(CurveListArray * const curveListArrayP,
+                  CurveList        const curveList);
 
 #endif
-
diff --git a/converter/other/pamtosvg/epsilon-equal.c b/converter/other/pamtosvg/epsilon.c
index 46d630c5..0c914dae 100644
--- a/converter/other/pamtosvg/epsilon-equal.c
+++ b/converter/other/pamtosvg/epsilon.c
@@ -1,8 +1,6 @@
-/* epsilon-equal.c: define a error resist compare. */
-
 #include <math.h>
 
-#include "epsilon-equal.h"
+#include "epsilon.h"
 
 /* Numerical errors sometimes make a floating point number just slightly
    larger or smaller than its true value.  When it matters, we need to
diff --git a/converter/other/pamtosvg/epsilon-equal.h b/converter/other/pamtosvg/epsilon.h
index fa0437cd..c8e7c8bc 100644
--- a/converter/other/pamtosvg/epsilon-equal.h
+++ b/converter/other/pamtosvg/epsilon.h
@@ -1,7 +1,7 @@
 /* epsilon-equal.h: define an error resist compare. */
 
-#ifndef EPSILON_EQUAL_H
-#define EPSILON_EQUAL_H
+#ifndef EPSILON_H
+#define EPSILON_H
 
 #include "pm_c_util.h"
 
@@ -16,5 +16,5 @@ bool epsilon_equal(float const v1,
 
 #define REAL_EPSILON 0.00001
 
-#endif /* not EPSILON_EQUAL_H */
+#endif
 
diff --git a/converter/other/pamtosvg/fit.c b/converter/other/pamtosvg/fit.c
index 06e708c2..d51b010b 100644
--- a/converter/other/pamtosvg/fit.c
+++ b/converter/other/pamtosvg/fit.c
@@ -34,90 +34,99 @@
 #include "message.h"
 #include "logreport.h"
 #include "spline.h"
+#include "point.h"
 #include "vector.h"
 #include "curve.h"
 #include "pxl-outline.h"
-#include "epsilon-equal.h"
+#include "epsilon.h"
 
 #define CUBE(x) ((x) * (x) * (x))
 
+typedef enum {LINEEND_INIT, LINEEND_TERM} LineEnd;
+
+static LineEnd
+otherEnd(LineEnd const thisEnd) {
+
+    switch (thisEnd) {
+    case LINEEND_INIT: return LINEEND_TERM;
+    case LINEEND_TERM: return LINEEND_INIT;
+    }
+    assert(false);  /* All cases handled above */
+    return LINEEND_INIT;  /* silence bogus compiler warning */
+}
+
+
+
 /* We need to manipulate lists of array indices.  */
 
-typedef struct index_list
-{
-  unsigned *data;
-  unsigned length;
-} index_list_type;
+typedef struct IndexList {
+    unsigned int * data;
+    unsigned int   length;
+} IndexList;
 
 /* The usual accessor macros.  */
 #define GET_INDEX(i_l, n)  ((i_l).data[n])
-#define INDEX_LIST_LENGTH(i_l)  ((i_l).length)
-#define GET_LAST_INDEX(i_l)  ((i_l).data[INDEX_LIST_LENGTH (i_l) - 1])
+#define INDEX_LIST_LENGTH(iL)  ((iL).length)
+#define GET_LAST_INDEX(iL)  ((iL).data[INDEX_LIST_LENGTH(iL) - 1])
 
 
 
 
 static pm_pixelcoord
-real_to_int_coord(float_coord const real_coord) {
+intCoordFmReal(Point const realCoord) {
 /*----------------------------------------------------------------------------
   Turn an real point into a integer one.
 -----------------------------------------------------------------------------*/
 
-    pm_pixelcoord int_coord;
+    pm_pixelcoord intCoord;
 
-    int_coord.col = ROUND(real_coord.x);
-    int_coord.row = ROUND(real_coord.y);
+    intCoord.col = ROUND(realCoord.x);
+    intCoord.row = ROUND(realCoord.y);
 
-    return int_coord;
+    return intCoord;
 }
 
 
 /* Lists of array indices (well, that is what we use it for).  */
 
-static index_list_type
-new_index_list (void)
-{
-  index_list_type index_list;
+static IndexList
+indexList_new(void) {
 
-  index_list.data = NULL;
-  INDEX_LIST_LENGTH (index_list) = 0;
+    IndexList indexList;
 
-  return index_list;
+    indexList.data = NULL;
+    INDEX_LIST_LENGTH(indexList) = 0;
+
+  return indexList;
 }
 
+
+
 static void
-free_index_list (index_list_type *index_list)
-{
-  if (INDEX_LIST_LENGTH (*index_list) > 0)
-    {
-      free (index_list->data);
-      index_list->data = NULL;
-      INDEX_LIST_LENGTH (*index_list) = 0;
+indexList_free(IndexList * const indexListP) {
+
+    if (INDEX_LIST_LENGTH(*indexListP) > 0) {
+        free(indexListP->data);
+        indexListP->data = NULL;
+        INDEX_LIST_LENGTH(*indexListP) = 0;
     }
 }
 
-static void
-append_index (index_list_type *list, unsigned new_index)
-{
-  INDEX_LIST_LENGTH (*list)++;
-  REALLOCARRAY_NOFAIL(list->data, INDEX_LIST_LENGTH(*list));
-  list->data[INDEX_LIST_LENGTH (*list) - 1] = new_index;
-}
 
 
-/* Return the Euclidean distance between P1 and P2.  */
+static void
+indexList_append(IndexList *  const listP,
+                 unsigned int const  newIndex) {
 
-static float
-distance (float_coord p1, float_coord p2)
-{
-  float x = p1.x - p2.x, y = p1.y - p2.y, z = p1.z - p2.z;
-  return (float) sqrt (SQR(x) + SQR(y) + SQR(z));
+    INDEX_LIST_LENGTH(*listP)++;
+    REALLOCARRAY_NOFAIL(listP->data, INDEX_LIST_LENGTH(*listP));
+    listP->data[INDEX_LIST_LENGTH(*listP) - 1] = newIndex;
 }
 
 
 
 static void
-appendCorner(index_list_type *  const cornerListP,
+appendCorner(IndexList       *  const cornerListP,
              unsigned int       const pixelSeq,
              pixel_outline_type const outline,
              float              const angle,
@@ -125,47 +134,49 @@ appendCorner(index_list_type *  const cornerListP,
 
     pm_pixelcoord const coord = O_COORDINATE(outline, pixelSeq);
 
-    append_index(cornerListP, pixelSeq);
+    indexList_append(cornerListP, pixelSeq);
     LOG4(" (%d,%d)%c%.3f", coord.col, coord.row, logType, angle);
 }
 
 
 
 static void
-find_vectors(unsigned int       const test_index,
-             pixel_outline_type const outline,
-             vector_type *      const in,
-             vector_type *      const out,
-             unsigned int       const corner_surround) {
+findVectors(unsigned int       const testIndex,
+            pixel_outline_type const outline,
+            Vector *      const inP,
+            Vector *      const outP,
+            unsigned int       const cornerSurround) {
 /*----------------------------------------------------------------------------
   Return the difference vectors coming in and going out of the outline
   OUTLINE at the point whose index is TEST_INDEX.  In Phoenix,
   Schneider looks at a single point on either side of the point we're
   considering.  That works for him because his points are not touching.
   But our points *are* touching, and so we have to look at
-  `corner_surround' points on either side, to get a better picture of
+  'cornerSurround' points on either side, to get a better picture of
   the outline's shape.
 -----------------------------------------------------------------------------*/
-    int i;
-    unsigned n_done;
-    pm_pixelcoord const candidate = O_COORDINATE(outline, test_index);
+    pm_pixelcoord const candidate = O_COORDINATE(outline, testIndex);
+
+    unsigned int i;
+    unsigned int doneCt;
 
-    in->dx  = in->dy  = in->dz  = 0.0;
-    out->dx = out->dy = out->dz = 0.0;
+    inP->dx  = inP->dy  = inP->dz  = 0.0;
+    outP->dx = outP->dy = outP->dz = 0.0;
 
-    /* Add up the differences from p of the `corner_surround' points
-       before p.
+    /* Add up the differences from p of the `corner_surround' points before p.
     */
-    for (i = O_PREV(outline, test_index), n_done = 0;
-         n_done < corner_surround;
-         i = O_PREV(outline, i), ++n_done)
-        *in = Vadd(*in, IPsubtract(O_COORDINATE(outline, i), candidate));
+    for (i = O_PREV(outline, testIndex), doneCt = 0;
+         doneCt < cornerSurround;
+         i = O_PREV(outline, i), ++doneCt)
+        *inP = vector_sum(*inP, vector_IPointDiff(O_COORDINATE(outline, i),
+                                                  candidate));
 
     /* And the points after p. */
-    for (i = O_NEXT (outline, test_index), n_done = 0;
-         n_done < corner_surround;
-         i = O_NEXT(outline, i), ++n_done)
-        *out = Vadd(*out, IPsubtract(O_COORDINATE(outline, i), candidate));
+    for (i = O_NEXT(outline, testIndex), doneCt = 0;
+         doneCt < cornerSurround;
+         i = O_NEXT(outline, i), ++doneCt)
+        *outP = vector_sum(*outP, vector_IPointDiff(O_COORDINATE(outline, i),
+                                                    candidate));
 }
 
 
@@ -179,8 +190,8 @@ lookAheadForBetterCorner(pixel_outline_type  const outline,
                          unsigned int *      const highestExaminedP,
                          float *             const bestCornerAngleP,
                          unsigned int *      const bestCornerIndexP,
-                         index_list_type *   const equallyGoodListP,
-                         index_list_type *   const cornerListP,
+                         IndexList *         const equallyGoodListP,
+                         IndexList *         const cornerListP,
                          at_exception_type * const exceptionP) {
 /*----------------------------------------------------------------------------
    'basePixelSeq' is the sequence position within 'outline' of a pixel
@@ -201,14 +212,14 @@ lookAheadForBetterCorner(pixel_outline_type  const outline,
 -----------------------------------------------------------------------------*/
     float bestCornerAngle;
     unsigned bestCornerIndex;
-    index_list_type equallyGoodList;
+    IndexList equallyGoodList;
     unsigned int q;
     unsigned int i;
 
     bestCornerIndex = basePixelSeq;     /* initial assumption */
     bestCornerAngle = baseCornerAngle;    /* initial assumption */
 
-    equallyGoodList = new_index_list();
+    equallyGoodList = indexList_new();
 
     q = basePixelSeq;
     i = basePixelSeq + 1;  /* Start with the next pixel */
@@ -217,14 +228,14 @@ lookAheadForBetterCorner(pixel_outline_type  const outline,
            i < O_LENGTH(outline) &&
            !at_exception_got_fatal(exceptionP)) {
 
-        vector_type inVector, outVector;
+        Vector inVector, outVector;
         float cornerAngle;
 
         /* Check the angle.  */
 
         q = i % O_LENGTH(outline);
-        find_vectors(q, outline, &inVector, &outVector, cornerSurround);
-        cornerAngle = Vangle(inVector, outVector, exceptionP);
+        findVectors(q, outline, &inVector, &outVector, cornerSurround);
+        cornerAngle = vector_angle(inVector, outVector, exceptionP);
         if (!at_exception_got_fatal(exceptionP)) {
             /* Perhaps the angle is sufficiently small that we want to
                consider this a corner, even if it's not the best
@@ -236,15 +247,15 @@ lookAheadForBetterCorner(pixel_outline_type  const outline,
                 appendCorner(cornerListP, q, outline, cornerAngle, '\\');
 
             if (epsilon_equal(cornerAngle, bestCornerAngle))
-                append_index(&equallyGoodList, q);
+                indexList_append(&equallyGoodList, q);
             else if (cornerAngle < bestCornerAngle) {
                 bestCornerAngle = cornerAngle;
                 /* We want to check `cornerSurround' pixels beyond the
                    new best corner.
                 */
                 i = bestCornerIndex = q;
-                free_index_list(&equallyGoodList);
-                equallyGoodList = new_index_list();
+                indexList_free(&equallyGoodList);
+                equallyGoodList = indexList_new();
             }
             ++i;
         }
@@ -279,10 +290,10 @@ establishCornerSearchLimits(pixel_outline_type  const outline,
 
 
 static void
-remove_adjacent_corners(index_list_type *   const list,
-                        unsigned int        const last_index,
-                        bool                const remove_adj_corners,
-                        at_exception_type * const exception) {
+removeAdjacentCorners(IndexList *         const listP,
+                      unsigned int        const lastIndex,
+                      bool                const mustRemoveAdjCorners,
+                      at_exception_type * const exception) {
 /*----------------------------------------------------------------------------
    Remove adjacent points from the index list LIST.  We do this by first
    sorting the list and then running through it.  Since these lists are
@@ -294,58 +305,61 @@ remove_adjacent_corners(index_list_type *   const list,
    We need to do this because the adjacent corners turn into
    two-pixel-long curves, which can be fit only by straight lines.
 -----------------------------------------------------------------------------*/
-  unsigned int j;
-  unsigned int last;
-  index_list_type new_list = new_index_list ();
+    unsigned int j;
+    unsigned int last;
+    IndexList newList;
 
-  for (j = INDEX_LIST_LENGTH (*list) - 1; j > 0; j--)
-    {
-      unsigned search;
-      unsigned temp;
-      /* Find maximal element below `j'.  */
-      unsigned max_index = j;
-
-      for (search = 0; search < j; search++)
-        if (GET_INDEX (*list, search) > GET_INDEX (*list, max_index))
-          max_index = search;
-
-      if (max_index != j)
-        {
-          temp = GET_INDEX (*list, j);
-          GET_INDEX (*list, j) = GET_INDEX (*list, max_index);
-          GET_INDEX (*list, max_index) = temp;
+    newList = indexList_new();  /* initial value */
+
+    for (j = INDEX_LIST_LENGTH (*listP) - 1; j > 0; --j) {
+        unsigned int search;
+        unsigned int maxIndex;
+            /* We find maximal element below `j' */
+
+        for (search = 0, maxIndex = j; search < j; ++search)
+            if (GET_INDEX (*listP, search) > GET_INDEX (*listP, maxIndex))
+                maxIndex = search;
+
+        if (maxIndex != j) {
+            unsigned int const temp = GET_INDEX (*listP, j);
+            GET_INDEX (*listP, j) = GET_INDEX (*listP, maxIndex);
+            GET_INDEX (*listP, maxIndex) = temp;
         }
     }
 
-  /* The list is sorted.  Now look for adjacent entries.  Each time
-     through the loop we insert the current entry and, if appropriate,
-     the next entry.  */
-  for (j = 0; j < INDEX_LIST_LENGTH (*list) - 1; j++)
-    {
-      unsigned current = GET_INDEX (*list, j);
-      unsigned next = GET_INDEX (*list, j + 1);
+    /* The list is sorted.  Now look for adjacent entries.  Each time through
+       the loop we insert the current entry and, if appropriate, the next
+       entry.
+    */
+    for (j = 0; j < INDEX_LIST_LENGTH(*listP) - 1; ++j) {
+        unsigned int const current = GET_INDEX(*listP, j);
+        unsigned int const next    = GET_INDEX(*listP, j + 1);
 
-      /* We should never have inserted the same element twice.  */
-      /* assert (current != next); */
+        /* We should never have inserted the same element twice.  */
+        /* assert (current != next); */
 
-      if ((remove_adj_corners) && ((next == current + 1) || (next == current)))
-        j++;
+        if ((mustRemoveAdjCorners) && ((next == current + 1) ||
+                                       (next == current)))
+            ++j;
 
-      append_index (&new_list, current);
+        indexList_append(&newList, current);
     }
 
-  /* Don't append the last element if it is 1) adjacent to the previous
-     one; or 2) adjacent to the very first one.  */
-  last = GET_LAST_INDEX (*list);
-  if (INDEX_LIST_LENGTH (new_list) == 0
-      || !(last == GET_LAST_INDEX (new_list) + 1
-           || (last == last_index && GET_INDEX (*list, 0) == 0)))
-    append_index (&new_list, last);
-
-  free_index_list (list);
-  *list = new_list;
+    /* Don't append the last element if it is 1) adjacent to the previous one;
+       or 2) adjacent to the very first one.
+    */
+    last = GET_LAST_INDEX(*listP);
+    if (INDEX_LIST_LENGTH(newList) == 0
+        || !(last == GET_LAST_INDEX(newList) + 1
+             || (last == lastIndex && GET_INDEX(*listP, 0) == 0)))
+        indexList_append(&newList, last);
+
+    indexList_free(listP);
+    *listP = newList;
 }
 
+
+
 /* A ``knee'' is a point which forms a ``right angle'' with its
    predecessor and successor.  See the documentation (the `Removing
    knees' section) for an example and more details.
@@ -386,29 +400,29 @@ remove_adjacent_corners(index_list_type *   const list,
 
 
 static void
-remove_knee_points(curve * const curveP,
+remove_knee_points(Curve * const curveP,
                    bool    const clockwise) {
 
     unsigned int const offset = CURVE_CYCLIC(curveP) ? 0 : 1;
-    curve * const trimmedCurveP = copy_most_of_curve(curveP);
+    Curve * const trimmedCurveP = curve_copyMost(curveP);
 
     pm_pixelcoord previous;
     unsigned int i;
 
     if (!CURVE_CYCLIC(curveP))
-        append_pixel(trimmedCurveP,
-                     real_to_int_coord(CURVE_POINT(curveP, 0)));
+        curve_appendPixel(trimmedCurveP,
+                          intCoordFmReal(CURVE_POINT(curveP, 0)));
 
-    previous = real_to_int_coord(CURVE_POINT(curveP,
-                                             CURVE_PREV(curveP, offset)));
+    previous = intCoordFmReal(CURVE_POINT(curveP,
+                                          CURVE_PREV(curveP, offset)));
 
     for (i = offset; i < CURVE_LENGTH(curveP) - offset; ++i) {
         pm_pixelcoord const current =
-            real_to_int_coord(CURVE_POINT(curveP, i));
+            intCoordFmReal(CURVE_POINT(curveP, i));
         pm_pixelcoord const next =
-            real_to_int_coord(CURVE_POINT(curveP, CURVE_NEXT(curveP, i)));
-        vector_type const prev_delta = IPsubtract(previous, current);
-        vector_type const next_delta = IPsubtract(next, current);
+            intCoordFmReal(CURVE_POINT(curveP, CURVE_NEXT(curveP, i)));
+        Vector const prev_delta = vector_IPointDiff(previous, current);
+        Vector const next_delta = vector_IPointDiff(next, current);
 
         if (ONLY_ONE_ZERO(prev_delta) && ONLY_ONE_ZERO(next_delta)
             && ((clockwise && CLOCKWISE_KNEE(prev_delta, next_delta))
@@ -417,26 +431,26 @@ remove_knee_points(curve * const curveP,
             LOG2(" (%d,%d)", current.col, current.row);
         else {
             previous = current;
-            append_pixel(trimmedCurveP, current);
+            curve_appendPixel(trimmedCurveP, current);
         }
     }
 
     if (!CURVE_CYCLIC(curveP))
-        append_pixel(trimmedCurveP,
-                     real_to_int_coord(LAST_CURVE_POINT(curveP)));
+        curve_appendPixel(trimmedCurveP,
+                          intCoordFmReal(LAST_CURVE_POINT(curveP)));
 
     if (CURVE_LENGTH(trimmedCurveP) == CURVE_LENGTH(curveP))
         LOG(" (none)");
 
     LOG(".\n");
 
-    move_curve(curveP, trimmedCurveP);
+    curve_move(curveP, trimmedCurveP);
 }
 
 
 
 static void
-filter(curve *             const curveP,
+filter(Curve *             const curveP,
        fitting_opts_type * const fittingOptsP) {
 /*----------------------------------------------------------------------------
   Smooth the curve by adding in neighboring points.  Do this
@@ -445,7 +459,7 @@ filter(curve *             const curveP,
     unsigned int const offset = CURVE_CYCLIC(curveP) ? 0 : 1;
 
     unsigned int iteration, thisPoint;
-    float_coord prevNewPoint;
+    Point prevNewPoint;
 
     /* We must have at least three points -- the previous one, the current
        one, and the next one.  But if we don't have at least five, we will
@@ -464,7 +478,7 @@ filter(curve *             const curveP,
     for (iteration = 0;
          iteration < fittingOptsP->filter_iterations;
          ++iteration) {
-        curve * const newcurveP = copy_most_of_curve(curveP);
+        Curve * const newcurveP = curve_copyMost(curveP);
 
         bool collapsed;
 
@@ -472,13 +486,13 @@ filter(curve *             const curveP,
 
         /* Keep the first point on the curve.  */
         if (offset)
-            append_point(newcurveP, CURVE_POINT(curveP, 0));
+            curve_appendPoint(newcurveP, CURVE_POINT(curveP, 0));
 
         for (thisPoint = offset;
              thisPoint < CURVE_LENGTH(curveP) - offset;
              ++thisPoint) {
-            vector_type in, out, sum;
-            float_coord newPoint;
+            Vector in, out, sum;
+            Point newPoint;
 
             /* Calculate the vectors in and out, computed by looking
                at n points on either side of this_point.  Experimental
@@ -487,7 +501,7 @@ filter(curve *             const curveP,
 
             signed int prev, prevprev; /* have to be signed */
             unsigned int next, nextnext;
-            float_coord candidate = CURVE_POINT(curveP, thisPoint);
+            Point candidate = CURVE_POINT(curveP, thisPoint);
 
             prev = CURVE_PREV(curveP, thisPoint);
             prevprev = CURVE_PREV(curveP, prev);
@@ -499,25 +513,32 @@ filter(curve *             const curveP,
             */
             in.dx = in.dy = in.dz = 0.0;
 
-            in = Vadd(in, Psubtract(CURVE_POINT(curveP, prev), candidate));
+            in = vector_sum(in,
+                            vector_fromTwoPoints(CURVE_POINT(curveP, prev),
+                                                 candidate));
             if (prevprev >= 0)
-                in = Vadd(in,
-                          Psubtract(CURVE_POINT(curveP, prevprev), candidate));
+                in = vector_sum(
+                    in,
+                    vector_fromTwoPoints(CURVE_POINT(curveP, prevprev),
+                                         candidate));
 
             /* And the points after p.  Don't use more points after p than we
                ended up with before it.
             */
             out.dx = out.dy = out.dz = 0.0;
 
-            out = Vadd(out, Psubtract(CURVE_POINT(curveP, next), candidate));
+            out = vector_sum(
+                out,
+                vector_fromTwoPoints(CURVE_POINT(curveP, next), candidate));
             if (nextnext < CURVE_LENGTH(curveP))
-                out = Vadd(out,
-                           Psubtract(CURVE_POINT(curveP, nextnext),
-                                     candidate));
+                out = vector_sum(
+                    out,
+                    vector_fromTwoPoints(CURVE_POINT(curveP, nextnext),
+                                         candidate));
 
             /* Start with the old point.  */
             newPoint = candidate;
-            sum = Vadd(in, out);
+            sum = vector_sum(in, out);
             /* We added 2*n+2 points, so we have to divide the sum by 2*n+2 */
             newPoint.x += sum.dx / 6;
             newPoint.y += sum.dy / 6;
@@ -532,31 +553,31 @@ filter(curve *             const curveP,
             /* Put the newly computed point into a separate curve, so it
                doesn't affect future computation (on this iteration).
             */
-            append_point(newcurveP, prevNewPoint = newPoint);
+            curve_appendPoint(newcurveP, prevNewPoint = newPoint);
         }
 
         if (collapsed)
-            free_curve(newcurveP);
+            curve_free(newcurveP);
         else {
             /* Just as with the first point, we have to keep the last
                point.
             */
             if (offset)
-                append_point(newcurveP, LAST_CURVE_POINT(curveP));
+                curve_appendPoint(newcurveP, LAST_CURVE_POINT(curveP));
 
             /* Set the original curve to the newly filtered one, and go
                again.
             */
-            move_curve(curveP, newcurveP);
+            curve_move(curveP, newcurveP);
         }
     }
-    log_curve(curveP, false);
+    curve_log(curveP, false);
 }
 
 
 
 static void
-removeAdjacent(index_list_type *   const cornerListP,
+removeAdjacent(IndexList *         const cornerListP,
                pixel_outline_type  const outline,
                fitting_opts_type * const fittingOptsP,
                at_exception_type * const exception) {
@@ -567,7 +588,7 @@ removeAdjacent(index_list_type *   const cornerListP,
     */
 
     if (INDEX_LIST_LENGTH(*cornerListP) > 0)
-        remove_adjacent_corners(
+        removeAdjacentCorners(
             cornerListP,
             O_LENGTH(outline) - (outline.open ? 2 : 1),
             fittingOptsP->remove_adjacent_corners,
@@ -576,10 +597,10 @@ removeAdjacent(index_list_type *   const cornerListP,
 
 
 
-static index_list_type
-find_corners(pixel_outline_type  const outline,
-             fitting_opts_type * const fittingOptsP,
-             at_exception_type * const exceptionP) {
+static IndexList
+findCorners(pixel_outline_type  const outline,
+            fitting_opts_type * const fittingOptsP,
+            at_exception_type * const exceptionP) {
 
     /* We consider a point to be a corner if (1) the angle defined by
        the `corner_surround' points coming into it and going out from
@@ -589,9 +610,9 @@ find_corners(pixel_outline_type  const outline,
     */
     unsigned int p;
     unsigned int firstPixelSeq, lastPixelSeq;
-    index_list_type cornerList;
+    IndexList cornerList;
 
-    cornerList = new_index_list();
+    cornerList = indexList_new();
 
     if (O_LENGTH(outline) <= fittingOptsP->corner_surround * 2 + 1)
         return cornerList;
@@ -601,13 +622,13 @@ find_corners(pixel_outline_type  const outline,
 
     /* Consider each pixel on the outline in turn.  */
     for (p = firstPixelSeq; p <= lastPixelSeq;) {
-        vector_type inVector, outVector;
+        Vector inVector, outVector;
         float cornerAngle;
 
         /* Check if the angle is small enough.  */
-        find_vectors(p, outline, &inVector, &outVector,
+        findVectors(p, outline, &inVector, &outVector,
                      fittingOptsP->corner_surround);
-        cornerAngle = Vangle(inVector, outVector, exceptionP);
+        cornerAngle = vector_angle(inVector, outVector, exceptionP);
         if (at_exception_got_fatal(exceptionP))
             goto cleanup;
 
@@ -624,7 +645,7 @@ find_corners(pixel_outline_type  const outline,
             */
             float bestCornerAngle;
             unsigned bestCornerIndex;
-            index_list_type equallyGoodList;
+            IndexList equallyGoodList;
             unsigned int q;
 
             if (cornerAngle <= fittingOptsP->corner_always_threshold)
@@ -663,7 +684,7 @@ find_corners(pixel_outline_type  const outline,
                     appendCorner(&cornerList, GET_INDEX(equallyGoodList, j),
                                  outline, bestCornerAngle, '@');
             }
-            free_index_list(&equallyGoodList);
+            indexList_free(&equallyGoodList);
 
             /* If we wrapped around in our search, we're done;
                otherwise, we move on to the pixel after the highest
@@ -683,19 +704,19 @@ cleanup:
 
 static void
 makeOutlineOneCurve(pixel_outline_type const outline,
-                    curve_list_type *  const curveListP) {
+                    CurveList *        const curveListP) {
 /*----------------------------------------------------------------------------
    Add to *curveListP a single curve that represents the outline 'outline'.
 
    That curve does not have beginning and ending slope information.
 -----------------------------------------------------------------------------*/
-    curve * curveP;
+    Curve * curveP;
     unsigned int pixelSeq;
 
-    curveP = new_curve();
+    curveP = curve_new();
 
     for (pixelSeq = 0; pixelSeq < O_LENGTH(outline); ++pixelSeq)
-        append_pixel(curveP, O_COORDINATE(outline, pixelSeq));
+        curve_appendPixel(curveP, O_COORDINATE(outline, pixelSeq));
 
     if (outline.open)
         CURVE_CYCLIC(curveP) = false;
@@ -706,17 +727,17 @@ makeOutlineOneCurve(pixel_outline_type const outline,
     NEXT_CURVE(curveP)     = curveP;
     PREVIOUS_CURVE(curveP) = curveP;
 
-    append_curve(curveListP, curveP);
+    curve_appendList(curveListP, curveP);
 }
 
 
 
 static void
 addCurveStartingAtCorner(pixel_outline_type const outline,
-                         index_list_type    const cornerList,
+                         IndexList          const cornerList,
                          unsigned int       const cornerSeq,
-                         curve_list_type *  const curveListP,
-                         curve **           const curCurvePP) {
+                         CurveList *        const curveListP,
+                         Curve **           const curCurvePP) {
 /*----------------------------------------------------------------------------
    Add to the list *curveListP a new curve that starts at the cornerSeq'th
    corner in outline 'outline' (whose corners are 'cornerList') and
@@ -730,7 +751,7 @@ addCurveStartingAtCorner(pixel_outline_type const outline,
     unsigned int const cornerPixelSeq = GET_INDEX(cornerList, cornerSeq);
 
     unsigned int lastPixelSeq;
-    curve * curveP;
+    Curve * curveP;
     unsigned int pixelSeq;
 
     if (cornerSeq + 1 >= cornerList.length)
@@ -740,16 +761,16 @@ addCurveStartingAtCorner(pixel_outline_type const outline,
         /* Go through the next corner */
         lastPixelSeq = GET_INDEX(cornerList, cornerSeq + 1);
 
-    curveP = new_curve();
+    curveP = curve_new();
 
     for (pixelSeq = cornerPixelSeq; pixelSeq <= lastPixelSeq; ++pixelSeq)
-        append_pixel(curveP, O_COORDINATE(outline, pixelSeq));
+        curve_appendPixel(curveP, O_COORDINATE(outline, pixelSeq));
 
-    append_curve(curveListP, curveP);
+    curve_appendList(curveListP, curveP);
     {
         /* Add the new curve to the outline chain */
 
-        curve * const oldCurCurveP = *curCurvePP;
+        Curve * const oldCurCurveP = *curCurvePP;
 
         if (oldCurCurveP) {
             NEXT_CURVE(oldCurCurveP) = curveP;
@@ -763,8 +784,8 @@ addCurveStartingAtCorner(pixel_outline_type const outline,
 
 static void
 divideOutlineWithCorners(pixel_outline_type const outline,
-                         index_list_type    const cornerList,
-                         curve_list_type *  const curveListP) {
+                         IndexList          const cornerList,
+                         CurveList *        const curveListP) {
 /*----------------------------------------------------------------------------
    Divide the outline 'outline' into curves at the corner points
    'cornerList' and add each curve to *curveListP.
@@ -788,7 +809,7 @@ divideOutlineWithCorners(pixel_outline_type const outline,
     unsigned int const firstCurveSeq = CURVE_LIST_LENGTH(*curveListP);
         /* Index in curve list of the first curve we add */
     unsigned int cornerSeq;
-    curve * curCurveP;
+    Curve * curCurveP;
         /* Pointer to the curve we most recently added for this outline.
            Null if none
         */
@@ -801,15 +822,15 @@ divideOutlineWithCorners(pixel_outline_type const outline,
         /* Start with a curve that contains the points up to the first
            corner
         */
-        curve * curveP;
+        Curve * curveP;
         unsigned int pixelSeq;
 
-        curveP = new_curve();
+        curveP = curve_new();
 
         for (pixelSeq = 0; pixelSeq <= GET_INDEX(cornerList, 0); ++pixelSeq)
-            append_pixel(curveP, O_COORDINATE(outline, pixelSeq));
+            curve_appendPixel(curveP, O_COORDINATE(outline, pixelSeq));
 
-        append_curve(curveListP, curveP);
+        curve_appendList(curveListP, curveP);
         curCurveP = curveP;  /* Only curve in outline chain now */
     } else {
         /* We'll pick up the pixels before the first corner at the end */
@@ -827,12 +848,12 @@ divideOutlineWithCorners(pixel_outline_type const outline,
            before the first corner to the last curve, and chain the last
            curve to the first one.
         */
-        curve * const firstCurveP = CURVE_LIST_ELT(*curveListP, firstCurveSeq);
+        Curve * const firstCurveP = CURVE_LIST_ELT(*curveListP, firstCurveSeq);
 
         unsigned int pixelSeq;
 
         for (pixelSeq = 0; pixelSeq <= GET_INDEX(cornerList, 0); ++pixelSeq)
-            append_pixel(curCurveP, O_COORDINATE(outline, pixelSeq));
+            curve_appendPixel(curCurveP, O_COORDINATE(outline, pixelSeq));
 
         NEXT_CURVE(curCurveP)       = firstCurveP;
         PREVIOUS_CURVE(firstCurveP) = curCurveP;
@@ -841,16 +862,16 @@ divideOutlineWithCorners(pixel_outline_type const outline,
 
 
 
-static curve_list_array_type
-split_at_corners(pixel_outline_list_type const pixel_list,
-                 fitting_opts_type *     const fitting_opts,
+static CurveListArray
+split_at_corners(pixel_outline_list_type const pixelList,
+                 fitting_opts_type *     const fittingOptsP,
                  at_exception_type *     const exception) {
 /*----------------------------------------------------------------------------
-   Find the corners in PIXEL_LIST, the list of points.  (Presumably we
+   Find the corners in 'pixelList', the list of points.  (Presumably we
    can't fit a single spline around a corner.)  The general strategy
    is to look through all the points, remembering which we want to
    consider corners.  Then go through that list, producing the
-   curve_list.  This is dictated by the fact that PIXEL_LIST does not
+   curve_list.  This is dictated by the fact that 'pixelList' does not
    necessarily start on a corner---it just starts at the character's
    first outline pixel, going left-to-right, top-to-bottom.  But we
    want all our splines to start and end on real corners.
@@ -860,41 +881,41 @@ split_at_corners(pixel_outline_list_type const pixel_list,
                      ***********
                   ******************
 
-   PIXEL_LIST will start at the pixel below the `x'.  If we considered
+   'pixelList' will start at the pixel below the `x'.  If we considered
    this pixel a corner, we would wind up matching a very small segment
    from there to the end of the line, probably as a straight line, which
    is certainly not what we want.
 
-   PIXEL_LIST has one element for each closed outline on the character.
+   'pixelList' has one element for each closed outline on the character.
    To preserve this information, we return an array of curve_lists, one
    element (which in turn consists of several curves, one between each
-   pair of corners) for each element in PIXEL_LIST.
+   pair of corners) for each element in 'pixelList'.
 
    The curves we return do not have beginning and ending slope
    information.
 -----------------------------------------------------------------------------*/
     unsigned outlineSeq;
-    curve_list_array_type curve_array;
+    CurveListArray curveArray;
 
-    curve_array = new_curve_list_array();
+    curveArray = curve_newListArray();
 
     LOG("\nFinding corners:\n");
 
     for (outlineSeq = 0;
-         outlineSeq < O_LIST_LENGTH(pixel_list);
+         outlineSeq < O_LIST_LENGTH(pixelList);
          ++outlineSeq) {
 
         pixel_outline_type const outline =
-            O_LIST_OUTLINE(pixel_list, outlineSeq);
+            O_LIST_OUTLINE(pixelList, outlineSeq);
 
-        index_list_type corner_list;
-        curve_list_type curve_list;
+        IndexList cornerList;
+        CurveList curveList;
 
-        curve_list = new_curve_list();
+        curveList = curve_newList();
 
-        CURVE_LIST_CLOCKWISE(curve_list) = O_CLOCKWISE(outline);
-        curve_list.color = outline.color;
-        curve_list.open  = outline.open;
+        CURVE_LIST_CLOCKWISE(curveList) = O_CLOCKWISE(outline);
+        curveList.color = outline.color;
+        curveList.open  = outline.open;
 
         LOG1("#%u:", outlineSeq);
 
@@ -904,43 +925,43 @@ split_at_corners(pixel_outline_list_type const pixel_list,
            either side of a point before it is conceivable that we might
            want another corner.
         */
-        if (O_LENGTH(outline) > fitting_opts->corner_surround * 2 + 2)
-            corner_list = find_corners(outline, fitting_opts, exception);
+        if (O_LENGTH(outline) > fittingOptsP->corner_surround * 2 + 2)
+            cornerList = findCorners(outline, fittingOptsP, exception);
 
         else {
             int const surround = (O_LENGTH(outline) - 3) / 2;
             if (surround >= 2) {
-                unsigned int const save_corner_surround =
-                    fitting_opts->corner_surround;
-                fitting_opts->corner_surround = surround;
-                corner_list = find_corners(outline, fitting_opts, exception);
-                fitting_opts->corner_surround = save_corner_surround;
+                unsigned int const oldCornerSurround =
+                    fittingOptsP->corner_surround;
+                fittingOptsP->corner_surround = surround;
+                cornerList = findCorners(outline, fittingOptsP, exception);
+                fittingOptsP->corner_surround = oldCornerSurround;
             } else {
-                corner_list.length = 0;
-                corner_list.data = NULL;
+                cornerList.length = 0;
+                cornerList.data = NULL;
             }
         }
 
-        if (corner_list.length == 0)
+        if (cornerList.length == 0)
             /* No corners.  Use all of the pixel outline as the one curve. */
-            makeOutlineOneCurve(outline, &curve_list);
+            makeOutlineOneCurve(outline, &curveList);
         else
-            divideOutlineWithCorners(outline, corner_list, &curve_list);
+            divideOutlineWithCorners(outline, cornerList, &curveList);
 
-        LOG1(" [%u].\n", corner_list.length);
-        free_index_list(&corner_list);
+        LOG1(" [%u].\n", cornerList.length);
+        indexList_free(&cornerList);
 
         /* And now add the just-completed curve list to the array.  */
-        append_curve_list(&curve_array, curve_list);
+        curve_appendArray(&curveArray, curveList);
     }
 
-    return curve_array;
+    return curveArray;
 }
 
 
 
 static void
-removeKnees(curve_list_type const curveList) {
+removeKnees(CurveList const curveList) {
 /*----------------------------------------------------------------------------
   Remove the extraneous ``knee'' points before filtering.  Since the
   corners have already been found, we don't need to worry about
@@ -949,6 +970,7 @@ removeKnees(curve_list_type const curveList) {
     unsigned int curveSeq;
 
     LOG("\nRemoving knees:\n");
+
     for (curveSeq = 0; curveSeq < curveList.length; ++curveSeq) {
         LOG1("#%u:", curveSeq);
         remove_knee_points(CURVE_LIST_ELT(curveList, curveSeq),
@@ -959,7 +981,7 @@ removeKnees(curve_list_type const curveList) {
 
 
 static void
-computePointWeights(curve_list_type     const curveList,
+computePointWeights(CurveList           const curveList,
                     fitting_opts_type * const fittingOptsP,
                     distance_map_type * const distP) {
 
@@ -968,12 +990,14 @@ computePointWeights(curve_list_type     const curveList,
     unsigned int curveSeq;
 
     for (curveSeq = 0; curveSeq < curveList.length; ++curveSeq) {
+        Curve * const curveP = CURVE_LIST_ELT(curveList, curveSeq);
+
         unsigned pointSeq;
-        curve_type const curve = CURVE_LIST_ELT(curveList, curveSeq);
-        for (pointSeq = 0; pointSeq < CURVE_LENGTH(curve); ++pointSeq) {
-            float_coord * const coordP = &CURVE_POINT(curve, pointSeq);
-            unsigned int x = coordP->x;
-            unsigned int y = height - (unsigned int)coordP->y - 1;
+
+        for (pointSeq = 0; pointSeq < CURVE_LENGTH(curveP); ++pointSeq) {
+            Point *      const coordP = &CURVE_POINT(curveP, pointSeq);
+            unsigned int const x = coordP->x;
+            unsigned int const y = height - (unsigned int)coordP->y - 1;
 
             float width, w;
 
@@ -1015,7 +1039,7 @@ computePointWeights(curve_list_type     const curveList,
 
 
 static void
-filterCurves(curve_list_type     const curveList,
+filterCurves(CurveList           const curveList,
              fitting_opts_type * const fittingOptsP) {
 
     unsigned int curveSeq;
@@ -1049,118 +1073,134 @@ logSplinesForCurve(unsigned int     const curveSeq,
 
 
 static void
-change_bad_lines(spline_list_type *        const spline_list,
-                 const fitting_opts_type * const fitting_opts) {
+changeBadLines(spline_list_type *        const splineListP,
+               const fitting_opts_type * const fittingOptsP) {
+
+    /* Unfortunately, we cannot tell in isolation whether a given spline
+       should be changed to a line or not.  That be known only after the
+       entire curve has been fit to a list of splines.  (The curve is the
+       pixel outline between two corners.)  After subdividing the curve, a
+       line may very well fit a portion of the curve just as well as the
+       spline---but unless a spline is truly close to being a line, it should
+       not be combined with other lines.
+    */
 
-/* Unfortunately, we cannot tell in isolation whether a given spline
-   should be changed to a line or not.  That can only be known after the
-   entire curve has been fit to a list of splines.  (The curve is the
-   pixel outline between two corners.)  After subdividing the curve, a
-   line may very well fit a portion of the curve just as well as the
-   spline---but unless a spline is truly close to being a line, it
-   should not be combined with other lines.  */
+    unsigned int const length = SPLINE_LIST_LENGTH(*splineListP);
 
-  unsigned this_spline;
-  bool found_cubic = false;
-  unsigned length = SPLINE_LIST_LENGTH (*spline_list);
+    unsigned int thisSpline;
+    bool foundCubic;
 
-  LOG1 ("\nChecking for bad lines (length %u):\n", length);
+    LOG1("\nChecking for bad lines (length %u):\n", length);
 
-  /* First see if there are any splines in the fitted shape.  */
-  for (this_spline = 0; this_spline < length; this_spline++)
-    {
-      if (SPLINE_DEGREE (SPLINE_LIST_ELT (*spline_list, this_spline)) ==
-       CUBICTYPE)
-        {
-          found_cubic = true;
-          break;
+    /* First see if there are any splines in the fitted shape.  */
+    for (thisSpline = 0, foundCubic = false;
+         thisSpline < length;
+         ++thisSpline) {
+        if (SPLINE_DEGREE(SPLINE_LIST_ELT(*splineListP, thisSpline)) ==
+            CUBICTYPE) {
+            foundCubic = true;
+            break;
         }
     }
 
-  /* If so, change lines back to splines (we haven't done anything to
-     their control points, so we only have to change the degree) unless
-     the spline is close enough to being a line.  */
-  if (found_cubic)
-    for (this_spline = 0; this_spline < length; this_spline++)
-      {
-        spline_type s = SPLINE_LIST_ELT (*spline_list, this_spline);
-
-        if (SPLINE_DEGREE (s) == LINEARTYPE)
-          {
-            LOG1 ("  #%u: ", this_spline);
-            if (SPLINE_LINEARITY (s) > fitting_opts->line_reversion_threshold)
-              {
-                LOG ("reverted, ");
-                SPLINE_DEGREE (SPLINE_LIST_ELT (*spline_list, this_spline))
-                  = CUBICTYPE;
-              }
-            LOG1 ("linearity %.3f.\n", SPLINE_LINEARITY (s));
-          }
-      }
-    else
-      LOG ("  No lines.\n");
+    /* If so, change lines back to splines (we haven't done anything to
+       their control points, so we only have to change the degree) unless
+       the spline is close enough to being a line.
+    */
+    if (foundCubic) {
+        unsigned int thisSpline;
+
+        for (thisSpline = 0; thisSpline < length; ++thisSpline) {
+            spline_type const s = SPLINE_LIST_ELT(*splineListP, thisSpline);
+
+            if (SPLINE_DEGREE(s) == LINEARTYPE) {
+                LOG1("  #%u: ", thisSpline);
+                if (SPLINE_LINEARITY(s) >
+                    fittingOptsP->line_reversion_threshold) {
+                    LOG("reverted, ");
+                    SPLINE_DEGREE(SPLINE_LIST_ELT(*splineListP, thisSpline))
+                        = CUBICTYPE;
+                }
+                LOG1("linearity %.3f.\n", SPLINE_LINEARITY(s));
+            }
+        }
+    } else
+        LOG("  No lines.\n");
 }
 
 
 
 static bool
-spline_linear_enough(spline_type *             const spline,
-                     curve_type                const curve,
-                     const fitting_opts_type * const fitting_opts) {
+splineLinearEnough(spline_type *             const splineP,
+                   Curve *                   const curve,
+                   const fitting_opts_type * const fittingOptsP) {
 
-/* Supposing that we have accepted the error, another question arises:
-   would we be better off just using a straight line?  */
+    /* Supposing that we have accepted the error, another question arises:
+       would we be better off just using a straight line?
+    */
 
-  float A, B, C;
-  unsigned this_point;
-  float dist = 0.0, start_end_dist, threshold;
+    float A, B, C;
+    unsigned int thisPoint;
+    float dist;
+    float startEndDist;
+    float threshold;
 
-  LOG ("Checking linearity:\n");
+    LOG ("Checking linearity:\n");
 
-  A = END_POINT(*spline).x - START_POINT(*spline).x;
-  B = END_POINT(*spline).y - START_POINT(*spline).y;
-  C = END_POINT(*spline).z - START_POINT(*spline).z;
+    A = END_POINT(*splineP).x - BEG_POINT(*splineP).x;
+    B = END_POINT(*splineP).y - BEG_POINT(*splineP).y;
+    C = END_POINT(*splineP).z - BEG_POINT(*splineP).z;
 
-  start_end_dist = (float) (SQR(A) + SQR(B) + SQR(C));
-  LOG1 ("start_end_distance is %.3f.\n", sqrt(start_end_dist));
+    startEndDist = (float) (SQR(A) + SQR(B) + SQR(C));
+    LOG1("start_end_distance is %.3f.\n", sqrt(startEndDist));
 
-  LOG3 ("  Line endpoints are (%.3f, %.3f, %.3f) and ", START_POINT(*spline).x, START_POINT(*spline).y, START_POINT(*spline).z);
-  LOG3 ("(%.3f, %.3f, %.3f)\n", END_POINT(*spline).x, END_POINT(*spline).y, END_POINT(*spline).z);
+    LOG3("  Line endpoints are (%.3f, %.3f, %.3f) and ",
+         BEG_POINT(*splineP).x,
+         BEG_POINT(*splineP).y,
+         BEG_POINT(*splineP).z);
+    LOG3("(%.3f, %.3f, %.3f)\n",
+         END_POINT(*splineP).x, END_POINT(*splineP).y, END_POINT(*splineP).z);
 
-  /* LOG3 ("  Line is %.3fx + %.3fy + %.3f = 0.\n", A, B, C); */
+    /* LOG3("  Line is %.3fx + %.3fy + %.3f = 0.\n", A, B, C); */
 
-  for (this_point = 0; this_point < CURVE_LENGTH (curve); this_point++)
-    {
-      float a, b, c, w;
-      float t = CURVE_T (curve, this_point);
-      float_coord spline_point = evaluate_spline (*spline, t);
+    for (thisPoint = 0, dist = 0.0;
+         thisPoint < CURVE_LENGTH(curve);
+         ++thisPoint) {
 
-      a = spline_point.x - START_POINT(*spline).x;
-      b = spline_point.y - START_POINT(*spline).y;
-      c = spline_point.z - START_POINT(*spline).z;
-      w = (A*a + B*b + C*c) / start_end_dist;
+        float const t           = CURVE_DIST(curve, thisPoint);
+        Point const splinePoint = evaluate_spline(*splineP, t);
 
-      dist += (float)sqrt(SQR(a-A*w) + SQR(b-B*w) + SQR(c-C*w));
+        float const a = splinePoint.x - BEG_POINT(*splineP).x;
+        float const b = splinePoint.y - BEG_POINT(*splineP).y;
+        float const c = splinePoint.z - BEG_POINT(*splineP).z;
+
+        float const w = (A*a + B*b + C*c) / startEndDist;
+
+        dist += (float)sqrt(SQR(a-A*w) + SQR(b-B*w) + SQR(c-C*w));
     }
-  LOG1 ("  Total distance is %.3f, ", dist);
-
-  dist /= (CURVE_LENGTH (curve) - 1);
-  LOG1 ("which is %.3f normalized.\n", dist);
-
-  /* We want reversion of short curves to splines to be more likely than
-     reversion of long curves, hence the second division by the curve
-     length, for use in `change_bad_lines'.  */
-  SPLINE_LINEARITY (*spline) = dist;
-  LOG1 ("  Final linearity: %.3f.\n", SPLINE_LINEARITY (*spline));
-  if (start_end_dist * (float) 0.5 > fitting_opts->line_threshold)
-    threshold = fitting_opts->line_threshold;
-  else
-    threshold = start_end_dist * (float) 0.5;
-  LOG1 ("threshold is %.3f .\n", threshold);
-  if (dist < threshold)
-    return true;
-  else
-    return false;
+    LOG1("  Total distance is %.3f, ", dist);
+
+    dist /= (CURVE_LENGTH (curve) - 1);
+
+    LOG1 ("which is %.3f normalized.\n", dist);
+
+    /* We want reversion of short curves to splines to be more likely than
+       reversion of long curves, hence the second division by the curve
+       length, for use in `change_bad_lines'.
+    */
+    SPLINE_LINEARITY(*splineP) = dist;
+    LOG1("  Final linearity: %.3f.\n", SPLINE_LINEARITY (*splineP));
+
+    if (startEndDist * (float) 0.5 > fittingOptsP->line_threshold)
+        threshold = fittingOptsP->line_threshold;
+    else
+        threshold = startEndDist * (float) 0.5;
+    LOG1("threshold is %.3f .\n", threshold);
+
+    if (dist < threshold)
+        return true;
+    else
+        return false;
 }
 
 
@@ -1168,16 +1208,16 @@ spline_linear_enough(spline_type *             const spline,
 /* Forward declaration for recursion */
 
 static spline_list_type *
-fitCurve(curve *                   const curveP,
-         vector_type               const begSlope,
-         vector_type               const endSlope,
+fitCurve(Curve *                   const curveP,
+         Vector                    const begSlope,
+         Vector                    const endSlope,
          const fitting_opts_type * const fittingOptsP,
          at_exception_type *       const exceptionP);
 
 
 
 static spline_list_type *
-fitWithLine(curve * const curveP) {
+fitWithLine(Curve * const curveP) {
 /*----------------------------------------------------------------------------
   Return a list of splines that fit curve *curveP in a very simple way:
   a single spline which is a straight line through the first and last
@@ -1190,7 +1230,7 @@ fitWithLine(curve * const curveP) {
     LOG("Fitting with straight line:\n");
 
     SPLINE_DEGREE(line) = LINEARTYPE;
-    START_POINT(line)   = CONTROL1(line) = CURVE_POINT(curveP, 0);
+    BEG_POINT(line)     = CONTROL1(line) = CURVE_POINT(curveP, 0);
     END_POINT(line)     = CONTROL2(line) = LAST_CURVE_POINT(curveP);
 
     /* Make sure that this line is never changed to a cubic.  */
@@ -1206,128 +1246,154 @@ fitWithLine(curve * const curveP) {
 
 
 
-#define B0(t) CUBE ((float) 1.0 - (t))
-#define B1(t) ((float) 3.0 * (t) * SQR ((float) 1.0 - (t)))
-#define B2(t) ((float) 3.0 * SQR (t) * ((float) 1.0 - (t)))
-#define B3(t) CUBE (t)
-
-static spline_type
-fitOneSpline(curve *             const curveP,
-             vector_type         const begSlope,
-             vector_type         const endSlope,
-             at_exception_type * const exceptionP) {
+static float
+b2(float const fracCurveDist) {
 /*----------------------------------------------------------------------------
-  Return a spline that fits the points of curve *curveP,
-  with slope 'begSlope' at its beginning and 'endSlope' at its end.
+   Some mysterious weighting function
 
-  Make it a cubic spline.
+   'fracCurveDist' is a fraction (range [0.0-1.0]) of the distance along
+   a curve that a point on the curve is.
 -----------------------------------------------------------------------------*/
-    /* We already have the start and end points of the spline, so all
-      we need are the control points.  And we know in what direction
-      each control point is from its respective end point, so all we
-      need to figure out is its distance.  (The control point's
-      distance from the end point is an indication of how long the
-      curve goes in its direction).
+    return 3.0 * SQR(fracCurveDist) * (1.0 - fracCurveDist);
+}
 
-      We call the distance from an end point to the associated control
-      point "alpha".
 
-      We want to find starting and ending alpha that minimize the
-      least-square error in approximating *curveP with the spline.
 
-      How we do that is a complete mystery to me, but the original author
-      said to see pp.57--59 of the Phoenix thesis.  I haven't seen that.
+struct Mat22 {
+    struct { float beg; float end; } beg;
+    struct { float beg; float end; } end;
+};
 
-      In our expression of the math here, we use a struct with "beg" and
-      "end" members where the paper uses a matrix with "1" and "2"
-      subscripts, respectively.  A C array is a closer match to a math
-      matrix, but we think the struct is easier to read.
+struct Mat2 { float beg; float end; };
 
-      The B?(t) here corresponds to B_i^3(U_i) there.
-      The Bernstein polynomials of degree n are defined by
-      B_i^n(t) = { n \choose i } t^i (1-t)^{n-i}, i = 0..n
+struct VectorBegEndPair {
+    Vector beg;
+    Vector end;
+};
 
-    */
-    struct vectorPair {
-        vector_type beg;
-        vector_type end;
-    };
-    struct vectorPair tang;
 
-    float X_Cend_det, Cbeg_X_det, C_det;
-    spline_type spline;
-    vector_type begVector, endVector;
-    unsigned i;
-    struct vectorPair * A;  /* malloc'ed array */
-        /* I don't know the meaning of this array, but it is one entry for
-           each point in the curve (A[i] is for the ith point in the curve).
-        */
-    struct {
-        struct { float beg; float end; } beg;
-        struct { float beg; float end; } end;
-    } C;
-    struct { float beg; float end; } X;
+static void
+computeCX(Curve *                 const curveP,
+          struct VectorBegEndPair const tang,
+          struct Mat22 *          const cP,
+          struct Mat2 *           const xP) {
 
-    tang.beg = begSlope; tang.end = endSlope;
+    Vector const begVector = vector_fromPoint(CURVE_POINT(curveP, 0));
+    Vector const endVector = vector_fromPoint(LAST_CURVE_POINT(curveP));
 
-    MALLOCARRAY_NOFAIL(A, CURVE_LENGTH(curveP));
+    unsigned int pointSeq;
 
-    BEG_POINT(spline) = CURVE_POINT(curveP, 0);
-    END_POINT(spline) = LAST_CURVE_POINT(curveP);
-    begVector = make_vector(BEG_POINT(spline));
-    endVector = make_vector(END_POINT(spline));
+    cP->beg.beg = 0.0; cP->beg.end = 0.0; cP->end.end = 0.0;/* initial value */
 
-    for (i = 0; i < CURVE_LENGTH(curveP); ++i) {
-        A[i].beg = Vmult_scalar(tang.beg, B1(CURVE_T(curveP, i)));
-        A[i].end = Vmult_scalar(tang.end, B2(CURVE_T(curveP, i)));
-    }
+    xP->beg = 0.0; xP->end = 0.0; /* initial value */
 
-    C.beg.beg = 0.0; C.beg.end = 0.0; C.end.end = 0.0;  /* initial value */
+    for (pointSeq = 0; pointSeq < CURVE_LENGTH(curveP); ++pointSeq) {
+        float const curveDistFmBeg = CURVE_DIST(curveP, pointSeq);
+        float const curveDistToEnd = 1.0 - curveDistFmBeg;
+        struct VectorBegEndPair a;  /* constant */
+            /* I don't know the meaning of this, but the vectors of the pair
+               are in the direction of the beginning and points of the curve,
+               respectively, with magnitude a function of the fractional
+               distance from their respective endpoints of the current point.
+               "Fractional distance" means e.g. "this point is 20% of the way
+               to the end of the curve from its beginning".  The function is
 
-    X.beg = 0.0; X.end = 0.0; /* initial value */
+                 3 * <fracdistance> * SQR(1-<fracdistance>) .
+            */
+        Vector temp, temp0, temp1;
 
-    for (i = 0; i < CURVE_LENGTH(curveP); ++i) {
-        struct vectorPair * const AP = &A[i];
-        vector_type temp, temp0, temp1, temp2, temp3;
+        a.beg = vector_scaled(tang.beg, b2(curveDistToEnd));
+        a.end = vector_scaled(tang.end, b2(curveDistFmBeg));
 
-        C.beg.beg += Vdot(AP->beg, AP->beg);
-        C.beg.end += Vdot(AP->beg, AP->end);
-        /* C.end.beg = Vdot(AP->end, AP->beg) is done outside of loop */
-        C.end.end += Vdot(AP->end, AP->end);
+        cP->beg.beg += vector_dotProduct(a.beg, a.beg);
+        cP->beg.end += vector_dotProduct(a.beg, a.end);
+        cP->end.beg += vector_dotProduct(a.end, a.beg);
+        cP->end.end += vector_dotProduct(a.end, a.end);
 
         /* Now the right-hand side of the equation in the paper.  */
-        temp0 = Vmult_scalar(begVector, B0(CURVE_T(curveP, i)));
-        temp1 = Vmult_scalar(begVector, B1(CURVE_T(curveP, i)));
-        temp2 = Vmult_scalar(endVector, B2(CURVE_T(curveP, i)));
-        temp3 = Vmult_scalar(endVector, B3(CURVE_T(curveP, i)));
+        temp0 = vector_scaled(begVector,
+                              CUBE(curveDistToEnd) + b2(curveDistToEnd));
+        temp1 = vector_scaled(endVector,
+                              CUBE(curveDistFmBeg) + b2(curveDistFmBeg));
 
-        temp = make_vector(
-            Vsubtract_point(CURVE_POINT(curveP, i),
-                            Vadd(temp0, Vadd(temp1, Vadd(temp2, temp3)))));
+        temp = vector_fromPoint(
+            vector_diffPoint(
+                CURVE_POINT(curveP, pointSeq), vector_sum(temp0, temp1)));
 
-        X.beg += Vdot(temp, AP->beg);
-        X.end += Vdot(temp, AP->end);
+        xP->beg += vector_dotProduct(temp, a.beg);
+        xP->end += vector_dotProduct(temp, a.end);
     }
-    free(A);
+}
 
-    C.end.beg = C.beg.end;
 
-    X_Cend_det  = X.beg * C.end.end - X.end * C.beg.end;
-    Cbeg_X_det  = C.beg.beg * X.end - C.beg.end * X.beg;
-    C_det = C.beg.beg * C.end.end - C.end.beg * C.beg.end;
-    if (C_det == 0.0) {
-        LOG("zero determinant of C matrix");
-        at_exception_fatal(exceptionP, "zero determinant of C matrix");
-    } else {
-        struct { float beg; float end; } alpha;  /* constant */
-        alpha.beg = X_Cend_det / C_det;
-        alpha.end = Cbeg_X_det / C_det;
-
-        CONTROL1(spline) = Vadd_point(BEG_POINT(spline),
-                                      Vmult_scalar(tang.beg, alpha.beg));
-        CONTROL2(spline) = Vadd_point(END_POINT(spline),
-                                      Vmult_scalar(tang.end, alpha.end));
-        SPLINE_DEGREE(spline) = CUBICTYPE;
+
+static spline_type
+fitOneSpline(Curve *             const curveP,
+             Vector              const begSlope,
+             Vector              const endSlope,
+             at_exception_type * const exceptionP) {
+/*----------------------------------------------------------------------------
+  Return a spline that best fits the points of curve *curveP, passing through
+  the endpoints of *curveP and having slope 'begSlope' at its beginning and
+  'endSlope' at its end (both are unit vectors).
+
+  Make it a cubic spline.
+-----------------------------------------------------------------------------*/
+    /* We already have the start and end points of the spline, so all we need
+       are the control points.  And we know in what direction each control
+       point is from its respective end point, so all we need to figure out is
+       its distance.  (The control point's distance from the end point is an
+       indication of how long the curve goes in its direction).
+
+       We call the distance from an end point to the associated control point
+       "alpha".
+
+       We want to find starting and ending alpha that minimize the
+       least-square error in approximating *curveP with the spline.
+
+       How we do that is a complete mystery to me, but the original author
+       said to see pp. 57-59 of the Phoenix thesis.  Whatever that is, I
+       haven't seen it.
+
+       In our expression of the math here, we use a struct with "beg" and
+       "end" members where the paper uses a matrix with "1" and "2"
+       subscripts, respectively.  A C array is a closer match to a math
+       matrix, but we think the struct is easier to read.
+
+       The B?(t) here corresponds to B_i^3(U_i) there.
+       The Bernstein polynomials of degree n are defined by
+       B_i^n(t) = { n \choose i } t^i (1-t)^{n-i}, i = 0..n
+    */
+    struct VectorBegEndPair tang;
+    spline_type spline;
+    struct Mat22 C;
+    struct Mat2  X;
+
+    tang.beg = begSlope; tang.end = endSlope;
+
+    computeCX(curveP, tang, &C, &X);
+
+    {
+        float const XCendDet  = X.beg * C.end.end - X.end * C.beg.end;
+        float const CbegXDet  = C.beg.beg * X.end - C.beg.end * X.beg;
+        float const CDet = C.beg.beg * C.end.end - C.end.beg * C.beg.end;
+
+        if (CDet == 0.0) {
+            LOG("zero determinant of C matrix");
+            at_exception_fatal(exceptionP, "zero determinant of C matrix");
+        } else {
+            /* See above for meaning of "alpha */
+            float const alphaBeg = XCendDet / CDet;
+            float const alphaEnd = CbegXDet / CDet;
+
+            BEG_POINT(spline) = CURVE_POINT(curveP, 0);
+            END_POINT(spline) = LAST_CURVE_POINT(curveP);
+            CONTROL1(spline) = vector_sumPoint(
+                BEG_POINT(spline), vector_scaled(tang.beg, alphaBeg));
+            CONTROL2(spline) = vector_sumPoint(
+                END_POINT(spline), vector_scaled(tang.end, alphaEnd));
+            SPLINE_DEGREE(spline) = CUBICTYPE;
+        }
     }
     return spline;
 }
@@ -1344,108 +1410,84 @@ logSplineFit(spline_type const spline) {
 
     if (log_file) {
         LOG ("    ");
-        print_spline (log_file, spline);
+        print_spline(log_file, spline);
     }
 }
 
 
 
-static vector_type
-findHalfTangentBeg(curve *      const curveP,
-                   unsigned int const tangentSurround) {
+static Vector
+findHalfTangent(LineEnd      const toWhichEnd,
+                Curve *      const curveP,
+                unsigned int const tangentSurround) {
 /*----------------------------------------------------------------------------
-  Find the slope in the vicinity of the beginning of the curve
-  *curveP.
-
-  To wit, this is the mean slope between the first point on the curve and
-  each of the 'tangentSurround' following points, up to half the curve.
+  Find the slope in the vicinity of one of the ends of the curve *curveP,
+  as specified by 'toWhichEnd'.
 
-  For example, if 'tangentSurround' is 3 and the curve is 10 points
-  long, we imagine a line through Point 0 and Point 1, another through
-  Point 0 and Point 2, and a third through Point 0 and Point 3.  We
-  return the mean of the slopes of those 3 lines.
------------------------------------------------------------------------------*/
-    float_coord const tangentPoint = CURVE_POINT(curveP, 0);
-    vector_type const zeroZero = { 0.0, 0.0 };
-    unsigned int const surround =
-        MIN(CURVE_LENGTH(curveP) / 2, tangentSurround);
-
-    unsigned int p;
-    vector_type sum;
-    vector_type mean;
-    unsigned int n;
-
-    for (p = 0, n = 0, sum = zeroZero; p < surround; ++p) {
-        unsigned int const thisIndex = p + 1;
-        float_coord  const thisPoint = CURVE_POINT(curveP, thisIndex);
-
-        if (epsilon_equal(thisPoint.x, tangentPoint.x) &&
-            epsilon_equal(thisPoint.y, tangentPoint.y) &&
-            epsilon_equal(thisPoint.z, tangentPoint.z)) {
-            /* It's the same point; can't compute a slope */
-        } else {
-            /* Perhaps we should weight the tangent from `thisPoint' by some
-               factor dependent on the distance from the tangent point.
-            */
-            sum = Vadd(sum, Pdirection(thisPoint, tangentPoint));
-            ++n;
-        }
-    }
-
-    if (n >= 1)
-        mean = Vmult_scalar(sum, 1.0 / n);
-    else {
-        mean.dx = 1.0;
-        mean.dy = 0.0;
-        mean.dz = 0.0;
-    }
+  To wit, this is the mean slope between the end point and each of the
+  'tangentSurround' adjacent points, up to half the curve.
 
-    return mean;
-}
+  For example, if 'toWhichEnd' is LINEEND_INIT and 'tangentSurround' is 3 and
+  the curve is 10 points long, we imagine a line through Point 0 and Point 1,
+  another through Point 0 and Point 2, and a third through Point 0 and Point
+  3.  We return the mean of the slopes of those 3 lines.
 
+  Don't consider points that are identical to the end point (as there could
+  be no slope between those points) -- they're part of the count, but don't
+  contribute to the slope.  If _all_ of the points to be considered are
+  identical to the end point, arbitrarily return a horizontal slope.
 
+  Return the slope as an unnormalized vector.  (I don't know if that was
+  intended by the designer, since it isn't sensible unless it's a
+  computational efficiency thing; it's just how I found the code).
 
-static vector_type
-findHalfTangentEnd(curve *      const curveP,
-                   unsigned int const tangentSurround) {
-/*----------------------------------------------------------------------------
-  Find the slope in the vicinity of the end of the curve
-  *curveP.
-
-  This is analogous to findHalfTangentBeg(), but at the other end of the
-  curve.
+  It is possible for the mean described above to be the zero vector, because
+  the mean of a vector pointing left and one pointing right is the zero
+  vector.  In that case, we use fewer "tangentSurround" points.
 -----------------------------------------------------------------------------*/
-    float_coord const tangentPoint =
-        CURVE_POINT(curveP, CURVE_LENGTH(curveP) - 1);
-    vector_type const zeroZero = { 0.0, 0.0 };
-    unsigned int const surround =
-        MIN(CURVE_LENGTH(curveP) / 2, tangentSurround);
-
-    unsigned int p;
-    vector_type sum;
-    vector_type mean;
-    unsigned int n;
-
-    for (p = 0, n = 0, sum = zeroZero; p < surround; ++p) {
-        unsigned int const thisIndex = CURVE_LENGTH(curveP) - 1 - p;
-        float_coord  const thisPoint = CURVE_POINT(curveP, thisIndex);
-
-        if (epsilon_equal(thisPoint.x, tangentPoint.x) &&
-            epsilon_equal(thisPoint.y, tangentPoint.y) &&
-            epsilon_equal(thisPoint.z, tangentPoint.z)) {
-            /* It's the same point; can't compute a slope */
-        } else {
-            sum = Vadd(sum, Pdirection(tangentPoint, thisPoint));
-            ++n;
+    Point  const tangentPoint =
+        CURVE_POINT(curveP,
+                    toWhichEnd == LINEEND_INIT ? 0 : CURVE_LENGTH(curveP) - 1);
+    Vector  const zeroZero = { 0.0, 0.0 };
+
+    unsigned int surroundCt;
+    bool         gotNonzero;
+    Vector  mean;
+
+    for (surroundCt = MIN(CURVE_LENGTH(curveP) / 2, tangentSurround),
+             gotNonzero = false;
+         !gotNonzero;
+         --surroundCt) {
+
+        unsigned int i;
+        Vector sum;
+        unsigned int n;
+
+        for (i = 0, n = 0, sum = zeroZero; i < surroundCt; ++i) {
+            unsigned int const thisIndex =
+                toWhichEnd == LINEEND_INIT ?
+                    i + 1 :  CURVE_LENGTH(curveP) - 1 - i;
+            Point const thisPoint = CURVE_POINT(curveP, thisIndex);
+
+            if (!point_equal(thisPoint, tangentPoint)) {
+                /* Perhaps we should weight the tangent from `thisPoint' by
+                   some factor dependent on the distance from the tangent
+                   point.
+                */
+                sum = vector_sum(sum, vector_pointDirection(thisPoint,
+                                                            tangentPoint));
+                ++n;
+            }
         }
-    }
+        mean = n > 0 ? vector_scaled(sum, 1.0 / n) : vector_horizontal();
 
-    if (n >= 1)
-        mean = Vmult_scalar(sum, 1.0 / n);
-    else {
-        mean.dx = 1.0;
-        mean.dy = 0.0;
-        mean.dz = 0.0;
+        if (vector_equal(mean, vector_zero())) {
+            /* We have points on multiple sides of the endpoint whose vectors
+               happen to add up to zero, which is not usable.
+            */
+            assert(surroundCt > 0);
+        } else
+            gotNonzero = true;
     }
 
     return mean;
@@ -1453,73 +1495,65 @@ findHalfTangentEnd(curve *      const curveP,
 
 
 
-static vector_type
-findHalfTangent(bool         const toStartPoint,
-                curve *      const curveP,
-                unsigned int const tangentSurround) {
-
-    if (toStartPoint)
-        return findHalfTangentBeg(curveP, tangentSurround);
-    else
-        return findHalfTangentEnd(curveP, tangentSurround);
-}
-
-
-
 static void
-findTangent(curve *       const curveP,
-            bool          const toStartPoint,
-            curve *       const adjacentCurveP,
-            unsigned int  const tangentSurroundArg,
-            vector_type * const tangentP) {
+findTangent(Curve *       const curveP,
+            LineEnd       const toWhichEnd,
+            Curve *       const adjacentCurveP,
+            unsigned int  const tangentSurround,
+            Vector *      const tangentP) {
 /*----------------------------------------------------------------------------
   Find an approximation to the slope of *curveP (i.e. slope of tangent
-  line) at an endpoint (the first point if 'toStartPoint' is true,
-  else the last).
-
-  If 'adjacentCurveP' is non-null, consider points on the adjacent
-  curve to *curveP.  The adjacent curve is *adjacentCurveP.  Adjacent
-  means the previous curve in the outline chain for the slope at the
-  start point ('toStartPoint' == true), the next curve otherwise.
-  If *curveP is cyclic, then it is its own adjacent curve.
+  line) at an endpoint (per 'toWhichEnd').
+
+  This approximation is the mean of the slopes between the end of the curve
+  and the 'tangentSurround' points leading up to it (but not more than one
+  point beyond the midpoint of the curve).  Note that the curve may loop.
+  Since there is no slope between two identical points, we ignore points that
+  are identical to the endpoint.  They count toward the limit; they just
+  aren't included in the result.  If none of the points to be considered are
+  distinct from the endpoint, we arbitrarily consider the curve to be
+  horizontal there.
+
+  If 'adjacentCurveP' is non-null, average this slope with the slope of the
+  other end of curve *adjacentCurveP, which we assume is adjacent.  Adjacent
+  means the previous curve in the outline chain for the slope at the start
+  point ('toWhichEnd' == LINEEND_BEG), the next curve otherwise.  If *curveP
+  is cyclic, then it is its own adjacent curve.
 
   It is important to compute an accurate approximation, because the
   control points that we eventually decide upon to fit the curve will
   be placed on the half-lines defined by the slopes and endpoints, and
   we never recompute the tangent after this.
 -----------------------------------------------------------------------------*/
-    vector_type slope;
-    unsigned int tangentSurround;
+    Vector const slopeThisCurve =
+        findHalfTangent(toWhichEnd, curveP, tangentSurround);
 
     LOG2("  tangent to %s of curve %lx: ",
-         toStartPoint ? "start" : "end", (unsigned long)curveP);
+         toWhichEnd == LINEEND_INIT ? "start" : "end", (unsigned long)curveP);
 
-    tangentSurround = tangentSurroundArg;  /* initial value */
-    do {
-        slope = findHalfTangent(toStartPoint, curveP, tangentSurround);
+    LOG3("(this curve half tangent (%.3f,%.3f,%.3f)) ",
+         slopeThisCurve.dx, slopeThisCurve.dy, slopeThisCurve.dz);
 
-        if (adjacentCurveP) {
-            vector_type const slopeAdj =
-                findHalfTangent(!toStartPoint, adjacentCurveP,
-                                tangentSurround);
+    if (adjacentCurveP) {
+        Vector const slopeAdjCurve =
+            findHalfTangent(otherEnd(toWhichEnd),
+                            adjacentCurveP,
+                            tangentSurround);
 
-            LOG3("(adjacent curve half tangent (%.3f,%.3f,%.3f)) ",
-                 slopeAdj.dx, slopeAdj.dy, slopeAdj.dz);
-            slope = Vmult_scalar(Vadd(slope, slopeAdj), 0.5);
-        }
-        --tangentSurround;
-    } while (slope.dx == 0.0 && slope.dy == 0.0);
-
-    *tangentP = slope;
+        LOG3("(adjacent curve half tangent (%.3f,%.3f,%.3f)) ",
+             slopeAdjCurve.dx, slopeAdjCurve.dy, slopeAdjCurve.dz);
+        *tangentP = vector_scaled(vector_sum(slopeThisCurve, slopeAdjCurve),
+                                  0.5);
+    } else
+        *tangentP = slopeThisCurve;
 
-    LOG3("(%.3f,%.3f,%.3f).\n",
-         tangentP->dx, tangentP->dy, tangentP->dz);
+    LOG3("(%.3f,%.3f,%.3f).\n", tangentP->dx, tangentP->dy, tangentP->dz);
 }
 
 
 
 static void
-findError(curve *             const curveP,
+findError(Curve *             const curveP,
           spline_type         const spline,
           float *             const errorP,
           unsigned int *      const worstPointP,
@@ -1547,10 +1581,10 @@ findError(curve *             const curveP,
     worstPoint = 0;
 
     for (thisPoint = 0; thisPoint < CURVE_LENGTH(curveP); ++thisPoint) {
-        float_coord const curvePoint = CURVE_POINT(curveP, thisPoint);
-        float const t = CURVE_T(curveP, thisPoint);
-        float_coord const splinePoint = evaluate_spline(spline, t);
-        float const thisError = distance(curvePoint, splinePoint);
+        Point const curvePoint  = CURVE_POINT(curveP, thisPoint);
+        float const t           = CURVE_DIST(curveP, thisPoint);
+        Point const splinePoint = evaluate_spline(spline, t);
+        float const thisError   = point_distance(curvePoint, splinePoint);
         if (thisError >= worstError) {
             worstPoint = thisPoint;
             worstError = thisError;
@@ -1578,56 +1612,12 @@ findError(curve *             const curveP,
 
 
 static void
-setInitialParameterValues(curve * const curveP) {
-/*----------------------------------------------------------------------------
-   Fill in the 't' values in *curveP.
-
-   The t value for point P on a curve is the distance P is along the
-   curve from the initial point, normalized so the entire curve is
-   length 1.0 (i.e. t of the initial point is 0.0; t of the final
-   point is 1.0).
-
-   There are a lot of curves that pass through the points indicated by
-   *curveP, but for practical computation of t, we just take the
-   piecewise linear locus that runs through all of them.  That means
-   we can just step through *curveP, adding up the distance from one
-   point to the next to get the t value for each point.
-
-   This is the "chord-length parameterization" method, which is
-   described in Plass & Stone.
------------------------------------------------------------------------------*/
-    unsigned int p;
-
-    LOG("\nAssigning initial t values:\n  ");
-
-    CURVE_T(curveP, 0) = 0.0;
-
-    for (p = 1; p < CURVE_LENGTH(curveP); ++p) {
-        float_coord const point      = CURVE_POINT(curveP, p);
-        float_coord const previous_p = CURVE_POINT(curveP, p - 1);
-        float const d = distance(point, previous_p);
-        CURVE_T(curveP, p) = CURVE_T(curveP, p - 1) + d;
-    }
-
-    assert(LAST_CURVE_T(curveP) != 0.0);
-
-    /* Normalize to a curve length of 1.0 */
-
-    for (p = 1; p < CURVE_LENGTH(curveP); ++p)
-        CURVE_T(curveP, p) = CURVE_T(curveP, p) / LAST_CURVE_T(curveP);
-
-    log_entire_curve(curveP);
-}
-
-
-
-static void
-subdivideCurve(curve *                   const curveP,
+subdivideCurve(Curve *                   const curveP,
                unsigned int              const subdivisionIndex,
                const fitting_opts_type * const fittingOptsP,
-               curve **                  const leftCurvePP,
-               curve **                  const rghtCurvePP,
-               vector_type *             const joinSlopeP) {
+               Curve **                  const leftCurvePP,
+               Curve **                  const rghtCurvePP,
+               Vector *                  const joinSlopeP) {
 /*----------------------------------------------------------------------------
   Split curve *curveP into two, at 'subdivisionIndex'.  (Actually,
   leave *curveP alone, but return as *leftCurvePP and *rghtCurvePP
@@ -1640,11 +1630,11 @@ subdivideCurve(curve *                   const curveP,
   To be precise, the point with sequence number 'subdivisionIndex'
   becomes the first pixel of the right-hand curve.
 -----------------------------------------------------------------------------*/
-    curve * leftCurveP;
-    curve * rghtCurveP;
+    Curve * leftCurveP;
+    Curve * rghtCurveP;
 
-    leftCurveP = new_curve();
-    rghtCurveP = new_curve();
+    leftCurveP = curve_new();
+    rghtCurveP = curve_new();
 
     LOG4("  Subdividing curve %lx into %lx and %lx at point #%u\n",
          (unsigned long)curveP,
@@ -1658,13 +1648,13 @@ subdivideCurve(curve *                   const curveP,
     CURVE_LENGTH(leftCurveP) = subdivisionIndex + 1;
     CURVE_LENGTH(rghtCurveP) = CURVE_LENGTH(curveP) - subdivisionIndex;
 
-    MALLOCARRAY_NOFAIL(leftCurveP->point_list, CURVE_LENGTH(leftCurveP));
-    memcpy(leftCurveP->point_list, &curveP->point_list[0],
-           CURVE_LENGTH(leftCurveP) * sizeof(curveP->point_list[0]));
+    MALLOCARRAY_NOFAIL(leftCurveP->pointList, CURVE_LENGTH(leftCurveP));
+    memcpy(leftCurveP->pointList, &curveP->pointList[0],
+           CURVE_LENGTH(leftCurveP) * sizeof(curveP->pointList[0]));
 
-    MALLOCARRAY_NOFAIL(rghtCurveP->point_list, CURVE_LENGTH(rghtCurveP));
-    memcpy(rghtCurveP->point_list, &curveP->point_list[subdivisionIndex],
-           CURVE_LENGTH(rghtCurveP) * sizeof(curveP->point_list[0]));
+    MALLOCARRAY_NOFAIL(rghtCurveP->pointList, CURVE_LENGTH(rghtCurveP));
+    memcpy(rghtCurveP->pointList, &curveP->pointList[subdivisionIndex],
+           CURVE_LENGTH(rghtCurveP) * sizeof(curveP->pointList[0]));
 
     /* We have to set up the two curves before finding the slope at
        the subdivision point.  The slope at that point must be the
@@ -1673,7 +1663,7 @@ subdivideCurve(curve *                   const curveP,
        point to compute the slope, hence we use adjacentCurveP.
     */
     findTangent(leftCurveP,
-                /* toStartPoint: */   false,
+                LINEEND_TERM,
                 /* adjacentCurveP: */ rghtCurveP,
                 fittingOptsP->tangent_surround, joinSlopeP);
 
@@ -1715,7 +1705,7 @@ leftRightConcat(const spline_list_type *  const leftSplineListP,
 
 
 static unsigned int
-divisionPoint(curve *      const curveP,
+divisionPoint(Curve *      const curveP,
               unsigned int const worstFitPoint) {
 /*----------------------------------------------------------------------------
    Return the sequence number of the point at which we should divide
@@ -1739,9 +1729,9 @@ divisionPoint(curve *      const curveP,
 
 
 static spline_list_type *
-divideAndFit(curve *                   const curveP,
-             vector_type               const begSlope,
-             vector_type               const endSlope,
+divideAndFit(Curve *                   const curveP,
+             Vector               const begSlope,
+             Vector               const endSlope,
              unsigned int              const subdivisionIndex,
              const fitting_opts_type * const fittingOptsP,
              at_exception_type *       const exceptionP) {
@@ -1757,11 +1747,11 @@ divideAndFit(curve *                   const curveP,
   Assume 'subdivisionIndex' leaves at least two pixels on each side.
 -----------------------------------------------------------------------------*/
     spline_list_type * retval;
-    curve * leftCurveP;
+    Curve * leftCurveP;
         /* The beginning (lower indexes) subcurve */
-    curve * rghtCurveP;
+    Curve * rghtCurveP;
         /* The other subcurve */
-    vector_type joinSlope;
+    Vector joinSlope;
         /* The slope of the end of the left subcurve and start of the right
            subcurve.
         */
@@ -1799,8 +1789,8 @@ divideAndFit(curve *                   const curveP,
         }
     }
 
-    free_curve(leftCurveP);
-    free_curve(rghtCurveP);
+    curve_free(leftCurveP);
+    curve_free(rghtCurveP);
 
     return retval;
 }
@@ -1808,9 +1798,9 @@ divideAndFit(curve *                   const curveP,
 
 
 static spline_list_type *
-fitWithLeastSquares(curve *                   const curveP,
-                    vector_type               const begSlope,
-                    vector_type               const endSlope,
+fitWithLeastSquares(Curve *                   const curveP,
+                    Vector               const begSlope,
+                    Vector               const endSlope,
                     const fitting_opts_type * const fittingOptsP,
                     at_exception_type *       const exceptionP) {
 /*----------------------------------------------------------------------------
@@ -1823,17 +1813,17 @@ fitWithLeastSquares(curve *                   const curveP,
 
     LOG("\nFitting with least squares:\n");
 
-    /* Phoenix reduces the number of points with a "linear spline
-       technique."  But for fitting letterforms, that is
-       inappropriate.  We want all the points we can get.
+    /* Phoenix reduces the number of points with a "linear spline technique."
+       But for fitting letterforms, that is inappropriate.  We want all the
+       points we can get.
     */
 
-    setInitialParameterValues(curveP);
+    curve_setDistance(curveP);
 
     if (CURVE_CYCLIC(curveP) && CURVE_LENGTH(curveP) < 4) {
         unsigned i;
         for (i = 0; i < CURVE_LENGTH(curveP); ++i) {
-            float_coord const point = CURVE_POINT(curveP, i);
+            Point const point = CURVE_POINT(curveP, i);
             fprintf(stderr, "point %u = (%f, %f)\n", i, point.x, point.y);
         }
     }
@@ -1855,7 +1845,7 @@ fitWithLeastSquares(curve *                   const curveP,
                see if the "curve" that was fit should really just be a
                straight line.
             */
-            if (spline_linear_enough(&spline, curveP, fittingOptsP)) {
+            if (splineLinearEnough(&spline, curveP, fittingOptsP)) {
                 SPLINE_DEGREE(spline) = LINEARTYPE;
                 LOG("Changed to line.\n");
             }
@@ -1883,9 +1873,9 @@ fitWithLeastSquares(curve *                   const curveP,
 
 
 static spline_list_type *
-fitCurve(curve *                   const curveP,
-         vector_type               const begSlope,
-         vector_type               const endSlope,
+fitCurve(Curve *                   const curveP,
+         Vector               const begSlope,
+         Vector               const endSlope,
          const fitting_opts_type * const fittingOptsP,
          at_exception_type *       const exceptionP) {
 /*----------------------------------------------------------------------------
@@ -1913,7 +1903,7 @@ fitCurve(curve *                   const curveP,
 
 
 static void
-fitCurves(curve_list_type           const curveList,
+fitCurves(CurveList                 const curveList,
           pixel                     const color,
           const fitting_opts_type * const fittingOptsP,
           spline_list_type *        const splinesP,
@@ -1932,19 +1922,19 @@ fitCurves(curve_list_type           const curveList,
          curveSeq < curveList.length && !at_exception_got_fatal(exceptionP);
          ++curveSeq) {
 
-        curve * const curveP = CURVE_LIST_ELT(curveList, curveSeq);
+        Curve * const curveP = CURVE_LIST_ELT(curveList, curveSeq);
 
-        vector_type begSlope, endSlope;
+        Vector begSlope, endSlope;
         spline_list_type * curveSplinesP;
 
         LOG2("\nFitting curve #%u (%lx):\n", curveSeq, (unsigned long)curveP);
 
         LOG("Finding tangents:\n");
-        findTangent(curveP, /* toStart */ true,
+        findTangent(curveP, LINEEND_INIT,
                     CURVE_CYCLIC(curveP) ? curveP : NULL,
                     fittingOptsP->tangent_surround,
                     &begSlope);
-        findTangent(curveP, /* toStart */ false,
+        findTangent(curveP, LINEEND_TERM,
                     CURVE_CYCLIC(curveP) ? curveP : NULL,
                     fittingOptsP->tangent_surround, &endSlope);
 
@@ -1961,7 +1951,7 @@ fitCurves(curve_list_type           const curveList,
                    back to curves, because they are in a list with other
                    curves.
                 */
-                change_bad_lines(curveSplinesP, fittingOptsP);
+                changeBadLines(curveSplinesP, fittingOptsP);
 
                 concat_spline_lists(&curveListSplines, *curveSplinesP);
                 free_spline_list(*curveSplinesP);
@@ -1995,7 +1985,7 @@ logFittedSplines(spline_list_type const curve_list_splines) {
 
 
 static void
-fitCurveList(curve_list_type     const curveList,
+fitCurveList(CurveList           const curveList,
              fitting_opts_type * const fittingOptsP,
              distance_map_type * const dist,
              pixel               const color,
@@ -2006,7 +1996,7 @@ fitCurveList(curve_list_type     const curveList,
   it.  CURVE_LIST represents a single closed paths, e.g., either the
   inside or outside outline of an `o'.
 -----------------------------------------------------------------------------*/
-    curve_type curve;
+    Curve * curveP;
     spline_list_type curveListSplines;
 
     removeKnees(curveList);
@@ -2031,9 +2021,9 @@ fitCurveList(curve_list_type     const curveList,
        and three points isn't enough to determine a spline.  Therefore,
        the fitting will fail.
     */
-    curve = CURVE_LIST_ELT(curveList, 0);
-    if (CURVE_CYCLIC(curve))
-        append_point(curve, CURVE_POINT(curve, 0));
+    curveP = CURVE_LIST_ELT(curveList, 0);
+    if (CURVE_CYCLIC(curveP))
+        curve_appendPoint(curveP, CURVE_POINT(curveP, 0));
 
     /* Finally, fit each curve in the list to a list of splines.  */
 
@@ -2048,7 +2038,7 @@ fitCurveList(curve_list_type     const curveList,
 
 
 static void
-fitCurvesToSplines(curve_list_array_type    const curveArray,
+fitCurvesToSplines(CurveListArray           const curveArray,
                    fitting_opts_type *      const fittingOptsP,
                    distance_map_type *      const dist,
                    unsigned short           const width,
@@ -2079,7 +2069,7 @@ fitCurvesToSplines(curve_list_array_type    const curveArray,
              !at_exception_got_fatal(exception) && !cancelled;
          ++splineListSeq) {
 
-        curve_list_type const curveList =
+        CurveList const curveList =
             CURVE_LIST_ARRAY_ELT(curveArray, splineListSeq);
 
         spline_list_type curveSplineList;
@@ -2120,14 +2110,14 @@ fit_outlines_to_splines(pixel_outline_list_type  const pixelOutlineList,
    Transform a list of pixels in the outlines of the original character to
    a list of spline lists fitted to those pixels.
 -----------------------------------------------------------------------------*/
-    curve_list_array_type const curveListArray =
+    CurveListArray const curveListArray =
         split_at_corners(pixelOutlineList, fittingOptsP, exception);
 
     fitCurvesToSplines(curveListArray, fittingOptsP, dist, width, height,
                        exception, notifyProgress, progressData,
                        testCancel, testcancelData, splineListArrayP);
 
-    free_curve_list_array(&curveListArray, notifyProgress, progressData);
+    curve_freeListArray(&curveListArray, notifyProgress, progressData);
 
     flush_log_output();
 }
diff --git a/converter/other/pamtosvg/fit.h b/converter/other/pamtosvg/fit.h
index 529da5c7..8c234f33 100644
--- a/converter/other/pamtosvg/fit.h
+++ b/converter/other/pamtosvg/fit.h
@@ -10,7 +10,7 @@
 #include "exception.h"
 
 /* See fit.c for descriptions of these variables, all of which can be
-   set using options. 
+   set using options.
 */
 typedef at_fitting_opts_type fitting_opts_type;
 
@@ -21,7 +21,7 @@ fit_outlines_to_splines(pixel_outline_list_type  const pixelOutlineList,
                         unsigned short           const width,
                         unsigned short           const height,
                         at_exception_type *      const exception,
-                        at_progress_func               notifyProgress, 
+                        at_progress_func               notifyProgress,
                         void *                   const progressData,
                         at_testcancel_func             testCancel,
                         void *                   const testcancelData,
diff --git a/converter/other/pamtosvg/output-svg.c b/converter/other/pamtosvg/output-svg.c
index 53a8d4fd..13ac5201 100644
--- a/converter/other/pamtosvg/output-svg.c
+++ b/converter/other/pamtosvg/output-svg.c
@@ -82,7 +82,7 @@ out_splines(FILE *                 const fileP,
                     (shape.centerline || splineList.open) ? "fill" : "stroke");
         }
         fprintf(fileP, "M%g %g",
-                START_POINT(first).x, height - START_POINT(first).y);
+                BEG_POINT(first).x, height - BEG_POINT(first).y);
 
         outSplineList(fileP, splineList, height);
 
diff --git a/converter/other/pamtosvg/pamtosvg.test b/converter/other/pamtosvg/pamtosvg.test
deleted file mode 100644
index 3217287e..00000000
--- a/converter/other/pamtosvg/pamtosvg.test
+++ /dev/null
@@ -1,8 +0,0 @@
-echo "Test 1.  Should print nothing"
-# This will print nothing if successful (diff will find no difference)
-ppmmake black 20 20 | ppmdraw -script="line 5 2 15 17" | ./pamtosvg | \
-  diff testline.svg -
-
-echo "Test 2.  Should print nothing"
-# This will print nothing if successful (diff will find no difference)
-./pamtosvg ../../../testgrid.pbm | diff testgrid.svg -
diff --git a/converter/other/pamtosvg/point.c b/converter/other/pamtosvg/point.c
new file mode 100644
index 00000000..0e10b6b6
--- /dev/null
+++ b/converter/other/pamtosvg/point.c
@@ -0,0 +1,90 @@
+#include <stdbool.h>
+#include <math.h>
+
+#include "epsilon.h"
+
+#include "point.h"
+
+
+
+/* Operations on points with real coordinates.  It is not orthogonal,
+   but more convenient, to have the subtraction operator return a
+   vector, and the addition operator return a point.
+*/
+
+
+
+Point
+point_make(float const x,
+           float const y,
+           float const z) {
+
+    Point retval;
+
+    retval.x = x;
+    retval.y = y;
+    retval.z = z;
+
+    return retval;
+}
+
+
+
+bool
+point_equal(Point const comparand,
+            Point const comparator) {
+
+    return
+        epsilon_equal(comparand.x, comparator.x)
+        &&
+        epsilon_equal(comparand.y, comparator.y)
+        &&
+        epsilon_equal(comparand.z, comparator.z)
+        ;
+}
+
+
+
+Point
+point_sum(Point const coord1,
+          Point const coord2) {
+
+    Point retval;
+
+    retval.x = coord1.x + coord2.x;
+    retval.y = coord1.y + coord2.y;
+    retval.z = coord1.z + coord2.z;
+
+    return retval;
+}
+
+
+
+Point
+point_scaled(Point const coord,
+             float const r) {
+
+    Point retval;
+
+    retval.x = coord.x * r;
+    retval.y = coord.y * r;
+    retval.z = coord.z * r;
+
+    return retval;
+}
+
+
+
+float
+point_distance(Point const p1,
+               Point const p2) {
+/*----------------------------------------------------------------------------
+  Return the Euclidean distance between 'p1' and 'p2'.
+-----------------------------------------------------------------------------*/
+    float const x = p1.x - p2.x, y = p1.y - p2.y, z = p1.z - p2.z;
+
+    return (float) sqrt(SQR(x) + SQR(y) + SQR(z));
+}
+
+
+
diff --git a/converter/other/pamtosvg/point.h b/converter/other/pamtosvg/point.h
index 037ec8a0..0346f301 100644
--- a/converter/other/pamtosvg/point.h
+++ b/converter/other/pamtosvg/point.h
@@ -1,8 +1,31 @@
 #ifndef POINT_H_INCLUDED
 #define POINT_H_INCLUDED
 
+#include <stdbool.h>
+
 typedef struct {
   float x, y, z;
-} float_coord;
+} Point;
+
+Point
+point_make(float const x,
+           float const y,
+           float const z);
+
+bool
+point_equal(Point const comparand,
+            Point const comparator);
+
+Point
+point_sum(Point const coord1,
+          Point const coord2);
+
+Point
+point_scaled(Point const coord,
+             float const r);
+
+float
+point_distance(Point const p1,
+               Point const p2);
 
 #endif
diff --git a/converter/other/pamtosvg/spline.c b/converter/other/pamtosvg/spline.c
index 61167ec4..6d867131 100644
--- a/converter/other/pamtosvg/spline.c
+++ b/converter/other/pamtosvg/spline.c
@@ -18,15 +18,15 @@ print_spline (FILE *f, spline_type s)
 
   if (SPLINE_DEGREE (s) == LINEARTYPE)
     fprintf (f, "(%.3f,%.3f)--(%.3f,%.3f).\n",
-                START_POINT (s).x, START_POINT (s).y,
+                BEG_POINT (s).x, BEG_POINT (s).y,
                 END_POINT (s).x, END_POINT (s).y);
 
   else if (SPLINE_DEGREE (s) == CUBICTYPE)
     fprintf (f, "(%.3f,%.3f)..ctrls(%.3f,%.3f)&(%.3f,%.3f)..(%.3f,%.3f).\n",
-                START_POINT (s).x, START_POINT (s).y,
-                CONTROL1 (s).x, CONTROL1 (s).y,
-                CONTROL2 (s).x, CONTROL2 (s).y,
-                END_POINT (s).x, END_POINT (s).y);
+             BEG_POINT (s).x, BEG_POINT (s).y,
+             CONTROL1  (s).x, CONTROL1  (s).y,
+             CONTROL2  (s).x, CONTROL2  (s).y,
+             END_POINT (s).x, END_POINT (s).y);
 }
 
 
@@ -34,7 +34,7 @@ print_spline (FILE *f, spline_type s)
    of de Casteljau's algorithm.  See Schneider's thesis, p.37.
    The variable names are taken from there.  */
 
-float_coord
+Point
 evaluate_spline (spline_type s, float t)
 {
   spline_type V[4];    /* We need degree+1 splines, but assert degree <= 3.  */
@@ -52,9 +52,9 @@ evaluate_spline (spline_type s, float t)
   for (j = 1; j <= degree; j++)
     for (i = 0; i <= degree - j; i++)
       {
-        float_coord t1 = Pmult_scalar (V[j - 1].v[i], one_minus_t);
-        float_coord t2 = Pmult_scalar (V[j - 1].v[i + 1], t);
-        float_coord temp = Padd (t1, t2);
+        Point t1 = point_scaled(V[j - 1].v[i], one_minus_t);
+        Point t2 = point_scaled(V[j - 1].v[i + 1], t);
+        Point temp = point_sum(t1, t2);
         V[j].v[i].x = temp.x;
         V[j].v[i].y = temp.y;
         V[j].v[i].z = temp.z;
@@ -76,7 +76,7 @@ new_spline_list (void)
   return answer;
 }
 
-spline_list_type 
+spline_list_type
 empty_spline_list (void)
 {
   spline_list_type answer;
@@ -192,4 +192,3 @@ append_spline_list (spline_list_array_type *l, spline_list_type s)
                       SPLINE_LIST_ARRAY_LENGTH(*l));
   LAST_SPLINE_LIST_ARRAY_ELT (*l) = s;
 }
-
diff --git a/converter/other/pamtosvg/spline.h b/converter/other/pamtosvg/spline.h
index 96ceab4e..cfdce248 100644
--- a/converter/other/pamtosvg/spline.h
+++ b/converter/other/pamtosvg/spline.h
@@ -18,20 +18,19 @@ typedef at_spline_type spline_type;
 #define ELLIPSETYPE         AT_ELLIPSETYPE
 #define CIRCLETYPE          AT_CIRCLETYPE
 
-#define START_POINT(spl)        ((spl).v[0])
+#define BEG_POINT(spl)          ((spl).v[0])
 #define CONTROL1(spl)           ((spl).v[1])
 #define CONTROL2(spl)           ((spl).v[2])
-#define BEG_POINT(spl)          ((spl).v[0])
 #define END_POINT(spl)          ((spl).v[3])
 #define SPLINE_DEGREE(spl)      ((spl).degree)
 #define SPLINE_LINEARITY(spl)   ((spl).linearity)
 
 #ifndef _IMPORTING
 /* Print a spline on the given file.  */
-extern void print_spline (FILE *, spline_type);
+void print_spline (FILE *, spline_type);
 
 /* Evaluate SPLINE at the given T value.  */
-extern float_coord evaluate_spline (spline_type spline, float t);
+Point evaluate_spline (spline_type spline, float t);
 #endif
 
 /* Each outline in a character is typically represented by many
diff --git a/converter/other/pamtosvg/vector.c b/converter/other/pamtosvg/vector.c
index 771e5f27..8972f4a5 100644
--- a/converter/other/pamtosvg/vector.c
+++ b/converter/other/pamtosvg/vector.c
@@ -10,17 +10,41 @@
 
 #include "vector.h"
 #include "message.h"
-#include "epsilon-equal.h"
+#include "epsilon.h"
 
-static float acos_d (float, at_exception_type * excep);
+static float
+acosD(float               const v,
+      at_exception_type * const excepP) {
+
+    float vAdj;
+    float a;
+    float retval;
+
+    if (epsilon_equal(v, 1.0))
+        vAdj = 1.0;
+    else if (epsilon_equal(v, -1.0))
+        vAdj = -1.0;
+    else
+        vAdj = v;
+
+    errno = 0;
+    a = acos(vAdj);
+    if (errno == ERANGE || errno == EDOM) {
+        at_exception_fatal(excepP, strerror(errno));
+        retval = 0.0;
+    } else
+        retval = a * 180.0 / M_PI;
+
+    return retval;
+}
 
 
-/* Given the point COORD, return the corresponding vector.  */
 
-vector_type
-make_vector(float_coord const c) {
+Vector
+vector_fromPoint(Point const c) {
+/* Vector corresponding to point 'c', taken as a vector from the origin.  */
 
-    vector_type v;
+    Vector v;
 
     v.dx = c.x;
     v.dy = c.y;
@@ -31,12 +55,28 @@ make_vector(float_coord const c) {
 
 
 
+Vector
+vector_fromTwoPoints(Point const c1,
+                     Point const c2) {
+
+    Vector retval;
+
+    retval.dx = c1.x - c2.x;
+    retval.dy = c1.y - c2.y;
+    retval.dz = c1.z - c2.z;
+
+    return retval;
+}
+
+
+
 /* And the converse: given a vector, return the corresponding point.  */
 
-float_coord
-vector_to_point(vector_type const v) {
+Point
+vector_toPoint_point(Vector const v) {
+/* vector as a point, i.e., a displacement from the origin.  */
 
-    float_coord coord;
+    Point coord;
 
     coord.x = v.dx;
     coord.y = v.dy;
@@ -48,18 +88,18 @@ vector_to_point(vector_type const v) {
 
 
 float
-magnitude(vector_type const v) {
+vector_magnitude(Vector const v) {
 
     return sqrt(SQR(v.dx) + SQR(v.dy) + SQR(v.dz));
 }
 
 
 
-vector_type
-normalize(vector_type const v) {
+Vector
+vector_normalized(Vector const v) {
 
-    vector_type new_v;
-    float const m = magnitude(v);
+    Vector new_v;
+    float const m = vector_magnitude(v);
 
     if (m > 0.0) {
         new_v.dx = v.dx / m;
@@ -70,221 +110,192 @@ normalize(vector_type const v) {
         new_v.dy = v.dy;
         new_v.dz = v.dz;
     }
-    
+
     return new_v;
 }
 
 
 
-vector_type
-Vadd(vector_type const v1,
-     vector_type const v2) {
+Vector
+vector_sum(Vector const addend,
+           Vector const adder) {
 
-    vector_type new_v;
+    Vector retval;
 
-    new_v.dx = v1.dx + v2.dx;
-    new_v.dy = v1.dy + v2.dy;
-    new_v.dz = v1.dz + v2.dz;
+    retval.dx = addend.dx + adder.dx;
+    retval.dy = addend.dy + adder.dy;
+    retval.dz = addend.dz + adder.dz;
 
-    return new_v;
+    return retval;
 }
 
 
 
 float
-Vdot(vector_type const v1,
-     vector_type const v2) {
+vector_dotProduct(Vector const v1,
+                  Vector const v2) {
 
     return v1.dx * v2.dx + v1.dy * v2.dy + v1.dz * v2.dz;
 }
 
 
 
-vector_type
-Vmult_scalar(vector_type const v,
-             float       const r) {
+Vector
+vector_scaled(Vector const v,
+              float  const r) {
 
-    vector_type new_v;
+    Vector retval;
 
-    new_v.dx = v.dx * r;
-    new_v.dy = v.dy * r;
-    new_v.dz = v.dz * r;
+    retval.dx = v.dx * r;
+    retval.dy = v.dy * r;
+    retval.dz = v.dz * r;
 
-    return new_v;
+    return retval;
 }
 
 
 
-/* Given the IN_VECTOR and OUT_VECTOR, return the angle between them in
-   degrees, in the range zero to 180.
-*/
-
 float
-Vangle(vector_type         const in_vector, 
-       vector_type         const out_vector,
-       at_exception_type * const exP) {
-
-    vector_type const v1 = normalize(in_vector);
-    vector_type const v2 = normalize(out_vector);
-
-    return acos_d(Vdot(v2, v1), exP);
-}
-
+vector_angle(Vector              const inVector,
+             Vector              const outVector,
+             at_exception_type * const exP) {
 
+/* The angle between 'inVector' and 'outVector' in degrees, in the range zero
+   to 180.
+*/
 
-float_coord
-Vadd_point(float_coord const c,
-           vector_type const v) {
-
-    float_coord new_c;
-
-    new_c.x = c.x + v.dx;
-    new_c.y = c.y + v.dy;
-    new_c.z = c.z + v.dz;
+    Vector const v1 = vector_normalized(inVector);
+    Vector const v2 = vector_normalized(outVector);
 
-    return new_c;
+    return acosD(vector_dotProduct(v2, v1), exP);
 }
 
 
 
-float_coord
-Vsubtract_point(float_coord const c,
-                vector_type const v) {
+Point
+vector_sumPoint(Point const c,
+                Vector      const v) {
 
-    float_coord new_c;
+    Point retval;
 
-    new_c.x = c.x - v.dx;
-    new_c.y = c.y - v.dy;
-    new_c.z = c.z - v.dz;
+    retval.x = c.x + v.dx;
+    retval.y = c.y + v.dy;
+    retval.z = c.z + v.dz;
 
-    return new_c;
+    return retval;
 }
 
 
 
-pm_pixelcoord
-Vadd_int_point(pm_pixelcoord const c,
-               vector_type   const v) {
+Point
+vector_diffPoint(Point  const c,
+                 Vector const v) {
+
+    Point retval;
 
-    pm_pixelcoord a;
+    retval.x = c.x - v.dx;
+    retval.y = c.y - v.dy;
+    retval.z = c.z - v.dz;
 
-    a.col = ROUND ((float) c.col + v.dx);
-    a.row = ROUND ((float) c.row + v.dy);
-    
-    return a;
+    return retval;
 }
 
 
 
-vector_type
-Vabs(vector_type const v) {
+Vector
+vector_IPointDiff(pm_pixelcoord const coord1,
+                  pm_pixelcoord const coord2) {
 
-    vector_type new_v;
+    Vector retval;
 
-    new_v.dx = (float) fabs (v.dx);
-    new_v.dy = (float) fabs (v.dy);
-    new_v.dz = (float) fabs (v.dz);
+    retval.dx = (int) (coord1.col - coord2.col);
+    retval.dy = (int) (coord1.row - coord2.row);
+    retval.dz = 0.0;
 
-    return new_v;
+    return retval;
 }
 
 
 
-/* Operations on points.  */
+pm_pixelcoord
+vector_sumIntPoint(pm_pixelcoord const c,
+                   Vector        const v) {
 
-float_coord
-Padd(float_coord const coord1,
-     float_coord const coord2) {
+/* This returns the rounded sum.  */
 
-    float_coord sum;
+    pm_pixelcoord retval;
 
-    sum.x = coord1.x + coord2.x;
-    sum.y = coord1.y + coord2.y;
-    sum.z = coord1.z + coord2.z;
+    retval.col = ROUND ((float) c.col + v.dx);
+    retval.row = ROUND ((float) c.row + v.dy);
 
-    return sum;
+    return retval;
 }
 
 
 
-float_coord
-Pmult_scalar(float_coord const coord,
-             float       const r) {
+Vector
+vector_abs(Vector const v) {
 
-    float_coord answer;
+/* First-quadrant mirror of 'v' (both components unsigned) */
 
-    answer.x = coord.x * r;
-    answer.y = coord.y * r;
-    answer.z = coord.z * r;
+    Vector retval;
 
-    return answer;
+    retval.dx = (float) fabs (v.dx);
+    retval.dy = (float) fabs (v.dy);
+    retval.dz = (float) fabs (v.dz);
+
+    return retval;
 }
 
 
 
-vector_type
-Psubtract(float_coord const c1,
-          float_coord const c2) {
+Vector
+vector_pointDirection(Point const final,
+                      Point const initial) {
 
-    vector_type v;
+    return vector_normalized(vector_fromTwoPoints(final, initial));
+}
 
-    v.dx = c1.x - c2.x;
-    v.dy = c1.y - c2.y;
-    v.dz = c1.z - c2.z;
 
-    return v;
-}
 
+Vector
+vector_horizontal(void) {
 
+    Vector retval;
 
-vector_type
-Pdirection(float_coord const final,
-           float_coord const initial) {
+    retval.dx = 1.0;
+    retval.dy = 0.0;
+    retval.dz = 0.0;
 
-    return normalize(Psubtract(final, initial));
+    return retval;
 }
 
 
+Vector
+vector_zero(void) {
 
-/* Operations on integer points.  */
-
-vector_type
-IPsubtract(pm_pixelcoord const coord1,
-           pm_pixelcoord const coord2) {
+    Vector retval;
 
-    vector_type v;
+    retval.dx = 0.0;
+    retval.dy = 0.0;
+    retval.dz = 0.0;
 
-    v.dx = (int) (coord1.col - coord2.col);
-    v.dy = (int) (coord1.row - coord2.row);
-    v.dz = 0.0;
-    
-    return v;
+    return retval;
 }
 
 
+bool
+vector_equal(Vector const comparand,
+             Vector const comparator) {
 
-static float
-acos_d(float               const v,
-       at_exception_type * const excepP) {
-
-    float vAdj;
-    float a;
-    float retval;
+    return
+        epsilon_equal(comparand.dx, comparator.dx)
+        &&
+        epsilon_equal(comparand.dy, comparator.dy)
+        &&
+        epsilon_equal(comparand.dz, comparator.dz)
+        ;
+}
 
-    if (epsilon_equal(v, 1.0))
-        vAdj = 1.0;
-    else if (epsilon_equal(v, -1.0))
-        vAdj = -1.0;
-    else
-        vAdj = v;
 
-    errno = 0;
-    a = acos(vAdj);
-    if (errno == ERANGE || errno == EDOM) {
-        at_exception_fatal(excepP, strerror(errno));
-        retval = 0.0;
-    } else
-        retval = a * 180.0 / M_PI;
 
-    return retval;
-}
diff --git a/converter/other/pamtosvg/vector.h b/converter/other/pamtosvg/vector.h
index b5c85c38..65364c82 100644
--- a/converter/other/pamtosvg/vector.h
+++ b/converter/other/pamtosvg/vector.h
@@ -11,93 +11,79 @@
 typedef struct
 {
   float dx, dy, dz;
-} vector_type;
+} Vector;
 
 
-/* Consider a point as a vector from the origin.  */
-vector_type
-make_vector(float_coord const);
+Vector
+vector_fromPoint(Point const c);
 
-/* And a vector as a point, i.e., a displacement from the origin.  */
-float_coord
-vector_to_point(vector_type const);
+Vector
+vector_fromTwoPoints(Point const c1,
+                     Point const c2);
+
+Point
+vector_toPoint_point(Vector const v);
 
 
 /* Definitions for these common operations can be found in any decent
-   linear algebra book, and most calculus books.  */
+   linear algebra book, and most calculus books.
+*/
 
 float
-magnitude(vector_type const);
+vector_magnitude(Vector const v);
 
-vector_type
-normalize(vector_type const);
+Vector
+vector_normalized(Vector const v);
 
-vector_type
-Vadd(vector_type const,
-     vector_type const);
+Vector
+vector_sum(Vector const addend,
+           Vector const adder);
 
 float
-Vdot(vector_type const,
-     vector_type const);
+vector_dotProduct(Vector const v1,
+                  Vector const v2);
 
-vector_type
-Vmult_scalar(vector_type const,
-             float       const);
+Vector
+vector_scaled(Vector const v,
+              float  const r);
 
 float
-Vangle(vector_type         const in,
-       vector_type         const out,
-       at_exception_type * const exP);
-
-/* These operations could have been named `P..._vector' just as well as
-   V..._point, so we may as well allow both names.  */
-
-#define Padd_vector Vadd_point
-
-float_coord
-Vadd_point(float_coord const,
-           vector_type const);
+vector_angle(Vector              const inVector,
+             Vector              const outVector,
+             at_exception_type * const exP);
 
-#define Psubtract_vector Vsubtract_point
+Point
+vector_sumPoint(Point  const c,
+                Vector const v);
 
-float_coord
-Vsubtract_point(float_coord const,
-                vector_type const);
-
-vector_type
-Pdirection(float_coord const final,
-           float_coord const initial);
-
-/* This returns the rounded sum.  */
-#define IPadd_vector Vadd_int_point
+Point
+vector_diffPoint(Point  const c,
+                 Vector const v);
 
 pm_pixelcoord
-Vadd_int_point(pm_pixelcoord const c,
-               vector_type   const v);
+vector_sumIntPoint(pm_pixelcoord const c,
+                   Vector        const v);
+
+Vector
+vector_abs(Vector const v);
 
-/* Take the absolute value of both components.  */
-vector_type
-Vabs(vector_type const);
+Vector
+vector_pointDirection(Point const final,
+                      Point const initial);
 
-/* Operations on points with real coordinates.  It is not orthogonal,
-   but more convenient, to have the subtraction operator return a
-   vector, and the addition operator return a point.  */
-vector_type
-Psubtract(float_coord const,
-          float_coord const);
 
-vector_type
-IPsubtract(pm_pixelcoord const coord1,
-           pm_pixelcoord const coord2);
+Vector
+vector_IPointDiff(pm_pixelcoord const coord1,
+                  pm_pixelcoord const coord2);
 
-/* These are heavily used in spline fitting.  */
+Vector
+vector_horizontal(void);
 
-float_coord
-Padd(float_coord const,
-     float_coord const);
+Vector
+vector_zero(void);
 
-float_coord
-Pmult_scalar(float_coord const,
-             float       const);
+bool
+vector_equal(Vector const comparand,
+             Vector const comparator);
 
 #endif
diff --git a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c
index 817fb5b3..44d8cbc2 100644
--- a/converter/other/pbmtopgm.c
+++ b/converter/other/pbmtopgm.c
@@ -9,85 +9,118 @@
 #include "nstring.h"
 #include "pgm.h"
 
-int
-main(int argc, char *argv[]) {
 
-    gray *outrow, maxval;
-    int right, left, down, up;
-    bit **inbits;
-    int rows, cols;
-    FILE *ifd;
-    int row;
-    unsigned int width, height;
-    const char * const usage = "<w> <h> [pbmfile]";
-    const char * error; /* error message of pm_string_to_uint */
 
-    pgm_init( &argc, argv );
+struct CmdlineInfo {
+    unsigned int convCols;
+    unsigned int convRows;
+    const char * inputFileName;
+};
+
+
+
+static void
+parseCommandLine(int                  const argc,
+                 const char **        const argv,
+                 struct CmdlineInfo * const cmdlineP) {
+
+    const char * error; /* error message from pm_string_to_uint */
+
+    if (argc-1 < 2)
+        pm_error("Insufficient arguments (%d).  Need width and height "
+                 "of convolution kernel, in pixels", argc-1);
+    else {
+        pm_string_to_uint(argv[1], &cmdlineP->convCols, &error);
+        if (error)
+            pm_error("Invalid convolution kernel width argument.  %s", error);
+
+        pm_string_to_uint(argv[2], &cmdlineP->convRows, &error);
+        if (error)
+            pm_error("Invalid convolution kernel height argument. %s", error);
+        if (cmdlineP->convCols < 1 || cmdlineP->convRows < 1)
+            pm_error("convolution kernel width and height must be > 0");
+
+        if (argc-1 >= 3)
+            cmdlineP->inputFileName = argv[3];
+        else {
+            cmdlineP->inputFileName = "-";
+
+            if (argc-1 > 3)
+                pm_error("Too many arguments (%d).  The most possible are "
+                         "convolution kernel width and height "
+                         "and input file name", argc-1);
+        }
+    }
+}
+
+
 
-    if (argc > 4 || argc < 3)
-        pm_usage(usage);
+int
+main(int argc, const char ** argv) {
 
-    pm_string_to_uint(argv[1], &width, &error);
-    if (error)
-        pm_error("Invalid width argument: %s", error);
-    pm_string_to_uint(argv[2], &height, &error);
-    if (error)
-        pm_error("Invalid height argument: %s", error);
-    if (width < 1 || height < 1)
-        pm_error("width and height must be > 0");
+    struct CmdlineInfo cmdline;
+    gray * outrow;
+    gray maxval;
+    unsigned int right, left, down, up;
+    bit ** inbits;
+    int rows, cols;
+    FILE * ifP;
+    unsigned int row;
 
-    if (argc == 4)
-        ifd = pm_openr(argv[3]);
-    else
-        ifd = stdin ;
+    pm_proginit(&argc, argv);
 
-    inbits = pbm_readpbm(ifd, &cols, &rows) ;
+    parseCommandLine(argc, argv, &cmdline);
 
-    if (width > cols)
-        pm_error("You specified a sample width (%u columns) which is greater "
-                 "than the image width (%u columns)", height, rows);
-    if (height > rows)
-        pm_error("You specified a sample height (%u rows) which is greater "
-                 "than the image height (%u rows)", height, rows);
-    if (width > INT_MAX / height)
-        /* prevent overflow of "value" below */
-        pm_error("sample area (%u columns %u rows) too large",
-                 width, height);
+    ifP = pm_openr(cmdline.inputFileName);
 
-    left = width  / 2;  right = width  - left;
-    up   = height / 2;  down  = height - up;
+    inbits = pbm_readpbm(ifP, &cols, &rows);
 
+    if (cmdline.convCols > cols)
+        pm_error("You specified a convolution kernel width (%u columns) "
+                 "which is greater than the image width (%u columns)",
+                 cmdline.convCols, cols);
+    if (cmdline.convRows > rows)
+        pm_error("You specified a convolution kernel height (%u rows) "
+                 "which is greater than the image height (%u rows)",
+                 cmdline.convRows, rows);
 
+    left = cmdline.convCols / 2;  right = cmdline.convCols - left;
+    up   = cmdline.convRows / 2;  down  = cmdline.convRows - up;
 
     outrow = pgm_allocrow(cols) ;
-    maxval = MIN(PGM_OVERALLMAXVAL, width*height);
+    maxval = MIN(PGM_OVERALLMAXVAL, cmdline.convCols * cmdline.convRows);
     pgm_writepgminit(stdout, cols, rows, maxval, 0) ;
 
-    for (row = 0; row < rows; row++) {
-        int const t = (row > up) ? (row-up) : 0;
-        int const b = (row+down < rows) ? (row+down) : rows;
-        int const onv = height - (t-row+up) - (row+down-b);
+    for (row = 0; row < rows; ++row) {
+        unsigned int const t = (row > up) ? (row - up) : 0;
+        unsigned int const b = (row + down < rows) ? (row + down) : rows;
+        unsigned int const actualConvRows =
+            cmdline.convRows - (t - row + up) - (row + down - b);
         unsigned int col;
-        for (col = 0; col < cols; col++) {
-            int const l = (col > left) ? (col-left) : 0;
-            int const r = (col+right < cols) ? (col+right) : cols;
-            int const onh = width - (l-col+left) - (col+right-r);
-            int value;  /* See above */
-            int x;
-
-            value = 0;  /* initial value */
-
-            for (x = l; x < r; ++x) {
-                int y;
+        for (col = 0; col < cols; ++col) {
+            unsigned int const l = (col > left) ? (col - left) : 0;
+            unsigned int const r = (col + right < cols) ? (col + right) : cols;
+            unsigned int const actualConvCols =
+                cmdline.convCols - (l - col + left) - (col + right - r);
+            unsigned int value;
+            unsigned int x;
+
+            for (x = l, value = 0; x < r; ++x) {
+                unsigned int y;
                 for (y = t; y < b; ++y)
                     if (inbits[y][x] == PBM_WHITE)
                         ++value;
             }
-            outrow[col] = (gray) ((double) maxval*value/(onh*onv));
+            {
+                unsigned int const convKernelArea =
+                    actualConvRows * actualConvCols;
+                outrow[col] = (gray) (((double) value/convKernelArea)*maxval);
+            }
         }
         pgm_writepgmrow(stdout, outrow, cols, maxval, 0) ;
     }
-    pm_close(ifd);
+    pbm_freearray(inbits, rows);
+    pm_close(ifP);
 
     return 0;
 }
diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c
index e3458319..1a7aa22c 100644
--- a/converter/other/pnmtojpeg.c
+++ b/converter/other/pnmtojpeg.c
@@ -21,6 +21,7 @@
 #define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */
 
 #include <ctype.h>		/* to declare isdigit(), etc. */
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -39,11 +40,11 @@
 
 #define EXIT_WARNING 2   /* Goes with EXIT_SUCCESS, EXIT_FAILURE in stdlib.h */
 
-enum restart_unit {RESTART_MCU, RESTART_ROW, RESTART_NONE};
-enum density_unit {DEN_UNSPECIFIED, DEN_DOTS_PER_INCH, DEN_DOTS_PER_CM};
+enum RestartUnit {RESTART_MCU, RESTART_ROW, RESTART_NONE};
+enum DensityUnit {DEN_UNSPECIFIED, DEN_DOTS_PER_INCH, DEN_DOTS_PER_CM};
 
-struct density {
-    enum density_unit unit;
+struct Density {
+    enum DensityUnit unit;
         /* The units of density for 'horiz', 'vert' */
     unsigned short horiz;  /* Not 0 */
         /* Horizontal density, in units specified by 'unit' */
@@ -51,92 +52,93 @@ struct density {
         /* Same as 'horiz', but vertical */
 };
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
      */
-    char *input_filespec;
-    unsigned int verbose;
-    unsigned int quality;
-    unsigned int force_baseline;
-    unsigned int progressive;
-    unsigned int arith_code;
-    J_DCT_METHOD dct_method;
-    unsigned int grayscale;
-    unsigned int rgb;
-    long int max_memory_to_use;
-    unsigned int trace_level;
-    char *qslots;
-    char *qtablefile;
-    char *sample;
-    char *scans;
-    int smoothing_factor;
-    unsigned int optimize;
-    unsigned int restart_value;
-    enum restart_unit restart_unit;
-    char *restart;
-    char *comment;              /* NULL if none */
-    const char *exif_filespec;  /* NULL if none */
-    unsigned int density_spec;
+    char *           inputFileNm;
+    unsigned int     verbose;
+    unsigned int     quality;
+    unsigned int     baseline;
+    unsigned int     progressive;
+    unsigned int     arithmetic;
+    J_DCT_METHOD     dctMethod;
+    unsigned int     grayscale;
+    unsigned int     rgb;
+    long int         maxMemoryToUse;
+    unsigned int     tracelevel;
+    char *           qslots;
+    char *           qtablefile;
+    char *           sample;
+    char *           scans;
+    int              smooth;
+    unsigned int     optimize;
+    unsigned int     restartValue;
+    enum RestartUnit restartUnit;
+    char *           restart;
+    char *           comment;            /* NULL if none */
+    const char *     exif;               /* NULL if none */
+    unsigned int     densitySpec;
         /* boolean: JFIF should specify a density.  If false, 'density'
            is undefined.
         */
-    struct density density;
+    struct Density density;
 };
 
 static void
-interpret_maxmemory (const char * const maxmemory,
-                     long int * const max_memory_to_use_p) {
+interpretMaxmemory (const char * const maxmemory,
+                    long int *   const maxMemoryToUseP) {
     long int lval;
     char ch;
 
     if (maxmemory == NULL) {
-        *max_memory_to_use_p = -1;  /* unspecified */
+        *maxMemoryToUseP = -1;  /* unspecified */
     } else if (sscanf(maxmemory, "%ld%c", &lval, &ch) < 1) {
         pm_error("Invalid value for --maxmemory option: '%s'.", maxmemory);
         exit(EXIT_FAILURE);
     } else {
         if (ch == 'm' || ch == 'M') lval *= 1000L;
-        *max_memory_to_use_p = lval * 1000L;
+        *maxMemoryToUseP = lval * 1000L;
     }
 }
 
 
 
 static void
-interpret_restart(const char * const restart,
-                  unsigned int * const restart_value_p,
-                  enum restart_unit * const restart_unit_p) {
+interpretRestart(const char *       const restartOpt,
+                 unsigned int *     const restartValueP,
+                 enum RestartUnit * const restartUnitP) {
 /*----------------------------------------------------------------------------
    Interpret the restart command line option.  Return values suitable
    for plugging into a jpeg_compress_struct to control compression.
 -----------------------------------------------------------------------------*/
-    if (restart == NULL) {
+    if (restartOpt == NULL) {
         /* No --restart option.  Set default */
-        *restart_unit_p = RESTART_NONE;
+        *restartUnitP = RESTART_NONE;
     } else {
         /* Restart interval in MCU rows (or in MCUs with 'b'). */
         long lval;
         char ch;
         unsigned int matches;
 
-        matches= sscanf(restart, "%ld%c", &lval, &ch);
+        matches= sscanf(restartOpt, "%ld%c", &lval, &ch);
         if (matches == 0)
             pm_error("Invalid value for the --restart option : '%s'.",
-                     restart);
+                     restartOpt);
         else {
             if (lval < 0 || lval > 65535L) {
                 pm_error("--restart value %ld is out of range.", lval);
                 exit(EXIT_FAILURE);
             } else {
                 if (matches == 1) {
-                    *restart_value_p = lval;
-                    *restart_unit_p = RESTART_ROW;
+                    *restartValueP = lval;
+                    *restartUnitP  = RESTART_ROW;
                 } else {
                     if (ch == 'b' || ch == 'B') {
-                        *restart_value_p = lval;
-                        *restart_unit_p = RESTART_MCU;
-                    } else pm_error("Invalid --restart value '%s'.", restart);
+                        *restartValueP = lval;
+                        *restartUnitP  = RESTART_MCU;
+                    } else
+                        pm_error("Invalid --restart value '%s'.", restartOpt);
                 }
             }
         }
@@ -147,8 +149,8 @@ interpret_restart(const char * const restart,
 
 
 static void
-interpret_density(const char *        const densityString,
-                  struct density *    const densityP) {
+interpretDensity(const char *     const densityString,
+                 struct Density * const densityP) {
 /*----------------------------------------------------------------------------
    Interpret the value of the "-density" option.
 -----------------------------------------------------------------------------*/
@@ -200,8 +202,8 @@ interpret_density(const char *        const densityString,
 
 
 static void
-parseCommandLine(const int argc, char ** argv,
-                   struct cmdlineInfo *cmdlineP) {
+parseCommandLine(const int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    Note that many of the strings that this function returns in the
    *cmdlineP structure are actually in the supplied argv array.  And
@@ -211,140 +213,143 @@ parseCommandLine(const int argc, char ** argv,
    On the other hand, unlike other option processing functions, we do
    not change argv at all.
 -----------------------------------------------------------------------------*/
-    optEntry *option_def = malloc(100*sizeof(optEntry));
+    optEntry * option_def;
         /* Instructions to OptParseOptions3 on how to parse our options.
          */
     optStruct3 opt;
 
     int i;  /* local loop variable */
 
-    const char *dctval;
-    const char *maxmemory;
-    const char *restart;
-    const char *density;
+    const char * dctval;
+    const char * maxmemory;
+    const char * restart;
+    const char * density;
 
     unsigned int qualitySpec, smoothSpec;
 
     unsigned int option_def_index;
 
-    int argc_parse;       /* argc, except we modify it as we parse */
-    char ** argv_parse;
+    int argcParse;       /* argc, except we modify it as we parse */
+    const char ** argvParse;
         /* argv, except we modify it as we parse */
 
-    MALLOCARRAY(argv_parse, argc + 1);  /* +1 for the terminating null ptr */
+    MALLOCARRAY_NOFAIL(option_def, 100);
+
+    MALLOCARRAY(argvParse, argc + 1);  /* +1 for the terminating null ptr */
 
     option_def_index = 0;   /* incremented by OPTENTRY */
     OPTENT3(0, "verbose",     OPT_FLAG,   NULL, &cmdlineP->verbose,        0);
     OPTENT3(0, "quality",     OPT_UINT,   &cmdlineP->quality,
             &qualitySpec,        0);
-    OPTENT3(0, "baseline",    OPT_FLAG,   NULL, &cmdlineP->force_baseline, 0);
+    OPTENT3(0, "baseline",    OPT_FLAG,   NULL, &cmdlineP->baseline,       0);
     OPTENT3(0, "progressive", OPT_FLAG,   NULL, &cmdlineP->progressive,    0);
-    OPTENT3(0, "arithmetic",  OPT_FLAG,   NULL, &cmdlineP->arith_code,     0);
-    OPTENT3(0, "dct",         OPT_STRING, &dctval, NULL,                    0);
+    OPTENT3(0, "arithmetic",  OPT_FLAG,   NULL, &cmdlineP->arithmetic,     0);
+    OPTENT3(0, "dct",         OPT_STRING, &dctval, NULL,                   0);
     OPTENT3(0, "grayscale",   OPT_FLAG,   NULL, &cmdlineP->grayscale,      0);
     OPTENT3(0, "greyscale",   OPT_FLAG,   NULL, &cmdlineP->grayscale,      0);
     OPTENT3(0, "rgb",         OPT_FLAG,   NULL, &cmdlineP->rgb,            0);
-    OPTENT3(0, "maxmemory",   OPT_STRING, &maxmemory, NULL,                 0);
-    OPTENT3(0, "tracelevel",  OPT_UINT,   &cmdlineP->trace_level, NULL,    0);
+    OPTENT3(0, "maxmemory",   OPT_STRING, &maxmemory, NULL,                0);
+    OPTENT3(0, "tracelevel",  OPT_UINT,   &cmdlineP->tracelevel, NULL,    0);
     OPTENT3(0, "qslots",      OPT_STRING, &cmdlineP->qslots,      NULL,    0);
     OPTENT3(0, "qtables",     OPT_STRING, &cmdlineP->qtablefile,  NULL,    0);
     OPTENT3(0, "sample",      OPT_STRING, &cmdlineP->sample,      NULL,    0);
     OPTENT3(0, "scans",       OPT_STRING, &cmdlineP->scans,       NULL,    0);
-    OPTENT3(0, "smooth",      OPT_UINT,   &cmdlineP->smoothing_factor,
+    OPTENT3(0, "smooth",      OPT_UINT,   &cmdlineP->smooth,
             &smoothSpec,  0);
     OPTENT3(0, "optimize",    OPT_FLAG,   NULL, &cmdlineP->optimize,       0);
     OPTENT3(0, "optimise",    OPT_FLAG,   NULL, &cmdlineP->optimize,       0);
     OPTENT3(0, "restart",     OPT_STRING, &restart, NULL,                   0);
     OPTENT3(0, "comment",     OPT_STRING, &cmdlineP->comment, NULL,        0);
-    OPTENT3(0, "exif",        OPT_STRING, &cmdlineP->exif_filespec, NULL,  0);
+    OPTENT3(0, "exif",        OPT_STRING, &cmdlineP->exif, NULL,  0);
     OPTENT3(0, "density",     OPT_STRING, &density,
-            &cmdlineP->density_spec, 0);
+            &cmdlineP->densitySpec, 0);
+
 
     /* Set the defaults */
     dctval = NULL;
     maxmemory = NULL;
-    cmdlineP->trace_level = 0;
+    cmdlineP->tracelevel = 0;
     cmdlineP->qslots = NULL;
     cmdlineP->qtablefile = NULL;
     cmdlineP->sample = NULL;
     cmdlineP->scans = NULL;
     restart = NULL;
     cmdlineP->comment = NULL;
-    cmdlineP->exif_filespec = NULL;
+    cmdlineP->exif = NULL;
 
     /* Make private copy of arguments for pm_optParseOptions to corrupt */
-    argc_parse = argc;
-    for (i=0; i < argc+1; i++) argv_parse[i] = argv[i];
+    argcParse = argc;
+    for (i = 0; i < argc+1; ++i)
+        argvParse[i] = argv[i];
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    pm_optParseOptions3(&argc_parse, argv_parse, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argcParse, (char **)argvParse, opt, sizeof(opt), 0);
 
     if (!qualitySpec)
         cmdlineP->quality = -1;  /* unspecified */
 
     if (!smoothSpec)
-        cmdlineP->smoothing_factor = -1;
+        cmdlineP->smooth = -1;
 
     if (cmdlineP->rgb && cmdlineP->grayscale)
         pm_error("You can't specify both -rgb and -grayscale");
 
-    if (argc_parse - 1 == 0)
-        cmdlineP->input_filespec = strdup("-");  /* he wants stdin */
-    else if (argc_parse - 1 == 1)
-        cmdlineP->input_filespec = strdup(argv_parse[1]);
+    if (argcParse - 1 == 0)
+        cmdlineP->inputFileNm = strdup("-");  /* he wants stdin */
+    else if (argcParse - 1 == 1)
+        cmdlineP->inputFileNm = strdup(argvParse[1]);
     else
         pm_error("Too many arguments.  The only argument accepted "
                  "is the input file specification.");
     if (dctval == NULL)
-        cmdlineP->dct_method = JDCT_DEFAULT;
+        cmdlineP->dctMethod = JDCT_DEFAULT;
     else {
         if (streq(dctval, "int"))
-            cmdlineP->dct_method = JDCT_ISLOW;
+            cmdlineP->dctMethod = JDCT_ISLOW;
         else if (streq(dctval, "fast"))
-            cmdlineP->dct_method = JDCT_IFAST;
+            cmdlineP->dctMethod = JDCT_IFAST;
         else if (streq(dctval, "float"))
-            cmdlineP->dct_method = JDCT_FLOAT;
+            cmdlineP->dctMethod = JDCT_FLOAT;
         else
             pm_error("Invalid value for the --dct option: '%s'.", dctval);
     }
 
-    interpret_maxmemory(maxmemory, &cmdlineP->max_memory_to_use);
-    interpret_restart(restart, &cmdlineP->restart_value,
-                      &cmdlineP->restart_unit);
-    if (cmdlineP->density_spec)
-        interpret_density(density, &cmdlineP->density);
+    interpretMaxmemory(maxmemory, &cmdlineP->maxMemoryToUse);
+    interpretRestart(restart, &cmdlineP->restartValue,
+                      &cmdlineP->restartUnit);
+    if (cmdlineP->densitySpec)
+        interpretDensity(density, &cmdlineP->density);
 
-    if (cmdlineP->smoothing_factor > 100)
+    if (cmdlineP->smooth > 100)
         pm_error("Smoothing factor %d is greater than 100 (%%).",
-                 cmdlineP->smoothing_factor);
+                 cmdlineP->smooth);
 
-    if (streq(cmdlineP->input_filespec, "=") &&
-        cmdlineP->exif_filespec &&
-        streq(cmdlineP->exif_filespec, "-"))
+    if (streq(cmdlineP->inputFileNm, "=") &&
+        cmdlineP->exif && streq(cmdlineP->exif, "-"))
 
         pm_error("Cannot have both input image and exif header be from "
                  "Standard Input.");
 
 
-    free(argv_parse);
+    free(argvParse);
 }
 
 
 
 static void
-report_compressor(const struct jpeg_compress_struct cinfo) {
+reportCompressor(const struct jpeg_compress_struct cinfo) {
 
     if (cinfo.scan_info == NULL)
         pm_message("No scan script is being used");
     else {
-        int i;
+        unsigned int i;
         pm_message("A scan script with %d entries is being used:",
                    cinfo.num_scans);
-        for (i = 0; i < cinfo.num_scans; i++) {
-            int j;
+        for (i = 0; i < cinfo.num_scans; ++i) {
+            unsigned int j;
             pm_message("    Scan %2d: Ss=%2d Se=%2d Ah=%2d Al=%2d  "
                        "%d components",
                        i,
@@ -354,7 +359,7 @@ report_compressor(const struct jpeg_compress_struct cinfo) {
                        cinfo.scan_info[i].Al,
                        cinfo.scan_info[i].comps_in_scan
                        );
-            for (j = 0; j < cinfo.scan_info[i].comps_in_scan; j++)
+            for (j = 0; j < cinfo.scan_info[i].comps_in_scan; ++j)
                 pm_message("        Color component %d index: %d", j,
                            cinfo.scan_info[i].component_index[j]);
         }
@@ -364,14 +369,14 @@ report_compressor(const struct jpeg_compress_struct cinfo) {
 
 
 static void
-setup_jpeg_source_parameters(struct jpeg_compress_struct * const cinfoP,
-                             int const width, int const height,
-                             int const format) {
+setupJpegSourceParameters(struct jpeg_compress_struct * const cinfoP,
+                          unsigned int                  const width,
+                          unsigned int                  const height,
+                          int                           const format) {
 /*----------------------------------------------------------------------------
    Set up in the compressor descriptor *cinfoP the description of the
    source image as required by the compressor.
 -----------------------------------------------------------------------------*/
-
     switch PNM_FORMAT_TYPE(format) {
     case PBM_TYPE:
     case PGM_TYPE:
@@ -391,8 +396,8 @@ setup_jpeg_source_parameters(struct jpeg_compress_struct * const cinfoP,
 
 
 static void
-setup_jpeg_density(struct jpeg_compress_struct * const cinfoP,
-                   struct density                const density) {
+setupJpegDensity(struct jpeg_compress_struct * const cinfoP,
+                 struct Density                const density) {
 /*----------------------------------------------------------------------------
    Set up in the compressor descriptor *cinfoP the density information
    'density'.
@@ -421,24 +426,28 @@ setup_jpeg_density(struct jpeg_compress_struct * const cinfoP,
 -----------------------------------------------------------------------------*/
 
 static 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;
+textGetc (FILE * fileP) {
+/*----------------------------------------------------------------------------
+  Read next char, skipping over any comments (# to end of line).
 
-    ch = getc(file);
+  Return a comment/newline sequence as a newline.
+-----------------------------------------------------------------------------*/
+    int ch;
+
+    ch = getc(fileP);
     if (ch == '#') {
         do {
-            ch = getc(file);
+            ch = getc(fileP);
         } while (ch != '\n' && ch != EOF);
     }
     return ch;
 }
 
 
-static boolean
+
+static void
 readTextInteger(FILE * const fileP,
+                bool * const gotOneP,
                 long * const resultP,
                 int *  const termcharP) {
 /*----------------------------------------------------------------------------
@@ -450,234 +459,335 @@ readTextInteger(FILE * const fileP,
    If there is no character after the integer, return *termcharP == EOF.
 
    Iff the next thing in the file is not a valid unsigned decimal integer,
-   return FALSE.
+   return *gotOneP false.
 -----------------------------------------------------------------------------*/
     int ch;
-    boolean retval;
 
     /* Skip any leading whitespace, detect EOF */
     do {
-        ch = text_getc(fileP);
+        ch = textGetc(fileP);
     } while (isspace(ch));
 
     if (!isdigit(ch))
-        retval = FALSE;
+        *gotOneP = false;
     else {
         long val;
         val = ch - '0';  /* initial value */
-        while ((ch = text_getc(fileP)) != EOF) {
+        while ((ch = textGetc(fileP)) != EOF) {
             if (! isdigit(ch))
                 break;
             val *= 10;
             val += ch - '0';
         }
         *resultP = val;
-        retval = TRUE;
+        *gotOneP = true;
     }
     *termcharP = ch;
-    return retval;
 }
 
 
-static boolean
-read_scan_integer (FILE * file, long * result, int * termchar)
-/* Variant of readTextInteger that always looks for a non-space termchar;
- * this simplifies parsing of punctuation in scan scripts.
- */
-{
-    register int ch;
-
-    if (! readTextInteger(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 != ':')
+
+static void
+readScanInteger(FILE * const fileP,
+                bool * const gotOneP,
+                long * const resultP,
+                int *  const termcharP) {
+/*----------------------------------------------------------------------------
+  Variant of readTextInteger that always looks for a non-space termchar.
+  this simplifies parsing of punctuation in scan scripts.
+-----------------------------------------------------------------------------*/
+    readTextInteger(fileP, gotOneP, resultP, termcharP);
+
+    if (*gotOneP) {
+        int ch;
+
+        ch = *termcharP;  /* initial value */
+
+        while (ch != EOF && isspace(ch))
+            ch = textGetc(fileP);
+
+        if (isdigit(ch)) {		/* oops, put it back */
+            if (ungetc(ch, fileP) == EOF)
+                pm_error("Unexpected failure of ungetc");
             ch = ' ';
+        } else {
+            /* Any separators other than ';' and ':' are ignored;
+             * this allows user to insert commas, etc, if desired.
+             */
+            if (ch != EOF && ch != ';' && ch != ':')
+                ch = ' ';
+        }
+        *termcharP = ch;
     }
-    *termchar = ch;
-    return TRUE;
 }
 
 
 
-static boolean
-read_scan_script(j_compress_ptr const cinfo,
-                 const char *   const filename) {
+static void
+readScanScriptComponents(FILE *           const fP,
+                         jpeg_scan_info * const scanP,
+                         int *            const termcharP,
+                         long *           const valP,
+                         const char **    const errorP) {
+/*----------------------------------------------------------------------------
+   Set component table in *scanP, i.e. scanP->component_index and
+   scanP->comps_in_scan.
+
+   *termcharP and *valP at entry are for the value we already read from the
+   file; at exit, they are the value beyond the component table.
+-----------------------------------------------------------------------------*/
+    unsigned int compCt;
+
+    *errorP = NULL;  /* initial value */
+
+    /* First component is value we already read: */
+    scanP->component_index[0] = (int) *valP;
+    compCt = 1;
+
+    /* Rest of components follow, until termchar other than ' ': */
+    while (*termcharP == ' ' && !*errorP) {
+        bool gotOne;
+        if (compCt >= MAX_COMPS_IN_SCAN) {
+            pm_asprintf(errorP, "Too many components in one scan "
+                        "(Max allowed is %u)", MAX_COMPS_IN_SCAN);
+        }
+        readScanInteger(fP, &gotOne, valP, termcharP);
+        if (!gotOne)
+            pm_asprintf(errorP, "Invalid scan entry format");
+        else
+            scanP->component_index[compCt++] = (int) *valP;
+    }
+    scanP->comps_in_scan = compCt;
+}
+
+
+
+static void
+readScanScriptProg(FILE *           const fP,
+                   jpeg_scan_info * const scanP,
+                   int *            const termcharP,
+                   long *           const valP,
+                   const char **    const errorP) {
+
+    bool gotOne;
+    readScanInteger(fP, &gotOne, valP, termcharP);
+    if (!gotOne || *termcharP != ' ')
+        pm_asprintf(errorP, "Error in Ss");
+    else {
+        bool gotOne;
+        scanP->Ss = (int) *valP;
+        readScanInteger(fP, &gotOne, valP, termcharP);
+        if (!gotOne || *termcharP != ' ')
+            pm_asprintf(errorP, "Error in Se");
+        else {
+            bool gotOne;
+            scanP->Se = (int) *valP;
+            readScanInteger(fP, &gotOne, valP, termcharP);
+            if (!gotOne || *termcharP != ' ')
+                pm_asprintf(errorP, "Error in Ah");
+            else {
+                bool gotOne;
+                scanP->Ah = (int) *valP;
+                readScanInteger(fP, &gotOne, valP, termcharP);
+                if (!gotOne)
+                    pm_asprintf(errorP, "Error in Al");
+                else {
+                    scanP->Al = (int) *valP;
+                    *errorP = NULL;
+                }
+            }
+        }
+    }
+}
+
+
+
+static void
+setScanScriptNonProgressive(jpeg_scan_info * const scanP) {
+
+    scanP->Ss = 0;
+    scanP->Se = DCTSIZE2-1;
+    scanP->Ah = 0;
+    scanP->Al = 0;
+}
+
+
+
+static void
+readScanScript1(FILE *           const fP,
+                jpeg_scan_info * const scanP,
+                int *            const termcharP,
+                long *           const valP,
+                const char **    const errorP) {
+
+    const char * error;
+
+    readScanScriptComponents(fP, scanP, termcharP, valP, &error);
+
+    if (error) {
+        pm_asprintf(errorP, "Error in component table.  %s", error);
+        pm_strfree(error);
+    } else {
+        if (*termcharP == ':') {
+            const char * error;
+
+            readScanScriptProg(fP, scanP, termcharP, valP, &error);
+
+            if (error) {
+                pm_asprintf(errorP, "Invalid progressive parameters.  %s",
+                            error);
+                pm_strfree(error);
+            }
+        } else
+            setScanScriptNonProgressive(scanP);
+
+        if (*termcharP != ';' && *termcharP != EOF) {
+            pm_asprintf(errorP, "Expected ';' or EOF");
+        }
+    }
+}
+
+
+
+static void
+readScanScript(j_compress_ptr const cinfoP,
+               const char *   const fileNm,
+               const char **  const errorP) {
 /*----------------------------------------------------------------------------
   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.
+
+  An entry contains one to four component indexes, optionally followed by a
+  colon ':' and four progressive-JPEG parameters.  The indexes and parameters
+  are separated by spaces.
+
+  The component indexes identify the color components 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.
+
+  Any whitespace may appear between numbers and the ':' and ';' punctuation
+  marks.  Also, other punctuation (such as commas or dashes) may be placed
+  between numbers.
+
   Comments preceded by '#' may be included in the file.
-  Note: we do very little validity checking here;
-  jcmaster.c will validate the script parameters.
+
+  Note: we do very little validity checking here; libjpeg will validate the
+  script parameters.
+
+  The data goes into newly malloc'ed memory pointed to by cinfo->scan_info,
+  with its size as cinfo->num_scans.  If there isn't any scan script,
+  cinfo->scan_info is null.
 -----------------------------------------------------------------------------*/
-    FILE * fp;
-    unsigned int nscans;
-    unsigned int ncomps;
-    int termchar;
-    long val;
-#define MAX_SCANS  100      /* quite arbitrary limit */
-    jpeg_scan_info scans[MAX_SCANS];
+    FILE * fP;
 
-    fp = fopen(filename, "r");
-    if (fp == NULL) {
-        pm_message("Can't open scan definition file %s", filename);
-        return FALSE;
-    }
-    nscans = 0;
-
-    while (read_scan_integer(fp, &val, &termchar)) {
-        ++nscans;  /* We got another scan */
-        if (nscans > MAX_SCANS) {
-            pm_message("Too many scans defined in file %s", filename);
-            fclose(fp);
-            return FALSE;
-        }
-        scans[nscans-1].component_index[0] = (int) val;
-        ncomps = 1;
-        while (termchar == ' ') {
-            if (ncomps >= MAX_COMPS_IN_SCAN) {
-                pm_message("Too many components in one scan in file %s",
-                           filename);
-                fclose(fp);
-                return FALSE;
+    fP = fopen(fileNm, "r");
+    if (!fP)
+        pm_asprintf(errorP, "Can't open file");
+    else {
+        bool notEof;
+        unsigned int scanCt;
+        int termchar;
+        long val;
+        jpeg_scan_info * scan;  /* malloc'ed array */
+            /* Index 0 in this array is called "Entry 1" by libjpeg messages */
+
+        for (notEof = true, *errorP = NULL, scanCt = 0, scan = NULL;
+             notEof && !*errorP;
+            ) {
+            readScanInteger(fP, &notEof, &val, &termchar);
+            if (notEof && !*errorP) {
+                ++scanCt;  /* We got another scan */
+
+                REALLOCARRAY(scan, scanCt);
+
+                if (!scan)
+                    pm_error("Unable to allocate memory for scan table");
+
+                readScanScript1(fP, &scan[scanCt-1], &termchar, &val, errorP);
             }
-            if (! read_scan_integer(fp, &val, &termchar))
-                goto bogus;
-            scans[nscans-1].component_index[ncomps] = (int) val;
-            ++ncomps;
         }
-        scans[nscans-1].comps_in_scan = ncomps;
-        if (termchar == ':') {
-            if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
-                goto bogus;
-            scans[nscans-1].Ss = (int) val;
-            if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
-                goto bogus;
-            scans[nscans-1].Se = (int) val;
-            if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
-                goto bogus;
-            scans[nscans-1].Ah = (int) val;
-            if (! read_scan_integer(fp, &val, &termchar))
-                goto bogus;
-            scans[nscans-1].Al = (int) val;
+        if (!*errorP && termchar != EOF)
+            pm_asprintf(errorP, "Non-numeric data in file '%s'", fileNm);
+
+        if (*errorP) {
+            if (scan)
+                free(scan);
+            cinfoP->scan_info = NULL;
         } else {
-            /* set non-progressive parameters */
-            scans[nscans-1].Ss = 0;
-            scans[nscans-1].Se = DCTSIZE2-1;
-            scans[nscans-1].Ah = 0;
-            scans[nscans-1].Al = 0;
+            cinfoP->scan_info = scanCt > 0 ? scan : NULL;
+            cinfoP->num_scans = scanCt;
         }
-        if (termchar != ';' && termchar != EOF) {
-        bogus:
-            pm_message("Invalid scan entry format in file %s", filename);
-            fclose(fp);
-            return FALSE;
-        }
-    }
-
-    if (termchar != EOF) {
-        pm_message("Non-numeric data in file %s", filename);
-        fclose(fp);
-        return FALSE;
+        fclose(fP);
     }
-
-    if (nscans > 0) {
-        /* Stash completed scan list in cinfo structure.  NOTE: in
-           this program, JPOOL_IMAGE is the right lifetime for this
-           data, but if you want to compress multiple images you'd
-           want JPOOL_PERMANENT.
-        */
-        const unsigned int scan_info_size = nscans * sizeof(jpeg_scan_info);
-        jpeg_scan_info * const scan_info =
-            (jpeg_scan_info *)
-            (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                                        scan_info_size);
-        memcpy(scan_info, scans, scan_info_size);
-        cinfo->scan_info = scan_info;
-        cinfo->num_scans = nscans;
-    }
-
-    fclose(fp);
-    return TRUE;
 }
 
 
 
-static 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.
- */
-{
+static bool
+readQuantTables(j_compress_ptr const cinfo,
+                const char *   const fileNm,
+                int            const scaleFactor,
+                bool           const forceBaseline) {
+/*----------------------------------------------------------------------------
+  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;
-    boolean retval;
+    bool retval;
 
-    fp = fopen(filename, "rb");
+    fp = fopen(fileNm, "rb");
     if (fp == NULL) {
-        pm_message("Can't open table file %s", filename);
-        retval = FALSE;
+        pm_message("Can't open table file '%s'", fileNm);
+        retval = false;
     } else {
         boolean eof, error;
         unsigned int tblno;
 
-        for (tblno = 0, eof = FALSE, error = FALSE; !eof && !error; ++tblno) {
+        for (tblno = 0, eof = false, error = false; !eof && !error; ++tblno) {
             long val;
             int termchar;
-            boolean gotOne;
+            bool gotOne;
 
-            gotOne = readTextInteger(fp, &val, &termchar);
+            readTextInteger(fp, &gotOne, &val, &termchar);
             if (gotOne) {
                 /* read 1st element of table */
                 if (tblno >= NUM_QUANT_TBLS) {
-                    pm_message("Too many tables in file %s", filename);
-                    error = TRUE;
+                    pm_message("Too many tables in file '%s'", fileNm);
+                    error = true;
                 } else {
                     unsigned int table[DCTSIZE2];
                     unsigned int i;
 
                     table[0] = (unsigned int) val;
                     for (i = 1; i < DCTSIZE2 && !error; ++i) {
-                        if (! readTextInteger(fp, &val, &termchar)) {
-                            pm_message("Invalid table data in file %s",
-                                       filename);
-                            error = TRUE;
+                        bool gotOne;
+                        readTextInteger(fp, &gotOne, &val, &termchar);
+                        if (!gotOne) {
+                            pm_message("Invalid table data in file '%s'",
+                                       fileNm);
+                            error = true;
                         } else
                             table[i] = (unsigned int) val;
                     }
                     if (!error)
                         jpeg_add_quant_table(
-                            cinfo, tblno, table, scale_factor, force_baseline);
+                            cinfo, tblno, table, scaleFactor, forceBaseline);
                 }
             } else {
                 if (termchar == EOF)
                     eof = TRUE;
                 else {
-                    pm_message("Non-numeric data in file %s", filename);
+                    pm_message("Non-numeric data in file '%s'", fileNm);
                     error = TRUE;
                 }
             }
@@ -692,75 +802,87 @@ read_quant_tables (j_compress_ptr cinfo, char * filename,
 
 
 
-static 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 # */
+static bool
+setQuantSlots(j_compress_ptr const cinfo,
+              const char *   const 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;
     int ci;
     char ch;
+    unsigned int i;
 
-    for (ci = 0; ci < MAX_COMPONENTS; ci++) {
-        if (*arg) {
+    val = 0; /* initial value - default table */
+
+    for (ci = 0, i = 0; ci < MAX_COMPONENTS; ++ci) {
+        if (arg[i]) {
             ch = ',';			/* if not set by sscanf, will be ',' */
-            if (sscanf(arg, "%d%c", &val, &ch) < 1)
-                return FALSE;
+            if (sscanf(&arg[i], "%d%c", &val, &ch) < 1)
+                return false;
             if (ch != ',')		/* syntax check */
-                return FALSE;
+                return false;
             if (val < 0 || val >= NUM_QUANT_TBLS) {
                 pm_message("Invalid quantization table number: %d.  "
                            "JPEG quantization tables are numbered 0..%d",
                            val, NUM_QUANT_TBLS - 1);
-                return FALSE;
+                return false;
             }
             cinfo->comp_info[ci].quant_tbl_no = val;
-            while (*arg && *arg++ != ',')
+            while (arg[i] && arg[i] != ',') {
+                ++i;
                 /* advance to next segment of arg string */
-                ;
+            }
         } else {
             /* reached end of parameter, set remaining components to last tbl*/
             cinfo->comp_info[ci].quant_tbl_no = val;
         }
     }
-    return TRUE;
+    return true;
 }
 
 
-static 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;
+static bool
+setSampleFactors (j_compress_ptr const cinfo,
+                  const char *   const 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 val1, val2;
     char ch1, ch2;
+    unsigned int i;
+    unsigned int ci;
 
-    for (ci = 0; ci < MAX_COMPONENTS; ci++) {
-        if (*arg) {
+    for (ci = 0, i = 0; ci < MAX_COMPONENTS; ++ci) {
+        if (arg[i]) {
             ch2 = ',';		/* if not set by sscanf, will be ',' */
-            if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
-                return FALSE;
+            if (sscanf(&arg[i], "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
+                return false;
             if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
-                return FALSE;
+                return false;
             if (val1 <= 0 || val1 > 4) {
                 pm_message("Invalid sampling factor: %d.  "
                            "JPEG sampling factors must be 1..4", val1);
-                return FALSE;
+                return false;
             }
             if (val2 <= 0 || val2 > 4) {
                 pm_message("Invalid sampling factor: %d.  "
                            "JPEG sampling factors must be 1..4", val2);
-                return FALSE;
+                return false;
             }
             cinfo->comp_info[ci].h_samp_factor = val1;
             cinfo->comp_info[ci].v_samp_factor = val2;
-            while (*arg && *arg++ != ',')
+
+            while (arg[i] && arg[i] != ',') {
                 /* advance to next segment of arg string */
-                ;
+                ++i;
+            }
         } else {
             /* reached end of parameter, set remaining components
                to 1x1 sampling */
@@ -768,42 +890,42 @@ set_sample_factors (j_compress_ptr cinfo, char *arg)
             cinfo->comp_info[ci].v_samp_factor = 1;
         }
     }
-    return TRUE;
+    return true;
 }
 
 
 
 static void
-setup_jpeg(struct jpeg_compress_struct * const cinfoP,
-           struct jpeg_error_mgr       * const jerrP,
-           struct cmdlineInfo            const cmdline,
-           int                           const width,
-           int                           const height,
-           pixval                        const maxval,
-           int                           const input_fmt,
-           FILE *                        const output_file) {
+setupJpeg(struct jpeg_compress_struct * const cinfoP,
+          struct jpeg_error_mgr       * const jerrP,
+          struct CmdlineInfo            const cmdline,
+          unsigned int                  const width,
+          unsigned int                  const height,
+          pixval                        const maxval,
+          int                           const inputFmt,
+          FILE *                        const ofP) {
 
     int quality;
-    int q_scale_factor;
+    int qScaleFactor;
 
     /* Initialize the JPEG compression object with default error handling. */
     cinfoP->err = jpeg_std_error(jerrP);
     jpeg_create_compress(cinfoP);
 
-    setup_jpeg_source_parameters(cinfoP, width, height, input_fmt);
+    setupJpegSourceParameters(cinfoP, width, height, inputFmt);
 
     jpeg_set_defaults(cinfoP);
 
     cinfoP->data_precision = BITS_IN_JSAMPLE;
         /* we always rescale data to this */
-    cinfoP->image_width = (unsigned int) width;
-    cinfoP->image_height = (unsigned int) height;
+    cinfoP->image_width = width;
+    cinfoP->image_height = height;
 
-    cinfoP->arith_code = cmdline.arith_code;
-    cinfoP->dct_method = cmdline.dct_method;
-    if (cmdline.trace_level == 0 && cmdline.verbose)
+    cinfoP->arith_code = cmdline.arithmetic;
+    cinfoP->dct_method = cmdline.dctMethod;
+    if (cmdline.tracelevel == 0 && cmdline.verbose)
         cinfoP->err->trace_level = 1;
-    else cinfoP->err->trace_level = cmdline.trace_level;
+    else cinfoP->err->trace_level = cmdline.tracelevel;
     if (cmdline.grayscale)
         jpeg_set_colorspace(cinfoP, JCS_GRAYSCALE);
     else if (cmdline.rgb)
@@ -812,38 +934,38 @@ setup_jpeg(struct jpeg_compress_struct * const cinfoP,
     else
         /* This default will be based on the in_color_space set above */
         jpeg_default_colorspace(cinfoP);
-    if (cmdline.max_memory_to_use != -1)
-        cinfoP->mem->max_memory_to_use = cmdline.max_memory_to_use;
+    if (cmdline.maxMemoryToUse != -1)
+        cinfoP->mem->max_memory_to_use = cmdline.maxMemoryToUse;
     cinfoP->optimize_coding = cmdline.optimize;
     if (cmdline.quality == -1) {
         quality = 75;
-        q_scale_factor = 100;
+        qScaleFactor = 100;
     } else {
         quality = cmdline.quality;
-        q_scale_factor = jpeg_quality_scaling(cmdline.quality);
+        qScaleFactor = jpeg_quality_scaling(cmdline.quality);
     }
-    if (cmdline.smoothing_factor != -1)
-        cinfoP->smoothing_factor = cmdline.smoothing_factor;
+    if (cmdline.smooth != -1)
+        cinfoP->smoothing_factor = cmdline.smooth;
 
     /* Set quantization tables for selected quality. */
     /* Some or all may be overridden if user specified --qtables. */
-    jpeg_set_quality(cinfoP, quality, cmdline.force_baseline);
+    jpeg_set_quality(cinfoP, quality, cmdline.baseline);
 
     if (cmdline.qtablefile != NULL) {
-        if (! read_quant_tables(cinfoP, cmdline.qtablefile,
-                                q_scale_factor, cmdline.force_baseline))
+        if (! readQuantTables(cinfoP, cmdline.qtablefile,
+                              qScaleFactor, cmdline.baseline))
             pm_error("Can't use quantization table file '%s'.",
                      cmdline.qtablefile);
     }
 
     if (cmdline.qslots != NULL) {
-        if (! set_quant_slots(cinfoP, cmdline.qslots))
+        if (! setQuantSlots(cinfoP, cmdline.qslots))
             pm_error("Bad quantization-table-selectors parameter string '%s'.",
                      cmdline.qslots);
     }
 
     if (cmdline.sample != NULL) {
-        if (! set_sample_factors(cinfoP, cmdline.sample))
+        if (! setSampleFactors(cinfoP, cmdline.sample))
             pm_error("Bad sample-factors parameters string '%s'.",
                      cmdline.sample);
     }
@@ -851,19 +973,24 @@ setup_jpeg(struct jpeg_compress_struct * const cinfoP,
     if (cmdline.progressive)
         jpeg_simple_progression(cinfoP);
 
-    if (cmdline.density_spec)
-        setup_jpeg_density(cinfoP, cmdline.density);
+    if (cmdline.densitySpec)
+        setupJpegDensity(cinfoP, cmdline.density);
 
     if (cmdline.scans != NULL) {
-        if (! read_scan_script(cinfoP, cmdline.scans)) {
-            pm_message("Error in scan script '%s'.", cmdline.scans);
+        const char * error;
+        readScanScript(cinfoP, cmdline.scans, &error);
+        if (error) {
+            pm_message("Error in scan script '%s'.  %s", cmdline.scans, error);
+            pm_strfree(error);
         }
-    }
+    } else
+        cinfoP->scan_info = NULL;
 
     /* Specify data destination for compression */
-    jpeg_stdio_dest(cinfoP, output_file);
+    jpeg_stdio_dest(cinfoP, ofP);
 
-    if (cmdline.verbose) report_compressor(*cinfoP);
+    if (cmdline.verbose)
+        reportCompressor(*cinfoP);
 
     /* Start compressor */
     jpeg_start_compress(cinfoP, TRUE);
@@ -873,115 +1000,122 @@ setup_jpeg(struct jpeg_compress_struct * const cinfoP,
 
 
 static void
-write_exif_header(struct jpeg_compress_struct * const cinfoP,
-                  const char * const exif_filespec) {
+writeExifHeader(struct jpeg_compress_struct * const cinfoP,
+                const char *                  const exifFileNm) {
 /*----------------------------------------------------------------------------
    Generate an APP1 marker in the JFIF output that is an Exif header.
 
    The contents of the Exif header are in the file with filespec
-   'exif_filespec' (file spec and contents are not validated).
+   'exifFileNm' (file spec and contents are not validated).
 
-   exif_filespec = "-" means Standard Input.
+   exifFileNm = "-" means Standard Input.
 
    If the file contains just two bytes of zero, don't write any marker
    but don't recognize any error either.
 -----------------------------------------------------------------------------*/
-    FILE * exif_file;
+    FILE * exifFp;
     unsigned short length;
 
-    exif_file = pm_openr(exif_filespec);
+    exifFp = pm_openr(exifFileNm);
 
-    pm_readbigshort(exif_file, (short*)&length);
+    pm_readbigshort(exifFp, (short*)&length);
 
     if (length == 0) {
         /* Special value meaning "no header" */
     } else if (length < 3)
         pm_error("Invalid length %u at start of exif file", length);
     else {
-        unsigned char * exif_data;
-        size_t rc;
-        size_t const data_length = length - 2;
+        unsigned char * exifData;
+        size_t const dataLength = length - 2;
             /* Subtract 2 byte length field*/
+        size_t rc;
 
-        assert(data_length > 0);
+        assert(dataLength > 0);
 
-        exif_data = malloc(data_length);
-        if (exif_data == NULL)
+        MALLOCARRAY(exifData, dataLength);
+        if (!exifData)
             pm_error("Unable to allocate %u bytes for exif header buffer",
-                     (unsigned)data_length);
+                     (unsigned)dataLength);
 
-        rc = fread(exif_data, 1, data_length, exif_file);
+        rc = fread(exifData, 1, dataLength, exifFp);
 
-        if (rc != data_length)
+        if (rc != dataLength)
             pm_error("Premature end of file on exif header file.  Should be "
                      "%u bytes of data, read only %u",
-                     (unsigned)data_length, (unsigned)rc);
+                     (unsigned)dataLength, (unsigned)rc);
 
         jpeg_write_marker(cinfoP, JPEG_APP0+1,
-                          (const JOCTET *) exif_data, data_length);
+                          (const JOCTET *) exifData, dataLength);
 
-        free(exif_data);
+        free(exifData);
     }
 
-    pm_close(exif_file);
+    pm_close(exifFp);
 }
 
 
 
 static void
-compute_rescaling_array(JSAMPLE ** const rescale_p, const pixval maxval,
-                        const struct jpeg_compress_struct cinfo) {
+computeRescalingArray(JSAMPLE **                  const rescaleP,
+                      pixval                      const maxval,
+                      struct jpeg_compress_struct const cinfo) {
 /*----------------------------------------------------------------------------
    Compute the rescaling array for a maximum pixval of 'maxval'.
    Allocate the memory for it too.
 -----------------------------------------------------------------------------*/
-  const long half_maxval = maxval / 2;
-  long val;
-
-  *rescale_p = (JSAMPLE *)
-    (cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_IMAGE,
-                              (size_t) (((long) maxval + 1L) *
-                                        sizeof(JSAMPLE)));
-  for (val = 0; val <= maxval; val++) {
-    /* The multiplication here must be done in 32 bits to avoid overflow */
-    (*rescale_p)[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval);
-  }
+    long const halfMaxval = maxval / 2;
+
+    JSAMPLE * rescale;
+    long val;
+
+    MALLOCARRAY(rescale, maxval + 1);
+
+    if (!rescale)
+        pm_error("Failed to get memory for map of %u possible sample values",
+                 maxval + 1);
+
+    for (val = 0; val <= maxval; ++val) {
+        /* The multiplication here must be done in 32 bits to avoid overflow */
+        rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + halfMaxval)/maxval);
+    }
+
+    *rescaleP = rescale;
 }
 
 
 
 static void
-translate_row(const pixel pnm_buffer[],
-              JSAMPLE jpeg_buffer[],
-              int const width,
-              int const input_components,
-              const JSAMPLE translate[]) {
+translateRow(pixel        const pnm_buffer[],
+             unsigned int const width,
+             unsigned int const inputComponentCt,
+             JSAMPLE      const translate[],
+             JSAMPLE *    const jpegBuffer) {
 /*----------------------------------------------------------------------------
    Convert the input row, in pnm format, to an output row in JPEG compressor
    input format.
 
    This is a byte for byte copy, translated through the array 'translate'.
 -----------------------------------------------------------------------------*/
-  unsigned int column;
+  unsigned int col;
   /* I'm not sure why the JPEG library data structures don't have some kind
      of pixel data structure (such that a row buffer is an array of pixels,
      rather than an array of samples).  But because of this, we have to
      index jpeg_buffer the old fashioned way.
      */
 
-  switch (input_components) {
+  switch (inputComponentCt) {
   case 1:
-      for (column = 0; column < width; column++)
-          jpeg_buffer[column] = translate[(int)PNM_GET1(pnm_buffer[column])];
+      for (col = 0; col < width; ++col)
+          jpegBuffer[col] = translate[(int)PNM_GET1(pnm_buffer[col])];
       break;
   case 3:
-      for (column = 0; column < width; column++) {
-          jpeg_buffer[column*3+0] =
-              translate[(int)PPM_GETR(pnm_buffer[column])];
-          jpeg_buffer[column*3+1] =
-              translate[(int)PPM_GETG(pnm_buffer[column])];
-          jpeg_buffer[column*3+2] =
-              translate[(int)PPM_GETB(pnm_buffer[column])];
+      for (col = 0; col < width; ++col) {
+          jpegBuffer[col * 3 + 0] =
+              translate[(int)PPM_GETR(pnm_buffer[col])];
+          jpegBuffer[col * 3 + 1] =
+              translate[(int)PPM_GETG(pnm_buffer[col])];
+          jpegBuffer[col * 3 + 2] =
+              translate[(int)PPM_GETB(pnm_buffer[col])];
       }
       break;
   default:
@@ -994,72 +1128,69 @@ translate_row(const pixel pnm_buffer[],
 
 
 static void
-convert_scanlines(struct jpeg_compress_struct * const cinfo_p,
-                  FILE *                        const input_file,
-                  pixval                        const maxval,
-                  int                           const input_fmt,
-                  JSAMPLE                             xlate_table[]){
+convertScanLines(struct jpeg_compress_struct * const cinfoP,
+                 FILE *                        const inputFileNm,
+                 pixval                        const maxval,
+                 int                           const inputFmt,
+                 const JSAMPLE *               const xlateTable){
 /*----------------------------------------------------------------------------
-   Read scan lines from the input file, which is already opened in the
-   netpbm library sense and ready for reading, and write them to the
-   output JPEG object.  Translate the pnm sample values to JPEG sample
-   values through the thable xlate_table[].
+  Read scan lines from the input file, which is already opened in the
+  netpbm library sense and ready for reading, and write them to the
+  output JPEG object.  Translate the pnm sample values to JPEG sample
+  values through the table xlateTable[].
 -----------------------------------------------------------------------------*/
-  xel * pnm_buffer;
-    /* contains the row of the input image currently being processed,
-       in pnm_readpnmrow format
-    */
-  JSAMPARRAY buffer;
-    /* Row 0 of this array contains the row of the output image currently
-       being processed, in JPEG compressor input format.  The array only
-       has that one row.
-    */
+    xel * pnmBuffer;
+        /* This malloc'ed array contains the row of the input image currently
+           being processed, in pnm_readpnmrow format.
+        */
+    JSAMPLE * jpegBuffer;
+        /* This malloc'ed array contains the row of the output image currently
+           being processed, in JPEG compressor input format.
+        */
 
-  /* Allocate the libpnm output and compressor input buffers */
-  buffer = (*cinfo_p->mem->alloc_sarray)
-    ((j_common_ptr) cinfo_p, JPOOL_IMAGE,
-     (unsigned int) cinfo_p->image_width * cinfo_p->input_components,
-     (unsigned int) 1);
-
-  pnm_buffer = pnm_allocrow(cinfo_p->image_width);
-
-  while (cinfo_p->next_scanline < cinfo_p->image_height) {
-    if (cinfo_p->err->trace_level > 1)
-        pm_message("Converting Row %d...", cinfo_p->next_scanline);
-    pnm_readpnmrow(input_file, pnm_buffer, cinfo_p->image_width,
-                   maxval, input_fmt);
-    translate_row(pnm_buffer, buffer[0],
-                  cinfo_p->image_width, cinfo_p->input_components,
-                  xlate_table);
-    jpeg_write_scanlines(cinfo_p, buffer, 1);
-    if (cinfo_p->err->trace_level > 1)
-        pm_message("Done.");
-  }
+    MALLOCARRAY(jpegBuffer, cinfoP->image_width * cinfoP->input_components);
+    if (!jpegBuffer)
+        pm_error("Unable to allocate buffer for a row of %u pixels, "
+                 "%u samples each",
+                 cinfoP->image_width, cinfoP->input_components);
+
+    pnmBuffer = pnm_allocrow(cinfoP->image_width);
+
+    while (cinfoP->next_scanline < cinfoP->image_height) {
+        if (cinfoP->err->trace_level > 1)
+            pm_message("Converting Row %d...", cinfoP->next_scanline);
+        pnm_readpnmrow(inputFileNm, pnmBuffer, cinfoP->image_width,
+                       maxval, inputFmt);
+        translateRow(pnmBuffer,
+                     cinfoP->image_width, cinfoP->input_components,
+                     xlateTable,  jpegBuffer);
+        jpeg_write_scanlines(cinfoP, &jpegBuffer, 1);
+        if (cinfoP->err->trace_level > 1)
+            pm_message("Done.");
+    }
 
-  pnm_freerow(pnm_buffer);
-  /* Don't worry about the compressor input buffer; it gets freed
-     automatically
-  */
+    pnm_freerow(pnmBuffer);
+    free(jpegBuffer);
 }
 
 
 
 int
-main(int     argc,
-     char ** argv) {
+main(int           argc,
+     const char ** argv) {
 
-    struct cmdlineInfo cmdline;
+    struct CmdlineInfo cmdline;
     struct jpeg_compress_struct cinfo;
     struct jpeg_error_mgr jerr;
-    FILE * input_file;
-    FILE * output_file;
+    FILE * ifP;
+    FILE * ofP;
     int height;
         /* height of the input image in rows, as specified by its header */
     int width;
         /* width of the input image in columns, as specified by its header */
     pixval maxval;
         /* maximum value of an input pixel component, as specified by header */
-    int input_fmt;
+    int inputFmt;
         /* The input format, as determined by its header.  */
     JSAMPLE *rescale;         /* => maxval-remapping array, or NULL */
         /* This is an array that maps each possible pixval in the input to
@@ -1067,48 +1198,53 @@ main(int     argc,
            0 .. maxval, the range of the output values is 0 .. MAXJSAMPLE.
         */
 
-    pnm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
-    input_file = pm_openr(cmdline.input_filespec);
-    free(cmdline.input_filespec);
+    ifP = pm_openr(cmdline.inputFileNm);
 
-    output_file = stdout;
+    ofP = stdout;
 
     /* Open the pnm input */
-    pnm_readpnminit(input_file, &width, &height, &maxval, &input_fmt);
+    pnm_readpnminit(ifP, &width, &height, &maxval, &inputFmt);
     if (cmdline.verbose) {
         pm_message("Input file has format %c%c.\n"
                    "It has %d rows of %d columns of pixels "
                    "with max sample value of %d.",
-                   (char) (input_fmt/256), (char) (input_fmt % 256),
+                   (char) (inputFmt/256), (char) (inputFmt % 256),
                    height, width, maxval);
     }
 
-    setup_jpeg(&cinfo, &jerr, cmdline, width, height, maxval, input_fmt,
-               output_file);
+    setupJpeg(&cinfo, &jerr, cmdline, width, height, maxval, inputFmt, ofP);
 
-    compute_rescaling_array(&rescale, maxval, cinfo);
+    computeRescalingArray(&rescale, maxval, cinfo);
 
     if (cmdline.comment)
         jpeg_write_marker(&cinfo, JPEG_COM, (const JOCTET *) cmdline.comment,
                           strlen(cmdline.comment));
 
-    if (cmdline.exif_filespec)
-        write_exif_header(&cinfo, cmdline.exif_filespec);
+    if (cmdline.exif)
+        writeExifHeader(&cinfo, cmdline.exif);
 
     /* Translate and copy over the actual scanlines */
-    convert_scanlines(&cinfo, input_file, maxval, input_fmt, rescale);
+    convertScanLines(&cinfo, ifP, maxval, inputFmt, rescale);
 
     /* Finish compression and release memory */
     jpeg_finish_compress(&cinfo);
     jpeg_destroy_compress(&cinfo);
 
+    if (cinfo.scan_info) {
+        free((void*)cinfo.scan_info);
+        cinfo.scan_info = NULL;
+    }
+    free(rescale);
+
     /* Close files, if we opened them */
-    if (input_file != stdin)
-        pm_close(input_file);
+    if (ifP != stdin)
+        pm_close(ifP);
 
+    free(cmdline.inputFileNm);
     /* Program may have exited with non-zero completion code via
        various function calls above.
     */
diff --git a/converter/other/sirtopnm.c b/converter/other/sirtopnm.c
index fafcc913..6a36a110 100644
--- a/converter/other/sirtopnm.c
+++ b/converter/other/sirtopnm.c
@@ -10,86 +10,152 @@
 ** implied warranty.
 */
 
+#include <stdbool.h>
+#include <assert.h>
+
+#include "mallocvar.h"
 #include "pnm.h"
 
-int main( argc, argv )
-int argc;
-char* argv[];
-{
-    FILE *ifp;
-    xel *xelrow, *xP;
-    unsigned char *sirarray;
-    int rows, cols, row, format, picsize, planesize;
-    register int col, i;
+
+
+static void
+readSirHeader(FILE *         const ifP,
+              int *          const formatP,
+              unsigned int * const rowsP,
+              unsigned int * const colsP) {
+
     short info;
 
-    pnm_init( &argc, argv );
+    pm_readlittleshort(ifP, &info);
+    if (info != 0x3a4f)
+        pm_error( "Input file is not a Solitaire file");
 
-    if ( argc > 2 )
-	pm_usage( "[sirfile]" );
+    pm_readlittleshort(ifP, &info);
 
-    if ( argc == 2 )
-	ifp = pm_openr( argv[1] );
+    pm_readlittleshort(ifP, &info);
+    if (info == 17)
+        *formatP = PGM_TYPE;
+    else if (info == 11)
+        *formatP = PPM_TYPE;
     else
-	ifp = stdin;
-
-    pm_readlittleshort( ifp, &info );
-    if ( info != 0x3a4f)
-	pm_error( "Input file is not a Solitaire file" );
-    pm_readlittleshort( ifp, &info );
-    pm_readlittleshort( ifp, &info );
-    if ( info == 17 )
+        pm_error( "Input is not MGI TYPE 11 or MGI TYPE 17" );
+
+    pm_readlittleshort(ifP, &info);
+    *colsP = info;
+
+    pm_readlittleshort(ifP, &info);
+    *rowsP = info;
+
     {
-	format = PGM_TYPE;
+        unsigned int i;
+        for (i = 1; i < 1531; ++i)
+            pm_readlittleshort(ifP, &info);
     }
-    else if ( info == 11 )
-    {
-	format = PPM_TYPE;
+}
+
+
+
+static void
+convertPgm(FILE *       const ifP,
+           FILE *       const ofP,
+           unsigned int const rows,
+           unsigned int const cols,
+           xel *        const xelrow) {
+
+    unsigned int row;
+
+    pm_message("Writing a PGM file");
+
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
+        for (col = 0; col < cols; ++col)
+            PNM_ASSIGN1(xelrow[col], fgetc(ifP));
+
+        pnm_writepnmrow(ofP, xelrow, cols, 255, PGM_TYPE, 0);
+    }
+}
+
+
+
+static void
+convertPpm(FILE *       const ifP,
+           FILE *       const ofP,
+           unsigned int const rows,
+           unsigned int const cols,
+           xel *        const xelrow) {
+
+    unsigned int const picsize = cols * rows * 3;
+    unsigned int const planesize = cols * rows;
+
+    unsigned char * sirarray;  /* malloc'ed array */
+    unsigned int row;
+
+    if (UINT_MAX/cols/rows < 3)
+        pm_error("Image is too large (%u x %u x %u) for computation",
+                 cols, rows, 3);
+
+    MALLOCARRAY(sirarray, picsize);
+
+    if (!sirarray)
+        pm_error( "Not enough memory to load %u x %u x %u SIR file",
+                  cols, rows, 3);
+
+    if (fread(sirarray, 1, picsize, ifP) != picsize)
+        pm_error("Error reading SIR file");
+
+    pm_message("Writing a PPM file");
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
+
+        for (col = 0; col < cols; col++)
+            PPM_ASSIGN(xelrow[col], sirarray[row*cols+col],
+                       sirarray[planesize + (row*cols+col)],
+                       sirarray[2*planesize + (row*cols+col)]);
+
+        pnm_writepnmrow(ofP, xelrow, cols, 255, PPM_TYPE, 0);
     }
+    free(sirarray);
+}
+
+
+
+int
+main(int argc, const char ** argv) {
+
+    FILE * ifP;
+    xel * xelrow;
+    unsigned int rows, cols;
+    int format;
+
+    pm_proginit(&argc, argv);
+
+    if (argc-1 > 1)
+        pm_error ("Too many arguments.  The only possible argument is "
+                  "the input file name");
+    else if (argc-1 >= 1)
+        ifP = pm_openr(argv[1]);
     else
-	pm_error( "Input is not MGI TYPE 11 or MGI TYPE 17" );
-    pm_readlittleshort( ifp, &info );
-    cols = (int) ( info );
-    pm_readlittleshort( ifp, &info );
-    rows = (int) ( info );
-    for ( i = 1; i < 1531; i++ )
-	pm_readlittleshort( ifp, &info );
-
-    pnm_writepnminit( stdout, cols, rows, 255, format, 0 );
-    xelrow = pnm_allocrow( cols );
-    switch ( PNM_FORMAT_TYPE(format) )
-    {
-	case PGM_TYPE:
-            pm_message( "Writing a PGM file" );
-	    for ( row = 0; row < rows; ++row )
-	    {
-	        for ( col = 0, xP = xelrow; col < cols; col++, xP++ )
-	        	PNM_ASSIGN1( *xP, fgetc( ifp ) );
-	        pnm_writepnmrow( stdout, xelrow, cols, 255, format, 0 );
-	    }
-	    break;
-	case PPM_TYPE:
-	    picsize = cols * rows * 3;
-	    planesize = cols * rows;
-            if ( !( sirarray = (unsigned char*) malloc( picsize ) ) ) 
-	        pm_error( "Not enough memory to load SIR file" );
-	    if ( fread( sirarray, 1, picsize, ifp ) != picsize )
-	        pm_error( "Error reading SIR file" );
-            pm_message( "Writing a PPM file" );
-            for ( row = 0; row < rows; row++ )
-	    {
-	        for ( col = 0, xP = xelrow; col < cols; col++, xP++ )
-        	    PPM_ASSIGN( *xP, sirarray[row*cols+col],
-				 sirarray[planesize + (row*cols+col)],
-				 sirarray[2*planesize + (row*cols+col)] );
-                pnm_writepnmrow( stdout, xelrow, cols, 255, format, 0 );
-	    }
-	    break;
-	default:
-	    pm_error( "Shouldn't happen" );
+        ifP = stdin;
+
+    readSirHeader(ifP, &format, &rows, &cols);
+
+    pnm_writepnminit(stdout, cols, rows, 255, format, 0);
+
+    xelrow = pnm_allocrow(cols);
+
+    switch (PNM_FORMAT_TYPE(format)) {
+    case PGM_TYPE:
+        convertPgm(ifP, stdout, rows, cols, xelrow);
+        break;
+    case PPM_TYPE:
+        convertPpm(ifP, stdout, rows, cols, xelrow);
+        break;
+    default:
+        assert(false);
     }
+    pnm_freerow(xelrow);
 
-    pm_close( ifp );
+    pm_close(ifP);
 
-    exit( 0 );
+    exit(0);
 }
diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c
index 0c301a4a..e8f076a4 100644
--- a/converter/other/tifftopnm.c
+++ b/converter/other/tifftopnm.c
@@ -1372,6 +1372,9 @@ convertRasterByRows(pnmOut *       const pnmOutP,
     if (scanbuf == NULL)
         pm_error("can't allocate memory for scanline buffer");
 
+    if (UINT_MAX/cols < spp)
+        pm_error("Image is too wide/deep (%u x %u) for computations",
+                 cols, spp);
     MALLOCARRAY(samplebuf, cols * spp);
     if (samplebuf == NULL)
         pm_error("can't allocate memory for row buffer");
diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
index 4eb16def..5523acab 100644
--- a/converter/other/xwdtopnm.c
+++ b/converter/other/xwdtopnm.c
@@ -39,14 +39,14 @@
 #include "x10wd.h"
 #include "x11wd.h"
 
-struct compMask {
+struct CompMask {
     unsigned long red;
     unsigned long grn;
     unsigned long blu;
 };
 
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
@@ -62,32 +62,33 @@ static bool debug;
 static bool verbose;
 
 #ifdef DEBUG_PIXEL
-static unsigned int pixel_count = 0;
+static unsigned int pixelCount = 0;
 #endif
 
 /* Byte-swapping junk. */
 
 static int
-zero_bits(const unsigned long mask) {
+zeroBits(unsigned long const mask) {
 /*----------------------------------------------------------------------------
    Return the number of consecutive zero bits at the least significant end
    of the binary representation of 'mask'.  E.g. if mask == 0x00fff800,
    we would return 11.
 -----------------------------------------------------------------------------*/
-    int i;
-    unsigned long shifted_mask;
+    unsigned int i;
+    unsigned long shiftedMask;
+
+    for (i = 0, shiftedMask = mask;
+         i < sizeof(mask)*8 && (shiftedMask & 0x00000001) == 0;
+         ++i, shiftedMask >>= 1 );
 
-    for (i=0, shifted_mask = mask;
-         i < sizeof(mask)*8 && (shifted_mask & 0x00000001) == 0;
-         i++, shifted_mask >>= 1 );
-    return(i);
+    return i;
 }
 
 
 
 static void
-parseCommandLine(int argc, char ** argv,
-                 struct cmdlineInfo * const cmdlineP) {
+parseCommandLine(int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    Note that many of the strings that this function returns in the
    *cmdline_p structure are actually in the supplied argv array.  And
@@ -114,7 +115,7 @@ parseCommandLine(int argc, char ** argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
 
-    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, (char **) argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (argc - 1 == 0)
@@ -125,7 +126,7 @@ parseCommandLine(int argc, char ** argv,
         else
             cmdlineP->inputFilename = strdup(argv[1]);
     } else
-        pm_error("Too many arguments.  The only argument accepted\n"
+        pm_error("Too many arguments.  The only argument accepted "
                  "is the input file specification");
 }
 
@@ -141,19 +142,24 @@ processX10Header(X10WDFileHeader *  const h10P,
                  enum visualclass * const visualclassP,
                  int *              const formatP,
                  xel **             const colorsP,
-                 int *              const bits_per_pixelP,
-                 int *              const bits_per_itemP,
-                 struct compMask *  const compMaskP,
-                 enum byteorder *   const byte_orderP,
-                 enum byteorder *   const bit_orderP) {
-
-    int i;
-    X10Color* x10colors;
+                 int *              const bitsPerPixelP,
+                 int *              const bitsPerItemP,
+                 struct CompMask *  const compMaskP,
+                 enum byteorder *   const byteOrderP,
+                 enum byteorder *   const bitOrderP) {
+/*----------------------------------------------------------------------------
+  *h10P is a mapping of the raw bytes of the header.  Interpret and validate
+  it and return the information as *colsP, etc.
+
+  As a side effect, destroy *h10P.
+-----------------------------------------------------------------------------*/
+    unsigned int i;
+    X10Color * x10colors;
     bool grayscale;
-    bool byte_swap;
+    bool bytesSwapped;
 
     if (h10P->file_version != X10WD_FILE_VERSION) {
-        byte_swap = TRUE;
+        bytesSwapped = true;
         h10P->header_size     = pm_bs_long(h10P->header_size);
         h10P->file_version    = pm_bs_long(h10P->file_version);
         h10P->display_type    = pm_bs_long(h10P->display_type);
@@ -168,7 +174,7 @@ processX10Header(X10WDFileHeader *  const h10P,
         h10P->window_bdrwidth = pm_bs_short(h10P->window_bdrwidth);
         h10P->window_ncolors  = pm_bs_short(h10P->window_ncolors);
     } else
-        byte_swap = FALSE;
+        bytesSwapped = false;
 
     for (i = 0; i < h10P->header_size - sizeof(*h10P); ++i)
         if (getc(file) == EOF)
@@ -192,7 +198,7 @@ processX10Header(X10WDFileHeader *  const h10P,
             bytesRead = fread(&x10colors[i], sizeof(X10Color), 1, file);
             if (bytesRead != 1)
                 pm_error("couldn't read X10 XWD colormap");
-            if (byte_swap) {
+            if (bytesSwapped) {
                 x10colors[i].red   = pm_bs_short(x10colors[i].red);
                 x10colors[i].green = pm_bs_short(x10colors[i].green);
                 x10colors[i].blue  = pm_bs_short(x10colors[i].blue);
@@ -203,6 +209,14 @@ processX10Header(X10WDFileHeader *  const h10P,
         }
     }
 
+    if (h10P->pixmap_width < 0)
+        pm_error("XWD header says pixmap_width is negative: %d",
+                 h10P->pixmap_width);
+    if (h10P->pixmap_width > UINT_MAX/8 - 15)
+        pm_error("XWD header says pixmap_width is %d, "
+                 "which is too large for this program to compute",
+                 h10P->pixmap_width);
+
     if (h10P->display_planes == 1) {
         *formatP = PBM_TYPE;
         *visualclassP = StaticGray;
@@ -212,8 +226,8 @@ processX10Header(X10WDFileHeader *  const h10P,
         PNM_ASSIGN1((*colorsP)[1], *maxvalP);
         *padrightP =
             (((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width) * 8;
-        *bits_per_itemP = 16;
-        *bits_per_pixelP = 1;
+        *bitsPerItemP = 16;
+        *bitsPerPixelP = 1;
     } else if (h10P->window_ncolors == 0) {
         /* Must be grayscale. */
         unsigned int i;
@@ -233,8 +247,8 @@ processX10Header(X10WDFileHeader *  const h10P,
             PNM_ASSIGN1((*colorsP)[i], i);
         *padrightP =
             (((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width) * 8;
-        *bits_per_itemP = 16;
-        *bits_per_pixelP = 1;
+        *bitsPerItemP = 16;
+        *bitsPerPixelP = 1;
     } else {
         *maxvalP = 65535;
 
@@ -255,20 +269,20 @@ processX10Header(X10WDFileHeader *  const h10P,
         }
 
         *padrightP = (h10P->pixmap_width & 1) * 8;
-        *bits_per_itemP = 8;
-        *bits_per_pixelP = 8;
+        *bitsPerItemP  = 8;
+        *bitsPerPixelP = 8;
     }
     *colsP = h10P->pixmap_width;
     *rowsP = h10P->pixmap_height;
-    *byte_orderP = MSBFirst;
-    *bit_orderP = LSBFirst;
+    *byteOrderP = MSBFirst;
+    *bitOrderP  = LSBFirst;
 }
 
 
 
 static void
-fixH11ByteOrder(X11WDFileHeader *  const h11P,
-                X11WDFileHeader ** const h11FixedPP) {
+fixH11ByteOrder(const X11WDFileHeader * const h11P,
+                X11WDFileHeader **      const h11FixedPP) {
 
     X11WDFileHeader * h11FixedP;
 
@@ -325,7 +339,7 @@ static void
 readX11Colormap(FILE *       const file,
                 unsigned int const nColors,
                 bool         const byteSwap,
-                bool         const cmapDump,
+                bool         const mustDumpCmap,
                 X11XColor**  const x11colorsP) {
 
     X11XColor * x11colors;
@@ -346,7 +360,7 @@ readX11Colormap(FILE *       const file,
             x11colors[i].blue  = pm_bs_short(x11colors[i].blue);
         }
     }
-    if (cmapDump)
+    if (mustDumpCmap)
         dumpX11Cmap(nColors, x11colors);
 
     *x11colorsP = x11colors;
@@ -467,7 +481,7 @@ reverseBits(unsigned long arg,
 
 static void
 computeComponentMasks(X11WDFileHeader * const h11P,
-                      struct compMask * const compMaskP) {
+                      struct CompMask * const compMaskP) {
 /*----------------------------------------------------------------------------
    You'd think the component (red, green, blue) masks in the header
    would just be right.  But we've seen a direct color image which has
@@ -517,31 +531,34 @@ computeComponentMasks(X11WDFileHeader * const h11P,
 
 
 static void
-processX11Header(X11WDFileHeader *  const h11P,
-                 FILE *             const fileP,
-                 bool               const cmapDump,
-                 int *              const colsP,
-                 int *              const rowsP,
-                 unsigned int *     const padrightP,
-                 xelval *           const maxvalP,
-                 enum visualclass * const visualclassP,
-                 int *              const formatP,
-                 xel **             const colorsP,
-                 int *              const bits_per_pixelP,
-                 int *              const bits_per_itemP,
-                 struct compMask *  const compMaskP,
-                 enum byteorder *   const byte_orderP,
-                 enum byteorder *   const bit_orderP) {
-
-    int i;
-    X11XColor* x11colors;
+processX11Header(const X11WDFileHeader *  const h11P,
+                 FILE *                   const fileP,
+                 bool                     const mustDumpCmap,
+                 int *                    const colsP,
+                 int *                    const rowsP,
+                 unsigned int *           const padrightP,
+                 xelval *                 const maxvalP,
+                 enum visualclass *       const visualclassP,
+                 int *                    const formatP,
+                 xel **                   const colorsP,
+                 int *                    const bitsPerPixelP,
+                 int *                    const bitsPerItemP,
+                 struct CompMask *        const compMaskP,
+                 enum byteorder *         const byteOrderP,
+                 enum byteorder *         const bitOrderP) {
+/*----------------------------------------------------------------------------
+  *h11P is a mapping of the raw bytes of the header.  Interpret and validate
+   it and return the information as *colsP, etc.
+-----------------------------------------------------------------------------*/
+    unsigned int i;
+    X11XColor * x11colors;
     bool grayscale;
-    bool const byte_swap = (h11P->file_version != X11WD_FILE_VERSION);
+    bool const bytesSwapped = (h11P->file_version != X11WD_FILE_VERSION);
     X11WDFileHeader * h11FixedP;
 
     fixH11ByteOrder(h11P, &h11FixedP);
 
-    if (byte_swap && verbose)
+    if (bytesSwapped && verbose)
         pm_message("Header is different endianness from this machine.");
 
     for (i = 0; i < h11FixedP->header_size - sizeof(*h11FixedP); ++i)
@@ -567,11 +584,11 @@ processX11Header(X11WDFileHeader *  const h11P,
                  h11FixedP->bitmap_unit);
 
     if (h11FixedP->ncolors > 0) {
-        readX11Colormap(fileP, h11FixedP->ncolors, byte_swap, cmapDump,
+        readX11Colormap(fileP, h11FixedP->ncolors, bytesSwapped, mustDumpCmap,
                         &x11colors);
         grayscale = colormapAllGray(x11colors, h11FixedP->ncolors);
     } else
-        grayscale = TRUE;
+        grayscale = true;
 
     *visualclassP = (enum visualclass) h11FixedP->visual_class;
     if (*visualclassP == DirectColor) {
@@ -600,7 +617,7 @@ processX11Header(X11WDFileHeader *  const h11P,
     } else if (*visualclassP == StaticGray && h11FixedP->bits_per_pixel == 1) {
         *formatP = PBM_TYPE;
         *maxvalP = 1;
-        *colorsP = pnm_allocrow( 2 );
+        *colorsP = pnm_allocrow(2);
         PNM_ASSIGN1((*colorsP)[0], *maxvalP);
         PNM_ASSIGN1((*colorsP)[1], 0);
     } else if (*visualclassP == StaticGray) {
@@ -636,8 +653,25 @@ processX11Header(X11WDFileHeader *  const h11P,
         *maxvalP = 65535;
     }
 
+    if (h11FixedP->pixmap_width < 1)
+        pm_error("XWD header states zero width");
+
     *colsP = h11FixedP->pixmap_width;
+
+    if (h11FixedP->pixmap_height < 1)
+        pm_error("XWD header states zero height");
+
     *rowsP = h11FixedP->pixmap_height;
+
+    if (h11FixedP->bytes_per_line > UINT_MAX/8)
+        pm_error("XWD header says bytes per line is %u, "
+                 "which is too large for this program to compute",
+                 h11FixedP->bytes_per_line);
+    if (h11FixedP->pixmap_width > UINT_MAX/h11FixedP->bits_per_pixel)
+        pm_error("XWD header says there are %u pixels per row and "
+                 "%u bits per pixel, which is too many for this program "
+                 "to compute",
+                 h11FixedP->pixmap_width, h11FixedP->bits_per_pixel);
     *padrightP =
         h11FixedP->bytes_per_line * 8 -
         h11FixedP->pixmap_width * h11FixedP->bits_per_pixel;
@@ -674,18 +708,18 @@ processX11Header(X11WDFileHeader *  const h11P,
        We still don't see any logic in these fields at all, but we
        figure whichever one is greater (assuming both are meaningful)
        has to be the item size.  */
-    *bits_per_itemP  = MAX(h11FixedP->bitmap_pad, h11FixedP->bitmap_unit);
-    *bits_per_pixelP = h11FixedP->bits_per_pixel;
+    *bitsPerItemP  = MAX(h11FixedP->bitmap_pad, h11FixedP->bitmap_unit);
+    *bitsPerPixelP = h11FixedP->bits_per_pixel;
 
     if (*visualclassP == DirectColor) {
         /* Strange, but we've seen a Direct Color 24/32 image that
            says LSBFirst and it's a lie.  And Xwud renders it correctly.
         */
-        *byte_orderP = MSBFirst;
-        *bit_orderP = MSBFirst;
+        *byteOrderP = MSBFirst;
+        *bitOrderP  = MSBFirst;
     } else {
-        *byte_orderP = (enum byteorder) h11FixedP->byte_order;
-        *bit_orderP  = (enum byteorder) h11FixedP->bitmap_bit_order;
+        *byteOrderP = (enum byteorder) h11FixedP->byte_order;
+        *bitOrderP  = (enum byteorder) h11FixedP->bitmap_bit_order;
     }
     computeComponentMasks(h11FixedP, compMaskP);
 
@@ -695,21 +729,21 @@ processX11Header(X11WDFileHeader *  const h11P,
 
 
 static void
-getinit(FILE *             const ifP,
-        int *              const colsP,
-        int *              const rowsP,
-        unsigned int *     const padrightP,
-        xelval *           const maxvalP,
-        enum visualclass * const visualclassP,
-        int *              const formatP,
-        xel **             const colorsP,
-        int *              const bits_per_pixelP,
-        int *              const bits_per_itemP,
-        struct compMask *  const compMaskP,
-        enum byteorder *   const byte_orderP,
-        enum byteorder *   const bit_orderP,
-        bool               const headerDump,
-        bool               const cmapDump) {
+readXwdHeader(FILE *             const ifP,
+              int *              const colsP,
+              int *              const rowsP,
+              unsigned int *     const padrightP,
+              xelval *           const maxvalP,
+              enum visualclass * const visualclassP,
+              int *              const formatP,
+              xel **             const colorsP,
+              int *              const bitsPerPixelP,
+              int *              const bitsPerItemP,
+              struct CompMask *  const compMaskP,
+              enum byteorder *   const byteOrderP,
+              enum byteorder *   const bitOrderP,
+              bool               const headerDump,
+              bool               const mustDumpCmap) {
 /*----------------------------------------------------------------------------
    Read the header from the XWD image in input stream 'ifP'.  Leave
    the stream positioned to the beginning of the raster.
@@ -718,20 +752,20 @@ getinit(FILE *             const ifP,
 
    Return as *padrightP the number of additional bits of padding are
    at the end of each line of input.  This says the input stream
-   contains *colsP pixels of image data (at *bits_per_pixelP bits each)
+   contains *colsP pixels of image data (at *bitsPerPixelP bits each)
    plus *padrightP bits of padding.
 -----------------------------------------------------------------------------*/
     /* Assume X11 headers are larger than X10 ones. */
     unsigned char header[sizeof(X11WDFileHeader)];
-    X10WDFileHeader* h10P;
-    X11WDFileHeader* h11P;
+    X10WDFileHeader * h10P;
+    X11WDFileHeader * h11P;
     int rc;
 
     h10P = (X10WDFileHeader*) header;
     h11P = (X11WDFileHeader*) header;
     if ( sizeof(*h10P) > sizeof(*h11P) )
         pm_error("ARGH!  On this machine, X10 headers are larger than "
-                 "X11 headers!\n    You will have to re-write xwdtopnm." );
+                 "X11 headers!  You will have to re-write xwdtopnm." );
 
     /* We read an X10 header's worth of data from the file, then look
        at it to see if it looks like an X10 header.  If so we process
@@ -752,8 +786,8 @@ getinit(FILE *             const ifP,
             pm_message("Input is X10");
         processX10Header(h10P, ifP, colsP, rowsP, padrightP, maxvalP,
                          visualclassP, formatP,
-                         colorsP, bits_per_pixelP, bits_per_itemP,
-                         compMaskP, byte_orderP, bit_orderP);
+                         colorsP, bitsPerPixelP, bitsPerItemP,
+                         compMaskP, byteOrderP, bitOrderP);
     } else if (h11P->file_version == X11WD_FILE_VERSION ||
                pm_bs_long(h11P->file_version) == X11WD_FILE_VERSION) {
 
@@ -771,13 +805,14 @@ getinit(FILE *             const ifP,
         if (headerDump)
             dumpX11Header(h11P);
 
-        processX11Header(h11P, ifP, cmapDump,
+        processX11Header(h11P, ifP, mustDumpCmap,
                          colsP, rowsP, padrightP, maxvalP,
                          visualclassP, formatP,
-                         colorsP, bits_per_pixelP, bits_per_itemP,
-                         compMaskP, byte_orderP, bit_orderP);
+                         colorsP, bitsPerPixelP, bitsPerItemP,
+                         compMaskP, byteOrderP, bitOrderP);
     } else
-        pm_error("unknown XWD file version: %u", h11P->file_version);
+        pm_error("unknown XWD file version: %u.  "
+                 "Probably not an XWD file", h11P->file_version);
 }
 
 
@@ -970,7 +1005,7 @@ readItem(pixelReader * const rdrP) {
     }
         break;
     default:
-        pm_error("INTERNAL ERROR: impossible bits_per_item");
+        pm_error("INTERNAL ERROR: impossible bitsPerItem");
     }
 }
 
@@ -1069,21 +1104,21 @@ pixelReader_getpix(pixelReader * const rdrP) {
    pure binary cipher, with the first bit the most significant bit.
 
    The basic unit of storage in the input file is an "item."  An item
-   can be 1, 2, or 4 bytes, and 'bits_per_item' tells us which.  Each
+   can be 1, 2, or 4 bytes, and 'bitsPerItem' tells us which.  Each
    item can have its bytes stored in forward or reverse order, and
-   'byte_order' tells us which.  We have seen a Direct Color 24 bpp/32 bpi
-   image which said 'byte_order' == LSBFirst, but the byte order is
+   'byteOrder' tells us which.  We have seen a Direct Color 24 bpp/32 bpi
+   image which said 'byteOrder' == LSBFirst, but the byte order is
    nonetheless MSB first.
 
    Each item can contain one or more pixels, and may contain
-   fractional pixels.  'bits_per_pixel' tells us how many bits each
-   pixel has, and 'bits_per_pixel' is always less than or equal to
-   'bits_per_item', but not necessarily a factor of it.  Within an item,
+   fractional pixels.  'bitsPerPixel' tells us how many bits each
+   pixel has, and 'bitsPerPixel' is always less than or equal to
+   'bitsPerItem', but not necessarily a factor of it.  Within an item,
    after taking care of the endianness of its storage format, the pixels
-   may be arranged from left to right or right to left.  'bit_order' tells
+   may be arranged from left to right or right to left.  'bitOrder' tells
    us which.  We have also seen images in which the pixels are arranged
    from left to right within the items, but the RGB components within
-   each pixel are right to left and 'bit_order' is LSBFirst.
+   each pixel are right to left and 'bitOrder' is LSBFirst.
 
    But it's not that simple.  Sometimes dummy bits are added to the
    right edge of the image in order to make an integral number of
@@ -1112,15 +1147,15 @@ reportInfo(int              const cols,
            xelval           const maxval,
            enum visualclass const visualclass,
            int              const format,
-           int              const bits_per_pixel,
-           int              const bits_per_item,
-           struct compMask  const compMask,
-           enum byteorder   const byte_order,
-           enum byteorder   const bit_order) {
+           int              const bitsPerPixel,
+           int              const bitsPerItem,
+           struct CompMask  const compMask,
+           enum byteorder   const byteOrder,
+           enum byteorder   const bitOrder) {
 
     const char *visualclass_name;
-    const char *byte_order_name;
-    const char *bit_order_name;
+    const char *byteOrder_name;
+    const char *bitOrder_name;
     switch (visualclass) {
     case StaticGray:  visualclass_name="StaticGray";  break;
     case GrayScale:   visualclass_name="Grayscale";   break;
@@ -1130,25 +1165,25 @@ reportInfo(int              const cols,
     case DirectColor: visualclass_name="DirectColor"; break;
     default:          visualclass_name="(invalid)";    break;
     }
-    switch (byte_order) {
-    case MSBFirst: byte_order_name = "MSBFirst";  break;
-    case LSBFirst: byte_order_name = "LSBFirst";  break;
-    default:       byte_order_name = "(invalid)"; break;
+    switch (byteOrder) {
+    case MSBFirst: byteOrder_name = "MSBFirst";  break;
+    case LSBFirst: byteOrder_name = "LSBFirst";  break;
+    default:       byteOrder_name = "(invalid)"; break;
     }
-    switch (bit_order) {
-    case MSBFirst: bit_order_name = "MSBFirst";  break;
-    case LSBFirst: bit_order_name = "LSBFirst";  break;
-    default:       bit_order_name = "(invalid)"; break;
+    switch (bitOrder) {
+    case MSBFirst: bitOrder_name = "MSBFirst";  break;
+    case LSBFirst: bitOrder_name = "LSBFirst";  break;
+    default:       bitOrder_name = "(invalid)"; break;
     }
     pm_message("%d rows of %d columns with maxval %d",
                rows, cols, maxval);
     pm_message("padright=%u bits.  visualclass = %s.  format=%d (%c%c)",
                padright, visualclass_name,
                format, format/256, format%256);
-    pm_message("bits_per_pixel=%d; bits_per_item=%d",
-               bits_per_pixel, bits_per_item);
-    pm_message("byte_order=%s; bit_order=%s",
-               byte_order_name, bit_order_name);
+    pm_message("bitsPerPixel=%d; bitsPerItem=%d",
+               bitsPerPixel, bitsPerItem);
+    pm_message("byteOrder=%s; bitOrder=%s",
+               byteOrder_name, bitOrder_name);
     pm_message("component mask: red=0x%.8lx; grn=0x%.8lx; blu=0x%.8lx",
                compMask.red, compMask.grn, compMask.blu);
 }
@@ -1194,7 +1229,7 @@ static void
 convertRowDirect(pixelReader *   const pixelReaderP,
                  int             const cols,
                  const xel *     const colors,
-                 struct compMask const compMask,
+                 struct CompMask const compMask,
                  xel *           const xelrow) {
 
     unsigned int col;
@@ -1204,20 +1239,20 @@ convertRowDirect(pixelReader *   const pixelReaderP,
             /* This is a triplet of indices into the color map, packed
                into this bit string according to compMask
             */
-        unsigned int red_index, grn_index, blu_index;
+        unsigned int redIndex, grnIndex, bluIndex;
             /* These are indices into the color map, unpacked from 'pixel'.
              */
 
         pixel = pixelReader_getpix(pixelReaderP);
 
-        red_index = (pixel & compMask.red) >> zero_bits(compMask.red);
-        grn_index = (pixel & compMask.grn) >> zero_bits(compMask.grn);
-        blu_index = (pixel & compMask.blu) >> zero_bits(compMask.blu);
+        redIndex = (pixel & compMask.red) >> zeroBits(compMask.red);
+        grnIndex = (pixel & compMask.grn) >> zeroBits(compMask.grn);
+        bluIndex = (pixel & compMask.blu) >> zeroBits(compMask.blu);
 
         PPM_ASSIGN(xelrow[col],
-                   PPM_GETR(colors[red_index]),
-                   PPM_GETG(colors[grn_index]),
-                   PPM_GETB(colors[blu_index])
+                   PPM_GETR(colors[redIndex]),
+                   PPM_GETG(colors[grnIndex]),
+                   PPM_GETB(colors[bluIndex])
             );
     }
 }
@@ -1229,16 +1264,16 @@ convertRowTrueColor(pixelReader *   const pixelReaderP,
                     int             const cols,
                     pixval          const maxval,
                     const xel *     const colors,
-                    struct compMask const compMask,
+                    struct CompMask const compMask,
                     xel *           const xelrow) {
 
     unsigned int col;
     unsigned int red_shift, grn_shift, blu_shift;
     unsigned int red_maxval, grn_maxval, blu_maxval;
 
-    red_shift = zero_bits(compMask.red);
-    grn_shift = zero_bits(compMask.grn);
-    blu_shift = zero_bits(compMask.blu);
+    red_shift = zeroBits(compMask.red);
+    grn_shift = zeroBits(compMask.grn);
+    blu_shift = zeroBits(compMask.blu);
 
     red_maxval = compMask.red >> red_shift;
     grn_maxval = compMask.grn >> grn_shift;
@@ -1270,7 +1305,7 @@ convertRow(pixelReader *    const pixelReaderP,
            int              const cols,
            xelval           const maxval,
            int              const format,
-           struct compMask  const compMask,
+           struct CompMask  const compMask,
            const xel*       const colors,
            enum visualclass const visualclass) {
 /*----------------------------------------------------------------------------
@@ -1337,9 +1372,9 @@ reportOutputType(int const format) {
 
 
 int
-main(int argc, char *argv[]) {
+main(int argc, const char ** argv) {
 
-    struct cmdlineInfo cmdline;
+    struct CmdlineInfo cmdline;
     FILE * ifP;
     int rows, cols, format;
     unsigned int padright;
@@ -1347,14 +1382,14 @@ main(int argc, char *argv[]) {
     unsigned int row;
     int bitsPerPixel;
     int bitsPerItem;
-    struct compMask compMask;
+    struct CompMask compMask;
     xelval maxval;
     enum visualclass visualclass;
     enum byteorder byteOrder, bitOrder;
     xel * colors;  /* the color map */
     pixelReader pixelReader;
 
-    pnm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
@@ -1366,10 +1401,10 @@ main(int argc, char *argv[]) {
     else
         ifP = stdin;
 
-    getinit(ifP, &cols, &rows, &padright, &maxval, &visualclass, &format,
-            &colors, &bitsPerPixel, &bitsPerItem,
-            &compMask, &byteOrder, &bitOrder,
-            cmdline.headerdump, cmdline.cmapdump);
+    readXwdHeader(ifP, &cols, &rows, &padright, &maxval, &visualclass, &format,
+                  &colors, &bitsPerPixel, &bitsPerItem,
+                  &compMask, &byteOrder, &bitOrder,
+                  cmdline.headerdump, cmdline.cmapdump);
 
     warn16Bit(maxval);
 
@@ -1413,7 +1448,7 @@ main(int argc, char *argv[]) {
    doesn't match these hard-coded shift amounts, so we have replaced
    this whole switch thing.  -Bryan 00.03.01
 
-   switch (bits_per_pixel) {
+   switch (bitsPerPixel) {
 
    case 16:
        PPM_ASSIGN( *xP,
diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c
index 5db507a3..f9655fce 100644
--- a/converter/pbm/g3topbm.c
+++ b/converter/pbm/g3topbm.c
@@ -21,6 +21,8 @@
 #define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */
 #define _BSD_SOURCE   /* Make nstring.h define strcaseeq() */
 
+#include <assert.h>
+
 #include "pm_c_util.h"
 #include "pbm.h"
 #include "shhopt.h"
@@ -71,10 +73,6 @@ The receiver may be less patient.  It may opt to disconnect if one row
 is not received within 5 seconds.
 */
 
-static G3TableEntry * whash[HASHSIZE];
-static G3TableEntry * bhash[HASHSIZE];
-
-
 struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
@@ -85,6 +83,7 @@ struct CmdlineInfo {
     unsigned int stretch;
     unsigned int stop_error;
     unsigned int expectedLineSize;
+    unsigned int correctlong;
 };
 
 
@@ -120,6 +119,8 @@ parseCommandLine(int argc, const char ** const argv,
             &widthSpec,                0);
     OPTENT3(0, "paper_size",       OPT_STRING, &paperSize,
             &paper_sizeSpec,           0);
+    OPTENT3(0, "correctlong",      OPT_FLAG,  NULL, &cmdlineP->correctlong,
+            0);
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -163,6 +164,11 @@ parseCommandLine(int argc, const char ** const argv,
 
 
 
+typedef struct {
+    const G3TableEntry * whash[HASHSIZE];
+    const G3TableEntry * bhash[HASHSIZE];
+} BwHash;
+
 struct BitStream {
 
     FILE * fileP;
@@ -275,16 +281,16 @@ skipToNextLine(struct BitStream * const bitStreamP) {
 
 
 static void
-addtohash(G3TableEntry *     hash[],
-          G3TableEntry       table[],
-          unsigned int const n,
-          int          const a,
-          int          const b) {
+addtohash(const G3TableEntry ** const hash,
+          const G3TableEntry *  const table,
+          unsigned int          const n,
+          int                   const a,
+          int                   const b) {
 
     unsigned int i;
 
     for (i = 0; i < n; ++i) {
-        G3TableEntry * const teP = &table[i*2];
+        const G3TableEntry * const teP = &table[i*2];
         unsigned int const pos =
             ((teP->length + a) * (teP->code + b)) % HASHSIZE;
         if (hash[pos])
@@ -295,38 +301,51 @@ addtohash(G3TableEntry *     hash[],
 
 
 
-static G3TableEntry *
-hashfind(G3TableEntry *       hash[],
-         int            const length,
-         int            const code,
-         int            const a,
-         int            const b) {
+static const G3TableEntry *
+hashfind(const G3TableEntry * const * const hash,
+         unsigned int                 const length,
+         int                          const code,
+         int                          const a,
+         int                          const b) {
 
-    unsigned int pos;
-    G3TableEntry * te;
+    unsigned int         const pos = ((length + a) * (code + b)) % HASHSIZE;
+    const G3TableEntry * const teP = hash[pos];
 
-    pos = ((length + a) * (code + b)) % HASHSIZE;
-    te = hash[pos];
-    return ((te && te->length == length && te->code == code) ? te : NULL);
+    return ((teP && teP->length == length && teP->code == code) ? teP : NULL);
 }
 
 
 
-static void
-buildHashes(G3TableEntry * (*whashP)[HASHSIZE],
-            G3TableEntry * (*bhashP)[HASHSIZE]) {
+static BwHash *
+newBwHash() {
 
-    unsigned int i;
+    BwHash * bwHashP;
 
-    for (i = 0; i < HASHSIZE; ++i)
-        (*whashP)[i] = (*bhashP)[i] = NULL;
+    MALLOCVAR(bwHashP);
 
-    addtohash(*whashP, &g3ttable_table[0], 64, WHASHA, WHASHB);
-    addtohash(*whashP, &g3ttable_mtable[2], 40, WHASHA, WHASHB);
+    if (!bwHashP)
+        pm_error("Unable to allocate memory for hashes");
+    else {
+        unsigned int i;
+        /* Initialize */
+        for (i = 0; i < HASHSIZE; ++i)
+            bwHashP->whash[i] = bwHashP->bhash[i] = NULL;
 
-    addtohash(*bhashP, &g3ttable_table[1], 64, BHASHA, BHASHB);
-    addtohash(*bhashP, &g3ttable_mtable[3], 40, BHASHA, BHASHB);
+        addtohash(bwHashP->whash, &g3ttable_table [0], 64, WHASHA, WHASHB);
+        addtohash(bwHashP->whash, &g3ttable_mtable[2], 40, WHASHA, WHASHB);
 
+        addtohash(bwHashP->bhash, &g3ttable_table [1], 64, BHASHA, BHASHB);
+        addtohash(bwHashP->bhash, &g3ttable_mtable[3], 40, BHASHA, BHASHB);
+    }
+    return bwHashP;
+}
+
+
+
+static void
+freeBwHash(BwHash * const bwHashP) {
+
+    free(bwHashP);
 }
 
 
@@ -342,10 +361,11 @@ makeRowWhite(unsigned char * const packedBitrow,
 
 
 
-static G3TableEntry *
-g3code(unsigned int const curcode,
-       unsigned int const curlen,
-       bit          const color) {
+static const G3TableEntry *
+g3code(unsigned int   const curcode,
+       unsigned int   const curlen,
+       bit            const color,
+       const BwHash * const bwHashP) {
 /*----------------------------------------------------------------------------
    Return the position in the code tables mtable and ttable of the
    G3 code which is the 'curlen' bits long with value 'curcode'.
@@ -353,20 +373,20 @@ g3code(unsigned int const curcode,
    Note that it is the _position_ in the table that determines the meaning
    of the code.  The contents of the table entry do not.
 -----------------------------------------------------------------------------*/
-    G3TableEntry * retval;
+    const G3TableEntry * retval;
 
     switch (color) {
     case PBM_WHITE:
         if (curlen < 4)
             retval = NULL;
         else
-            retval = hashfind(whash, curlen, curcode, WHASHA, WHASHB);
+            retval = hashfind(bwHashP->whash, curlen, curcode, WHASHA, WHASHB);
         break;
     case PBM_BLACK:
         if (curlen < 2)
             retval = NULL;
         else
-            retval = hashfind(bhash, curlen, curcode, BHASHA, BHASHB);
+            retval = hashfind(bwHashP->bhash, curlen, curcode, BHASHA, BHASHB);
         break;
     default:
         pm_error("INTERNAL ERROR: color is not black or white");
@@ -481,6 +501,7 @@ formatBadCodeException(const char ** const exceptionP,
 static void
 readFaxRow(struct BitStream * const bitStreamP,
            unsigned char *    const packedBitrow,
+           BwHash *           const bwHashP,
            unsigned int *     const lineLengthP,
            const char **      const exceptionP,
            const char **      const errorP) {
@@ -561,7 +582,7 @@ readFaxRow(struct BitStream * const bitStreamP,
                     done = TRUE;
                 } else if (curcode != 0) {
                     const G3TableEntry * const teP =
-                        g3code(curcode, curlen, currentColor);
+                        g3code(curcode, curlen, currentColor, bwHashP);
                         /* Address of structure that describes the
                            current G3 code.  Null means 'curcode' isn't
                            a G3 code yet (probably just the beginning of one)
@@ -644,16 +665,21 @@ typedef struct {
         */
     bool warned;
         /* We have warned the user that he has a line length problem */
+
     bool tolerateErrors;
         /* Try to continue when we detect a line size error, as opposed to
            aborting the program.
         */
-} lineSizeAnalyzer;
+    unsigned int lineSizeCt[MAXCOLS+1];
+        /* Histogram of line sizes in image -- lineSizeCt[i] is the number
+           of lines we've seen of size i.
+        */
+} LineSizeAnalyzer;
 
 
 
 static void
-initializeLineSizeAnalyzer(lineSizeAnalyzer * const analyzerP,
+initializeLineSizeAnalyzer(LineSizeAnalyzer * const analyzerP,
                            unsigned int       const expectedLineSize,
                            bool               const tolerateErrors) {
 
@@ -662,12 +688,19 @@ initializeLineSizeAnalyzer(lineSizeAnalyzer * const analyzerP,
 
     analyzerP->maxLineSize = 0;
     analyzerP->warned      = FALSE;
+
+    {
+        unsigned int i;
+
+        for (i = 0; i < MAXCOLS; ++i)
+            analyzerP->lineSizeCt[i] = 0;
+    }
 }
 
 
 
 static void
-analyzeLineSize(lineSizeAnalyzer * const analyzerP,
+analyzeLineSize(LineSizeAnalyzer * const analyzerP,
                 unsigned int       const thisLineSize) {
 
     const char * error;
@@ -700,6 +733,45 @@ analyzeLineSize(lineSizeAnalyzer * const analyzerP,
         pm_strfree(error);
     }
     analyzerP->maxLineSize = MAX(thisLineSize, analyzerP->maxLineSize);
+
+    assert(thisLineSize <= MAXCOLS);
+    ++analyzerP->lineSizeCt[thisLineSize];
+}
+
+
+
+static unsigned int
+imageLineSize(const LineSizeAnalyzer * const lineSizeAnalyzerP,
+              bool                     const mustCorrectLongLine) {
+/*----------------------------------------------------------------------------
+   The width of the fax in pixels, based on the analysis of the image
+   *lineSizeAnalyzerP.
+
+   Zero if the fax contains no lines.
+-----------------------------------------------------------------------------*/
+    unsigned int retval;
+
+    if (mustCorrectLongLine) {
+        /* Assume that long lines are actually concatenation of two
+           lines because the EOL code that was supposed to separate them
+           got lost.
+
+           Assume the most common line length in the image is the correct line
+           length for the image and that other line lengths are due to
+           corruption
+        */
+        unsigned int modeSoFar;
+        unsigned int i;
+
+        for (i = 0, modeSoFar = 0; i <= MAXCOLS; ++i) {
+            if (lineSizeAnalyzerP->lineSizeCt[i] > modeSoFar)
+                modeSoFar = i;
+        }
+        retval = modeSoFar;
+    } else {
+        retval = lineSizeAnalyzerP->maxLineSize;
+    }
+    return retval;
 }
 
 
@@ -717,12 +789,14 @@ static void
 readFax(struct BitStream * const bitStreamP,
         bool               const stretch,
         unsigned int       const expectedLineSize,
-        bool               const tolerateErrors,
+        bool               const mustTolerateErrors,
+        bool               const mustCorrectLongLine,
+        BwHash *           const bwHashP,
         unsigned char ***  const packedBitsP,
         unsigned int *     const colsP,
         unsigned int *     const rowsP) {
 
-    lineSizeAnalyzer lineSizeAnalyzer;
+    LineSizeAnalyzer lineSizeAnalyzer;
     unsigned char ** packedBits;
     const char * error;
     bool eof;
@@ -731,7 +805,7 @@ readFax(struct BitStream * const bitStreamP,
     MALLOCARRAY_NOFAIL(packedBits, MAXROWS);
 
     initializeLineSizeAnalyzer(&lineSizeAnalyzer,
-                               expectedLineSize, tolerateErrors);
+                               expectedLineSize, mustTolerateErrors);
 
     eof = FALSE;
     error = NULL;
@@ -747,10 +821,10 @@ readFax(struct BitStream * const bitStreamP,
             const char * exception;
 
             packedBits[row] = pbm_allocrow_packed(MAXCOLS);
-            readFaxRow(bitStreamP, packedBits[row],
+            readFaxRow(bitStreamP, packedBits[row], bwHashP,
                        &lineSize, &exception, &error);
 
-            handleRowException(exception, error, row, tolerateErrors);
+            handleRowException(exception, error, row, mustTolerateErrors);
 
             if (!error) {
                 if (lineSize == 0) {
@@ -774,7 +848,8 @@ readFax(struct BitStream * const bitStreamP,
         }
     }
     *rowsP        = row;
-    *colsP        = lineSizeAnalyzer.maxLineSize;
+    *colsP        = imageLineSize(&lineSizeAnalyzer, mustCorrectLongLine);
+
     *packedBitsP  = packedBits;
 }
 
@@ -788,6 +863,7 @@ main(int argc, const char * argv[]) {
     struct BitStream bitStream;
     unsigned int rows, cols;
     unsigned char ** packedBits;
+    BwHash * bwHashP;
 
     pm_proginit(&argc, argv);
 
@@ -805,10 +881,10 @@ main(int argc, const char * argv[]) {
     }
     skipToNextLine(&bitStream);
 
-    buildHashes(&whash, &bhash);
+    bwHashP = newBwHash();
 
     readFax(&bitStream, cmdline.stretch, cmdline.expectedLineSize,
-            !cmdline.stop_error,
+            !cmdline.stop_error, !!cmdline.correctlong, bwHashP,
             &packedBits, &cols, &rows);
 
     pm_close(ifP);
@@ -825,5 +901,10 @@ main(int argc, const char * argv[]) {
 
     freeBits(packedBits, rows, cmdline.stretch);
 
+    freeBwHash(bwHashP);
+
     return 0;
 }
+
+
+
diff --git a/converter/pbm/mdatopbm.c b/converter/pbm/mdatopbm.c
index 461b3f80..670ba8c4 100644
--- a/converter/pbm/mdatopbm.c
+++ b/converter/pbm/mdatopbm.c
@@ -1,4 +1,3 @@
-
 /***************************************************************************
 
     MDATOPBM: Convert Microdesign area to portable bitmap
@@ -30,156 +29,188 @@
 
 typedef unsigned char mdbyte;   /* Must be exactly one byte */
 
-static FILE *infile;            /* Input file */
 static mdbyte header[128];      /* MDA file header */
 static bit **data;          /* PBM image */
 static mdbyte *mdrow;           /* MDA row after decompression (MD3 only) */
 static int bInvert = 0;     /* Invert image? */
 static int bScale  = 0;     /* Scale image? */
 static int bAscii  = 0;     /* Output ASCII PBM? */
-static int nInRows, nInCols;        /* Height, width of input (rows x bytes) */
-static int nOutCols, nOutRows;      /* Height, width of output (rows x bytes) */
 
-static mdbyte 
-getbyte(void) {
+static mdbyte
+getbyte(FILE * const ifP) {
     /* Read a byte from the input stream, with error trapping */
     int b;
 
-    b = fgetc(infile);
+    b = fgetc(ifP);
+
+    if (b == EOF)
+        pm_error("Unexpected end of MDA file");
 
-    if (b == EOF) pm_error("Unexpected end of MDA file\n");
-    
     return (mdbyte)b;
 }
 
 
 
-static void 
-render_byte(int *col, int *xp, int *yp, int b) {
+static void
+renderByte(unsigned int   const nInCols,
+           unsigned int   const nOutRows,
+           unsigned int * const colP,
+           unsigned int * const xP,
+           unsigned int * const yP,
+           int            const b) {
+/*----------------------------------------------------------------------------
+  Convert a byte to 8 cells in the destination bitmap
 
-/* Convert a byte to 8 cells in the destination bitmap 
- *
- * *col = source column
- * *xp  = destination column
- * *yp  = destination row
- *  b   = byte to draw
- *
- * Will update *col, *xp and *yp to point to the next bit of the row.
- */
+  As input
 
-    int mask = 0x80;
-    int n;
-    int y3 = *yp;
+    *colP = source column
+    *xP  = destination column
+    *yP  = destination row
+    b    = byte to draw
 
-    if (bScale) y3 *= 2;
+  As output, update *colP, *xP and *yP to point to the next bit of the row.
+-----------------------------------------------------------------------------*/
+    int const y3 =  bScale ? *yP * 2 : *yP;
 
-    if (y3 >= nOutRows) return;
+    if (y3 < nOutRows) {
+        unsigned int n;
+        int mask;
 
-    for (n = 0; n < 8; ++n) {
-        if (bInvert) data[y3][*xp] = (b & mask) ? PBM_BLACK : PBM_WHITE;
-        else         data[y3][*xp] = (b & mask) ? PBM_WHITE : PBM_BLACK;
-        mask = mask >> 1;
-        if (bScale) data[y3+1][*xp] = data[y3][*xp];
-        ++(*xp);
-    }
-    ++(*col);       /* Next byte */
-    if ((*col) >= nInCols) {
-        /* Onto next line? */
-        *col = 0;
-        *xp = 0;
-        ++(*yp);
+        for (n = 0, mask = 0x80; n < 8; ++n) {
+            if (bInvert) data[y3][*xP] = (b & mask) ? PBM_BLACK : PBM_WHITE;
+            else         data[y3][*xP] = (b & mask) ? PBM_WHITE : PBM_BLACK;
+            mask = mask >> 1;
+            if (bScale)
+                data[y3+1][*xP] = data[y3][*xP];
+            ++(*xP);
+        }
+        ++(*colP);       /* Next byte */
+        if ((*colP) >= nInCols) {
+            /* Onto next line? */
+            *colP = 0;
+            *xP = 0;
+            ++(*yP);
+        }
     }
 }
 
 
-static void 
-md2_trans(void) {
-    /* Convert a MicroDesign 2 area to PBM */
-    /* MD2 has RLE encoding that may go over */
 
-    int x1, y1, col;    /* multiple lines. */
+static void
+md2Trans(FILE *       const ifP,
+         unsigned int const nInRows,
+         unsigned int const nInCols,
+         unsigned int const nOutRows,
+         unsigned int const nOutCols) {
+/*----------------------------------------------------------------------------
+   Convert a MicroDesign 2 area to PBM
+
+   MD2 has RLE encoding that may go over
+-----------------------------------------------------------------------------*/
+    unsigned int x1, y1, col;    /* multiple lines. */
     mdbyte b;
-    int c;
 
     x1 = y1 = col = 0;
 
     while (y1 < nInRows) {
-        b = getbyte();
-    
+        b = getbyte(ifP);
+
         if (b == 0 || b == 0xFF) {
             /* RLE sequence */
-            c = getbyte();
-            if (c == 0) c = 256;
-            while (c > 0) { 
-                render_byte(&col, &x1, &y1, b); 
-                --c; 
+            int c;
+            c = getbyte(ifP);
+            if (c == 0)
+                c = 256;
+            while (c > 0) {
+                renderByte(nInCols, nOutRows, &col, &x1, &y1, b);
+                --c;
             }
-        }
-        else 
-            render_byte(&col, &x1, &y1, b);    /* Not RLE */
+        } else
+            /* Not RLE */
+            renderByte(nInCols, nOutRows, &col, &x1, &y1, b);
     }
 }
 
 
 
-static void 
-md3_trans(void) {
-    /* Convert MD3 file. MD3 are encoded as rows, and 
-       there are three types. 
-    */
-    int x1, y1, col;
-    mdbyte b;
-    int c, d, n;
+static void
+md3Trans(FILE *       const ifP,
+         unsigned int const nInRows,
+         unsigned int const nInCols,
+         unsigned int const nOutRows,
+         unsigned int const nOutCols) {
+/*----------------------------------------------------------------------------
+   Convert MD3 file. MD3 are encoded as rows, and there are three types.
+-----------------------------------------------------------------------------*/
+    unsigned int y1;
 
     for (y1 = 0; y1 < nInRows; ++y1) {
-        b = getbyte();   /* Row type */
+        mdbyte b;
+
+        b = getbyte(ifP);   /* Row type */
         switch(b)  {
-        case 0: /* All the same byte */
-            c = getbyte();
-            for (n = 0; n < nInCols; n++) 
-                mdrow[n] = c;
-            break;
-            
+        case 0: {  /* All the same byte */
+            int c;
+            unsigned int i;
+            c = getbyte(ifP);
+            for (i = 0; i < nInCols; ++i)
+                mdrow[i] = c;
+        } break;
+
         case 1:      /* Encoded data */
-        case 2: col = 0; /* Encoded as XOR with previous row */
+        case 2: {     /* Encoded as XOR with previous row */
+            unsigned int col;
+            col = 0;
             while (col < nInCols) {
-                c = getbyte();
+                int c;
+                c = getbyte(ifP);
                 if (c >= 129) {
                     /* RLE sequence */
+                    unsigned int i;
+                    int d;
                     c = 257 - c;
-                    d = getbyte();
-                    for (n = 0; n < c; ++n) {
-                        if (b == 1) 
+                    d = getbyte(ifP);
+                    for (i = 0; i < c; ++i) {
+                        if (b == 1)
                             mdrow[col++] = d;
-                        else 
+                        else
                             mdrow[col++] ^= d;
-                    }   
+                    }
                 } else {
                     /* not RLE sequence */
-                        ++c;
-                        for (n = 0; n < c; ++n) {
-                            d = getbyte();
-                            if (b == 1) 
-                                mdrow[col++] = d;
-                            else
-                                mdrow[col++] ^= d;
-                        }
-                } 
+                    unsigned int i;
+                    ++c;
+                    for (i = 0; i < c; ++i) {
+                        int d;
+                        d = getbyte(ifP);
+                        if (b == 1)
+                            mdrow[col++] = d;
+                        else
+                            mdrow[col++] ^= d;
+                    }
+                }
             }
+        } break;
         }
-        /* Row loaded. Convert it. */
-        x1 = 0; col = 0; 
-        for (n = 0; n < nInCols; ++n) {
-            d  = y1;
-            render_byte(&col, &x1, &d, mdrow[n]);
+        {
+            /* Row loaded. Convert it. */
+            unsigned int x1;
+            unsigned int col;
+            unsigned int i;
+
+            for (i = 0, x1 = 0, col = 0; i < nInCols; ++i) {
+                unsigned int d;
+                d = y1;
+                renderByte(nInCols, nOutRows, &col, &x1, &d, mdrow[i]);
+            }
         }
     }
 }
 
 
 
-static void 
-usage(char *s) {        
+static void
+usage(const char *s) {
     printf("mdatopbm v1.00, Copyright (C) 1999 "
            "John Elliott <jce@seasip.demon.co.uk>\n"
            "This program is redistributable under the terms of "
@@ -197,17 +228,24 @@ usage(char *s) {
 
 
 
-int 
-main(int argc, char **argv) {
+int
+main(int argc, const char **argv) {
+
+    FILE * ifP;
     int n, optstop = 0;
-    char *fname = NULL;
+    const char * fname;
+    unsigned int nInRows, nInCols;
+        /* Height, width of input (rows x bytes) */
+    unsigned int nOutCols, nOutRows;
+        /* Height, width of output (rows x bytes) */
 
-    pbm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
     /* Parse options */
 
+    fname = NULL;  /* initial value */
     for (n = 1; n < argc; ++n) {
-        if (argv[n][0] == '-' && !optstop) {   
+        if (argv[n][0] == '-' && !optstop) {
             if (argv[n][1] == 'a' || argv[n][1] == 'A') bAscii = 1;
             if (argv[n][1] == 'd' || argv[n][1] == 'D') bScale = 1;
             if (argv[n][1] == 'i' || argv[n][1] == 'I') bInvert = 1;
@@ -225,47 +263,50 @@ main(int argc, char **argv) {
         }
     }
 
-    if (fname) 
-        infile = pm_openr(fname);
+    if (fname)
+        ifP = pm_openr(fname);
     else
-        infile = stdin;
+        ifP = stdin;
 
     /* Read MDA file header */
 
-    if (fread(header, 1, 128, infile) < 128)
+    if (fread(header, 1, 128, ifP) < 128)
         pm_error("Not a .MDA file\n");
 
-    if (strncmp((char*) header, ".MDA", 4) && 
+    if (strncmp((char*) header, ".MDA", 4) &&
         strncmp((char*) header, ".MDP", 4))
         pm_error("Not a .MDA file\n");
 
     {
         short yy;
-        pm_readlittleshort(infile, &yy); nInRows = yy;
-        pm_readlittleshort(infile, &yy); nInCols = yy;
+        pm_readlittleshort(ifP, &yy); nInRows = yy;
+        pm_readlittleshort(ifP, &yy); nInCols = yy;
     }
-    
+
     nOutCols = 8 * nInCols;
     nOutRows = nInRows;
-    if (bScale) 
+    if (bScale)
         nOutRows *= 2;
 
     data = pbm_allocarray(nOutCols, nOutRows);
-    
+
     MALLOCARRAY_NOFAIL(mdrow, nInCols);
 
-    if (header[21] == '0') 
-        md2_trans();
+    if (header[21] == '0')
+        md2Trans(ifP, nInRows, nInCols, nOutRows, nOutCols);
     else
-        md3_trans();
+        md3Trans(ifP, nInRows, nInCols, nOutRows, nOutCols);
 
-    pbm_writepbm(stdout, data, nInCols*8, nOutRows, bAscii);
+    pbm_writepbm(stdout, data, nOutCols, nOutRows, bAscii);
 
-    if (infile != stdin) 
-        pm_close(infile);
+    if (ifP != stdin)
+        pm_close(ifP);
     fflush(stdout);
     pbm_freearray(data, nOutRows);
     free(mdrow);
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmto4425.c b/converter/pbm/pbmto4425.c
index 1d97ac6a..f18b2e5a 100644
--- a/converter/pbm/pbmto4425.c
+++ b/converter/pbm/pbmto4425.c
@@ -1,178 +1,155 @@
+#include <assert.h>
 #include <string.h>
 
 #include "nstring.h"
+#include "mallocvar.h"
 #include "pbm.h"
 
-static char bit_table[2][3] = {
-{1, 4, 0x10},
-{2, 8, 0x40}
+static char const bit_table[2][3] = {
+    {1, 4, 0x10},
+    {2, 8, 0x40}
 };
 
-static int vmap_width;
-static int vmap_height;
+static unsigned int const vmapWidth  = 132;
+static unsigned int const vmapHeight = 23;
 
-static int xres;
-static int yres;
-
-static char *vmap;
 
 
 static void
-init_map()
-{
-    int x, y;
+initMap(char * const vmap) {
 
+    unsigned int col;
 
-    for(x = 0; x < vmap_width; ++x)
-    {
-        for(y = 0; y < vmap_height; ++y)
-        {
-            vmap[y*(vmap_width) + x] = 0x20;
-        }
+    for (col = 0; col < vmapWidth; ++col) {
+        unsigned int row;
+
+        for (row = 0; row < vmapHeight; ++row)
+            vmap[row * vmapWidth + col] = ' ';
     }
 }
 
 
 
 static void
-set_vmap(x, y)
-    int x, y;
-{
-    int ix, iy;
+setVmap(char *       const vmap,
+        unsigned int const x,
+        unsigned int const y) {
+
+    unsigned int const ix = x/2;
+    unsigned int const iy = y/3;
 
-    ix = x/2;
-    iy = y/3;
+    assert(ix < vmapWidth);
+    assert(iy < vmapHeight);
 
-    vmap[iy*(vmap_width) + ix] |= bit_table[x % 2][y % 3];
+    vmap[iy * vmapWidth + ix] |= bit_table[x % 2][y % 3];
 }
 
 
 
 static void
-fill_map(pbmfp)
-    FILE *pbmfp;
-{
-    bit **pbm_image;
+fillMap(FILE * const pbmFileP,
+        char * const vmap) {
+
+    unsigned int const xres = vmapWidth  * 2;
+    unsigned int const yres = vmapHeight * 3;
+
+    bit ** pbmImage;
     int cols;
     int rows;
-    int x;
-    int y;
-
-    pbm_image = pbm_readpbm(pbmfp, &cols, &rows);
-    for(y = 0; y < rows && y < yres; ++y)
-    {
-        for(x = 0; x < cols && x < xres; ++x)
-        {
-            if(pbm_image[y][x] == PBM_WHITE)
-            {
-                set_vmap(x, y);
-            }
+    unsigned int row;
+
+    pbmImage = pbm_readpbm(pbmFileP, &cols, &rows);
+
+    for (row = 0; row < rows && row < yres; ++row) {
+        unsigned int col;
+
+        for (col = 0; col < cols && col < xres; ++col) {
+            if (pbmImage[row][col] == PBM_WHITE)
+                setVmap(vmap, col, row);
         }
     }
 }
 
 
+
 static void
-print_map()
-{
-    int x, y;
-    int last_byte;
-
-#ifdef BUFFERED
-    char *iobuf;
-    iobuf = (char *)malloc(BUFSIZ);
-    if(iobuf == NULL)
-    {
-        pm_message( "Can't allocate space for I/O buffer.  "
-                    "Using unbuffered I/O...\n" );
-        setbuf(stdout, NULL);
-    }
-    else
-    {
-        setbuf(stdout, iobuf);
-    }
-#endif
-
-    fputs("\033[H\033[J", stdout);	/* clear screen */
-    fputs("\033[?3h", stdout);	/* 132 column mode */
-    fputs("\033)}\016", stdout);	/* mosaic mode */
-
-    for(y = 0; y < vmap_height; ++y)
-    {
-        for(last_byte = vmap_width - 1;
-            last_byte >= 0
-                && vmap[y * vmap_width + last_byte] == 0x20;
-            --last_byte)
+printMap(char * const vmap,
+         FILE * const ofP) {
+
+    unsigned int row;
+
+    fputs("\033[H\033[J", ofP);  /* clear screen */
+    fputs("\033[?3h",     ofP);  /* 132 column mode */
+    fputs("\033)}\016",   ofP);  /* mosaic mode */
+
+    for (row = 0; row < vmapHeight; ++row) {
+        unsigned int endCol;
+            /* Column number just past the non-space data in the row;
+               (i.e. spaces on the right are padding; not data
+            */
+        unsigned int col;
+
+        for (endCol = vmapWidth;
+             endCol > 0 && vmap[row * vmapWidth + (endCol-1)] == ' ';
+             --endCol)
             ;
 
-        for(x = 0; x <= last_byte; ++x)
-        {
-            fputc(vmap[y*(vmap_width) + x], stdout);
-        }
-        fputc('\n', stdout);
+        for (col = 0; col < endCol; ++col)
+            fputc(vmap[row * vmapWidth + col], ofP);
+
+        fputc('\n', ofP);
     }
 
-    fputs("\033(B\017", stdout);
+    fputs("\033(B\017", ofP);
 }
 
 
 
 int
-main(int argc, char * argv[]) {
-    int argn;
-    const char *pbmfile;
-    FILE *pbmfp;
-    const char *usage="[pbmfile]";
-
-    pbm_init( &argc, argv );
-    for(argn = 1;
-        argn < argc && argv[argn][0] == '-' && strlen(argv[argn]) > 1;
-        ++argn)
-    {
-        pm_usage(usage);
-    }
+main(int argc, const char ** argv) {
 
-    if(argn >= argc)
-    {
-        pbmfile = "-";
-    }
-    else if(argc - argn != 1)
-    {
-        pm_usage(usage);
-    }
-    else
-    {
-        pbmfile = argv[argn];
-    }
+    unsigned int argn;
+    const char * inputFileNm;
+    FILE * ifP;
+
+    char * vmap;  /* malloced */
+
+    pm_proginit(&argc, argv);
 
-    if(streq(pbmfile, "-"))
-    {
-        pbmfp = stdin;
+    for (argn = 1;
+         argn < argc && argv[argn][0] == '-' && strlen(argv[argn]) > 1;
+         ++argn) {
+        pm_error("Unrecognized option '%s'", argv[argn]);
     }
-    else
-    {
-        pbmfp = pm_openr( argv[argn] );
+
+    if (argn >= argc) {
+        inputFileNm = "-";
+    } else if(argc - argn != 1) {
+        pm_error("Too many arguments.  At most one argument is allowed: "
+                 "Name of the input file");
+    } else {
+        inputFileNm = argv[argn];
     }
 
-    vmap_width = 132;
-    vmap_height = 23;
+    ifP = pm_openr(inputFileNm);
+
+    assert(vmapWidth < UINT_MAX/vmapHeight);
+
+    MALLOCARRAY(vmap, vmapWidth * vmapHeight);
+    if (!vmap)
+        pm_error("Cannot allocate memory for %u x %u pixels",
+                 vmapWidth, vmapHeight);
 
-    xres = vmap_width * 2;
-    yres = vmap_height * 3;
+    initMap(vmap);
+    fillMap(ifP, vmap);
+    printMap(vmap, stdout);
 
-    vmap = malloc(vmap_width * vmap_height * sizeof(char));
-    if(vmap == NULL)
-	{
-        pm_error( "Cannot allocate memory" );
-	}
+    free(vmap);
 
-    init_map();
-    fill_map(pbmfp);
-    print_map();
     /* If the program failed, it previously aborted with nonzero completion
        code, via various function calls.
     */
-    return 0; 
+    return 0;
 }
 
 
diff --git a/converter/pbm/pbmtolj.c b/converter/pbm/pbmtolj.c
index 3cd76703..1936544f 100644
--- a/converter/pbm/pbmtolj.c
+++ b/converter/pbm/pbmtolj.c
@@ -27,12 +27,14 @@
 ** implied warranty.
 */
 
+#include <stdbool.h>
+#include <assert.h>
+#include <string.h>
+
 #include "pm_c_util.h"
 #include "pbm.h"
 #include "shhopt.h"
 #include "mallocvar.h"
-#include <string.h>
-#include <assert.h>
 
 static char *rowBuffer, *prevRowBuffer, *packBuffer, *deltaBuffer;
 static int rowBufferSize, rowBufferIndex, prevRowBufferIndex;
@@ -43,7 +45,7 @@ static int item, bitsperitem, bitshift;
 
 
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
@@ -58,8 +60,8 @@ struct cmdlineInfo {
 
 
 static void
-parseCommandLine(int argc, char ** argv,
-                 struct cmdlineInfo * const cmdlineP) {
+parseCommandLine(int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    Note that the file spec array we return is stored in the storage that
    was passed to us as the argv array.
@@ -91,10 +93,10 @@ parseCommandLine(int argc, char ** argv,
             &compressSpec, 0);
 
     opt.opt_table = option_def;
-    opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
-    opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
+    opt.short_allowed = false;  /* We have no short (old-fashioned) options */
+    opt.allowNegNum = false;  /* We may have parms that are negative numbers */
 
-    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (argc-1 == 0)
@@ -144,7 +146,7 @@ freeBuffers(void) {
 
 
 static void
-putinit(struct cmdlineInfo const cmdline) {
+putinit(struct CmdlineInfo const cmdline) {
     if (!cmdline.noreset) {
         /* Printer reset. */
         printf("\033E");
@@ -352,9 +354,9 @@ findRightmostBlackCol(const bit *    const bitrow,
     for (i = cols - 1; i >= 0 && bitrow[i] == PBM_WHITE; --i);
 
     if (i < 0)
-        *allWhiteP = TRUE;
+        *allWhiteP = true;
     else {
-        *allWhiteP = FALSE;
+        *allWhiteP = false;
         *blackColP = i;
     }
 }
@@ -495,7 +497,7 @@ printRow(void) {
 
 static void
 doPage(FILE *             const ifP,
-       struct cmdlineInfo const cmdline) {
+       struct CmdlineInfo const cmdline) {
 
     bit * bitrow;
     int rows, cols, format, row;
@@ -541,19 +543,19 @@ doPage(FILE *             const ifP,
 
 
 int
-main(int argc, char * argv[]) {
+main(int argc, const char ** argv) {
 
-    struct cmdlineInfo cmdline;
+    struct CmdlineInfo cmdline;
     FILE * ifP;
     int eof;
 
-    pbm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFilename);
 
-    eof = FALSE;
+    eof = false;
     while (!eof) {
         doPage(ifP, cmdline);
         pbm_nextimage(ifP, &eof);
diff --git a/converter/pbm/pbmtomda.c b/converter/pbm/pbmtomda.c
index 3ad51499..a39cf1a7 100644
--- a/converter/pbm/pbmtomda.c
+++ b/converter/pbm/pbmtomda.c
@@ -1,7 +1,7 @@
 
 /***************************************************************************
 
-    PBMTOMDA: Convert portable bitmap to Microdesign area
+    PBMTOMDA: Convert PBM to Microdesign area
     Copyright (C) 1999,2004 John Elliott <jce@seasip.demon.co.uk>
 
     This program is free software; you can redistribute it and/or modify
@@ -20,31 +20,80 @@
 
 ******************************************************************************/
 
+#include <stdbool.h>
+#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "pbm.h"
 #include "mallocvar.h"
+#include "shhopt.h"
+
+struct CmdlineInfo {
+    /* All the information the user supplied in the command line,
+       in a form easy for the program to use.
+    */
+    const char * inputFileNm;
+    unsigned int dscale;
+    unsigned int invert;
+};
+
+
+static void
+parseCommandLine(int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
+/*----------------------------------------------------------------------------
+   Note that the file spec array we return is stored in the storage that
+   was passed to as as the argv array.
+-----------------------------------------------------------------------------*/
+    optEntry * option_def;
+        /* Instructions to pm_optParseOptions3 on how to parse our options.
+         */
+    optStruct3 opt;
+
+    unsigned int option_def_index;
+
+    MALLOCARRAY_NOFAIL(option_def, 100);
+
+    option_def_index = 0;   /* incremented by OPTENT3 */
+    OPTENT3(0,   "dscale", OPT_FLAG,  NULL, &cmdlineP->dscale,   0);
+    OPTENT3(0,   "invert", OPT_FLAG,  NULL, &cmdlineP->invert,   0);
+
+    opt.opt_table     = option_def;
+    opt.short_allowed = false; /* We have no short (old-fashioned) options */
+    opt.allowNegNum   = false; /* We have no parms that are negative numbers */
+
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
+        /* Uses and sets argc, argv, and some of *cmdlineP and others */
+
+    if (argc-1 < 1)
+        cmdlineP->inputFileNm = "-";
+    else if (argc-1 == 1)
+        cmdlineP->inputFileNm = argv[1];
+    else
+        pm_error("Program takes at most one argument:  input file name");
+
+    free(option_def);
+}
+
+
 
-/* I'm being somewhat conservative in the PBM -> MDA translation. I output 
+/* I'm being somewhat conservative in the PBM -> MDA translation. I output
  * only the MD2 format and don't allow RLE over the ends of lines.
  */
 
-typedef unsigned char mdbyte;
-
-static FILE *infile;
-static mdbyte header[128];
-static int bInvert = 0;
-static int bScale  = 0;
+typedef unsigned char Mdbyte;
 
 /* Encode 8 pixels as a byte */
 
-static mdbyte 
-encode(bit ** const bits, int const row, int const col)
-{
+static Mdbyte
+encode(bit ** const bits,
+       int    const row,
+       int    const col) {
+
     int n;
     int mask;
-    mdbyte b;
+    Mdbyte b;
 
     mask = 0x80;   /* initial value */
     b = 0;  /* initial value */
@@ -56,131 +105,109 @@ encode(bit ** const bits, int const row, int const col)
     return b;
 }
 
-/* Translate a pbm to MD2 format, one row at a time */
 
-static void 
-do_translation(bit ** const bits, 
-               int    const nOutCols, 
-               int    const nOutRows,
-               int    const nInRows)
-{
-    int row;
-    mdbyte *mdrow;  /* malloc'ed */
+static void
+doTranslation(bit **       const bits,
+              unsigned int const nOutCols,
+              unsigned int const nOutRows,
+              unsigned int const nInRows,
+              bool         const mustInvert,
+              bool         const mustScale) {
+/*----------------------------------------------------------------------------
+  Translate a pbm to MD2 format, one row at a time
+-----------------------------------------------------------------------------*/
+    unsigned int const step = mustScale ? 2 : 1;
 
-    int const step = bScale ? 2 : 1;
+    unsigned int row;
+    Mdbyte * mdrow;  /* malloc'ed */
 
     MALLOCARRAY(mdrow, nOutCols);
 
     if (mdrow == NULL)
-        pm_error("Not enough memory for conversion.");
+        pm_error("Unable to allocate memory for %u columns", nOutCols);
 
-    for (row = 0; row < nOutRows; row+=step)
-    {
-        int col;
-        int x1;
+    for (row = 0; row < nOutRows; row += step) {
+        unsigned int col;
 
         /* Encode image into non-compressed bitmap */
         for (col = 0; col < nOutCols; ++col) {
-            mdbyte b;
+            Mdbyte b;
 
             if (row < nInRows)
-                b = encode(bits, row, col*8);
+                b = encode(bits, row, col * 8);
             else
                 b = 0xff;  /* All black */
 
-            mdrow[col] = bInvert ? b : ~b;
+            mdrow[col] = mustInvert ? b : ~b;
         }
 
         /* Encoded. Now RLE it */
-        for (col = 0; col < nOutCols; )
-        {
-            mdbyte const b = mdrow[col];
+        for (col = 0; col < nOutCols; ) {
+            Mdbyte const b = mdrow[col];
 
-            if (b != 0xFF && b != 0) /* Normal byte */
-            {
+            if (b != 0xFF && b != 0) {
+                /* Normal byte */
                 putchar(b);
                 ++col;
-            }
-            else    /* RLE a run of 0s or 0xFFs */
-            {
-                for (x1 = col; x1 < nOutCols; x1++)
-                {
+            } else {
+                /* RLE a run of 0s or 0xFFs */
+
+                unsigned int x1;
+
+                for (x1 = col; x1 < nOutCols; ++x1) {
                     if (mdrow[x1] != b) break;
+                    assert(x1 >= col);
                     if (x1 - col > 256) break;
                 }
+                assert(x1 >= col);
                 x1 -= col;    /* x1 = no. of repeats */
                 if (x1 == 256) x1 = 0;
                 putchar(b);
                 putchar(x1);
-                col += x1;        
-            }   
+                col += x1;
+            }
         }
     }
     free(mdrow);
 }
 
 
-static void usage(char *s)
-{        
-    printf("pbmtomda v1.01, Copyright (C) 1999,2004 John Elliott <jce@seasip.demon.co.uk>\n"
-         "This program is redistributable under the terms of the GNU General Public\n"
-                 "License, version 2 or later.\n\n"
-                 "Usage: %s [ -d ] [ -i ] [ -- ] [ infile ]\n\n"
-                 "-d: Halve height (to compensate for the PCW aspect ratio)\n"
-                 "-i: Invert colors\n"
-                 "--: No more options (use if filename begins with a dash)\n",
-        s);
 
-    exit(0);
-}
+int
+main(int argc, const char ** argv) {
 
-int main(int argc, char **argv)
-{
-    int nOutRowsUnrounded;  /* Before rounding up to multiple of 4 */
-    int nOutCols, nOutRows;
+    const char * const headerValue = ".MDAMicroDesignPCWv1.00\r\npbm2mda\r\n";
+
+    struct CmdlineInfo cmdline;
+    FILE * ifP;
+    unsigned int nOutRowsUnrounded;  /* Before rounding up to multiple of 4 */
+    unsigned int nOutCols, nOutRows;
     int nInCols, nInRows;
-    bit **bits;
+    bit ** bits;
+    Mdbyte header[128];
     int rc;
 
-    int n, optstop = 0;
-    char *fname = NULL;
+    pm_proginit(&argc, argv);
 
-    pbm_init(&argc, argv);
+    parseCommandLine(argc, argv, &cmdline);
 
     /* Output v2-format MDA images. Simulate MDA header...
-     * 2004-01-11: Hmm. Apparently some (but not all) MDA-reading 
-     * programs insist on the program identifier being exactly 
+     * 2004-01-11: Hmm. Apparently some (but not all) MDA-reading
+     * programs insist on the program identifier being exactly
      * 'MicroDesignPCW'. The spec does not make this clear. */
-    strcpy((char*) header, ".MDAMicroDesignPCWv1.00\r\npbm2mda\r\n");
-
-    for (n = 1; n < argc; n++)
-    {
-        if (argv[n][0] == '-' && !optstop)
-        {   
-            if (argv[n][1] == 'd' || argv[n][1] == 'D') bScale = 1;
-            if (argv[n][1] == 'i' || argv[n][1] == 'I') bInvert = 1;
-            if (argv[n][1] == 'h' || argv[n][1] == 'H') usage(argv[0]);
-            if (argv[n][1] == '-' && argv[n][2] == 0 && !fname)     /* "--" */
-            {
-                optstop = 1;
-            }
-            if (argv[n][1] == '-' && (argv[n][2] == 'h' || argv[n][2] == 'H')) usage(argv[0]);
-        }
-        else if (argv[n][0] && !fname)  /* Filename */
-        {
-            fname = argv[n];
-        }
-    }
+    memcpy(header + 0, headerValue, strlen(headerValue));
+    memset(header + strlen(headerValue),
+           0x00,
+           sizeof(header)-strlen(headerValue));
 
-    if (fname) infile = pm_openr(fname);
-    else       infile = stdin;
+    ifP = pm_openr(cmdline.inputFileNm);
 
-    bits = pbm_readpbm(infile, &nInCols, &nInRows);
-    
-    nOutRowsUnrounded = bScale ? nInRows/2 : nInRows;
+    bits = pbm_readpbm(ifP, &nInCols, &nInRows);
+
+    nOutRowsUnrounded = cmdline.dscale ? nInRows/2 : nInRows;
 
     nOutRows = ((nOutRowsUnrounded + 3) / 4) * 4;
-        /* MDA wants rows a multiple of 4 */   
+        /* MDA wants rows a multiple of 4 */
     nOutCols = nInCols / 8;
 
     rc = fwrite(header, 1, 128, stdout);
@@ -191,11 +218,15 @@ int main(int argc, char **argv)
     pm_writelittleshort(stdout, nOutRows);
     pm_writelittleshort(stdout, nOutCols);
 
-    do_translation(bits, nOutCols, nOutRows, nInRows);
+    doTranslation(bits, nOutCols, nOutRows, nInRows,
+                  !!cmdline.invert, !!cmdline.dscale);
 
-    pm_close(infile);
+    pm_close(ifP);
     fflush(stdout);
     pbm_freearray(bits, nInRows);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoppa/pbmtoppa.c b/converter/pbm/pbmtoppa/pbmtoppa.c
index ff4a599e..47e64ecc 100644
--- a/converter/pbm/pbmtoppa/pbmtoppa.c
+++ b/converter/pbm/pbmtoppa/pbmtoppa.c
@@ -14,6 +14,8 @@
 #include <unistd.h>
 
 #include "pbm.h"
+#include "nstring.h"
+
 #include "ppa.h"
 #include "ppapbm.h"
 #include "cutswath.h"
@@ -40,8 +42,8 @@ int Pwidth;     /* width in bytes */
 
 ppa_stat printer;
 
-static int 
-print_pbm(FILE * const in) {
+static int
+printPbm(FILE * const ifP) {
 
     char line[1024];
     pbm_stat pbm;
@@ -51,8 +53,8 @@ print_pbm(FILE * const in) {
 
     ppa_init_job(&printer);
 
-    while(make_pbm_stat(&pbm, in)) {
-        if (pbm.width != Width || pbm.height != Height) 
+    while(make_pbm_stat(&pbm, ifP)) {
+        if (pbm.width != Width || pbm.height != Height)
             pm_error("print_pbm(): Input image is not the size "
                     "of a page for Page %d.  "
                     "The input is %dW x %dH, "
@@ -123,7 +125,7 @@ print_pbm(FILE * const in) {
 
         /* eat any remaining whitespace */
         if(pbm.version==P1)
-            fgets (line, 1024, in);
+            fgets (line, 1024, ifP);
 
         ++numpages;
     }
@@ -141,11 +143,13 @@ print_pbm(FILE * const in) {
 
 
 
-static void 
-set_printer_specific_defaults()
-{
-    switch(printer.version)
-    {
+static void
+setPrinterSpecificDefaults() {
+
+    switch(printer.version) {
+    case HP710:
+        pm_error("Don't know how to drive HP 710");
+        break;
     case HP720:
         printer.marg_diff     = HP720_MARG_DIFF;
         printer.bufsize       = HP720_BUFSIZE;
@@ -179,14 +183,12 @@ set_printer_specific_defaults()
         printer.right_margin  = HP1000_RIGHT_MARGIN;
         printer.bottom_margin = HP1000_BOTTOM_MARGIN;
         break;
-    default:
-        pm_error("set_printer_defaults(): unknown printer version");
     }
 }
 
 
 
-static void 
+static void
 show_usage(const char* const prog)
 {
     printf("usage: %s [ options ] [ <infile> [ <outfile> ] ]\n\n",prog);
@@ -220,9 +222,9 @@ show_usage(const char* const prog)
 
 
 
-static void 
-parm_version(char* arg)
-{
+static void
+parmVersion(char * const arg) {
+
     if(!strcasecmp(arg,"hp720") || !strcmp(arg,"720"))
         printer.version=HP720;
     else if(!strcasecmp(arg,"hp820") || !strcmp(arg,"820"))
@@ -231,39 +233,39 @@ parm_version(char* arg)
         printer.version=HP1000;
     else
         pm_error("parm_version(): unknown printer version '%s'",arg);
-    set_printer_specific_defaults();
+    setPrinterSpecificDefaults();
 }
 
 
 
-static void 
-parm_iversion(int arg)
-{
+static void
+parmIversion(int const arg) {
+
     switch(arg)
     {
     case 720:
-        printer.version=HP720;
+        printer.version = HP720;
         break;
     case 820:
-        printer.version=HP820;
+        printer.version = HP820;
         break;
     case 1000:
-        printer.version=HP1000;
+        printer.version = HP1000;
         break;
     default:
-        pm_error("parm_iversion(): unknown printer version '%d'", arg);
+        pm_error("parmIversion(): unknown printer version '%d'", arg);
     }
-    set_printer_specific_defaults();
+    setPrinterSpecificDefaults();
 }
 
 
 
-static void 
-dump_config()
-{
+static void
+dumpConfig() {
+
     printf("version:  ");
-    switch(printer.version)
-    {
+
+    switch(printer.version) {
     case HP710:  printf("HP710\n");  break;
     case HP720:  printf("HP720\n");  break;
     case HP820:  printf("HP820\n");  break;
@@ -278,90 +280,88 @@ dump_config()
 
 
 
-static void 
-read_config_file(const char* const fname)
-{
-    FILE* cfgfile=fopen(fname,"r");
-    char line[1024],key[14],buf[10];
-    int len,value,lineno=1;
+static void
+readConfigFile(const char * const fname) {
+
+    FILE * cfgFileP;
+    char line[1024];
+    char key[14];
+    char buf[10];
+    int len;
+    int value;
+    int lineno;
 
-    if(!cfgfile)
+    cfgFileP = fopen(fname, "r");
+
+    lineno = 1;  /* initial value */
+
+    if (!cfgFileP)
         pm_error("read_config_file(): couldn't open file '%s'", fname);
 
-    while(fgets(line,1024,cfgfile))
-    {
-        if(strchr(line,'#'))
-            *strchr(line,'#')=0;
-        switch(sscanf(line,"%13s%9s",key,buf))
-        {
+    while (fgets(line, 1024, cfgFileP)) {
+        if (strchr(line, '#'))
+            *strchr(line, '#')=0;
+        switch(sscanf(line, "%13s%9s", key, buf)) {
         case 2:
-            value=atoi(buf);
-            len=strlen(key);
-            if(!strncmp(key,"version",len))
-                parm_iversion(value);
-            else if(!strncmp(key,"xoffset",len))
-                printer.x_offset=value;
-            else if(!strncmp(key,"yoffset",len))
-                printer.y_offset=value;
-            else if(!strncmp(key,"topmargin",len))
-                printer.top_margin=value;
-            else if(!strncmp(key,"leftmargin",len))
-                printer.left_margin=value;
-            else if(!strncmp(key,"rightmargin",len))
-                printer.right_margin=value;
-            else if(!strncmp(key,"bottommargin",len))
-                printer.bottom_margin=value;
-            else if(!strncmp(key,"papersize",len))
-            {
-                if(!strcmp(buf,"us"))
-                {
-                    Width = USWIDTH;
+            value = atoi(buf);
+            len   = strlen(key);
+            if (strneq(key, "version",           len))
+                parmIversion(value);
+            else if (strneq(key, "xoffset",      len))
+                printer.x_offset = value;
+            else if (strneq(key, "yoffset",      len))
+                printer.y_offset = value;
+            else if(strneq(key,  "topmargin",    len))
+                printer.top_margin = value;
+            else if(strneq(key,  "leftmargin",   len))
+                printer.left_margin = value;
+            else if(strneq(key,  "rightmargin",  len))
+                printer.right_margin = value;
+            else if(strneq(key,  "bottommargin", len))
+                printer.bottom_margin = value;
+            else if(strneq(key,  "papersize"   , len)) {
+                if(streq(buf, "us")) {
+                    Width  = USWIDTH;
                     Height = USHEIGHT;
-                }
-                else if(!strcmp(buf,"a4"))
-                {
-                    Width = A4WIDTH;
+                } else if (streq(buf, "a4")) {
+                    Width  = A4WIDTH;
                     Height = A4HEIGHT;
-                }
-                else
+                } else
                     pm_error("read_config_file(): unknown paper size %s", buf);
-            }
-            else if(!strcmp(key,"dump"))
-                dump_config();
-            else 
+            } else if(!strcmp(key,"dump"))
+                dumpConfig();
+            else
                 pm_error("read_config_file(): unrecognized parameter '%s' "
                          "(line %d)", key, lineno);
         case EOF:
-        case 0: 
+        case 0:
             break;
         default:
             pm_error("read_config_file(): error parsing config file "
                      "(line %d)", lineno);
         }
-        lineno++;
+        ++lineno;
     }
 
-    if(feof(cfgfile))
-    {
-        fclose(cfgfile);
-        return;
-    }
-
-    pm_error("read_config_file(): error parsing config file");
+    if (feof(cfgFileP)) {
+        fclose(cfgFileP);
+    } else
+        pm_error("read_config_file(): error parsing config file");
 }
 
 
 
-const char* const defaultcfgfile="/etc/pbmtoppa.conf";
+const char * const defaultCfgFileNm = "/etc/pbmtoppa.conf";
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
 
     int argn;
     int got_in=0, got_out=0, do_continue=1;
-    FILE *in=stdin, *out=stdout;
+    FILE * ifP;
+    FILE * ofP;
     struct stat tmpstat;
 
     pbm_init(&argc, argv);
@@ -374,12 +374,15 @@ main(int argc, char *argv[]) {
     printer.right_margin  = DEFAULT_RIGHT_MARGIN;
     printer.bottom_margin = DEFAULT_BOTTOM_MARGIN;
     printer.DPI           = DEFAULT_DPI;
-    Width = USWIDTH;
+    Width  = USWIDTH;
     Height = USHEIGHT;
-    set_printer_specific_defaults();
+    setPrinterSpecificDefaults();
+
+    if (!stat(defaultCfgFileNm, &tmpstat))
+        readConfigFile(defaultCfgFileNm);
 
-    if(!stat(defaultcfgfile,&tmpstat))
-        read_config_file(defaultcfgfile);
+    ifP = stdin;  /* initial value */
+    ofP = stdout;  /* initial value */
 
     for(argn=1; argn<argc; argn++)
     {
@@ -389,12 +392,12 @@ main(int argc, char *argv[]) {
             return 0;
         }
         else if(!strcmp(argv[argn],"-d"))
-            dump_config();
+            dumpConfig();
         else if(argn+1<argc)
         {
             do_continue=1;
             if(!strcmp(argv[argn],"-v"))
-                parm_version(argv[++argn]);
+                parmVersion(argv[++argn]);
             else if(!strcmp(argv[argn],"-x"))
                 printer.x_offset+=atoi(argv[++argn]);
             else if(!strcmp(argv[argn],"-y"))
@@ -426,7 +429,7 @@ main(int argc, char *argv[]) {
                     pm_error("unknown paper size %s",argv[argn]);
             }
             else if(!strcmp(argv[argn],"-f"))
-                read_config_file(argv[++argn]);
+                readConfigFile(argv[++argn]);
             else do_continue=0;
             if(do_continue) continue;
         }
@@ -434,18 +437,18 @@ main(int argc, char *argv[]) {
         if(!got_in)
         {
             if (strcmp (argv[argn], "-") == 0)
-                in = stdin;
-            else if ((in = fopen (argv[argn], "rb")) == NULL)
-                pm_error("main(): couldn't open file '%s'", 
+                ifP = stdin;
+            else if ((ifP = fopen (argv[argn], "rb")) == NULL)
+                pm_error("main(): couldn't open file '%s'",
                          argv[argn]);
             got_in=1;
         }
         else if(!got_out)
         {
             if (strcmp (argv[argn], "-") == 0)
-                out = stdout;
-            else if ((out = fopen (argv[argn], "wb")) == NULL)
-                pm_error("main(): couldn't open file '%s'", 
+                ofP = stdout;
+            else if ((ofP = fopen (argv[argn], "wb")) == NULL)
+                pm_error("main(): couldn't open file '%s'",
                          argv[argn]);
             got_out=1;
         }
@@ -453,9 +456,11 @@ main(int argc, char *argv[]) {
             pm_error("main(): unrecognized parameter '%s'", argv[argn]);
     }
 
-    Pwidth=(Width+7)/8;
-    printer.fptr=out;
+    Pwidth = (Width+7)/8;
+    printer.fptr = ofP;
 
-    return print_pbm (in);
+    return printPbm(ifP);
 }
 
+
+
diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c
index 1a003189..4bd33dd8 100644
--- a/converter/pbm/pbmtoxbm.c
+++ b/converter/pbm/pbmtoxbm.c
@@ -10,10 +10,10 @@
 ** implied warranty.
 */
 
-/* 2006.10 (afu)   
+/* 2006.10 (afu)
    Changed bitrow from plain to raw, read function from pbm_readpbmrow() to
    pbm_readpbmrow_packed().  Retired bitwise transformation functions.
- 
+
    Output function putitem rewritten to handle both X10 and X11.
 
    Added -name option.  There is no check for the string thus given.
@@ -35,7 +35,7 @@
 #include "nstring.h"
 
 
-enum xbmVersion { X10, X11 };
+enum XbmVersion { X10, X11 };
 
 struct CmdlineInfo {
     /* All the information the user supplied in the command line,
@@ -43,16 +43,16 @@ struct CmdlineInfo {
     */
     const char *    inputFileName;
     const char *    name;
-    enum xbmVersion xbmVersion;
+    enum XbmVersion xbmVersion;
 };
 
 static void
-parseCommandLine(int                 argc, 
+parseCommandLine(int                 argc,
                  const char **       argv,
                  struct CmdlineInfo *cmdlineP ) {
 /*----------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -96,19 +96,19 @@ parseCommandLine(int                 argc,
                 pm_error("Image name '%s' contains invalid character (%c).",
                          cmdlineP->name, cmdlineP->name[i]);
     }
-    
+
     if (x10 && x11)
         pm_error("You can't specify both -x10 and -x11");
     else if (x10)
         cmdlineP->xbmVersion = X10;
-    else 
+    else
         cmdlineP->xbmVersion = X11;
-        
-    if (argc-1 < 1) 
+
+    if (argc-1 < 1)
         cmdlineP->inputFileName = "-";
     else {
         cmdlineP->inputFileName = argv[1];
-        
+
         if (argc-1 > 1)
             pm_error("Program takes zero or one argument (filename).  You "
                      "specified %u", argc-1);
@@ -141,22 +141,22 @@ generateName(char          const filenameArg[],
         /* indices into the input and output buffers */
 
         /* Start just after the rightmost slash, or at beginning if no slash */
-        if (strrchr(filenameArg, '/') == 0) 
+        if (strrchr(filenameArg, '/') == 0)
             argIndex = 0;
         else argIndex = strrchr(filenameArg, '/') - filenameArg + 1;
 
-        if (filenameArg[argIndex] == '\0') 
+        if (filenameArg[argIndex] == '\0')
             *nameP = strdup("noname");
         else {
             char * name;
             nameIndex = 0;  /* Start at beginning of name buffer */
 
             name = malloc(strlen(filenameArg));
-    
-            while (filenameArg[argIndex] != '\0' 
+
+            while (filenameArg[argIndex] != '\0'
                    && filenameArg[argIndex] != '.') {
                 const char filenameChar = filenameArg[argIndex++];
-                name[nameIndex++] = 
+                name[nameIndex++] =
                     ISALNUM(filenameChar) ? filenameChar : '_';
             }
             name[nameIndex] = '\0';
@@ -167,37 +167,46 @@ generateName(char          const filenameArg[],
 
 
 
-static unsigned short int itemBuff[22];
-static int itemCnt;    /* takes values 0 to 15 (x11) or 21 (x10) */
-static enum xbmVersion itemVersion;
+typedef struct {
+    unsigned short int buff[22];
+    int cnt;    /* takes values 0 to 15 (x11) or 21 (x10) */
+    enum XbmVersion version;
+} ItemWriter;
+
+static ItemWriter itemWriter;
 
 
 
 static void
 putitemX10(unsigned char const item) {
 
-    if (itemCnt == 22) {
+    if (itemWriter.cnt == 22) {
         /* Buffer is full.  Write out one line. */
         int rc;
         rc = printf(" 0x%02x%02x,0x%02x%02x,0x%02x%02x,0x%02x%02x,"
                     "0x%02x%02x,0x%02x%02x,0x%02x%02x,0x%02x%02x,"
                     "0x%02x%02x,0x%02x%02x,0x%02x%02x,\n",
-                    itemBuff[ 1], itemBuff[ 0], itemBuff[ 3], itemBuff[ 2],
-                    itemBuff[ 5], itemBuff[ 4], itemBuff[ 7], itemBuff[ 6],
-                    itemBuff[ 9], itemBuff[ 8], itemBuff[11], itemBuff[10],
-                    itemBuff[13], itemBuff[12], itemBuff[15], itemBuff[14],
-                    itemBuff[17], itemBuff[16], itemBuff[19], itemBuff[18],
-                    itemBuff[21], itemBuff[20]
+                    itemWriter.buff[ 1], itemWriter.buff[ 0],
+                    itemWriter.buff[ 3], itemWriter.buff[ 2],
+                    itemWriter.buff[ 5], itemWriter.buff[ 4],
+                    itemWriter.buff[ 7], itemWriter.buff[ 6],
+                    itemWriter.buff[ 9], itemWriter.buff[ 8],
+                    itemWriter.buff[11], itemWriter.buff[10],
+                    itemWriter.buff[13], itemWriter.buff[12],
+                    itemWriter.buff[15], itemWriter.buff[14],
+                    itemWriter.buff[17], itemWriter.buff[16],
+                    itemWriter.buff[19], itemWriter.buff[18],
+                    itemWriter.buff[21], itemWriter.buff[20]
             );
 
-        if (rc < 0)        
+        if (rc < 0)
             pm_error("Error writing X10 bitmap raster item.  "
                      "printf() failed with errno %d (%s)",
                      errno, strerror(errno));
-        
-        itemCnt = 0;
+
+        itemWriter.cnt = 0;
     }
-    itemBuff[itemCnt++] = bitreverse[item];
+    itemWriter.buff[itemWriter.cnt++] = bitreverse[item];
 }
 
 
@@ -205,26 +214,30 @@ putitemX10(unsigned char const item) {
 static void
 putitemX11(unsigned char const item) {
 
-    if (itemCnt == 15 ) {
+    if (itemWriter.cnt == 15 ) {
         /* Buffer is full.  Write out one line. */
         int rc;
         rc = printf(" 0x%02x,0x%02x,0x%02x,0x%02x,"
                     "0x%02x,0x%02x,0x%02x,0x%02x,"
                     "0x%02x,0x%02x,0x%02x,0x%02x,"
                     "0x%02x,0x%02x,0x%02x,\n",
-                    itemBuff[0], itemBuff[1], itemBuff[2], itemBuff[3],
-                    itemBuff[4], itemBuff[5], itemBuff[6], itemBuff[7],
-                    itemBuff[8], itemBuff[9], itemBuff[10],itemBuff[11],
-                    itemBuff[12],itemBuff[13],itemBuff[14]
+                    itemWriter.buff[ 0], itemWriter.buff[ 1],
+                    itemWriter.buff[ 2], itemWriter.buff[ 3],
+                    itemWriter.buff[ 4], itemWriter.buff[ 5],
+                    itemWriter.buff[ 6], itemWriter.buff[ 7],
+                    itemWriter.buff[ 8], itemWriter.buff[ 9],
+                    itemWriter.buff[10], itemWriter.buff[11],
+                    itemWriter.buff[12], itemWriter.buff[13],
+                    itemWriter.buff[14]
             );
-        if (rc < 0)        
+        if (rc < 0)
             pm_error("Error writing X11 bitmap raster item.  "
                      "printf() failed with errno %d (%s)",
                      errno, strerror(errno));
-        
-        itemCnt = 0;
+
+        itemWriter.cnt = 0;
     }
-    itemBuff[itemCnt++] = bitreverse[item];
+    itemWriter.buff[itemWriter.cnt++] = bitreverse[item];
 }
 
 
@@ -232,7 +245,7 @@ putitemX11(unsigned char const item) {
 static void
 putitem(unsigned char const item) {
 
-    switch (itemVersion) {
+    switch (itemWriter.version) {
     case X10: putitemX10(item); break;
     case X11: putitemX11(item); break;
     }
@@ -245,19 +258,19 @@ puttermX10(void) {
 
     unsigned int i;
 
-    assert(itemCnt % 2 == 0);
+    assert(itemWriter.cnt % 2 == 0);
 
-    for (i = 0; i < itemCnt; i += 2) {
+    for (i = 0; i < itemWriter.cnt; i += 2) {
         int rc;
 
-        assert(i + 1 < itemCnt);
+        assert(i + 1 < itemWriter.cnt);
 
         rc = printf("%s0x%02x%02x%s",
                     (i == 0) ? " " : "",
-                    itemBuff[i+1],
-                    itemBuff[i], 
-                    (i + 2 >= itemCnt) ? "" : ",");
-        if (rc < 0)        
+                    itemWriter.buff[i+1],
+                    itemWriter.buff[i],
+                    (i + 2 >= itemWriter.cnt) ? "" : ",");
+        if (rc < 0)
             pm_error("Error writing Item %u at end of X10 bitmap raster.  "
                      "printf() failed with errno %d (%s)",
                      i, errno, strerror(errno));
@@ -271,15 +284,15 @@ puttermX11(void) {
 
     unsigned int i;
 
-    for (i = 0; i < itemCnt; ++i) {
+    for (i = 0; i < itemWriter.cnt; ++i) {
         int rc;
 
         rc = printf("%s0x%02x%s",
                     (i == 0)  ? " " : "",
-                    itemBuff[i],
-                    (i + 1 >= itemCnt) ? "" : ",");
+                    itemWriter.buff[i],
+                    (i + 1 >= itemWriter.cnt) ? "" : ",");
 
-        if (rc < 0)        
+        if (rc < 0)
             pm_error("Error writing Item %u at end of X11 bitmap raster.  "
                      "printf() failed with errno %d (%s)",
                      i, errno, strerror(errno));
@@ -289,10 +302,10 @@ puttermX11(void) {
 
 
 static void
-putinit(enum xbmVersion const xbmVersion) {
+putinit(enum XbmVersion const xbmVersion) {
 
-    itemCnt = 0;
-    itemVersion = xbmVersion;
+    itemWriter.cnt = 0;
+    itemWriter.version = xbmVersion;
 }
 
 
@@ -300,7 +313,7 @@ putinit(enum xbmVersion const xbmVersion) {
 static void
 putterm(void) {
 
-    switch (itemVersion) {
+    switch (itemWriter.version) {
     case X10: puttermX10(); break;
     case X11: puttermX11(); break;
     }
@@ -310,7 +323,7 @@ putterm(void) {
 
         rc = printf("};\n");
 
-        if (rc < 0)        
+        if (rc < 0)
             pm_error("Error writing end of X11 bitmap raster.  "
                      "printf() failed with errno %d (%s)",
                      errno, strerror(errno));
@@ -320,7 +333,7 @@ putterm(void) {
 
 
 static void
-writeXbmHeader(enum xbmVersion const xbmVersion,
+writeXbmHeader(enum XbmVersion const xbmVersion,
                const char *    const name,
                unsigned int    const width,
                unsigned int    const height,
@@ -341,11 +354,11 @@ convertRaster(FILE *          const ifP,
               unsigned int    const rows,
               int             const format,
               FILE *          const ofP,
-              enum xbmVersion const xbmVersion) {
-              
-    unsigned int const bitsPerUnit = xbmVersion == X10 ? 16 : 8;   
+              enum XbmVersion const xbmVersion) {
+
+    unsigned int const bitsPerUnit = xbmVersion == X10 ? 16 : 8;
     unsigned int const padright = ROUNDUP(cols, bitsPerUnit) - cols;
-        /* Amount of padding to round cols up to the nearest multiple of 
+        /* Amount of padding to round cols up to the nearest multiple of
            8 (if x11) or 16 (if x10).
         */
     unsigned int const bitrowBytes = (cols + padright) / 8;
@@ -360,7 +373,7 @@ convertRaster(FILE *          const ifP,
     putinit(xbmVersion);
 
     bitrow = pbm_allocrow_packed(cols + padright);
-    
+
     for (row = 0; row < rows; ++row) {
         unsigned int i;
 
@@ -386,7 +399,7 @@ int
 main(int           argc,
      const char ** argv) {
 
-    struct CmdlineInfo cmdline; 
+    struct CmdlineInfo cmdline;
     FILE * ifP;
     int rows, cols, format;
     const char * name;
@@ -394,15 +407,15 @@ main(int           argc,
     pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
-    if (cmdline.name == NULL) 
+    if (cmdline.name == NULL)
         generateName(cmdline.inputFileName, &name);
     else
         name = strdup(cmdline.name);
 
     ifP = pm_openr(cmdline.inputFileName);
-    
+
     pbm_readpbminit(ifP, &cols, &rows, &format);
-    
+
     writeXbmHeader(cmdline.xbmVersion, name, cols, rows, stdout);
 
     convertRaster(ifP, cols, rows, format, stdout, cmdline.xbmVersion);
diff --git a/converter/pbm/pktopbm.c b/converter/pbm/pktopbm.c
index 712f339f..49e15c49 100644
--- a/converter/pbm/pktopbm.c
+++ b/converter/pbm/pktopbm.c
@@ -7,159 +7,279 @@
      * fix bitmap y placement of dynamically packed char
      * skip char early if no output file allocated
      - added debug output
-  
+
   compile with: cc -lpbm -o pktopbm pktopbm.c
   */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "pm_c_util.h"
 #include "nstring.h"
+#include "mallocvar.h"
+#include "shhopt.h"
 #include "pbm.h"
 
 #define NAMELENGTH 80
 #define MAXROWWIDTH 3200
 #define MAXPKCHAR 256
 
-typedef int integer ;
-typedef unsigned char quarterword ;
-typedef char boolean ;
-typedef quarterword eightbits ;
-
-static FILE *pkfile ;
-static char pkname[NAMELENGTH+1] ;
-static integer pktopbm_pkloc = 0;
-static char *filename[MAXPKCHAR] ;
-static bit **bitmap = NULL ;
-static integer dynf ;
-static eightbits inputbyte ;
-static eightbits bitweight ;
-static integer repeatcount ;
-static integer flagbyte ;
-static integer debug=0;
+struct CmdlineInfo {
+    /* All the information the user supplied in the command line,
+       in a form easy for the program to use.
+    */
+    const char * inputFileNm;
+    unsigned int outputFileCt;
+        /* The number of output files */
+    const char * outputFileNm[MAXPKCHAR];
+        /* The output file name, in order */
+    unsigned int character;
+    unsigned int xSpec;
+    unsigned int x;
+    unsigned int ySpec;
+    unsigned int y;
+    unsigned int debug;
+};
+
 
-#define dprintf(s,d) if (debug) printf(s,d)
-#define dprintf0(s) if (debug) printf(s)
 
-/* add a suffix to a filename in an allocated space */
 static void
-pktopbm_add_suffix(char *       const name, 
-                   const char * const suffix) {
-
-    char * const slash = strrchr(name, '/');
-    char * const dot   = strrchr(name, '.');
-    
-    if ((dot && slash ? dot < slash : !dot) && !streq(name, "-"))
-        strcat(name, suffix);
+parseCommandLine(int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
+/*----------------------------------------------------------------------------
+   Note that the file spec strings we return are stored in the storage that
+   was passed to us as the argv array.
+-----------------------------------------------------------------------------*/
+    optEntry * option_def;
+        /* Instructions to pm_optParseOptions3 on how to parse our options.
+         */
+    optStruct3 opt;
+
+    unsigned int option_def_index;
+    unsigned int characterSpec;
+    unsigned int firstOutputArgNm;
+
+    MALLOCARRAY_NOFAIL(option_def, 100);
+
+    option_def_index = 0;   /* incremented by OPTENTRY */
+    OPTENT3(0, "character",   OPT_UINT, &cmdlineP->character,
+            &characterSpec, 0);
+    OPTENT3(0, "x",   OPT_UINT, &cmdlineP->x,
+            &cmdlineP->xSpec, 0);
+    OPTENT3(0, "X",   OPT_UINT, &cmdlineP->x,
+            &cmdlineP->xSpec, 0);
+    OPTENT3(0, "y",   OPT_UINT, &cmdlineP->y,
+            &cmdlineP->ySpec, 0);
+    OPTENT3(0, "Y",   OPT_UINT, &cmdlineP->y,
+            &cmdlineP->ySpec, 0);
+    OPTENT3(0, "debug",   OPT_UINT, NULL,
+            &cmdlineP->debug, 0);
+
+    opt.opt_table = option_def;
+    opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
+    opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
+
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
+        /* Uses and sets argc, argv, and some of *cmdlineP and others. */
+
+    if (characterSpec) {
+        if (cmdlineP->character >= MAXPKCHAR)
+            pm_error("Character number (-character) must be in range 0 to %u",
+                     MAXPKCHAR-1);
+    } else
+        cmdlineP->character = 0;
+
+    if (argc-1 < 1) {
+        cmdlineP->inputFileNm = "-";
+        firstOutputArgNm = 1;
+    } else {
+        cmdlineP->inputFileNm = argv[1];
+        firstOutputArgNm = 2;
+    }
+
+    cmdlineP->outputFileCt = 0;  /* initial value */
+    {
+        unsigned int argn;
+        bool stdoutUsed;
+        for (argn = firstOutputArgNm, stdoutUsed = false;
+             argn < argc;
+             ++argn) {
+            if (cmdlineP->outputFileCt >= MAXPKCHAR)
+                pm_error("You may not specify more than %u output files.",
+                         MAXPKCHAR);
+            cmdlineP->outputFileNm[cmdlineP->outputFileCt++] = argv[argn];
+            if (streq(argv[argn], "-")) {
+                if (stdoutUsed)
+                    pm_error("You cannot specify Standard Output ('-') "
+                             "for more than one output file");
+                stdoutUsed = true;
+            }
+        }
+    }
+    if (cmdlineP->outputFileCt < 1)
+        cmdlineP->outputFileNm[cmdlineP->outputFileCt++] = "-";
+
+    if (cmdlineP->character + cmdlineP->outputFileCt >= MAXPKCHAR)
+        pm_error("Number of output files (%u) "
+                 "plus -character value (%u) exceeds "
+                 "the maximum number of characters is a PK font file (%u)",
+                 cmdlineP->character, cmdlineP->outputFileCt, MAXPKCHAR);
 }
 
 
 
-/* get a byte from the PK file */
-static eightbits 
-pktopbm_pkbyte(void) {
-   pktopbm_pkloc++ ;
-   return(getc(pkfile)) ;
+typedef unsigned char eightbits ;
+
+static FILE * ifP;
+static unsigned int pkLoc;
+static const char * fileName[MAXPKCHAR];
+static int dynf ;
+static eightbits inputByte ;
+static eightbits bitWeight ;
+static int repeatCount ;
+static int flagByte ;
+static int debug = 0;
+
+#define dprintf(s,d) if (debug) printf(s,d)
+#define dprintf0(s) if (debug) printf(s)
+
+static eightbits
+pkByte() {
+/*----------------------------------------------------------------------------
+  Get a byte from the PK file
+-----------------------------------------------------------------------------*/
+    ++pkLoc;
+
+    return getc(ifP);
 }
 
 
 
-/* get a 16-bit half word from the PK file */
-static integer 
-get16(void) {
-   integer const a = pktopbm_pkbyte() ;
-   return((a<<8) + pktopbm_pkbyte()) ;
+static int
+get16() {
+/*----------------------------------------------------------------------------
+  Get a 16-bit half word from the PK file
+-----------------------------------------------------------------------------*/
+    int const a = pkByte() ;
+
+    return (a<<8) + pkByte();
 }
 
 
 
-/* get a 32-bit word from the PK file */
-static integer get32(void) {
-    integer a;
-    a = get16() ;
-    if (a > 32767) a -= 65536 ;
-    return((a<<16) + get16()) ;
+static int
+get32() {
+/*----------------------------------------------------------------------------
+  Get a 32-bit word from the PK file
+-----------------------------------------------------------------------------*/
+    int a;
+
+    a = get16();  /* initial value */
+
+    if (a > 32767)
+        a -= 65536;
+
+    return (a << 16) + get16();
 }
 
 
 
-/* get a nibble from current input byte, or new byte if no current byte */
-static integer 
-getnyb(void) {
+static int
+getNybble() {
+/*----------------------------------------------------------------------------
+  Get a nibble from current input byte, or new byte if no current byte
+-----------------------------------------------------------------------------*/
     eightbits temp;
-    if (bitweight == 0) {
-        inputbyte = pktopbm_pkbyte() ;
-        bitweight = 16 ;
+
+    if (bitWeight == 0) {
+        inputByte = pkByte() ;
+        bitWeight = 16 ;
     }
-    temp = inputbyte / bitweight ;
-    inputbyte -= temp * bitweight ;
-    bitweight >>= 4 ;
-    return(temp) ;
+    temp = inputByte / bitWeight ;
+    inputByte -= temp * bitWeight ;
+    bitWeight >>= 4 ;
+
+    return temp;
 }
 
 
 
-/* get a bit from the current input byte, or a new byte if no current byte */
 static bool
-getbit(void) {
+getBit() {
+/*----------------------------------------------------------------------------
+  Get a bit from the current input byte, or a new byte if no current byte
+-----------------------------------------------------------------------------*/
     bool temp ;
-    bitweight >>= 1 ;
-    if (bitweight == 0) {
-        inputbyte = pktopbm_pkbyte() ;
-        bitweight = 128 ;
+
+    bitWeight >>= 1 ;
+    if (bitWeight == 0) {
+        inputByte = pkByte();
+        bitWeight = 128 ;
     }
-    temp = (inputbyte >= bitweight) ;
-    if (temp) inputbyte -= bitweight ;
-    return(temp) ;
+    temp = (inputByte >= bitWeight);
+    if (temp)
+        inputByte -= bitWeight;
+
+    return temp;
 }
 
 
 
-/* unpack a dynamically packed number. dynf is dynamic packing threshold  */
-static integer 
-pkpackednum(void) {
-    integer i, j ;
-    i = getnyb() ;
+static int
+pkPackedNum() {
+/*----------------------------------------------------------------------------
+  Unpack a dynamically packed number. dynf is dynamic packing threshold
+-----------------------------------------------------------------------------*/
+    int i, j ;
+
+    i = getNybble() ;
+
     if (i == 0) {           /* large run count, >= 3 nibbles */
         do {
-            j = getnyb() ;          /* count extra nibbles */
+            j = getNybble() ;          /* count extra nibbles */
             i++ ;
         } while (j == 0) ;
         while (i > 0) {
-            j = (j<<4) + getnyb() ; /* add extra nibbles */
+            j = (j<<4) + getNybble() ; /* add extra nibbles */
             i-- ;
         }
         return (j - 15 +((13 - dynf)<<4) + dynf) ;
     } else if (i <= dynf) return (i) ;  /* number > 0 and <= dynf */
-    else if (i < 14) return (((i - dynf - 1)<<4) + getnyb() + dynf + 1) ;
+    else if (i < 14) return (((i - dynf - 1)<<4) + getNybble() + dynf + 1) ;
     else {
-        if (i == 14) repeatcount = pkpackednum() ;  /* get repeat count */
-        else repeatcount = 1 ;      /* value 15 indicates repeat count 1 */
-        return(pkpackednum()) ;
+        if (i == 14)
+            repeatCount = pkPackedNum() ;  /* get repeat count */
+        else
+            repeatCount = 1 ;      /* value 15 indicates repeat count 1 */
+
+        return pkPackedNum();
     }
 }
 
 
 
-/* skip specials in PK files, inserted by Metafont or some other program */
 static void
-skipspecials(void) {
-    integer i, j;
+skipSpecials() {
+/*----------------------------------------------------------------------------
+  Skip specials in PK files, inserted by Metafont or some other program
+-----------------------------------------------------------------------------*/
     do {
-        flagbyte = pktopbm_pkbyte() ;
-        if (flagbyte >= 240)
-            switch(flagbyte) {
+        flagByte = pkByte() ;
+        if (flagByte >= 240)
+            switch(flagByte) {
             case 240:           /* specials of size 1-4 bytes */
             case 241:
             case 242:
-            case 243:
+            case 243: {
+                int i, j;
+
                 i = 0 ;
-                for (j = 240 ; j <= flagbyte ; ++j) 
-                    i = (i<<8) + pktopbm_pkbyte() ;
-                for (j = 1 ; j <= i ; ++j) 
-                    pktopbm_pkbyte() ;  /* ignore special */
-                break ;
+                for (j = 240 ; j <= flagByte ; ++j)
+                    i = (i<<8) + pkByte() ;
+                for (j = 1 ; j <= i ; ++j)
+                    pkByte() ;  /* ignore special */
+            } break ;
             case 244:           /* no-op, parameters to specials */
                 get32() ;
             case 245:           /* start of postamble */
@@ -174,272 +294,378 @@ skipspecials(void) {
             case 253:
             case 254:
             case 255:
-                pm_error("unexpected flag byte %d", flagbyte) ;
+                pm_error("unexpected flag byte %d", flagByte) ;
             }
-    } while (!(flagbyte < 240 || flagbyte == 245)) ;
+    } while (!(flagByte < 240 || flagByte == 245)) ;
 }
 
 
 
-/* ignore character packet */
 static void
-ignorechar(integer const car, 
-           integer const endofpacket) {
+ignoreChar(int          const car,
+           unsigned int const endOfPacket) {
+/*----------------------------------------------------------------------------
+   ignore character packet
+-----------------------------------------------------------------------------*/
+   while (pkLoc != endOfPacket)
+       pkByte();
 
-   while (pktopbm_pkloc != endofpacket) pktopbm_pkbyte() ;
    if (car < 0 || car >= MAXPKCHAR)
       pm_message("Character %d out of range", car) ;
-   skipspecials() ;
+
+   skipSpecials() ;
 }
 
 
 
-int
-main(int argc, char *argv[]) {
-    integer x;
-    integer endofpacket ;
-    boolean turnon ;
-    integer i, j;
-    integer car ;
-    integer bmx=0, bmy=0;
-    integer set_bmx=0, set_bmy=0;
-    bit row[MAXROWWIDTH+1] ;
-    const char * const usage = 
-        "pkfile[.pk] [-d] [[-x width] [-y height] [-c num] pbmfile]...";
-   
-    pbm_init(&argc, argv);
-    for (i = 0 ; i < MAXPKCHAR ; i ++) filename[i] = NULL ;
-
-    pm_message("This is PKtoPBM, version 2.5") ;
-
-    if (--argc < 1) pm_usage(usage) ;
-
-    ++argv;
-    if(strlen(*argv) + 4 > NAMELENGTH)
-        pm_error("pkname is too long");
-    strcpy(pkname, *argv) ;
-    pktopbm_add_suffix(pkname, ".pk") ;
-
-    car = 0 ;
-    /* urg: use getopt */
-    while (++argv, --argc) {
-        if (argv[0][0] == '-' && argv[0][1])
-            switch (argv[0][1]) {
-            case 'X':
-            case 'x':
-                if (argv[0][2]) bmx = atoi(*argv+2) ;
-                else if (++argv, --argc) set_bmx = atoi(*argv) ;
-                else pm_usage(usage) ;
-                continue ;
-            case 'Y':
-            case 'y':
-                if (argv[0][2]) bmy = atoi(*argv+2) ;
-                else if (++argv, --argc) set_bmy = atoi(*argv) ;
-                else pm_usage(usage) ;
-                continue ;
-            case 'C':
-            case 'c':
-                if (argv[0][2]) car = atoi(*argv+2) ;
-                else if (++argv, --argc) car = atoi(*argv) ;
-                else pm_usage(usage) ;
-                break ;
-            case 'd':
-                debug=1;
-                break ;
-            default:
-                pm_usage(usage) ;
-            } else if (car < 0 || car >= MAXPKCHAR) {
-                pm_error("character must be in range 0 to %d (-c)", 
-                         MAXPKCHAR-1) ;
-            } else filename[car++] = *argv ;
-    }
+static void
+readHeader() {
+/*----------------------------------------------------------------------------
+   Read the header of the input file.
+
+   Surprisingly, nothing in the header is useful to this program, so we're
+   just reading past it and doing some validation.
 
-    pkfile = pm_openr(pkname);
-    if (pktopbm_pkbyte() != 247)
+   We read through the first flag byte and update the global variable
+   'flagByte'.
+-----------------------------------------------------------------------------*/
+    unsigned int commentSz;
+    unsigned int i;
+
+    if (pkByte() != 247)
         pm_error("bad PK file (pre command missing)") ;
-    if (pktopbm_pkbyte() != 89)
+
+    if (pkByte() != 89)
         pm_error("wrong version of packed file") ;
-    j = pktopbm_pkbyte() ;              /* get header comment size */
-    for (i = 1 ; i <= j ; i ++) pktopbm_pkbyte() ;  /* ignore header comment */
+
+    commentSz = pkByte() ;              /* get header comment size */
+
+    for (i = 1 ; i <= commentSz ; ++i)
+        pkByte() ;  /* ignore header comment */
+
     get32() ;                   /* ignore designsize */
     get32() ;                   /* ignore checksum */
     if (get32() != get32())         /* h & v pixels per point */
         pm_message("Warning: aspect ratio not 1:1") ;
-    skipspecials() ;
-    while (flagbyte != 245) {           /* not at postamble */
-        integer cheight, cwidth ;
-        integer xoffs=0, yoffs=0;
-        FILE *ofp;
-
-        bmx=set_bmx;
-        bmy=set_bmy;
-        dynf = (flagbyte>>4) ;          /* get dynamic packing value */
-        flagbyte &= 15 ;
-        turnon = (flagbyte >= 8) ;      /* black or white initially? */
-        if (turnon) flagbyte &= 7 ;     /* long or short form */
-        if (flagbyte == 7) {            /* long form preamble */
-            integer packetlength = get32() ;    /* character packet length */
-            car = get32() ;         /* character number */
-            endofpacket = packetlength + pktopbm_pkloc;
-                /* calculate end of packet */
-            if ((car >= MAXPKCHAR) || !filename[car]) {
-                ignorechar(car, endofpacket);
-                continue;
-            }
-            dprintf0 ("flagbyte7\n");
-            dprintf ("car: %d\n", car);
-            get32() ;               /* ignore tfmwidth */
-            x=get32() ;             /* ignore horiz escapement */
-            x=get32() ;             /* ignore vert escapement */
-            dprintf ("horiz esc %d\n", x);
-            dprintf ("vert esc %d\n", x);
-            cwidth = get32() ;          /* bounding box width */
-            cheight = get32() ;         /* bounding box height */
-            dprintf ("cwidth %d\n", cwidth);
-            dprintf ("cheight %d\n", cheight);
-            if (cwidth < 0 || cheight < 0 || 
-                cwidth > 65535 || cheight > 65535) {
-                ignorechar(car, endofpacket);
-                continue;
-            }
-            xoffs= get32() ;              /* horiz offset */
-            yoffs= get32() ;              /* vert offset */
-            dprintf ("xoffs %d\n", xoffs);
-            dprintf ("yoffs %d\n", yoffs);
-        } else if (flagbyte > 3) {      /* extended short form */
-            integer packetlength = ((flagbyte - 4)<<16) + get16() ;
-            /* packet length */
-            car = pktopbm_pkbyte() ;            /* char number */
-            endofpacket = packetlength + pktopbm_pkloc ; 
-                /* calculate end of packet */
-            if ((car >= MAXPKCHAR) || !filename[car]) {
-                ignorechar(car, endofpacket);
-                continue;
-            }
-            dprintf0 ("flagbyte>3\n");
-            dprintf ("car: %d\n", car);
-            pktopbm_pkbyte() ;              /* ignore tfmwidth (3 bytes) */
-            get16() ;               /* ignore tfmwidth (3 bytes) */
-            get16() ;               /* ignore horiz escapement */
-            cwidth = get16() ;          /* bounding box width */
-            cheight = get16() ;         /* bounding box height */
-            dprintf ("cwidth %d\n", cwidth);
-            dprintf ("cheight %d\n", cheight);
-            xoffs=get16();                         /* horiz offset */
-            if (xoffs >= 32768)
-                xoffs-= 65536;
-            yoffs=get16();                         /* vert offset */
-            if (yoffs >= 32768)
-                yoffs-= 65536;
-            dprintf ("xoffs %d\n", xoffs);
-            dprintf ("yoffs %d\n", yoffs);
-        } else {                    /* short form preamble */
-            integer packetlength = (flagbyte<<8) + pktopbm_pkbyte() ;
-            /* packet length */
-            car = pktopbm_pkbyte() ;            /* char number */
-            endofpacket = packetlength + pktopbm_pkloc ;    
-                /* calculate end of packet */
-            if ((car >= MAXPKCHAR) || !filename[car]) {
-                ignorechar(car, endofpacket);
-                continue;
-            }
-            dprintf0 ("flagbyte<=3\n");
-            dprintf ("car: %d\n", car);
-            pktopbm_pkbyte() ;          /* ignore tfmwidth (3 bytes) */
-            get16() ;               /* ignore tfmwidth (3 bytes) */
-            x = pktopbm_pkbyte() ;  /* ignore horiz escapement */
-            dprintf ("horiz esc %d\n", x);
-            cwidth = pktopbm_pkbyte() ;            /* bounding box width */
-            cheight = pktopbm_pkbyte() ;           /* bounding box height */
-            dprintf ("cwidth %d\n", cwidth);
-            dprintf ("cheight %d\n", cheight);
-            xoffs=pktopbm_pkbyte ();               /* horiz offset */
-            if (xoffs >= 128)
-                xoffs-=256;
-            yoffs=pktopbm_pkbyte ();               /* vert offset */
-            if (yoffs >= 128)
-                yoffs-=256;
+
+    skipSpecials();
+}
+
+
+
+static void
+readCharacterHeader(int *          const carP,
+                    unsigned int * const endOfPacketP,
+                    bool *         const mustIgnoreP,
+                    int *          const cheightP,
+                    int *          const cwidthP,
+                    int *          const xoffsP,
+                    int *          const yoffsP,
+                    bool *         const turnonP) {
+
+    int packetLength;
+        /* character packet length field value */
+    int cheight, cwidth;
+        /* bounding box height, width field values */
+    int xoffs=0, yoffs=0;
+    bool turnon ;
+    int x;
+
+    dynf = (flagByte >> 4);          /* get dynamic packing value */
+    flagByte &= 15;
+    turnon = (flagByte >= 8) ;      /* black or white initially? */
+    if (turnon)
+        flagByte &= 7;     /* long or short form */
+
+    if (flagByte == 7) {            /* long form preamble */
+        packetLength  = get32();
+        *carP         = get32();         /* character number */
+
+        dprintf0("flagByte7\n");
+        dprintf("car: %d\n", *carP);
+        get32();               /* ignore tfmwidth */
+        x=get32();             /* ignore horiz escapement */
+        dprintf("horiz esc %d\n", x);
+        x=get32();             /* ignore vert escapement */
+        dprintf("vert esc %d\n", x);
+        cwidth = get32();          /* bounding box width */
+        cheight = get32();         /* bounding box height */
+        dprintf("cwidth %d\n", cwidth);
+        dprintf("cheight %d\n", cheight);
+        if (cwidth < 0 || cheight < 0 ||
+            cwidth > 65535 || cheight > 65535) {
+            *mustIgnoreP = true;
+        } else {
+            *mustIgnoreP = false;
+            xoffs = get32() ;              /* horiz offset */
+            yoffs = get32() ;              /* vert offset */
             dprintf ("xoffs %d\n", xoffs);
             dprintf ("yoffs %d\n", yoffs);
         }
-        if (filename[car]) {
-            if (!bmx) bmx= cwidth;
-            if (!bmy) bmy= cheight;
-            bitmap = pbm_allocarray(bmx, bmy) ;
-            if (bitmap == NULL)
-                pm_error("out of memory allocating bitmap") ;
-        } else {
-            ignorechar(car, endofpacket);
-            continue;
+    } else if (flagByte > 3) {      /* extended short form */
+        packetLength = ((flagByte - 4)<<16) + get16() ;
+
+        *carP = pkByte() ;            /* char number */
+
+        *mustIgnoreP = false;
+
+        dprintf0("flagByte>3\n");
+        dprintf("car: %d\n", *carP);
+        pkByte();              /* ignore tfmwidth (3 bytes) */
+        get16();               /* ignore tfmwidth (3 bytes) */
+        get16();               /* ignore horiz escapement */
+        cwidth = get16();          /* bounding box width */
+        cheight = get16();         /* bounding box height */
+        dprintf("cwidth %d\n", cwidth);
+        dprintf("cheight %d\n", cheight);
+        xoffs = get16();                         /* horiz offset */
+        if (xoffs >= 32768)
+            xoffs -= 65536;
+        yoffs = get16();                         /* vert offset */
+        if (yoffs >= 32768)
+            yoffs -= 65536;
+        dprintf("xoffs %d\n", xoffs);
+        dprintf("yoffs %d\n", yoffs);
+    } else {                    /* short form preamble */
+        packetLength  = (flagByte << 8) + pkByte();
+        *carP         = pkByte();            /* char number */
+
+        *mustIgnoreP = false;
+
+        dprintf0("flagByte<=3\n");
+        dprintf("car: %d\n", *carP);
+        pkByte();          /* ignore tfmwidth (3 bytes) */
+        get16();               /* ignore tfmwidth (3 bytes) */
+        x = pkByte() ;  /* ignore horiz escapement */
+        dprintf("horiz esc %d\n", x);
+        cwidth = pkByte();            /* bounding box width */
+        cheight = pkByte() ;           /* bounding box height */
+        dprintf("cwidth %d\n", cwidth);
+        dprintf("cheight %d\n", cheight);
+        xoffs = pkByte();               /* horiz offset */
+        if (xoffs >= 128)
+            xoffs -=256;
+        yoffs = pkByte();               /* vert offset */
+        if (yoffs >= 128)
+            yoffs -= 256;
+        dprintf("xoffs %d\n", xoffs);
+        dprintf("yoffs %d\n", yoffs);
+    }
+    if (packetLength < 0)
+        pm_error("Invalid character header - negative packet length");
+    if (packetLength > UINT_MAX - pkLoc)
+        pm_error("Invalid character header - excessive packet lenght");
+
+    *endOfPacketP = packetLength + pkLoc;
+
+    *cheightP = cheight;
+    *cwidthP  = cwidth;
+    *xoffsP   = xoffs;
+    *yoffsP   = yoffs;
+    *turnonP  = turnon;
+}
+
+
+
+static void
+readOneCharacter(bool           const bmxOverrideSpec,
+                 int            const bmxOverride,
+                 bool           const bmyOverrideSpec,
+                 int            const bmyOverride,
+                 unsigned int * const carP,
+                 bool *         const mustIgnoreP,
+                 bit ***        const bitmapP,
+                 unsigned int * const bmxP,
+                 unsigned int * const bmyP) {
+
+    int car;
+    unsigned int endOfPacket;
+    bool mustIgnore;
+    int cheight, cwidth;
+    int xoffs, yoffs;
+    bool turnon;
+    bit row[MAXROWWIDTH+1];
+
+    readCharacterHeader(&car, &endOfPacket, &mustIgnore,
+                        &cheight, &cwidth, &xoffs, &yoffs, &turnon);
+
+    *carP = car;
+
+    if (mustIgnore || !fileName[car]) {
+        /* Ignore this character in the font */
+        ignoreChar(car, endOfPacket);
+        *mustIgnoreP = true;
+    } else {
+        bit ** bitmap;
+        unsigned int i;
+
+        int const bmx = bmxOverrideSpec ? bmxOverride : cwidth;
+        int const bmy = bmyOverrideSpec ? bmyOverride : cheight;
+
+        *mustIgnoreP = false;
+
+        bitmap = pbm_allocarray(bmx, bmy);
+
+        bitWeight = 0 ;
+        for (i = 0 ; i < bmy ; ++i) {
+            /* make it blank */
+            unsigned int j;
+
+            for (j = 0 ; j < bmx ; ++j)
+                bitmap[i][j] = PBM_WHITE;
         }
-        bitweight = 0 ;
-        for (i = 0 ; i < bmy ; i ++)           /* make it blank */
-            for (j = 0 ; j < bmx ; j ++)
-                bitmap[i][j]= PBM_WHITE;
         if (dynf == 14) {               /* bitmapped character */
-            dprintf ("bmy: %d\n ", bmy);
-            dprintf ("y: %d\n ", bmy-yoffs-1);
-            for (i = 0 ; i < cheight ; i ++) {
-                int yi= i+(bmy-yoffs-1);
-                for (j = 0 ; j < cwidth ; j ++) {
-                    int xj= j-xoffs;
-                    if (getbit() && 0<=xj && xj<bmx && 0<=yi && yi<bmy)
+            dprintf("bmy: %d\n ", bmy);
+            dprintf("y: %d\n ", bmy - yoffs - 1);
+            for (i = 0 ; i < cheight ; ++i) {
+                unsigned int const yi = i + (bmy - yoffs - 1);
+                unsigned int j;
+                for (j = 0 ; j < cwidth ; ++j) {
+                    unsigned int const xj = j - xoffs;
+                    if (getBit() && 0 <= xj && xj < bmx && 0 <= yi && yi < bmy)
                         bitmap[yi][xj] = PBM_BLACK ;
                 }
             }
         } else {                    /* dynamically packed char */
-            integer rowsleft = cheight ;
-            integer hbit = cwidth ;
-            integer rp = 0;
-            repeatcount = 0 ;
-            dprintf ("bmy: %d\n ", bmy);
-            dprintf ("y: %d\n", cheight-rowsleft+(bmy-2*yoffs-1));
+            int rowsleft = cheight ;
+            int hbit = cwidth ;
+            int rp = 0;
+            repeatCount = 0 ;
+            dprintf("bmy: %d\n ", bmy);
+            dprintf("y: %d\n", cheight-rowsleft+(bmy-2*yoffs-1));
             while (rowsleft > 0) {
-                integer count = pkpackednum() ; /* get current color count */
+                int count = pkPackedNum() ; /* get current color count */
                 while (count > 0) {
                     if (count < hbit) {     /* doesn't extend past row */
                         hbit -= count ;
                         while (count--)
                             row[rp++] = turnon ? PBM_BLACK : PBM_WHITE;
                     } else {                /* reaches end of row */
-                        count -= hbit ;
+                        count -= hbit;
                         while (hbit--)
                             row[rp++] = turnon ? PBM_BLACK : PBM_WHITE;
-                        for (i = 0; i <= repeatcount; i++) {  /* fill row */
-                            int yi= i+cheight-rowsleft-1;
-                            if (0<=yi && yi < bmy)
+                        for (i = 0; i <= repeatCount; i++) {  /* fill row */
+                            unsigned int const yi = i + cheight - rowsleft - 1;
+                            if (0 <= yi && yi < bmy) {
+                                unsigned int j;
                                 for (j = 0; j < cwidth; j++) {
-                                    int xj= j-xoffs;
-                                    if (0<=xj && xj<bmx)
+                                    unsigned int const xj= j - xoffs;
+                                    if (0 <= xj && xj < bmx)
                                         bitmap[yi][xj] = row[j] ;
                                 }
+                            }
                         }
-                        rowsleft -= repeatcount + 1;
-                        repeatcount = rp = 0 ;
-                        hbit = cwidth ;
+                        rowsleft -= repeatCount + 1;
+                        repeatCount = rp = 0;
+                        hbit = cwidth;
                     }
                 }
-                turnon = !turnon ;
+                turnon = !turnon;
             }
             if (rowsleft != 0 || hbit != cwidth)
                 pm_error("bad pk file (more bits than required)") ;
         }
-        if (endofpacket != pktopbm_pkloc)
+        if (endOfPacket != pkLoc)
             pm_error("bad pk file (bad packet length)") ;
-
-        ofp = pm_openw(filename[car]);
-        filename[car] = NULL;
-        pbm_writepbm(ofp, bitmap, bmx, bmy, 0) ;
-        pbm_freearray(bitmap, bmy) ;
-        pm_close(ofp) ;
-        skipspecials() ;
+        *bitmapP = bitmap;
+        *bmxP    = bmx;
+        *bmyP    = bmy;
     }
-    while (! feof(pkfile)) pktopbm_pkbyte() ;       /* skip trailing junk */
-    pm_close(pkfile);
-    for (car = 0; car < MAXPKCHAR; car++)
-        if (filename[car])
+}
+
+
+
+static void
+generatePbmFile(const char * const fileNm,
+                bit **       const bitmap,
+                unsigned int const cols,
+                unsigned int const rows) {
+
+    FILE * ofP;
+
+    ofP = pm_openw(fileNm);
+
+    pbm_writepbm(ofP, bitmap, cols, rows, 0);
+
+    pm_close(ofP);
+}
+
+
+
+static void
+warnMissingCodePoint() {
+
+    unsigned int car;
+
+    for (car = 0; car < MAXPKCHAR; ++car) {
+        if (fileName[car])
             pm_message("Warning: No character in position %d (file %s).",
-                       car, filename[car]) ;
-    pm_message("%d bytes read from packed file.", pktopbm_pkloc-1) ;
+                       car, fileName[car]) ;
+    }
+}
+
+
+
+int
+main(int argc, const char ** argv) {
+
+    struct CmdlineInfo cmdline;
+    unsigned int i;
+
+    pm_proginit(&argc, argv);
+
+    parseCommandLine(argc, argv, &cmdline);
+
+    debug = cmdline.debug;
+
+    for (i = 0; i < cmdline.character; ++i)
+        fileName[i] = NULL;
+    for (i = 0; i < cmdline.outputFileCt; ++i)
+        fileName[cmdline.character + i] = cmdline.outputFileNm[i];
+    for (i = cmdline.character + cmdline.outputFileCt;
+         i < MAXPKCHAR;
+         ++i)
+        fileName[i] = NULL;
+
+    ifP = pm_openr(cmdline.inputFileNm);
+
+    pkLoc = 0;
+
+    readHeader();
+
+    while (flagByte != 245) {  /* not at postamble */
+
+        unsigned int car;
+        bool mustIgnore;
+        bit ** bitmap;
+        unsigned int cols, rows;
+
+        readOneCharacter(!!cmdline.xSpec, cmdline.x,
+                         !!cmdline.ySpec, cmdline.y,
+                         &car, &mustIgnore, &bitmap, &cols, &rows);
+
+        if (!mustIgnore) {
+            generatePbmFile(fileName[car], bitmap, cols, rows);
+
+            pbm_freearray(bitmap, rows) ;
+        }
+
+        fileName[car] = NULL;
+
+        skipSpecials();
+    }
+
+    while (!feof(ifP))
+        pkByte() ;       /* skip trailing junk */
+
+    pm_close(ifP);
+
+    warnMissingCodePoint();
+
+    pm_message("%u bytes read from packed file.", pkLoc);
+
     return 0;
 }
+
+
+
diff --git a/converter/pbm/thinkjettopbm.l b/converter/pbm/thinkjettopbm.l
index 5de4f2bb..c55a0085 100644
--- a/converter/pbm/thinkjettopbm.l
+++ b/converter/pbm/thinkjettopbm.l
@@ -38,6 +38,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include "pm_c_util.h"
+#include "mallocvar.h"
 #include "pbm.h"
 #include "shhopt.h"
 
@@ -114,8 +115,10 @@ DIG             [0-9]
 <RASTERMODE>\033\*b{DIG}+W  {
                             int l;
                             if (rowCount >= rowCapacity) {
+                                if (rowCapacity > INT_MAX-100)
+                                    pm_error("Too many rows to count");
                                 rowCapacity += 100;
-                                rows = realloc (rows, rowCapacity * sizeof *rows);
+                                REALLOCARRAY(rows, rowCapacity);
                                 if (rows == NULL)
                                     pm_error ("Out of memory.");
                             }
@@ -223,6 +226,9 @@ yywrap (void)
 
     debug ("Got %d rows, %d columns\n", rowCount, maxRowLength);
 
+    if (maxRowLength > INT_MAX/8)
+        pm_error("A row has an uncomputably large number of columns: %d",
+                 maxRowLength);
     /*
      * Quite simple since ThinkJet bit arrangement matches PBM
      */
diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c
index 36f2dee7..78eb79f2 100644
--- a/converter/pbm/ybmtopbm.c
+++ b/converter/pbm/ybmtopbm.c
@@ -10,6 +10,8 @@
 ** implied warranty.
 */
 
+#include <limits.h>
+
 #include "pm.h"
 #include "pbm.h"
 #include "bitreverse.h"
@@ -80,6 +82,9 @@ main(int argc, const char * argv[]) {
     getinit(ifP, &cols, &rows, &depth);
     if (depth != 1)
         pm_error("YBM file has depth of %u, must be 1", (unsigned int) depth);
+    if (cols > INT_MAX - 15)
+        pm_error("YBM file has uncomputably large width %d", cols);
+
 
     pbm_writepbminit(stdout, cols, rows, 0);
 
diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c
index 40dd3fb4..03bcb512 100644
--- a/converter/pgm/lispmtopgm.c
+++ b/converter/pgm/lispmtopgm.c
@@ -16,6 +16,8 @@
 **   this doesn't matter if you're using only single plane images.
 */
 
+#include <assert.h>
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -24,149 +26,159 @@
 
 #define LISPM_MAGIC  "This is a BitMap file"
 
-static void getinit ARGS(( FILE* file, short* colsP, short* rowsP, short* depthP, short* padrightP ));
-static int depth_to_word_size ARGS(( int depth ));
-static unsigned int getval ARGS(( FILE* file ));
-
-int
-main( argc, argv )
-    int argc;
-    char* argv[];
-    {
-    FILE* ifp;
-    gray* grayrow;
-    register gray* gP;
-    short rows, cols, padright, row, col;
-    short depth;
-    int maxval;
 
 
-    pgm_init( &argc, argv );
-
-    if ( argc > 2 )
-	pm_usage( "[lispmfile]" );
+static long item, bitmask;
+static unsigned int bitsperitem, maxbitsperitem, bitshift;
 
-    if ( argc == 2 )
-        ifp = pm_openr( argv[1] );
-    else
-	ifp = stdin;
-
-    getinit( ifp, &cols, &rows, &depth, &padright );
-    maxval = 1 << depth;
-
-    if ( maxval > PGM_OVERALLMAXVAL )
-        pm_error( "depth (%d bits) is too large", depth);
-
-    pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 );
-    grayrow = pgm_allocrow( ( cols + 7 ) / 8 * 8 );
-
-    for ( row = 0; row < rows; ++row )
-	{
-        for ( col = 0, gP = grayrow; col < cols; ++col, ++gP )
-	    *gP = getval( ifp );
-	pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 );
-	}
-    pm_close( ifp );
-    pm_close( stdout );
-    exit( 0 );
+static unsigned int
+wordSizeFmDepth(unsigned int const depth) {
+/*----------------------------------------------------------------------------
+  Lispm architecture specific - if a bitmap is written out with a depth of 5,
+  it really has a depth of 8, and is stored that way in the file.
+-----------------------------------------------------------------------------*/
+    if (depth==0 || depth==1) return  1;
+    else if (depth ==  2)     return  2;
+    else if (depth <=  4)     return  4;
+    else if (depth <=  8)     return  8;
+    else if (depth <= 16)     return 16;
+    else if (depth <= 32)     return 32;
+    else {
+        pm_error("depth was %u, which is not in the range 1-32.", depth);
+        assert(false);
     }
+}
+
 
-static long item, bitmask;
-static unsigned int bitsperitem, maxbitsperitem, bitshift;
 
 static void
-getinit( file, colsP, rowsP, depthP, padrightP )
-    FILE* file;
-    short* colsP;
-    short* rowsP;
-    short* padrightP;
-    short* depthP;
-    {
-    short cols_32;
+getinit(FILE *         const ifP,
+        unsigned int * const colsP,
+        unsigned int * const rowsP,
+        unsigned int * const depthP,
+        unsigned int * const padrightP) {
+
+    short cols, rows, cols32;
     char magic[sizeof(LISPM_MAGIC)];
-    int i;
+    unsigned int i;
+
+    for (i = 0; i < sizeof(magic)-1; ++i)
+        magic[i] = getc(ifP);
 
-    for ( i = 0; i < sizeof(magic)-1; ++i )
-        magic[i] = getc( file );
     magic[i]='\0';
+
     if (!streq(LISPM_MAGIC, magic))
-        pm_error( "bad id string in Lispm file" );
-    
-    if ( pm_readlittleshort( file, colsP ) == -1 )
-        pm_error( "EOF / read error" );
-    if ( pm_readlittleshort( file, rowsP ) == -1 )
-        pm_error( "EOF / read error" );
-    if ( pm_readlittleshort( file, &cols_32 ) == -1 )
-        pm_error( "EOF / read error" );
-    *depthP = getc( file );
-    
-    if ( *depthP == 0 )
-	*depthP = 1;	/* very old file */
-    
-    *padrightP = ( ( *colsP + 31 ) / 32 ) * 32 - *colsP;
-    
-    if ( *colsP != (cols_32 - *padrightP) ) {
-/*    pm_message( "inconsistent input: Width and Width(mod32) fields don't agree" );  */
-/*    *padrightP = cols_32 - *colsP;   */ /*    hmmmm....   */
-      /* This is a dilemma.  Usually the output is rounded up to mod32, but not always.
-       * For the Lispm code to not round up, the array size must be the same size as the
-       * portion being written - that is, the array itself must be an odd size, not just
-       * the selected portion.  Since arrays that are odd sizes can't be handed to bitblt,
-       * such arrays are probably not image data - so punt on it for now.
-       *
-       * Also, the lispm code for saving bitmaps has a bug, in that if you are writing a
-       * bitmap which is not mod32 across, the file may be up to 7 bits too short!  They
-       * round down instead of up.
-       *
-       * The code in 'pgmtolispm.c' always rounds up to mod32, which is totally reasonable.
-       */
-      }
-    bitsperitem = 0;
-    maxbitsperitem = depth_to_word_size( *depthP );
-    bitmask = ( 1 << maxbitsperitem ) - 1;		/* for depth=3, mask=00000111 */
+        pm_error("bad id string in Lispm file");
+
+    pm_readlittleshort(ifP, &cols);
+    pm_readlittleshort(ifP, &rows);
+    pm_readlittleshort(ifP, &cols32);
+
+    *colsP = cols;
+    *rowsP = rows;
+
+    *depthP = getc(ifP);
+
+    if (*depthP == 0)
+        *depthP = 1;    /* very old file */
+
+    assert(*colsP < UINT_MAX - 31);
+
+    *padrightP = ROUNDUP(*colsP, 32) - *colsP;
+
+# if 0
+    if (*colsP != (cols32 - *padrightP)) {
+        pm_message("inconsistent input: "
+                   "Width and Width(mod32) fields don't agree" );
+        *padrightP = cols32 - *colsP;   /*    hmmmm....   */
+
+        /* This is a dilemma.  Usually the output is rounded up to mod32, but
+           not always.  For the Lispm code to not round up, the array size
+           must be the same size as the portion being written - that is, the
+           array itself must be an odd size, not just the selected portion.
+           Since arrays that are odd sizes can't be handed to bitblt, such
+           arrays are probably not image data - so punt on it for now.
+
+           Also, the lispm code for saving bitmaps has a bug, in that if you
+           are writing a bitmap which is not mod32 across, the file may be up
+           to 7 bits too short!  They round down instead of up.
 
-    for ( i = 0; i < 9; ++i )
-	getc( file );	/* discard bytes reserved for future use */
+            The code in 'pgmtolispm.c' always rounds up to mod32, which is
+            totally reasonable.
+       */
     }
+#endif
+    bitsperitem = 0;
+    maxbitsperitem = wordSizeFmDepth(*depthP);
+    bitmask = (1 << maxbitsperitem) - 1;     /* for depth=3, mask=00000111 */
 
-static int
-depth_to_word_size (depth)	
-     int depth;			
-     /* Lispm architecture specific - if a bitmap is written    */
-     /* out with a depth of 5, it really has a depth of 8, and  */
-     /* is stored that way in the file.			   */
-{				
-    if (depth==0 || depth==1)	return ( 1);
-    else if (depth ==  2)	return ( 2);
-    else if (depth <=  4)	return ( 4);
-    else if (depth <=  8)	return ( 8);
-    else if (depth <= 16)	return (16);
-    else if (depth <= 32)	return (32);
-    else {
-      pm_error( "depth was %d, which is not in the range 1-32.", depth );
-      /* Should never reach here */
-      return(-1);
-  }
+    for (i = 0; i < 9; ++i)
+        getc(ifP);   /* discard bytes reserved for future use */
 }
 
 
 
 static unsigned int
-getval( file )
-    FILE* file;
-    {
+getval(FILE * const ifP) {
+
     unsigned int b;
 
-    if ( bitsperitem == 0 )
-	{
-	if ( pm_readlittlelong( file, &item ) == -1 )
-	    pm_error( "EOF / read error" );
-	bitsperitem = 32;
-	bitshift = 0;
-	item = ~item;
-	}
-    b = ( ( item >> bitshift ) & bitmask );
+    if (bitsperitem == 0) {
+        pm_readlittlelong(ifP, &item);
+        bitsperitem = 32;
+        bitshift = 0;
+        item = ~item;
+    }
+    b           = ((item >> bitshift ) & bitmask);
     bitsperitem = bitsperitem - maxbitsperitem;
-    bitshift = bitshift + maxbitsperitem;
+    bitshift    = bitshift + maxbitsperitem;
     return b;
+}
+
+
+
+int
+main(int argc, const char ** argv) {
+
+    FILE * ifP;
+    gray * grayrow;
+    unsigned int rows, cols, depth, padright;
+    unsigned int row;
+    gray maxval;
+
+
+    pm_proginit(&argc, argv);
+
+    if (argc-1 > 1)
+        pm_error("Too many arguments.  The only possible argument is the "
+                 "input file name");
+
+    if (argc-1 == 1)
+        ifP = pm_openr(argv[1]);
+    else
+        ifP = stdin;
+
+    getinit(ifP, &cols, &rows, &depth, &padright);
+
+    if (depth > 16)
+        pm_error("Invalid depth (%u bits).  Maximum is 15", depth);
+
+    maxval = (1 << depth);
+
+    pgm_writepgminit(stdout, cols, rows, maxval, 0);
+
+    grayrow = pgm_allocrow(ROUNDUP(cols, 8));
+
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
+
+        for (col = 0; col < cols; ++col)
+            grayrow[col] = getval(ifP);
+
+        pgm_writepgmrow(stdout, grayrow, cols, maxval, 0);
     }
+    pm_close(ifP);
+    pm_close(stdout);
+    exit(0);
+}
+
diff --git a/converter/pgm/psidtopgm.c b/converter/pgm/psidtopgm.c
index 07417d1b..99ce3710 100644
--- a/converter/pgm/psidtopgm.c
+++ b/converter/pgm/psidtopgm.c
@@ -10,6 +10,7 @@
 ** implied warranty.
 */
 
+#include "pm_c_util.h"
 #include "pgm.h"
 
 
@@ -36,19 +37,20 @@ gethexit(FILE * const ifp) {
 
 
 int
-main(int     argc,
-     char ** argv) {
+main(int           argc,
+     const char ** argv) {
 
     FILE * ifP;
     gray * grayrow;
-    int argn, row;
+    unsigned int argn;
+    unsigned int row;
     gray maxval;
     int rows, cols, bitspersample;
 
-    pgm_init(&argc, argv);
+    pm_proginit(&argc, argv);
+
+    argn = 1;  /* initial value */
 
-    argn = 1;
-    
     if (argn + 3 > argc)
         pm_error("Too few arguments");
 
@@ -78,7 +80,9 @@ main(int     argc,
         pm_error("bits/sample (%d) is too large.", bitspersample);
 
     pgm_writepgminit(stdout, cols, rows, maxval, 0);
-    grayrow = pgm_allocrow((cols + 7) / 8 * 8);
+
+    grayrow = pgm_allocrow(ROUNDUP(cols, 8));
+
     for (row = 0; row < rows; ++row) {
         unsigned int col;
         for (col = 0; col < cols; ) {
@@ -115,10 +119,10 @@ main(int     argc,
 
             default:
                 pm_error("This program does not know how to interpret a"
-                         "%d bitspersample image", bitspersample );
+                         "%d bitspersample image", bitspersample);
             }
         }
-        pgm_writepgmrow(stdout, grayrow, cols, (gray) maxval, 0);
+        pgm_writepgmrow(stdout, grayrow, cols, maxval, 0);
     }
     pgm_freerow(grayrow);
     pm_close(ifP);
@@ -126,3 +130,5 @@ main(int     argc,
 
     return 0;
 }
+
+
diff --git a/converter/ppm/ilbm.h b/converter/ppm/ilbm.h
index c0fac7d2..2f08a12f 100644
--- a/converter/ppm/ilbm.h
+++ b/converter/ppm/ilbm.h
@@ -1,9 +1,17 @@
+/*=============================================================================
+                                 ilbm.h
+===============================================================================
+  Facilities for processign IFF ILBM files
+=============================================================================*/
 #ifndef ILBM_H_INCLUDED
 #define ILBM_H_INCLUDED
 
-/* ilbm.h - definitions for IFF ILBM files */
+static __inline__ unsigned int
+ilbm_rowByteCt(unsigned int const cols) {
+
+    return (cols / 16 + (cols % 16 == 0 ? 0 : 1)) * 2;
+}
 
-#define RowBytes(cols)          ((((cols) + 15) / 16) * 2)
 
 
 /* definitions for BMHD */
diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c
index b9b89862..1b66c0b3 100644
--- a/converter/ppm/ilbmtoppm.c
+++ b/converter/ppm/ilbmtoppm.c
@@ -597,67 +597,73 @@ read_ilbm_plane(FILE *          const ifP,
 static const unsigned char bit_mask[] = {1, 2, 4, 8, 16, 32, 64, 128};
 
 static void
-decode_row(FILE *          const ifP,
-           unsigned long * const remainingChunksizeP,
-           rawtype *       const chunkyrow,
-           int             const nPlanes,
-           BitMapHeader *  const bmhdP) {
-
-    int plane, col, cols, cbit, bytes;
-    unsigned char *ilp;
-    rawtype *chp;
-
-    cols = bmhdP->w;
-    bytes = RowBytes(cols);
-    for( plane = 0; plane < nPlanes; plane++ ) {
+decodeRow(FILE *          const ifP,
+          unsigned long * const remainingChunksizeP,
+          rawtype *       const chunkyrow,
+          int             const nPlanes,
+          BitMapHeader *  const bmhdP) {
+
+    int plane;
+    int col;
+    int cols;
+    int bytes;
+    unsigned char * ilP;
+    rawtype * chP;
+
+    cols  = bmhdP->w;
+    bytes = ilbm_rowByteCt(cols);
+
+    for (plane = 0; plane < nPlanes; ++plane) {
         int mask;
+        int cbit;
 
         mask = 1 << plane;
         read_ilbm_plane(ifP, remainingChunksizeP, bytes, bmhdP->compression);
 
-        ilp = ilbmrow;
-        chp = chunkyrow;
+        ilP = ilbmrow;
+        chP = chunkyrow;
 
-        cbit = 7;
-        for( col = 0; col < cols; col++, cbit--, chp++ ) {
-            if( cbit < 0 ) {
+        for (col = 0, cbit = 7; col < cols; col++, cbit--, chP++ ) {
+            if (cbit < 0) {
                 cbit = 7;
-                ilp++;
+                ++ilP;
             }
-            if( *ilp & bit_mask[cbit] )
-                *chp |= mask;
+            if (*ilP & bit_mask[cbit])
+                *chP |= mask;
             else
-                *chp &= ~mask;
+                *chP &= ~mask;
         }
     }
 }
 
 
 static void
-decode_mask(FILE *          const ifP,
-            unsigned long * const remainingChunksizeP,
-            rawtype *       const chunkyrow,
-            BitMapHeader *  const bmhdP) {
+decodeMask(FILE *          const ifP,
+           unsigned long * const remainingChunksizeP,
+           rawtype *       const chunkyrow,
+           BitMapHeader *  const bmhdP) {
 
-    int col, cols, cbit;
-    unsigned char *ilp;
+    int cols;
+    unsigned char * ilP;
 
     cols = bmhdP->w;
     switch (bmhdP->masking) {
     case mskNone:
         break;
     case mskHasMask:        /* mask plane */
-        read_ilbm_plane(ifP, remainingChunksizeP, RowBytes(cols),
+        read_ilbm_plane(ifP, remainingChunksizeP, ilbm_rowByteCt(cols),
                         bmhdP->compression);
         if (maskfile) {
-            ilp = ilbmrow;
-            cbit = 7;
-            for (col = 0; col < cols; ++col, --cbit) {
+            int col;
+            int cbit;
+
+            ilP = ilbmrow;
+            for (col = 0, cbit = 7; col < cols; ++col, --cbit) {
                 if (cbit < 0) {
                     cbit = 7;
-                    ++ilp;
+                    ++ilP;
                 }
-                if (*ilp & bit_mask[cbit])
+                if (*ilP & bit_mask[cbit])
                     maskrow[col] = PBM_BLACK;
                 else
                     maskrow[col] = PBM_WHITE;
@@ -668,9 +674,11 @@ decode_mask(FILE *          const ifP,
         break;
     case mskHasTransparentColor:
         if (!chunkyrow)
-            pm_error("decode_mask(): chunkyrow == NULL - can't happen");
+            pm_error("decodeMask(): chunkyrow == NULL - can't happen");
 
         if (maskfile) {
+            unsigned int col;
+
             for (col = 0; col < cols; ++col) {
                 if (chunkyrow[col] == bmhdP->transparentColor)
                     maskrow[col] = PBM_WHITE;
@@ -685,7 +693,7 @@ decode_mask(FILE *          const ifP,
         pm_error("This program does not know how to process Lasso masking");
         break;
     default:
-        pm_error("decode_mask(): unknown masking type %d - can't happen",
+        pm_error("decodeMask(): unknown masking type %d - can't happen",
                  bmhdP->masking);
     }
 }
@@ -1129,8 +1137,8 @@ ham_to_ppm(FILE *         const ifP,
             if( HAS_MULTIPALETTE(cmap) )
                 multi_update(cmap, row);
 
-            decode_row(ifP, &remainingChunksize, rawrow, bmhdP->nPlanes, bmhdP);
-            decode_mask(ifP, &remainingChunksize, rawrow, bmhdP);
+            decodeRow(ifP, &remainingChunksize, rawrow, bmhdP->nPlanes, bmhdP);
+            decodeMask(ifP, &remainingChunksize, rawrow, bmhdP);
 
             r = g = b = 0;
             for( col = 0; col < cols; col++ ) {
@@ -1225,8 +1233,8 @@ std_to_ppm(FILE *         const ifP,
             if( HAS_MULTIPALETTE(cmap) )
                 multi_update(cmap, row);
 
-            decode_row(ifP, &remainingChunksize, rawrow, bmhdP->nPlanes, bmhdP);
-            decode_mask(ifP, &remainingChunksize, rawrow, bmhdP);
+            decodeRow(ifP, &remainingChunksize, rawrow, bmhdP->nPlanes, bmhdP);
+            decodeMask(ifP, &remainingChunksize, rawrow, bmhdP);
 
             for( col = 0; col < cols; col++ ) {
                 pixval r, g, b;
@@ -1255,25 +1263,27 @@ deep_to_ppm(FILE *         const ifP,
     unsigned int const rows = bmhdP->h;
     unsigned int const planespercolor = bmhdP->nPlanes / 3;
 
-    unsigned int col, row;
-    rawtype *Rrow, *Grow, *Brow;
+    unsigned int row;
+    rawtype * Rrow;
+    rawtype * Grow;
+    rawtype * Brow;
     pixval maxval;
     unsigned long remainingChunksize;
     pixel * transpColorP;
 
     pm_message("input is a deep (%d-bit) ILBM", bmhdP->nPlanes);
-    if( planespercolor > MAXPLANES )
+    if (planespercolor > MAXPLANES)
         pm_error("too many planes (max %d)", MAXPLANES * 3);
 
-    if( bmhdP->masking == mskHasTransparentColor ||
-        bmhdP->masking == mskLasso ) {
+    if (bmhdP->masking == mskHasTransparentColor ||
+        bmhdP->masking == mskLasso) {
         pm_message("masking type '%s' in a deep ILBM?? - ignoring it",
                    mskNAME[bmhdP->masking]);
         bmhdP->masking = mskNone;
     }
 
     maxval = lut_maxval(cmap, pm_bitstomaxval(planespercolor));
-    if( maxval > PPM_OVERALLMAXVAL )
+    if (maxval > PPM_OVERALLMAXVAL)
         pm_error("nPlanes is too large");
 
     transpColorP = transpColor(bmhdP, cmap, transpName, maxval);
@@ -1286,19 +1296,21 @@ deep_to_ppm(FILE *         const ifP,
 
     remainingChunksize = chunksize;  /* initial value */
 
-    for( row = 0; row < rows; row++ ) {
-        decode_row(ifP, &remainingChunksize, Rrow, planespercolor, bmhdP);
-        decode_row(ifP, &remainingChunksize, Grow, planespercolor, bmhdP);
-        decode_row(ifP, &remainingChunksize, Brow, planespercolor, bmhdP);
-        decode_mask(ifP, &remainingChunksize, NULL, bmhdP);
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
 
-        for( col = 0; col < cols; col++ ) {
-            if( transpColorP && maskrow && maskrow[col] == PBM_WHITE )
+        decodeRow(ifP, &remainingChunksize, Rrow, planespercolor, bmhdP);
+        decodeRow(ifP, &remainingChunksize, Grow, planespercolor, bmhdP);
+        decodeRow(ifP, &remainingChunksize, Brow, planespercolor, bmhdP);
+        decodeMask(ifP, &remainingChunksize, NULL, bmhdP);
+
+        for (col = 0; col < cols; ++col) {
+            if (transpColorP && maskrow && maskrow[col] == PBM_WHITE)
                 pixelrow[col] = *transpColorP;
             else
-                PPM_ASSIGN(pixelrow[col],   lookup_red(cmap, Rrow[col]),
-                                            lookup_green(cmap, Grow[col]),
-                                            lookup_blue(cmap, Brow[col]) );
+                PPM_ASSIGN(pixelrow[col], lookup_red(cmap, Rrow[col]),
+                                          lookup_green(cmap, Grow[col]),
+                                          lookup_blue(cmap, Brow[col]));
         }
         ppm_writeppmrow(stdout, pixelrow, cols, maxval, 0);
     }
@@ -1320,33 +1332,35 @@ dcol_to_ppm(FILE *         const ifP,
     unsigned int const greenplanes = dcol->g;
     unsigned int const blueplanes  = dcol->b;
 
-    int col, row;
-    rawtype *Rrow, *Grow, *Brow;
+    int row;
+    rawtype * Rrow;
+    rawtype * Grow;
+    rawtype * Brow;
     pixval maxval, redmaxval, greenmaxval, bluemaxval;
     pixval *redtable, *greentable, *bluetable;
     unsigned long remainingChunksize;
     pixel * transpColorP;
 
     pm_message("input is a %d:%d:%d direct color ILBM",
-                redplanes, greenplanes, blueplanes);
+               redplanes, greenplanes, blueplanes);
 
-    if( redplanes > MAXPLANES ||
+    if (redplanes > MAXPLANES ||
         blueplanes > MAXPLANES ||
-        greenplanes > MAXPLANES )
+        greenplanes > MAXPLANES)
         pm_error("too many planes (max %d per color component)", MAXPLANES);
 
-    if( bmhdP->nPlanes != (redplanes + greenplanes + blueplanes) )
+    if (bmhdP->nPlanes != (redplanes + greenplanes + blueplanes))
         pm_error("%s/%s plane number mismatch",
                  ID2string(ID_BMHD), ID2string(ID_DCOL));
 
-    if( bmhdP->masking == mskHasTransparentColor ||
-        bmhdP->masking == mskLasso ) {
+    if (bmhdP->masking == mskHasTransparentColor ||
+        bmhdP->masking == mskLasso) {
         pm_message("masking type '%s' in a direct color ILBM?? - ignoring it",
                    mskNAME[bmhdP->masking]);
         bmhdP->masking = mskNone;
     }
 
-    if( HAS_COLORLUT(cmap) ) {
+    if (HAS_COLORLUT(cmap)) {
         pm_error("This program does not know how to process a %s chunk "
                  "in direct color", ID2string(ID_CLUT));
         cmap->redlut = cmap->greenlut = cmap->bluelut = NULL;
@@ -1357,15 +1371,15 @@ dcol_to_ppm(FILE *         const ifP,
     bluemaxval  = pm_bitstomaxval(blueplanes);
     maxval = MAX(redmaxval, MAX(greenmaxval, bluemaxval));
 
-    if( maxval > PPM_OVERALLMAXVAL )
+    if (maxval > PPM_OVERALLMAXVAL)
         pm_error("too many planes");
 
-    if( redmaxval != maxval || greenmaxval != maxval || bluemaxval != maxval )
-        pm_message("scaling colors to %d bits", pm_maxvaltobits(maxval));
+    if (redmaxval != maxval || greenmaxval != maxval || bluemaxval != maxval)
+        pm_message("scaling colors to %u bits", pm_maxvaltobits(maxval));
 
-    MALLOCARRAY_NOFAIL(redtable,   redmaxval   +1);
-    MALLOCARRAY_NOFAIL(greentable, greenmaxval +1);
-    MALLOCARRAY_NOFAIL(bluetable,  bluemaxval  +1);
+    MALLOCARRAY_NOFAIL(redtable,   redmaxval   + 1);
+    MALLOCARRAY_NOFAIL(greentable, greenmaxval + 1);
+    MALLOCARRAY_NOFAIL(bluetable,  bluemaxval  + 1);
 
     {
         unsigned int i;
@@ -1386,19 +1400,21 @@ dcol_to_ppm(FILE *         const ifP,
 
     remainingChunksize = chunksize;  /* initial value */
 
-    for( row = 0; row < rows; row++ ) {
-        decode_row(ifP, &remainingChunksize, Rrow, redplanes, bmhdP);
-        decode_row(ifP, &remainingChunksize, Grow, greenplanes, bmhdP);
-        decode_row(ifP, &remainingChunksize, Brow, blueplanes, bmhdP);
-        decode_mask(ifP, &remainingChunksize, NULL, bmhdP);
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
 
-        for( col = 0; col < cols; col++ ) {
-            if( transpColorP && maskrow && maskrow[col] == PBM_WHITE )
+        decodeRow(ifP, &remainingChunksize, Rrow, redplanes, bmhdP);
+        decodeRow(ifP, &remainingChunksize, Grow, greenplanes, bmhdP);
+        decodeRow(ifP, &remainingChunksize, Brow, blueplanes, bmhdP);
+        decodeMask(ifP, &remainingChunksize, NULL, bmhdP);
+
+        for (col = 0; col < cols; ++col) {
+            if (transpColorP && maskrow && maskrow[col] == PBM_WHITE)
                 pixelrow[col] = *transpColorP;
             else
-                PPM_ASSIGN( pixelrow[col],  redtable[Rrow[col]],
-                                            greentable[Grow[col]],
-                                            bluetable[Brow[col]]   );
+                PPM_ASSIGN(pixelrow[col], redtable[Rrow[col]],
+                                          greentable[Grow[col]],
+                                          bluetable[Brow[col]]);
         }
         ppm_writeppmrow(stdout, pixelrow, cols, maxval, 0);
     }
@@ -1772,24 +1788,23 @@ PCHG_ConvertSmall(PCHGHeader *    const pchgP,
                   unsigned char * const mask,
                   unsigned long   const dataSize) {
 
-    unsigned char *data;
+    unsigned char * dataCursor;
     unsigned long remDataSize;
     unsigned char thismask;
-    int bits, row, i, changes, masklen, reg;
-    unsigned char ChangeCount16, ChangeCount32;
-    unsigned short SmallChange;
-    unsigned long totalchanges;
-    int changedlines;
+    int bits, row, masklen, reg;
+    unsigned int totalChangeCt;
+    unsigned int changedLineCt;
     unsigned char * maskCursor;
 
-    totalchanges = 0;  /* initial value */
-    changedlines = pchgP->ChangedLines;  /* initial value */
+    totalChangeCt = 0;  /* initial value */
+    changedLineCt = pchgP->ChangedLines;  /* initial value */
     masklen = 4 * MaskLongWords(pchgP->LineCount);
     maskCursor = mask;
-    data = maskCursor + masklen; remDataSize = dataSize - masklen;
-
+    dataCursor  = maskCursor + masklen;
+    remDataSize = dataSize - masklen;
     bits = 0;
-    for (row = pchgP->StartLine; changedlines && row < 0; ++row) {
+
+    for (row = pchgP->StartLine; changedLineCt > 0 && row < 0; ++row) {
         if (bits == 0) {
             if (masklen == 0) goto fail2;
             thismask = *maskCursor++;
@@ -1798,72 +1813,95 @@ PCHG_ConvertSmall(PCHGHeader *    const pchgP,
         }
         if (thismask & (1<<7)) {
             if (remDataSize < 2) goto fail;
-            ChangeCount16 = *data++;
-            ChangeCount32 = *data++;
-            remDataSize -= 2;
-
-            changes = ChangeCount16 + ChangeCount32;
-            for (i = 0; i < changes; ++i) {
-                if (totalchanges >= pchgP->TotalChanges) goto fail;
-                if (remDataSize < 2) goto fail;
-                SmallChange = BIG_WORD(data); data += 2; remDataSize -= 2;
-                reg = ((SmallChange & 0xf000) >> 12) +
-                    (i >= ChangeCount16 ? 16 : 0);
-                cmapP->mp_init[reg - pchgP->MinReg].reg = reg;
-                cmapP->mp_init[reg - pchgP->MinReg].r =
-                    ((SmallChange & 0x0f00) >> 8) * FACTOR_4BIT;
-                cmapP->mp_init[reg - pchgP->MinReg].g =
-                    ((SmallChange & 0x00f0) >> 4) * FACTOR_4BIT;
-                cmapP->mp_init[reg - pchgP->MinReg].b =
-                    ((SmallChange & 0x000f) >> 0) * FACTOR_4BIT;
-                ++totalchanges;
+            else {
+                unsigned int const changeCt16 = *dataCursor++;
+                unsigned int const changeCt32 = *dataCursor++;
+                unsigned int const changeCt = changeCt16 + changeCt32;
+
+                unsigned int i;
+
+                remDataSize -= 2;
+
+                for (i = 0; i < changeCt; ++i) {
+                    if (totalChangeCt >= pchgP->TotalChanges) goto fail;
+                    if (remDataSize < 2) goto fail;
+                    else {
+                        unsigned short const smallChange =
+                            BIG_WORD(dataCursor);
+
+                        dataCursor += 2; remDataSize -= 2;
+
+                        reg = ((smallChange & 0xf000) >> 12) +
+                            (i >= changeCt ? 16 : 0);
+                        cmapP->mp_init[reg - pchgP->MinReg].reg = reg;
+                        cmapP->mp_init[reg - pchgP->MinReg].r =
+                            ((smallChange & 0x0f00) >> 8) * FACTOR_4BIT;
+                        cmapP->mp_init[reg - pchgP->MinReg].g =
+                            ((smallChange & 0x00f0) >> 4) * FACTOR_4BIT;
+                        cmapP->mp_init[reg - pchgP->MinReg].b =
+                            ((smallChange & 0x000f) >> 0) * FACTOR_4BIT;
+                        ++totalChangeCt;
+                    }
+                }
+                --changedLineCt;
             }
-            --changedlines;
         }
         thismask <<= 1;
         --bits;
     }
 
-    for (row = pchgP->StartLine; changedlines && row < cmapP->mp_rows; row++) {
+    for (row = pchgP->StartLine;
+         changedLineCt > 0 && row < cmapP->mp_rows;
+         ++row) {
         if (bits == 0) {
             if (masklen == 0) goto fail2;
             thismask = *maskCursor++;
             --masklen;
             bits = 8;
         }
-        if(thismask & (1<<7)) {
+        if (thismask & (1<<7)) {
             if (remDataSize < 2) goto fail;
-            ChangeCount16 = *data++;
-            ChangeCount32 = *data++;
-            remDataSize -= 2;
-
-            changes = ChangeCount16 + ChangeCount32;
-            MALLOCARRAY_NOFAIL(cmapP->mp_change[row], changes + 1);
-            for (i = 0; i < changes; ++i) {
-                if (totalchanges >= pchgP->TotalChanges) goto fail;
-                if (remDataSize < 2) goto fail;
-                SmallChange = BIG_WORD(data); data += 2; remDataSize -= 2;
-                reg = ((SmallChange & 0xf000) >> 12) +
-                    (i >= ChangeCount16 ? 16 : 0);
-                cmapP->mp_change[row][i].reg = reg;
-                cmapP->mp_change[row][i].r =
-                    ((SmallChange & 0x0f00) >> 8) * FACTOR_4BIT;
-                cmapP->mp_change[row][i].g =
-                    ((SmallChange & 0x00f0) >> 4) * FACTOR_4BIT;
-                cmapP->mp_change[row][i].b =
-                    ((SmallChange & 0x000f) >> 0) * FACTOR_4BIT;
-                ++totalchanges;
+            else {
+                unsigned int const changeCt16 = *dataCursor++;
+                unsigned int const changeCt32 = *dataCursor++;
+                unsigned int const changeCt = changeCt16 + changeCt32;
+
+                unsigned int i;
+
+                remDataSize -= 2;
+
+                MALLOCARRAY_NOFAIL(cmapP->mp_change[row], changeCt + 1);
+                for (i = 0; i < changeCt; ++i) {
+                    if (totalChangeCt >= pchgP->TotalChanges) goto fail;
+                    if (remDataSize < 2) goto fail;
+                    else {
+                        unsigned short const smallChange =
+                            BIG_WORD(dataCursor);
+
+                        dataCursor += 2; remDataSize -= 2;
+                        reg = ((smallChange & 0xf000) >> 12) +
+                            (i >= changeCt16 ? 16 : 0);
+                        cmapP->mp_change[row][i].reg = reg;
+                        cmapP->mp_change[row][i].r =
+                            ((smallChange & 0x0f00) >> 8) * FACTOR_4BIT;
+                        cmapP->mp_change[row][i].g =
+                            ((smallChange & 0x00f0) >> 4) * FACTOR_4BIT;
+                        cmapP->mp_change[row][i].b =
+                            ((smallChange & 0x000f) >> 0) * FACTOR_4BIT;
+                        ++totalChangeCt;
+                    }
+                }
+                cmapP->mp_change[row][changeCt].reg = MP_REG_END;
+            --changedLineCt;
             }
-            cmapP->mp_change[row][changes].reg = MP_REG_END;
-            --changedlines;
         }
         thismask <<= 1;
         --bits;
     }
-    if (totalchanges != pchgP->TotalChanges)
-        pm_message("warning - got %ld change structures, "
+    if (totalChangeCt != pchgP->TotalChanges)
+        pm_message("warning - got %u change structures, "
                    "chunk header reports %ld",
-                   totalchanges, pchgP->TotalChanges);
+                   totalChangeCt, pchgP->TotalChanges);
     return;
 fail:
     pm_error("insufficient data in SmallLineChanges structures");
@@ -1989,20 +2027,20 @@ static void
 read_pchg(FILE *     const ifP,
           IFF_ID     const iffid,
           long       const chunksize,
-          ColorMap * const cmap) {
+          ColorMap * const cmapP) {
 
-    if( cmap->mp_type >= MP_TYPE_PCHG ) {
+    if (cmapP->mp_type >= MP_TYPE_PCHG ) {
         skip_chunk(ifP, iffid, chunksize);
     } else {
         PCHGHeader      PCHG;
-        unsigned char   *data;
+        unsigned char * data;
         unsigned long   datasize;
         unsigned long   remainingChunksize;
         int i;
 
-        if( cmap->mp_type )
-            multi_free(cmap);
-        cmap->mp_type = MP_TYPE_PCHG;
+        if (cmapP->mp_type)
+            multi_free(cmapP);
+        cmapP->mp_type = MP_TYPE_PCHG;
 
         remainingChunksize = chunksize;  /* initial value */
 
@@ -2014,7 +2052,7 @@ read_pchg(FILE *     const ifP,
         PCHG.MinReg      = get_big_short(ifP, iffid, &remainingChunksize);
         PCHG.MaxReg      = get_big_short(ifP, iffid, &remainingChunksize);
         PCHG.MaxChanges  = get_big_short(ifP, iffid, &remainingChunksize);
-        PCHG.TotalChanges= get_big_long(ifP, iffid, &remainingChunksize);
+        PCHG.TotalChanges= get_big_long (ifP, iffid, &remainingChunksize);
 
 #ifdef DEBUG
         pm_message("PCHG StartLine   : %d", PCHG.StartLine);
@@ -2023,9 +2061,10 @@ read_pchg(FILE *     const ifP,
         pm_message("PCHG TotalChanges: %d", PCHG.TotalChanges);
 #endif
 
-        if( PCHG.Compression != PCHG_COMP_NONE ) {
+        if (PCHG.Compression != PCHG_COMP_NONE) {
             PCHGCompHeader  CompHdr;
-            unsigned char *compdata, *comptree;
+            unsigned char * compdata;
+            unsigned char * comptree;
             long treesize, compsize;
 
             CompHdr.CompInfoSize     =
@@ -2057,37 +2096,47 @@ read_pchg(FILE *     const ifP,
             read_bytes(ifP, datasize, data, iffid, &remainingChunksize);
         }
 
-        if( PCHG.Flags & PCHGF_USE_ALPHA )
+        if (PCHG.Flags & PCHGF_USE_ALPHA)
             pm_message("warning - ignoring PCHG alpha channel because "
                        "this program doesn't know what to do with it");
 
-        cmap->mp_rows = PCHG.StartLine + PCHG.LineCount;
-        MALLOCARRAY_NOFAIL(cmap->mp_change, cmap->mp_rows);
-        for( i = 0; i < cmap->mp_rows; i++ )
-            cmap->mp_change[i] = NULL;
-        if( PCHG.StartLine < 0 ) {
-            int nch;
-            nch = PCHG.MaxReg - PCHG.MinReg +1;
-            MALLOCARRAY_NOFAIL(cmap->mp_init, nch + 1);
-            for( i = 0; i < nch; i++ )
-                cmap->mp_init[i].reg = MP_REG_IGNORE;
-            cmap->mp_init[nch].reg = MP_REG_END;
+        cmapP->mp_rows = PCHG.StartLine + PCHG.LineCount;
+        MALLOCARRAY_NOFAIL(cmapP->mp_change, cmapP->mp_rows);
+        for (i = 0; i < cmapP->mp_rows; ++i)
+            cmapP->mp_change[i] = NULL;
+
+        if (PCHG.StartLine < 0) {
+            if (PCHG.MaxReg < PCHG.MinReg)
+                pm_error("PCHG chunk says maxreg (%u) "
+                         "is less than minreg (%u)",
+                         PCHG.MaxReg, PCHG.MinReg);
+            else {
+                unsigned int const nch = PCHG.MaxReg - PCHG.MinReg + 1;
+
+                unsigned int i;
+
+                MALLOCARRAY_NOFAIL(cmapP->mp_init, nch + 1);
+
+                for (i = 0; i < nch; ++i)
+                    cmapP->mp_init[i].reg = MP_REG_IGNORE;
+
+                cmapP->mp_init[nch].reg = MP_REG_END;
+            }
         }
 
-        if( PCHG.Flags & PCHGF_12BIT ) {
+        if (PCHG.Flags & PCHGF_12BIT) {
 #ifdef DEBUG
             pm_message("SmallLineChanges");
 #endif
-            PCHG_ConvertSmall(&PCHG, cmap, data, datasize);
+            PCHG_ConvertSmall(&PCHG, cmapP, data, datasize);
         }
         else {
-            if( PCHG.Flags & PCHGF_32BIT ) {
+            if (PCHG.Flags & PCHGF_32BIT) {
 #ifdef DEBUG
                 pm_message("BigLineChanges");
 #endif
-                PCHG_ConvertBig(&PCHG, cmap, data, datasize);
-            }
-            else
+                PCHG_ConvertBig(&PCHG, cmapP, data, datasize);
+            } else
                 pm_error("unknown palette changes structure "
                          "format in %s chunk",
                          ID2string(iffid));
@@ -2143,7 +2192,7 @@ process_body( FILE *          const ifP,
     if (typeid == ID_ILBM) {
         int isdeep;
 
-        MALLOCARRAY_NOFAIL(ilbmrow, RowBytes(bmhdP->w));
+        MALLOCARRAY_NOFAIL(ilbmrow, ilbm_rowByteCt(bmhdP->w));
         *viewportmodesP |= fakeviewport;      /* -isham/-isehb */
 
         if( isdeepopt > 0 && (bmhdP->nPlanes % 3 != 0) ) {
diff --git a/converter/ppm/imgtoppm.c b/converter/ppm/imgtoppm.c
index 7078b882..60280383 100644
--- a/converter/ppm/imgtoppm.c
+++ b/converter/ppm/imgtoppm.c
@@ -12,131 +12,133 @@
 ** implied warranty.
 */
 
+#include <stdbool.h>
+#include <limits.h>
 #include <string.h>
+
+#include "nstring.h"
 #include "ppm.h"
 
 
 
 int
-main(int argc, char ** argv) {
+main(int argc, const char ** argv) {
 
-    FILE* ifp;
-    pixel* pixelrow;
+    FILE * ifP;
+    pixel * pixelrow;
     pixel colormap[256];
-    register pixel* pP;
     unsigned int cols;
     unsigned int rows;
-    int argn, row, i;
-    int col;
     pixval maxval;
     unsigned int cmaplen;
-    int len, gotAT, gotCM, gotPD;
+    bool gotAt, gotCm, gotPd;
     unsigned char buf[4096];
-    unsigned char* bP;
-
 
-    ppm_init( &argc, argv );
+    pm_proginit(&argc, argv);
 
-    argn = 1;
-
-    if ( argn < argc )
-    {
-        ifp = pm_openr( argv[argn] );
-        argn++;
-    }
+    if (argc-1 >= 1)
+        ifP = pm_openr(argv[1]);
     else
-        ifp = stdin;
+        ifP = stdin;
 
-    if ( argn != argc )
-        pm_usage( "[imgfile]" );
+    if (argc-1 > 1)
+        pm_error("Too many arguments (%u).  "
+                 "The only possible argument is the input file name", argc-1);
 
     /* Get signature. */
-    fread( buf, 8, 1, ifp );
+    fread(buf, 8, 1, ifP);
     buf[8] = '\0';
 
     /* Get entries. */
-    gotAT = 0;
-    gotCM = 0;
-    gotPD = 0;
-    while ( fread( buf, 2, 1, ifp ) == 1 )
-    {
-        if ( strncmp( (char*) buf, "AT", 2 ) == 0 )
-        {
-            if ( fread( buf, 8, 1, ifp ) != 1 )
-                pm_error( "bad attributes header" );
+    gotAt = false; /* initial value */
+    gotCm = false; /* initial value */
+    gotPd = false; /* initial value */
+    while (fread( buf, 2, 1, ifP) == 1) {
+        if (strneq((char*) buf, "AT", 2)) {
+            unsigned int len;
+
+            if (fread(buf, 8, 1, ifP) != 1)
+                pm_error("bad attributes header");
             buf[8] = '\0';
-            len = atoi( (char*) buf );
-            if ( fread( buf, len, 1, ifp ) != 1 )
-                pm_error( "bad attributes buf" );
+            len = atoi((char*) buf);
+            if (fread(buf, len, 1, ifP) != 1)
+                pm_error("bad attributes buf");
             buf[len] = '\0';
-            sscanf( (char*) buf, "%4u%4u%4u", &cols, &rows, &cmaplen );
+            sscanf((char*) buf, "%4u%4u%4u", &cols, &rows, &cmaplen);
+            if (cols > UINT_MAX/rows)
+                pm_message("height (%u) and width (%u) in header are "
+                           "uncomputably large", rows, cols);
+            if (cmaplen > UINT_MAX/3)
+                pm_message("colormap length (%u) in header is "
+                           "uncomputably large", cmaplen);
             maxval = 255;
-            gotAT = 1;
-        }
-
-        else if ( strncmp( (char*) buf, "CM", 2 ) == 0 )
-        {
-            if ( ! gotAT )
-                pm_error( "missing attributes header" );
-            if ( fread( buf, 8, 1, ifp ) != 1 )
-                pm_error( "bad colormap header" );
+            gotAt = true;
+        } else if (strneq((char*) buf, "CM", 2)) {
+            unsigned int i;
+            unsigned int len;
+
+            if (!gotAt)
+                pm_error("missing attributes header");
+            if (fread(buf, 8, 1, ifP) != 1)
+                pm_error("bad colormap header");
             buf[8] = '\0';
-            len = atoi((char*) buf );
-            if ( fread( buf, len, 1, ifp ) != 1 )
-                pm_error( "bad colormap buf" );
-            if ( cmaplen * 3 != len )
-            {
+            len = atoi((char*) buf);
+            if (fread(buf, len, 1, ifP) != 1)
+                pm_error("bad colormap buf");
+            if (len != cmaplen * 3) {
                 pm_message(
-                    "cmaplen (%d) and colormap buf length (%d) do not match",
-                    cmaplen, len );
-                if ( cmaplen * 3 < len )
+                    "cmaplen (%u) and colormap buf length (%u) do not match",
+                    cmaplen, len);
+                if (len > cmaplen * 3)
                     len = cmaplen * 3;
-                else if ( cmaplen * 3 > len )
+                else
                     cmaplen = len / 3;
             }
-            for ( i = 0; i < len; i += 3 )
-                PPM_ASSIGN( colormap[i / 3], buf[i], buf[i + 1], buf[i + 2] );
-            gotCM = 1;
-        }
-
-        else if ( strncmp( (char*) buf, "PD", 2 ) == 0 )
-        {
-            if ( fread( buf, 8, 1, ifp ) != 1 )
-                pm_error( "bad pixel data header" );
+            for (i = 0; i < len; i += 3)
+                PPM_ASSIGN(colormap[i / 3], buf[i], buf[i + 1], buf[i + 2]);
+            gotCm = true;
+        } else if (strneq((char*) buf, "PD", 2)) {
+            unsigned int len;
+            unsigned int row;
+
+            if (fread(buf, 8, 1, ifP) != 1)
+                pm_error("bad pixel data header");
             buf[8] = '\0';
-            len = atoi((char*) buf );
-            if ( len != cols * rows )
+            len = atoi((char*) buf);
+            if (len != cols * rows)
                 pm_message(
-                    "pixel data length (%d) does not match image size (%d)",
-                    len, cols * rows );
-
-            ppm_writeppminit( stdout, cols, rows, maxval, 0 );
-            pixelrow = ppm_allocrow( cols );
-
-            for ( row = 0; row < rows; row++ )
-            {
-                if ( fread( buf, 1, cols, ifp ) != cols )
-                    pm_error( "EOF / read error" );
-                for ( col = 0, pP = pixelrow, bP = buf;
-                      col < cols; col++, pP++, bP++ )
-                {
-                    if ( gotCM )
-                        *pP = colormap[*bP];
+                    "pixel data length (%u) does not match image size (%u)",
+                    len, cols * rows);
+
+            ppm_writeppminit(stdout, cols, rows, maxval, 0);
+            pixelrow = ppm_allocrow(cols);
+
+            for (row = 0; row < rows; ++row) {
+                unsigned int col;
+
+                if (fread(buf, 1, cols, ifP) != cols)
+                    pm_error("EOF / read error");
+                for (col = 0; col < cols; ++col) {
+                    if (gotCm)
+                        pixelrow[col] = colormap[buf[col]];
                     else
-                        PPM_ASSIGN( *pP, *bP, *bP, *bP );
+                        PPM_ASSIGN(pixelrow[col],
+                                   buf[col], buf[col], buf[col]);
                 }
-                ppm_writeppmrow( stdout, pixelrow, cols, maxval, 0 );
+                ppm_writeppmrow(stdout, pixelrow, cols, maxval, 0);
             }
-            gotPD = 1;
-
+            gotPd = true;
         }
     }
-    if ( ! gotPD )
-        pm_error( "missing pixel data header" );
+    if (!gotPd)
+        pm_error("missing pixel data header");
 
-    pm_close( ifp );
+    pm_close(ifP);
     /* If the program failed, it previously aborted with nonzero completion
        code, via various function calls.
     */
     return 0;
 }
+
+
+
diff --git a/converter/ppm/pcxtoppm.c b/converter/ppm/pcxtoppm.c
index e252ba22..05e09d73 100644
--- a/converter/ppm/pcxtoppm.c
+++ b/converter/ppm/pcxtoppm.c
@@ -31,6 +31,9 @@
  *  - moved check of 16-color-palette into pcx_16col_to_ppm(),
  *    now checks if it contains only a single color
  */
+#include <stdbool.h>
+#include <limits.h>
+
 #include "pm_c_util.h"
 #include "mallocvar.h"
 #include "shhopt.h"
@@ -52,30 +55,31 @@ static pixel stdPalette[16];
 static void
 generateStdPalette(void) {
 
-    int i;
-    for (i = 0; i < 16; i++)
+    unsigned int i;
+
+    for (i = 0; i < 16; ++i)
         PPM_ASSIGN(stdPalette[i], StdRed[i], StdGreen[i], StdBlue[i]);
 }
 
 
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char *inputFilespec;  /* '-' if stdin */
-    unsigned int verbose;  
+    const char * inputFileNm;  /* '-' if stdin */
+    unsigned int verbose;
     unsigned int stdpalette;
 };
 
 
 
 static void
-parseCommandLine ( int argc, char ** argv,
-                   struct cmdlineInfo *cmdlineP ) {
+parseCommandLine(int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
-   parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   Parse program command line described in Unix standard form by argc
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -91,22 +95,22 @@ parseCommandLine ( int argc, char ** argv,
     unsigned int option_def_index;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "stdpalette",     OPT_FLAG,   NULL,                  
+    OPTENT3(0, "stdpalette",     OPT_FLAG,   NULL,
             &cmdlineP->stdpalette,    0 );
-    OPTENT3(0, "verbose",        OPT_FLAG,   NULL,                  
+    OPTENT3(0, "verbose",        OPT_FLAG,   NULL,
             &cmdlineP->verbose,       0 );
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    pm_optParseOptions3( &argc, argv, opt, sizeof(opt), 0 );
+    pm_optParseOptions3(&argc, (char**)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdline_p and others. */
 
     if (argc-1 < 1)
-        cmdlineP->inputFilespec = "-";
+        cmdlineP->inputFileNm = "-";
     else if (argc-1 == 1)
-        cmdlineP->inputFilespec = argv[1];
+        cmdlineP->inputFileNm = argv[1];
     else
         pm_error("Program takes at most one argument "
                  "(input file specification).  You specified %d",
@@ -115,13 +119,13 @@ parseCommandLine ( int argc, char ** argv,
 
 
 
-struct pcxHeader {
+struct PcxHeader {
     int Version;
     /* Xmin, Ymin, Xmax, and Ymax are positions in some field (in units of
        pixels) of the edges of the image.  They may be negative.  You can
        derive the image width and height from these.
     */
-    short Xmin;            
+    short Xmin;
     short Ymin;
     short Xmax;
     short Ymax;
@@ -141,23 +145,8 @@ struct pcxHeader {
 
 
 
-static void
-readInt(FILE * const ifP, short * const retvalP) {
-/*----------------------------------------------------------------------------
-   Read a 2-byte little-endian word from the file.
------------------------------------------------------------------------------*/
-    int rc;
-
-    rc = pm_readlittleshort(ifP, retvalP);
-
-    if (rc != 0)
-        pm_error("EOF/error reading integer from input file.");
-}
-
-
-
 static int
-GetByte(FILE * const fp) {
+getByte(FILE * const fp) {
 
     int    c;
 
@@ -170,55 +159,55 @@ GetByte(FILE * const fp) {
 
 
 static void
-readPcxHeader(FILE *             const ifP, 
-              struct pcxHeader * const pcxHeaderP) {
+readPcxHeader(FILE *             const ifP,
+              struct PcxHeader * const pcxHeaderP) {
 /*----------------------------------------------------------------------------
    Read the PCX header
 -----------------------------------------------------------------------------*/
-    if (GetByte(ifP) != PCX_MAGIC)
+    if (getByte(ifP) != PCX_MAGIC)
         pm_error("bad magic number - not a PCX file");
 
-    pcxHeaderP->Version = GetByte(ifP);  /* get version # */
+    pcxHeaderP->Version = getByte(ifP);  /* get version # */
 
-    pcxHeaderP->Encoding = GetByte(ifP);
+    pcxHeaderP->Encoding = getByte(ifP);
     if (pcxHeaderP->Encoding != 1)    /* check for PCX run length encoding   */
         pm_error("unknown encoding scheme: %d", pcxHeaderP->Encoding);
 
-    pcxHeaderP->BitsPerPixel= GetByte(ifP);
-    readInt(ifP, &pcxHeaderP->Xmin);
-    readInt(ifP, &pcxHeaderP->Ymin);
-    readInt(ifP, &pcxHeaderP->Xmax);
-    readInt(ifP, &pcxHeaderP->Ymax);
+    pcxHeaderP->BitsPerPixel= getByte(ifP);
+    pm_readlittleshort(ifP, &pcxHeaderP->Xmin);
+    pm_readlittleshort(ifP, &pcxHeaderP->Ymin);
+    pm_readlittleshort(ifP, &pcxHeaderP->Xmax);
+    pm_readlittleshort(ifP, &pcxHeaderP->Ymax);
 
     if (pcxHeaderP->Xmax < pcxHeaderP->Xmin)
         pm_error("Invalid PCX input:  minimum X value (%d) is greater than "
-                 "maximum X value (%d).", 
+                 "maximum X value (%d).",
                  pcxHeaderP->Xmin, pcxHeaderP->Xmax);
     if (pcxHeaderP->Ymax < pcxHeaderP->Ymin)
         pm_error("Invalid PCX input:  minimum Y value (%d) is greater than "
-                 "maximum Y value (%d).", 
+                 "maximum Y value (%d).",
                  pcxHeaderP->Ymin, pcxHeaderP->Ymax);
 
-    readInt(ifP, &pcxHeaderP->HorizontalResolution);  
-    readInt(ifP, &pcxHeaderP->VerticalResolution);  
+    pm_readlittleshort(ifP, &pcxHeaderP->HorizontalResolution);
+    pm_readlittleshort(ifP, &pcxHeaderP->VerticalResolution);
 
     {
-        int i;
+        unsigned int i;
         /*
          * get the 16-color color map
          */
-        for (i = 0; i < 16; i++) {
-            unsigned int const r = GetByte(ifP);
-            unsigned int const g = GetByte(ifP);
-            unsigned int const b = GetByte(ifP);
+        for (i = 0; i < 16; ++i) {
+            unsigned int const r = getByte(ifP);
+            unsigned int const g = getByte(ifP);
+            unsigned int const b = getByte(ifP);
             PPM_ASSIGN(pcxHeaderP->cmap16[i], r, g, b);
         }
     }
 
-    GetByte(ifP);                /* skip reserved byte       */
-    pcxHeaderP->Planes      = GetByte(ifP);     /* # of color planes        */
-    readInt(ifP, &pcxHeaderP->BytesPerLine);
-    readInt(ifP, &pcxHeaderP->PaletteInfo);
+    getByte(ifP);                /* skip reserved byte       */
+    pcxHeaderP->Planes = getByte(ifP);     /* # of color planes        */
+    pm_readlittleshort(ifP, &pcxHeaderP->BytesPerLine);
+    pm_readlittleshort(ifP, &pcxHeaderP->PaletteInfo);
 
     /* Read past a bunch of reserved space in the header.  We have read
        70 bytes of the header so far.  We would just seek here, except that
@@ -228,28 +217,29 @@ readPcxHeader(FILE *             const ifP,
         unsigned int pos;
 
         for (pos = 70; pos < PCX_HDR_SIZE; ++pos)
-            GetByte(ifP);
+            getByte(ifP);
     }
 }
 
 
 
-static void 
-reportPcxHeader(struct pcxHeader const pcxHeader) {
+static void
+reportPcxHeader(struct PcxHeader const pcxHeader) {
 
     pm_message("Version: %d", pcxHeader.Version);
     pm_message("BitsPerPixel: %d", pcxHeader.BitsPerPixel);
-    pm_message("Xmin: %d   Ymin: %d   Xmax: %d   Ymax: %d", 
+    pm_message("Xmin: %d   Ymin: %d   Xmax: %d   Ymax: %d",
                pcxHeader.Xmin, pcxHeader.Ymin, pcxHeader.Xmax, pcxHeader.Ymax);
-    pm_message("Planes: %d    BytesPerLine: %d    PaletteInfo: %d", 
-               pcxHeader.Planes, pcxHeader.BytesPerLine, 
+    pm_message("Planes: %d    BytesPerLine: %d    PaletteInfo: %d",
+               pcxHeader.Planes, pcxHeader.BytesPerLine,
                pcxHeader.PaletteInfo);
     pm_message("Color map in image:  (index: r/g/b)");
+
     if (pcxHeader.BitsPerPixel < 8) {
         unsigned int colorIndex;
         for (colorIndex = 0; colorIndex < 16; ++colorIndex) {
             pixel const p = pcxHeader.cmap16[colorIndex];
-            pm_message("  %u: %u/%u/%u", colorIndex, 
+            pm_message("  %u: %u/%u/%u", colorIndex,
                        PPM_GETR(p), PPM_GETG(p), PPM_GETB(p));
         }
     }
@@ -278,42 +268,39 @@ allBlackPalette(pixel cmap16[]) {
 
 
 
-/*
- *  read a single row encoded row, handles encoding across rows
- */
 static void
-GetPCXRow(FILE * const ifP, unsigned char * const pcxrow, 
-          int const bytesperline) {
+getPCXRow(FILE *          const ifP,
+          unsigned char * const pcxrow,
+          unsigned int    const bytesperline) {
 /*----------------------------------------------------------------------------
    Read one row from the PCX raster.
-   
-   The PCX raster is run length encoded as follows:  If the upper two
-   bits of a byte are 11, the lower 6 bits are a repetition count for the
-   raster byte that follows.  If the upper two bits are not 11, the byte 
-   _is_ a raster byte, with repetition count 1.
-
-   A run can't span rows, but it can span planes within a row.  That's
-   why 'repetitionsLeft' and 'c' are static variables in this
-   subroutine.
+
+   The PCX raster is run length encoded as follows: If the upper two bits of a
+   byte are 11, the lower 6 bits are a repetition count for the raster byte
+   that follows.  If the upper two bits are not 11, the byte _is_ a raster
+   byte, with repetition count 1.
+
+   A run can't span rows, but it can span planes within a row.  That's why
+   'repetitionsLeft' and 'c' are static variables in this subroutine.
 -----------------------------------------------------------------------------*/
     static int repetitionsLeft = 0;
     static int c;
-    int bytesGenerated;
+    unsigned int bytesGenerated;
 
     bytesGenerated = 0;
-    while( bytesGenerated < bytesperline ) {
-        if(repetitionsLeft > 0) {
+    while(bytesGenerated < bytesperline) {
+        if (repetitionsLeft > 0) {
             pcxrow[bytesGenerated++] = c;
             --repetitionsLeft;
         } else {
-            c = GetByte(ifP);
+            c = getByte(ifP);
             if ((c & 0xc0) != 0xc0)
                 /* This is a 1-shot byte, not a repetition count */
                 pcxrow[bytesGenerated++] = c;
             else {
                 /* This is a repetition count for the following byte */
                 repetitionsLeft = c & 0x3f;
-                c = GetByte(ifP);
+                c = getByte(ifP);
             }
         }
     }
@@ -321,187 +308,185 @@ GetPCXRow(FILE * const ifP, unsigned char * const pcxrow,
 
 
 
-/*
- * convert packed pixel format into 1 pixel per byte
- */
 static void
-pcx_unpack_pixels(pixels, bitplanes, bytesperline, planes, bitsperpixel)
-    unsigned char   *pixels;
-    unsigned char   *bitplanes;
-    int             bytesperline;
-    int             planes;
-    int             bitsperpixel;
-{
-    register int        bits;
+pcxUnpackPixels(unsigned char * const pixels,
+                unsigned char * const bitplanes,
+                unsigned int    const bytesperline,
+                unsigned int    const planes,
+                unsigned int    const bitsperpixel) {
+/*----------------------------------------------------------------------------
+   Convert packed pixel format in bitplanes[] into 1 pixel per byte
+   in pixels[].
+-----------------------------------------------------------------------------*/
+    unsigned int i;
 
     if (planes != 1)
         pm_error("can't handle packed pixels with more than 1 plane" );
-#if 0
-    if (bitsperpixel == 8)
-    {
-        while (--bytesperline >= 0)
-            *pixels++ = *bitplanes++;
-    }
-    else
-#endif
-        if (bitsperpixel == 4)
-        {
-            while (--bytesperline >= 0)
-            {
-                bits        = *bitplanes++;
-                *pixels++   = (bits >> 4) & 0x0f;
-                *pixels++   = (bits     ) & 0x0f;
-            }
-        }
-        else if (bitsperpixel == 2)
-        {
-            while (--bytesperline >= 0)
-            {
-                bits        = *bitplanes++;
-                *pixels++   = (bits >> 6) & 0x03;
-                *pixels++   = (bits >> 4) & 0x03;
-                *pixels++   = (bits >> 2) & 0x03;
-                *pixels++   = (bits     ) & 0x03;
-            }
-        }
-        else if (bitsperpixel == 1)
-        {
-            while (--bytesperline >= 0)
-            {
-                bits        = *bitplanes++;
-                *pixels++   = ((bits & 0x80) != 0);
-                *pixels++   = ((bits & 0x40) != 0);
-                *pixels++   = ((bits & 0x20) != 0);
-                *pixels++   = ((bits & 0x10) != 0);
-                *pixels++   = ((bits & 0x08) != 0);
-                *pixels++   = ((bits & 0x04) != 0);
-                *pixels++   = ((bits & 0x02) != 0);
-                *pixels++   = ((bits & 0x01) != 0);
-            }
+
+    for (i = 0; i < bytesperline; ++i) {
+        unsigned int const bits = bitplanes[i];
+
+        switch (bitsperpixel) {
+        case 4:
+            pixels[2*i + 0] = (bits >> 4) & 0x0f;
+            pixels[2*i + 1] = (bits     ) & 0x0f;
+            break;
+        case 2:
+            pixels[i*4 + 0] = (bits >> 6) & 0x03;
+            pixels[i*4 + 1] = (bits >> 4) & 0x03;
+            pixels[i*4 + 2] = (bits >> 2) & 0x03;
+            pixels[i*4 + 3] = (bits     ) & 0x03;
+            break;
+        case 1:
+            pixels[i*8 + 0]  = ((bits & 0x80) != 0);
+            pixels[i*8 + 1]  = ((bits & 0x40) != 0);
+            pixels[i*8 + 2]  = ((bits & 0x20) != 0);
+            pixels[i*8 + 3]  = ((bits & 0x10) != 0);
+            pixels[i*8 + 4]  = ((bits & 0x08) != 0);
+            pixels[i*8 + 5]  = ((bits & 0x04) != 0);
+            pixels[i*8 + 6]  = ((bits & 0x02) != 0);
+            pixels[i*8 + 7]  = ((bits & 0x01) != 0);
+            break;
+        default:
+        pm_error("pcxUnpackPixels - can't handle %u bits per pixel",
+                 bitsperpixel);
         }
-        else
-            pm_error("pcx_unpack_pixels - can't handle %d bits per pixel", 
-                     bitsperpixel);
+    }
 }
 
 
 
-/*
- * convert multi-plane format into 1 pixel per byte
- */
 static void
-pcx_planes_to_pixels(pixels, bitplanes, bytesperline, planes, bitsperpixel)
-    unsigned char   *pixels;
-    unsigned char   *bitplanes;
-    int             bytesperline;
-    int             planes;
-    int             bitsperpixel;
-{
-    int  i, j;
-    int  npixels;
-    unsigned char    *p;
+pcxPlanesToPixels(unsigned char * const pixels,
+                  unsigned char * const bitPlanes,
+                  unsigned int    const bytesPerLine,
+                  unsigned int    const planes,
+                  unsigned int    const bitsPerPixel) {
+/*----------------------------------------------------------------------------
+   Convert multi-plane format into 1 pixel per byte.
+-----------------------------------------------------------------------------*/
+    unsigned int const npixels = (bytesPerLine * 8) / bitsPerPixel;
+
+    unsigned int  i;
 
     if (planes > 4)
-        pm_error("can't handle more than 4 planes" );
-    if (bitsperpixel != 1)
-        pm_error("can't handle more than 1 bit per pixel" );
+        pm_error("can't handle more than 4 planes");
+    if (bitsPerPixel != 1)
+        pm_error("can't handle more than 1 bit per pixel");
 
-    /*
-     * clear the pixel buffer
-     */
-    npixels = (bytesperline * 8) / bitsperpixel;
-    p    = pixels;
-    while (--npixels >= 0)
-        *p++ = 0;
+    /* Clear the pixel buffer - initial value */
+    for (i = 0; i < npixels; ++i)
+        pixels[i] = 0;
 
-    /*
-     * do the format conversion
-     */
-    for (i = 0; i < planes; i++)
-    {
-        int pixbit, bits, mask;
-
-        p    = pixels;
-        pixbit    = (1 << i);
-        for (j = 0; j < bytesperline; j++)
-        {
-            bits = *bitplanes++;
-            for (mask = 0x80; mask != 0; mask >>= 1, p++)
+    for (i = 0; i < planes; ++i) {
+        unsigned int const pixbit = (1 << i);
+
+        unsigned int j;
+
+        for (j = 0; j < bytesPerLine; ++j) {
+            unsigned int const bits = bitPlanes[j];
+
+            unsigned int mask;
+            unsigned int k;
+
+            for (mask = 0x80, k = 0; mask != 0; mask >>= 1, ++k)
                 if (bits & mask)
-                    *p |= pixbit;
+                    pixels[k] |= pixbit;
         }
     }
 }
 
 
 
-static void
-pcx_16col_to_ppm(FILE *       const ifP,
-                 unsigned int const headerCols,
-                 unsigned int const rows,
-                 unsigned int const BytesPerLine,
-                 unsigned int const BitsPerPixel,
-                 unsigned int const Planes,
-                 pixel *      const cmap) {
+static bool
+paletteIsOk(const pixel * const cmap,
+            unsigned int  const colorCt) {
 
-    unsigned int cols;
-    int row, col, rawcols, colors;
-    unsigned char * pcxrow;
-    unsigned char * rawrow;
-    pixel * ppmrow;
     bool paletteOk;
+    unsigned int col;
 
-    paletteOk = FALSE;
+    paletteOk = false;  /* initial assumption */
 
     /* check if palette is ok  */
-    colors = (1 << BitsPerPixel) * (1 << Planes);
-    for (col = 0; col < colors - 1; ++col) {
+    for (col = 0; col < colorCt - 1; ++col) {
         if (!PPM_EQUAL(cmap[col], cmap[col+1])) {
-            paletteOk = TRUE;
-            break;
+            paletteOk = true;
         }
     }
+    return paletteOk;
+}
+
+
+
+static void
+pcx16ColToPpm(FILE *       const ifP,
+              unsigned int const headerCols,
+              unsigned int const rows,
+              unsigned int const bytesPerLine,
+              unsigned int const bitsPerPixel,
+              unsigned int const planes,
+              pixel *      const cmap) {
+
+    unsigned int const colors = (1 << bitsPerPixel) * (1 << planes);
+    bool const paletteOk = paletteIsOk(cmap, colors);
+
+    unsigned int cols;
+    unsigned int row;
+    unsigned int rawcols;
+    unsigned char * pcxrow;
+    unsigned char * rawrow;
+    pixel * ppmrow;
+
     if (!paletteOk) {
         unsigned int col;
+
         pm_message("warning - useless header palette, "
                    "using builtin standard palette");
+
         for (col = 0; col < colors; ++col)
             PPM_ASSIGN(cmap[col], StdRed[col], StdGreen[col], StdBlue[col]);
     }
 
-    /*  BytesPerLine should be >= BitsPerPixel * cols / 8  */
-    rawcols = BytesPerLine * 8 / BitsPerPixel;
+    if (bytesPerLine > UINT_MAX/8)
+        pm_error("Image too wide to compute (%u bytes per line)",
+                 bytesPerLine);
+
+    /*  bytesPerLine should be >= bBitsPerPixel * cols / 8  */
+    rawcols = bytesPerLine * 8 / bitsPerPixel;
+
     if (headerCols > rawcols) {
-        pm_message("warning - BytesPerLine = %d, "
-                   "truncating image to %d pixels",
-                   BytesPerLine, rawcols);
+        pm_message("warning - BytesPerLine = %u, "
+                   "truncating image to %u pixels",
+                   bytesPerLine, rawcols);
         cols = rawcols;
     } else
         cols = headerCols;
 
-    MALLOCARRAY(pcxrow, Planes * BytesPerLine);
+    MALLOCARRAY(pcxrow, planes * bytesPerLine);
     if (pcxrow == NULL)
-        pm_error("Out of memory");
+        pm_error("Can't get memory for %u planes, %u bytes per line",
+                 planes, bytesPerLine);
     MALLOCARRAY(rawrow, rawcols);
     if (rawrow == NULL)
-        pm_error("Out of memory");
+        pm_error("Can't get memory for %u columns", rawcols);
 
     ppmrow = ppm_allocrow(cols);
 
     for (row = 0; row < rows; ++row) {
         unsigned int col;
 
-        GetPCXRow(ifP, pcxrow, Planes * BytesPerLine);
+        getPCXRow(ifP, pcxrow, planes * bytesPerLine);
 
-        if (Planes == 1)
-            pcx_unpack_pixels(rawrow, pcxrow, BytesPerLine, 
-                              Planes, BitsPerPixel);
+        if (planes == 1)
+            pcxUnpackPixels(rawrow, pcxrow, bytesPerLine,
+                            planes, bitsPerPixel);
         else
-            pcx_planes_to_pixels(rawrow, pcxrow, BytesPerLine, 
-                                 Planes, BitsPerPixel);
+            pcxPlanesToPixels(rawrow, pcxrow, bytesPerLine,
+                              planes, bitsPerPixel);
 
         for (col = 0; col < cols; ++col)
             ppmrow[col] = cmap[rawrow[col]];
+
         ppm_writeppmrow(stdout, ppmrow, cols, PCX_MAXVAL, 0);
     }
     ppm_freerow(ppmrow);
@@ -512,10 +497,10 @@ pcx_16col_to_ppm(FILE *       const ifP,
 
 
 static void
-pcx_256col_to_ppm(FILE *       const ifP,
-                  unsigned int const headerCols,
-                  unsigned int const rows,
-                  unsigned int const BytesPerLine) {
+pcx256ColToPpm(FILE *       const ifP,
+               unsigned int const headerCols,
+               unsigned int const rows,
+               unsigned int const bytesPerLine) {
 
     unsigned int cols;
     pixel colormap[256];
@@ -524,37 +509,37 @@ pcx_256col_to_ppm(FILE *       const ifP,
     unsigned char colormapSignature;
     unsigned int row;
 
-    if (headerCols > BytesPerLine) {
+    if (headerCols > bytesPerLine) {
         pm_message("warning - BytesPerLine = %u, "
                    "truncating image to %u pixels",
-                   BytesPerLine,  BytesPerLine);
-        cols = BytesPerLine;
+                   bytesPerLine,  bytesPerLine);
+        cols = bytesPerLine;
     } else
         cols = headerCols;
 
-    MALLOCARRAY2(image, rows, BytesPerLine);
+    MALLOCARRAY2(image, rows, bytesPerLine);
 
     for (row = 0; row < rows; ++row)
-        GetPCXRow(ifP, image[row], BytesPerLine);
+        getPCXRow(ifP, image[row], bytesPerLine);
 
     /*
      * 256 color images have their color map at the end of the file
      * preceded by a magic byte
      */
-    colormapSignature = GetByte(ifP);
+    colormapSignature = getByte(ifP);
     if (colormapSignature != PCX_256_COLORS)
         pm_error("bad color map signature.  In a 1-plane PCX image "
                  "such as this, we expect a magic number of %u in the byte "
                  "following the raster, to introduce the color map.  "
-                 "Instead, this image has %u.", 
+                 "Instead, this image has %u.",
                  PCX_256_COLORS, colormapSignature);
     else {
         unsigned int colorIndex;
-        
+
         for (colorIndex = 0; colorIndex < 256; ++colorIndex) {
-            pixval const r = GetByte(ifP);
-            pixval const g = GetByte(ifP);
-            pixval const b = GetByte(ifP);
+            pixval const r = getByte(ifP);
+            pixval const g = getByte(ifP);
+            pixval const b = getByte(ifP);
             PPM_ASSIGN(colormap[colorIndex], r, g, b);
         }
     }
@@ -574,51 +559,56 @@ pcx_256col_to_ppm(FILE *       const ifP,
 
 
 static void
-pcx_truecol_to_ppm(FILE *       const ifP,
-                   unsigned int const headerCols,
-                   unsigned int const rows,
-                   unsigned int const BytesPerLine,
-                   unsigned int const Planes) {
-
-    unsigned int cols;
-    unsigned char *redrow, *greenrow, *bluerow, *intensityrow;
-    pixel * ppmrow;
-    unsigned int row;
-    
-    if (headerCols > BytesPerLine) {
+pcxTruecolToPpm(FILE *       const ifP,
+                unsigned int const headerCols,
+                unsigned int const rows,
+                unsigned int const bytesPerLine,
+                unsigned int const planes) {
+
+    unsigned int    cols;
+    unsigned char * redrow;
+    unsigned char * grnrow;
+    unsigned char * blurow;
+    unsigned char * intensityrow;
+    pixel *         ppmrow;
+    unsigned int    row;
+
+    if (headerCols > bytesPerLine) {
         pm_message("warning - BytesPerLine = %u, "
                    "truncating image to %u pixels",
-                   BytesPerLine,  BytesPerLine);
-        cols = BytesPerLine;
+                   bytesPerLine, bytesPerLine);
+        cols = bytesPerLine;
     } else
         cols = headerCols;
 
-    MALLOCARRAY(redrow, BytesPerLine);
-    MALLOCARRAY(greenrow, BytesPerLine);
-    MALLOCARRAY(bluerow, BytesPerLine);
+    MALLOCARRAY(redrow, bytesPerLine);
+    MALLOCARRAY(grnrow, bytesPerLine);
+    MALLOCARRAY(blurow, bytesPerLine);
 
-    if (redrow == NULL || greenrow == NULL || bluerow == NULL)
-        pm_error("out of memory");
+    if (redrow == NULL || grnrow == NULL || blurow == NULL)
+        pm_error("Can't get memory for %u-byte row buffer", bytesPerLine);
 
-    if (Planes == 4) {
-        MALLOCARRAY(intensityrow, BytesPerLine);
+    if (planes == 4) {
+        MALLOCARRAY(intensityrow, bytesPerLine);
         if (intensityrow == NULL)
-            pm_error("out of memory");
+            pm_error("Can't get memory for %u-byte row buffer", bytesPerLine);
     } else
         intensityrow = NULL;
 
     ppmrow = ppm_allocrow(cols);
     for (row = 0; row < rows; ++row) {
         unsigned int col;
-        GetPCXRow(ifP, redrow, BytesPerLine);
-        GetPCXRow(ifP, greenrow, BytesPerLine);
-        GetPCXRow(ifP, bluerow, BytesPerLine);
-        if( intensityrow )
-            GetPCXRow(ifP, intensityrow, BytesPerLine);
+
+        getPCXRow(ifP, redrow, bytesPerLine);
+        getPCXRow(ifP, grnrow, bytesPerLine);
+        getPCXRow(ifP, blurow, bytesPerLine);
+        if (intensityrow)
+            getPCXRow(ifP, intensityrow, bytesPerLine);
+
         for (col = 0; col < cols; ++col) {
             unsigned int const r = redrow[col];
-            unsigned int const g = greenrow[col];
-            unsigned int const b = bluerow[col];
+            unsigned int const g = grnrow[col];
+            unsigned int const b = blurow[col];
             unsigned int const i = intensityrow ? intensityrow[col] : 256;
 
             PPM_ASSIGN(ppmrow[col],
@@ -630,29 +620,29 @@ pcx_truecol_to_ppm(FILE *       const ifP,
     ppm_freerow(ppmrow);
     if (intensityrow)
         free(intensityrow);
-    free(bluerow);
-    free(greenrow);
+    free(blurow);
+    free(grnrow);
     free(redrow);
 }
 
 
 
 int
-main(int argc, char *argv[]) {
+main(int argc, const char *argv[]) {
 
     FILE * ifP;
-    struct cmdlineInfo cmdline;
-    struct pcxHeader pcxHeader;
+    struct CmdlineInfo cmdline;
+    struct PcxHeader pcxHeader;
     unsigned int Width, Height;
     pixel * cmap16;
 
-    ppm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
     generateStdPalette();
 
     parseCommandLine(argc, argv, &cmdline);
 
-    ifP = pm_openr(cmdline.inputFilespec);
+    ifP = pm_openr(cmdline.inputFileNm);
 
     readPcxHeader(ifP, &pcxHeader);
 
@@ -668,31 +658,32 @@ main(int argc, char *argv[]) {
         cmap16 = pcxHeader.cmap16;
 
     ppm_writeppminit(stdout, Width, Height, PCX_MAXVAL, 0);
+
     switch (pcxHeader.BitsPerPixel) {
     case 1:
         if(pcxHeader.Planes >= 1 && pcxHeader.Planes <= 4)
-            pcx_16col_to_ppm(ifP, Width, Height, pcxHeader.BytesPerLine, 
-                             pcxHeader.BitsPerPixel, pcxHeader.Planes, cmap16);
+            pcx16ColToPpm(ifP, Width, Height, pcxHeader.BytesPerLine,
+                          pcxHeader.BitsPerPixel, pcxHeader.Planes, cmap16);
         else
             goto fail;
         break;
     case 2:
     case 4:
         if (pcxHeader.Planes == 1)
-            pcx_16col_to_ppm(ifP, Width, Height, pcxHeader.BytesPerLine, 
-                             pcxHeader.BitsPerPixel, pcxHeader.Planes, cmap16);
+            pcx16ColToPpm(ifP, Width, Height, pcxHeader.BytesPerLine,
+                          pcxHeader.BitsPerPixel, pcxHeader.Planes, cmap16);
         else
             goto fail;
         break;
     case 8:
         switch(pcxHeader.Planes) {
         case 1:
-            pcx_256col_to_ppm(ifP, Width, Height, pcxHeader.BytesPerLine);
+            pcx256ColToPpm(ifP, Width, Height, pcxHeader.BytesPerLine);
             break;
         case 3:
         case 4:
-            pcx_truecol_to_ppm(ifP, Width, Height, 
-                               pcxHeader.BytesPerLine, pcxHeader.Planes);
+            pcxTruecolToPpm(ifP, Width, Height,
+                            pcxHeader.BytesPerLine, pcxHeader.Planes);
             break;
         default:
             goto fail;
@@ -704,8 +695,9 @@ main(int argc, char *argv[]) {
                  pcxHeader.BitsPerPixel, pcxHeader.Planes);
     }
     pm_close(ifP);
-    
+
     return 0;
 }
 
 
+
diff --git a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c
index e556803f..7932886c 100644
--- a/converter/ppm/pjtoppm.c
+++ b/converter/ppm/pjtoppm.c
@@ -1,4 +1,4 @@
-/* pjtoppm.c - convert an HP PainJetXL image to a portable pixmap file
+/* pjtoppm.c - convert an HP PainJetXL image to a PPM
 **
 ** Copyright (C) 1990 by Christos Zoulas (christos@ee.cornell.edu)
 **
@@ -11,13 +11,12 @@
 */
 
 #include <stdbool.h>
+#include <assert.h>
 
 #include "ppm.h"
 #include "pm_c_util.h"
 #include "mallocvar.h"
 
-static char usage[] =  "[paintjetfile]";
-
 
 
 static unsigned int
@@ -46,44 +45,141 @@ egetc(FILE * const ifP) {
 
 
 
+static void
+modifyImageMode1(unsigned int     const rows,
+                 unsigned int     const planes,
+                 const int *      const imlen,
+                 unsigned char ** const image,
+                 unsigned int *   const colsP) {
+
+    unsigned int const newcols = 10240;
+    /* It could not be larger than that! */
+
+    unsigned int cols;
+    unsigned int row;
+
+    for (row = 0, cols = 0; row < rows; ++row) {
+        unsigned int plane;
+        if (image[row * planes]) {
+            for (plane = 0; plane < planes; ++plane) {
+                unsigned int i;
+                unsigned int col;
+                unsigned char * buf;
+
+                MALLOCARRAY(buf, newcols);
+                if (buf == NULL)
+                    pm_error("out of memory");
+                for (i = 0, col = 0;
+                     col < imlen[row * planes + plane];
+                     col += 2) {
+                    int cmd, val;
+                    for (cmd = image[row * planes + plane][col],
+                             val = image[plane + row * planes][col+1];
+                         cmd >= 0 && i < newcols; --cmd, ++i)
+                        buf[i] = val;
+                }
+                cols = MAX(cols, i);
+                free(image[row * planes + plane]);
+
+                /*
+                 * This is less than what we have so it realloc should
+                 * not return null. Even if it does, tough! We will
+                 * lose a line, and probably die on the next line anyway
+                 */
+                image[row * planes + plane] = realloc(buf, i);
+            }
+        }
+    }
+    *colsP = cols * 8;  assert(cols < UINT_MAX/8);
+}
+
+
+
+static void
+writePpm(FILE *           const ofP,
+         unsigned int     const cols,
+         unsigned int     const rows,
+         unsigned int     const planes,
+         unsigned char ** const image,
+         int              const mode,
+         const int *      const imlen) {
+
+    pixel * pixrow;
+    unsigned int row;
+
+    ppm_writeppminit(stdout, cols, rows, 255, 0);
+    pixrow = ppm_allocrow(cols);
+
+    for (row = 0; row < rows; ++row) {
+        if (image[row * planes + 0] == NULL) {
+            unsigned int col;
+            for (col = 0; col < cols; ++col)
+                PPM_ASSIGN(pixrow[col], 0, 0, 0);
+        } else {
+            unsigned int col;
+            unsigned int cmd;
+            for (cmd = 0, col = 0; col < cols; col += 8, ++cmd) {
+                unsigned int i;
+                for (i = 0; i < 8 && col + i < cols; ++i) {
+                    unsigned int plane;
+                    unsigned char bf[3];
+
+                    assert(planes == 3);
+
+                    for (plane = 0; plane < planes; ++plane) {
+                        if (mode == 0 && cmd >= imlen[row * planes + plane])
+                            bf[plane] = 0;
+                        else
+                            bf[plane] = (image[row * planes + plane][cmd] &
+                                     (1 << (7 - i))) ? 255 : 0;
+                    }
+                    PPM_ASSIGN(pixrow[col + i], bf[0], bf[1], bf[2]);
+                }
+            }
+            ppm_writeppmrow(stdout, pixrow, cols, 255, 0);
+        }
+    }
+}
+
+
+
 int
 main(int argc, const char ** argv) {
 
     int cmd, val;
     char buffer[BUFSIZ];
-    int planes = 3;
+    unsigned int planes;
     unsigned int rows;
     unsigned int rowsX;
     unsigned int cols;
     bool colsIsSet;
-    unsigned char **image = NULL;
-    int *imlen;
+    unsigned char ** image;  /* malloc'ed */
+    int * imlen;  /* malloc'ed */
     FILE * ifP;
     int mode;
     bool modeIsSet;
-    int argn;
-    unsigned char bf[3];
-    pixel * pixrow;
     int c;
-    int row;
-    int plane;
+    unsigned int plane;
+    unsigned int row;
 
     pm_proginit(&argc, argv);
 
-    argn = 1;
-    if (argn != argc)
-        ifP = pm_openr(argv[argn++]);
+    if (argc-1 > 0)
+        ifP = pm_openr(argv[1]);
     else
         ifP = stdin;
 
-    if (argn != argc)
-        pm_usage(usage);
+    if (argc-1 > 2)
+        pm_error("Too many arguments (%u).  Only possible argument is "
+                 "input file name", argc-1);
 
     row = 0;  /* initial value */
     plane = 0;  /* initial value */
     modeIsSet = false;  /* initial value */
     colsIsSet = false;  /* initial value */
     rowsX = 0;  /* initial value */
+    image = NULL;  /* initial value */
+    planes = 3;  /* initial value */
 
     while ((c = fgetc(ifP)) != -1) {
         if (c != '\033')
@@ -170,13 +266,8 @@ main(int argc, const char ** argv) {
                     if (row >= rowsX || image == NULL) {
                         if (row >= rowsX)
                             rowsX += 100;
-                        if (image == NULL) {
-                            MALLOCARRAY(image, uintProduct(rowsX, planes));
-                            MALLOCARRAY(imlen, uintProduct(rowsX, planes));
-                        } else {
-                            REALLOCARRAY(image, uintProduct(rowsX, planes));
-                            REALLOCARRAY(imlen, uintProduct(rowsX, planes));
-                        }
+                        REALLOCARRAY(image, uintProduct(rowsX, planes));
+                        REALLOCARRAY(imlen, uintProduct(rowsX, planes));
                     }
                     if (image == NULL || imlen == NULL)
                         pm_error("out of memory");
@@ -196,6 +287,9 @@ main(int argc, const char ** argv) {
                         ++plane;
                     else {
                         plane = 0;
+                        if (row > UINT_MAX/planes-100)
+                            pm_error("Too many rows (more than %u) "
+                                     "for computation", row);
                         ++row;
                     }
                     break;
@@ -241,72 +335,14 @@ main(int argc, const char ** argv) {
         pm_error("Input does not contain a 'bM' transmission mode order");
 
     rows = row;
-    if (mode == 1) {
-        unsigned int const newcols = 10240;
-            /* It could not be larger than that! */
 
-        unsigned char * buf;
-        unsigned int row;
+    if (mode == 1) {
+        modifyImageMode1(rows, planes, imlen, image, &cols);
 
-        for (row = 0, cols = 0; row < rows; ++row) {
-            unsigned int plane;
-            if (image[row * planes] == NULL)
-                continue;
-            for (plane = 0; plane < planes; ++plane) {
-                unsigned int i;
-                unsigned int col;
-                MALLOCARRAY(buf, newcols);
-                if (buf == NULL)
-                    pm_error("out of memory");
-                for (i = 0, col = 0;
-                     col < imlen[plane + row * planes];
-                     col += 2)
-                    for (cmd = image[plane + row * planes][col],
-                             val = image[plane + row * planes][col+1];
-                         cmd >= 0 && i < newcols; cmd--, i++)
-                        buf[i] = val;
-                cols = MAX(cols, i);
-                free(image[plane + row * planes]);
-                /*
-                 * This is less than what we have so it realloc should
-                 * not return null. Even if it does, tough! We will
-                 * lose a line, and probably die on the next line anyway
-                 */
-                image[plane + row * planes] = realloc(buf, i);
-            }
-        }
-        cols *= 8;
     }
 
-    ppm_writeppminit(stdout, cols, rows, (pixval) 255, 0);
-    pixrow = ppm_allocrow(cols);
+    writePpm(stdout, cols, rows, planes, image, mode, imlen);
 
-    for (row = 0; row < rows; ++row) {
-        if (image[row * planes] == NULL) {
-            unsigned int col;
-            for (col = 0; col < cols; ++col)
-                PPM_ASSIGN(pixrow[col], 0, 0, 0);
-            continue;
-        }
-        {
-            unsigned int col;
-            unsigned int cmd;
-            for (cmd = 0, col = 0; col < cols; col += 8, ++cmd) {
-                unsigned int i;
-                for (i = 0; i < 8 && col + i < cols; ++i) {
-                    unsigned int plane;
-                    for (plane = 0; plane < planes; ++plane)
-                        if (mode == 0 && cmd >= imlen[row * planes + plane])
-                            bf[plane] = 0;
-                        else
-                            bf[plane] = (image[row * planes + plane][cmd] &
-                                     (1 << (7 - i))) ? 255 : 0;
-                    PPM_ASSIGN(pixrow[col + i], bf[0], bf[1], bf[2]);
-                }
-            }
-        }
-        ppm_writeppmrow(stdout, pixrow, cols, 255, 0);
-    }
     pm_close(stdout);
 
     return 0;
diff --git a/converter/ppm/ppmtoeyuv.c b/converter/ppm/ppmtoeyuv.c
index f5ce1156..c4cedcdf 100644
--- a/converter/ppm/ppmtoeyuv.c
+++ b/converter/ppm/ppmtoeyuv.c
@@ -1,9 +1,9 @@
 /* Bryan got this from mm.ftp-cs.berkeley.edu from the package
-   mpeg-encode-1.5b-src under the name ppmtoeyuv.c on March 30, 2000.  
-   The file was dated January 19, 1995.  
+   mpeg-encode-1.5b-src under the name ppmtoeyuv.c on March 30, 2000.
+   The file was dated January 19, 1995.
 
    Bryan changed the program to take an argument as the input filename
-   and fixed a crash when the input image has an odd number of rows or 
+   and fixed a crash when the input image has an odd number of rows or
    columns.
 
    Then Bryan updated the program on March 15, 2001 to use the Netpbm
@@ -12,7 +12,7 @@
 
    There was no attached documentation except for this:  Encoder/Berkeley
    YUV format is merely the concatenation of Y, U, and V data in order.
-   Compare with Abekas YUV, which interlaces Y, U, and V data. 
+   Compare with Abekas YUV, which interlaces Y, U, and V data.
 
    Future enhancement: It may be useful to have an option to do the
    calculations without multiplication tables to save memory at the
@@ -43,7 +43,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/picasso/users/keving/encode/src/RCS/readframe.c,v 1.1 1993/07/22 22:23:43 keving Exp keving $
  *  $Log: readframe.c,v $
  * Revision 1.1  1993/07/22  22:23:43  keving
@@ -56,6 +56,7 @@
  * HEADER FILES *
  *==============*/
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
@@ -71,37 +72,37 @@ typedef	unsigned char uint8;
 
 #define YUVMAXVAL 255
 #define HALFYUVMAXVAL 128
-/* multXXX are multiplication tables used in RGB-YCC calculations for 
+/* multXXX are multiplication tables used in RGB-YCC calculations for
    speed.  mult299[x] is x * .299, scaled to a maxval of 255.  These
    are malloc'ed and essentially constant.
 
    We use these tables because it is much faster to do a
    multiplication once for each possible sample value than once for
-   each pixel in the image.  
+   each pixel in the image.
 */
 static float *mult299, *mult587, *mult114;
 static float *mult16874, *mult33126, *mult5;
 static float *mult41869, *mult08131;
 
 static __inline__ float
-luminance(const pixel p) {
+luminance(pixel const p) {
     return mult299[PPM_GETR(p)]
-        + mult587[PPM_GETG(p)] 
+        + mult587[PPM_GETG(p)]
         + mult114[PPM_GETB(p)]
         ;
 }
 
 static __inline__ float
-chrominance_red(const pixel p) {
-    return mult5[PPM_GETR(p)] 
+chrominanceRed(pixel const p) {
+    return mult5[PPM_GETR(p)]
         + mult41869[PPM_GETG(p)]
         + mult08131[PPM_GETB(p)]
         ;
 }
 
 static __inline__ float
-chrominance_blue(const pixel p) {
-    return mult16874[PPM_GETR(p)] 
+chrominanceBlue(pixel const p) {
+    return mult16874[PPM_GETR(p)]
         + mult33126[PPM_GETG(p)]
         + mult5[PPM_GETB(p)]
         ;
@@ -110,9 +111,7 @@ chrominance_blue(const pixel p) {
 
 
 static void
-create_multiplication_tables(const pixval maxval) {
-
-    int index;
+createMultiplicationTables(pixval const maxval) {
 
     MALLOCARRAY_NOFAIL(mult299   , maxval+1);
     MALLOCARRAY_NOFAIL(mult587   , maxval+1);
@@ -125,7 +124,9 @@ create_multiplication_tables(const pixval maxval) {
 
     if (maxval == YUVMAXVAL) {
         /* fast path */
-        for ( index = 0; index <= maxval; index++ ) {
+        unsigned int index;
+
+        for (index = 0; index <= maxval; ++index) {
             mult299[index]   =  0.29900*index;
             mult587[index]   =  0.58700*index;
             mult114[index]   =  0.11400*index;
@@ -136,7 +137,8 @@ create_multiplication_tables(const pixval maxval) {
             mult33126[index] = -0.33126*index;
         }
     } else {
-        for ( index = 0; index <= maxval; index++ ) {
+        unsigned int index;
+        for (index = 0; index <= maxval; ++index) {
             mult299[index]   =  0.29900*index*(maxval/YUVMAXVAL);
             mult587[index]   =  0.58700*index*(maxval/YUVMAXVAL);
             mult114[index]   =  0.11400*index*(maxval/YUVMAXVAL);
@@ -146,14 +148,13 @@ create_multiplication_tables(const pixval maxval) {
             mult16874[index] = -0.16874*index*(maxval/YUVMAXVAL);
             mult33126[index] = -0.33126*index*(maxval/YUVMAXVAL);
         }
-        
     }
 }
 
 
 
 static void
-free_multiplication_tables(void) {
+freeMultiplicationTables(void) {
     free(mult299   );
     free(mult587   );
     free(mult114   );
@@ -180,21 +181,23 @@ free_multiplication_tables(void) {
  * This function processes the input file in 4 pixel squares.  If the
  * Image does not have an even number of rows and columns, the rightmost
  * column or the bottom row gets ignored and output has one fewer row
- * or column than the input. 
+ * or column than the input.
  *
  *===========================================================================*/
-static void 
-PPMtoYUV(pixel ** const ppm_image, const int width, const int height,
-         uint8 *** const orig_yP, 
-         uint8 *** const orig_crP, 
-         uint8 *** const orig_cbP) {
+static void
+ppmToYuv(pixel **     const ppmImage,
+         unsigned int const width,
+         unsigned int const height,
+         uint8 ***    const orig_yP,
+         uint8 ***    const orig_crP,
+         uint8 ***    const orig_cbP) {
 
     int y;
     uint8 ** orig_y;
     uint8 ** orig_cr;
     uint8 ** orig_cb;
 
-    orig_y = *orig_yP;
+    orig_y  = *orig_yP;
     orig_cr = *orig_crP;
     orig_cb = *orig_cbP;
 
@@ -204,17 +207,17 @@ PPMtoYUV(pixel ** const ppm_image, const int width, const int height,
         const pixel *src0, *src1;
           /* Pair of contiguous rows of the ppm input image we are
              converting */
-        int x;
+        unsigned int x;
 
-        src0 = ppm_image[y];
-        src1 = ppm_image[y + 1];
+        src0 = ppmImage[y];
+        src1 = ppmImage[y + 1];
 
         dy0 = orig_y[y];
         dy1 = orig_y[y + 1];
         dcr = orig_cr[y / 2];
         dcb = orig_cb[y / 2];
 
-        for ( x = 0; x + 1 < width; x += 2) {
+        for (x = 0; x + 1 < width; x += 2) {
             dy0[x] = luminance(src0[x]);
             dy1[x] = luminance(src1[x]);
 
@@ -222,17 +225,17 @@ PPMtoYUV(pixel ** const ppm_image, const int width, const int height,
             dy1[x+1] = luminance(src1[x+1]);
 
             dcr[x/2] = ((
-                chrominance_red(src0[x]) +
-                chrominance_red(src1[x]) +
-                chrominance_red(src0[x+1]) +
-                chrominance_red(src1[x+1]) 
+                chrominanceRed(src0[x]) +
+                chrominanceRed(src1[x]) +
+                chrominanceRed(src0[x+1]) +
+                chrominanceRed(src1[x+1])
                 ) / 4) + HALFYUVMAXVAL;
 
             dcb[x/2] = ((
-                chrominance_blue(src0[x]) +
-                chrominance_blue(src1[x]) +
-                chrominance_blue(src0[x+1]) +
-                chrominance_blue(src1[x+1]) 
+                chrominanceBlue(src0[x]) +
+                chrominanceBlue(src1[x]) +
+                chrominanceBlue(src0[x+1]) +
+                chrominanceBlue(src1[x+1])
                 ) / 4) + HALFYUVMAXVAL;
         }
     }
@@ -240,74 +243,81 @@ PPMtoYUV(pixel ** const ppm_image, const int width, const int height,
 
 
 
-static void 
-WriteYUV(FILE *fpointer, const int width, const int height,
-         uint8 ** const orig_y, uint8 ** const orig_cr, uint8 ** const orig_cb)
-{
-    register int y;
+static void
+writeYUV(FILE *       const ofP,
+         unsigned int const width,
+         unsigned int const height,
+         uint8 **     const orig_y,
+         uint8 **     const orig_cr,
+         uint8 **     const orig_cb) {
+
+    unsigned int y;
 
-    for (y = 0; y < height; y++)                        /* Y */
-        fwrite(orig_y[y], 1, width, fpointer);
+    for (y = 0; y < height; ++y)                        /* Y */
+        fwrite(orig_y[y], 1, width, ofP);
 
-    for (y = 0; y < height / 2; y++)                    /* U */
-        fwrite(orig_cb[y], 1, width / 2, fpointer);
+    for (y = 0; y < height / 2; ++y)                    /* U */
+        fwrite(orig_cb[y], 1, width / 2, ofP);
 
-    for (y = 0; y < height / 2; y++)                    /* V */
-        fwrite(orig_cr[y], 1, width / 2, fpointer);
+    for (y = 0; y < height / 2; ++y)                    /* V */
+        fwrite(orig_cr[y], 1, width / 2, ofP);
 }
 
 
 
 static void
-AllocYUV(int       const width, 
+allocYUV(int       const width,
          int       const height,
-         uint8 *** const orig_yP, 
+         uint8 *** const orig_yP,
          uint8 *** const orig_crP,
          uint8 *** const orig_cbP) {
 
-    int y;
+    unsigned int y;
     uint8 ** orig_y;
     uint8 ** orig_cr;
     uint8 ** orig_cb;
 
     MALLOCARRAY_NOFAIL(*orig_yP, height);
     orig_y = *orig_yP;
-    for (y = 0; y < height; y++) 
+    for (y = 0; y < height; ++y)
         MALLOCARRAY_NOFAIL(orig_y[y], width);
 
     MALLOCARRAY_NOFAIL(*orig_crP, height / 2);
     orig_cr = *orig_crP;
-    for (y = 0; y < height / 2; y++) 
+    for (y = 0; y < height / 2; ++y)
         MALLOCARRAY_NOFAIL(orig_cr[y], width / 2);
 
     MALLOCARRAY_NOFAIL(*orig_cbP, height / 2);
     orig_cb = *orig_cbP;
-    for (y = 0; y < height / 2; y++) 
+    for (y = 0; y < height / 2; ++y)
         MALLOCARRAY_NOFAIL(orig_cb[y], width / 2);
 }
 
 
 
 static void
-FreeYUV(const int width, const int height,
-        uint8 ** const orig_y, uint8 ** const orig_cr, uint8 ** const orig_cb){
+freeYUV(unsigned int const width,
+        unsigned int const height,
+        uint8 **     const orig_y,
+        uint8 **     const orig_cr,
+        uint8 **     const orig_cb){
 
-    int y;
+    unsigned int y;
 
     if (orig_y) {
-       for (y = 0; y < height; y++)
+       for (y = 0; y < height; ++y)
            free(orig_y[y]);
        free(orig_y);
     }
 
     if (orig_cr) {
-       for (y = 0; y < height / 2; y++)
+       for (y = 0; y < height / 2; ++y)
            free(orig_cr[y]);
        free(orig_cr);
     }
 
     if (orig_cb) {
-       for (y = 0; y < height / 2; y++)
+       for (y = 0; y < height / 2; ++y)
            free(orig_cb[y]);
        free(orig_cb);
     }
@@ -316,81 +326,84 @@ FreeYUV(const int width, const int height,
 
 
 int
-main(int argc, char **argv) {
-    const char *input_filename;  /* NULL for stdin */
-    FILE * ifp;
+main(int argc, const char **argv) {
+
+    const char *inputFilename;  /* NULL for stdin */
+    FILE * ifP;
     int width, height;
     pixval maxval;
-    pixel **ppm_image;   /* malloc'ed */
+    pixel ** ppmImage;   /* malloc'ed */
     uint8 **orig_y, **orig_cr, **orig_cb;
-        /* orig_y is the height x width array of individual pixel luminances 
+        /* orig_y is the height x width array of individual pixel luminances
            orig_cr and orig_cb are the height/2 x width/2 arrays of average
            red and blue chrominance values over each 4 pixel square.
         */
     int eof;
 
-    /* The following are width, height, and maxval of the image we 
-       processed before this one.  Zero if there was no image before 
+    /* The following are width, height, and maxval of the image we
+       processed before this one.  Zero if there was no image before
        this one.
     */
-    int last_width, last_height;
-    pixval last_maxval;
+    int lastWidth, lastHeight;
+    pixval lastMaxval;
 
-    ppm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
-    if (argc > 2) {
+    if (argc-1 > 1) {
         pm_error("Program takes either one argument -- "
                 "the input filename -- or no arguments (input is stdin)");
         exit(1);
-    } else if (argc == 2)
-        input_filename = argv[1];
-    else input_filename = NULL;
+    } else if (argc-1 > 0)
+        inputFilename = argv[1];
+    else
+        inputFilename = "-";
 
-    if (input_filename == NULL) ifp = stdin;
-    else ifp = pm_openr(input_filename);
+    ifP = pm_openr(inputFilename);
 
-    eof = FALSE;
-    last_maxval = 0;  /* No previous maxval */
-    last_width = 0;	/* No previous width */
-    last_height = 0;	/* No previous height */
+    eof = false;  /* EOF not yet encountered */
+    lastMaxval = 0;  /* No previous maxval */
+    lastWidth = 0;	/* No previous width */
+    lastHeight = 0;	/* No previous height */
     orig_y = orig_cr = orig_cb = 0;
 
     while (!eof) {
-        ppm_image = ppm_readppm(ifp, &width, &height, &maxval);
+        ppmImage = ppm_readppm(ifP, &width, &height, &maxval);
 
-        if (width % 2 != 0) 
+        if (width % 2 != 0)
             pm_message("Input image has odd number of columns.  The rightmost "
                        "column will be omitted from the output.");
-        if (height % 2 != 0) 
+        if (height % 2 != 0)
             pm_message("Input image has odd number of rows.  The bottom "
                        "row will be omitted from the output.");
 
-        if (maxval != last_maxval) {
+        if (maxval != lastMaxval) {
             /* We're going to need all new multiplication tables. */
-            free_multiplication_tables();
-            create_multiplication_tables(maxval);
+            freeMultiplicationTables();
+            createMultiplicationTables(maxval);
         }
-        last_maxval = maxval;
-        
-        if (height != last_height || width != last_width) {
-            FreeYUV(width, height, orig_y, orig_cr, orig_cb);
+        lastMaxval = maxval;
+
+        if (height != lastHeight || width != lastWidth) {
+            freeYUV(width, height, orig_y, orig_cr, orig_cb);
             /* Need new YUV buffers for different size */
-            AllocYUV(width, height, &orig_y, &orig_cr, &orig_cb);
+            allocYUV(width, height, &orig_y, &orig_cr, &orig_cb);
         }
-        last_height = height;
-        last_width = width;
+        lastHeight = height;
+        lastWidth  = width;
 
-        PPMtoYUV(ppm_image, width, height, &orig_y, &orig_cr, &orig_cb);
+        ppmToYuv(ppmImage, width, height, &orig_y, &orig_cr, &orig_cb);
 
-        WriteYUV(stdout, (width/2)*2, (height/2)*2, orig_y, orig_cr, orig_cb);
+        writeYUV(stdout, (width/2)*2, (height/2)*2, orig_y, orig_cr, orig_cb);
 
-        ppm_freearray(ppm_image, height);
-        ppm_nextimage(ifp, &eof);
+        ppm_freearray(ppmImage, height);
+        ppm_nextimage(ifP, &eof);
     }
-    FreeYUV(width, height, orig_y, orig_cr, orig_cb);
-    free_multiplication_tables();
-    pm_close(ifp);
-        
+    freeYUV(width, height, orig_y, orig_cr, orig_cb);
+    freeMultiplicationTables();
+    pm_close(ifP);
+
     return 0;
 }
 
+
+
diff --git a/converter/ppm/ppmtogif.c b/converter/ppm/ppmtogif.c
index 8dd133b5..0564b7b4 100644
--- a/converter/ppm/ppmtogif.c
+++ b/converter/ppm/ppmtogif.c
@@ -46,19 +46,19 @@ dirname(const char * const fileName) {
 
 
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char *inputFileName;  /* Name of input file */
-    const char *alpha_filespec; /* Filespec of alpha file; NULL if none */
-    const char *alphacolor;     /* -alphacolor option value or default */
-    unsigned int interlace;     /* -interlace option value */
-    unsigned int sort;          /* -sort option value */
-    const char *mapfile;        /* -mapfile option value.  NULL if none. */
-    const char *transparent;    /* -transparent option value.  NULL if none. */
-    const char *comment;        /* -comment option value; NULL if none */
-    unsigned int nolzw;         /* -nolzw option */
+    const char * inputFileName;  /* Name of input file */
+    const char * alpha_filespec; /* Filespec of alpha file; NULL if none */
+    const char * alphacolor;     /* -alphacolor option value or default */
+    unsigned int interlace;      /* -interlace option value */
+    unsigned int sort;           /* -sort option value */
+    const char * mapfile;        /* -mapfile option value.  NULL if none. */
+    const char * transparent;    /* -transparent option value.  NULL if none.*/
+    const char * comment;        /* -comment option value; NULL if none */
+    unsigned int nolzw;          /* -nolzw option */
     unsigned int verbose;
 };
 
@@ -78,8 +78,8 @@ handleLatex2htmlHack(void) {
 
   So we issue a special error message just to trick latex2html into
   deciding that we have -interlace and -transparent options.  The function
-  is not documented in the man page.  We would like to see Latex2html 
-  either stop checking or check like configure programs usually do -- 
+  is not documented in the man page.  We would like to see Latex2html
+  either stop checking or check like configure programs usually do --
   try the option and see if you get success or failure.
 
   -Bryan 2001.11.14
@@ -93,7 +93,7 @@ handleLatex2htmlHack(void) {
 
 static void
 parseCommandLine(int argc, const char ** argv,
-                 struct cmdlineInfo * const cmdlineP) {
+                 struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    Parse the program arguments (given by argc and argv) into a form
    the program can deal with more easily -- a cmdline_info structure.
@@ -112,33 +112,33 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0,   "interlace",   OPT_FLAG,   
+    OPTENT3(0,   "interlace",   OPT_FLAG,
             NULL,                       &cmdlineP->interlace, 0);
-    OPTENT3(0,   "sort",        OPT_FLAG,   
+    OPTENT3(0,   "sort",        OPT_FLAG,
             NULL,                       &cmdlineP->sort, 0);
-    OPTENT3(0,   "nolzw",       OPT_FLAG,   
+    OPTENT3(0,   "nolzw",       OPT_FLAG,
             NULL,                       &cmdlineP->nolzw, 0);
-    OPTENT3(0,   "mapfile",     OPT_STRING, 
+    OPTENT3(0,   "mapfile",     OPT_STRING,
             &cmdlineP->mapfile,        NULL, 0);
-    OPTENT3(0,   "transparent", OPT_STRING, 
+    OPTENT3(0,   "transparent", OPT_STRING,
             &cmdlineP->transparent,    NULL, 0);
-    OPTENT3(0,   "comment",     OPT_STRING, 
+    OPTENT3(0,   "comment",     OPT_STRING,
             &cmdlineP->comment,        NULL, 0);
-    OPTENT3(0,   "alpha",       OPT_STRING, 
+    OPTENT3(0,   "alpha",       OPT_STRING,
             &cmdlineP->alpha_filespec, NULL, 0);
-    OPTENT3(0,   "alphacolor",  OPT_STRING, 
+    OPTENT3(0,   "alphacolor",  OPT_STRING,
             &cmdlineP->alphacolor,     NULL, 0);
-    OPTENT3(0,   "h",           OPT_FLAG, 
+    OPTENT3(0,   "h",           OPT_FLAG,
             NULL,                       &latex2htmlhack, 0);
-    OPTENT3(0,   "verbose",     OPT_FLAG, 
+    OPTENT3(0,   "verbose",     OPT_FLAG,
             NULL,                       &cmdlineP->verbose, 0);
-    
+
     /* Set the defaults */
     cmdlineP->mapfile = NULL;
     cmdlineP->transparent = NULL;  /* no transparency */
     cmdlineP->comment = NULL;      /* no comment */
     cmdlineP->alpha_filespec = NULL;      /* no alpha file */
-    cmdlineP->alphacolor = "rgb:0/0/0";      
+    cmdlineP->alphacolor = "rgb:0/0/0";
         /* We could say "black" here, but then we depend on the color names
            database existing.
         */
@@ -150,10 +150,10 @@ parseCommandLine(int argc, const char ** argv,
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
-    if (latex2htmlhack) 
+    if (latex2htmlhack)
         handleLatex2htmlHack();
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFileName = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -206,7 +206,7 @@ openPnmremapStream(const char * const inputFileName,
 
 static const char *
 pamtogifCommand(const char *       const arg0,
-                struct cmdlineInfo const cmdline) {
+                struct CmdlineInfo const cmdline) {
 
     const char * const pamtogifName = "pamtogif";
 
@@ -252,7 +252,7 @@ pamtogifCommand(const char *       const arg0,
                 commentOpt,
                 cmdline.nolzw ? "-nolzw" : "",
                 cmdline.verbose ? "-verbose" : "");
-    
+
     pm_strfree(transparentOpt);
     pm_strfree(commentOpt);
 
@@ -264,7 +264,7 @@ pamtogifCommand(const char *       const arg0,
 static void
 feedPamtogifNoAlpha(struct pam * const inPamP,
                     FILE *       const pipeToPamtogif) {
-    
+
     unsigned int row;
     struct pam outPam;
     tuple * tuplerow;
@@ -273,7 +273,7 @@ feedPamtogifNoAlpha(struct pam * const inPamP,
 
     outPam = *inPamP;
     outPam.file = pipeToPamtogif;
-    
+
     pnm_writepaminit(&outPam);
 
     for (row = 0; row < inPamP->height; ++row) {
@@ -303,7 +303,7 @@ copyRasterWithAlpha(struct pam * const inPamP,
 
     for (row = 0; row < inPamP->height; ++row) {
         unsigned int col;
-            
+
         pnm_readpamrow(inPamP, tuplerow);
         pnm_readpamrow(alphaPamP, alpharow);
 
@@ -360,7 +360,7 @@ static void
 feedPamtogif(struct pam * const inPamP,
              const char * const alphaFilespec,
              FILE *       const pipeToPamtogif) {
-    
+
     if (alphaFilespec) {
         FILE * afP;
         struct pam alphaPam;
@@ -378,7 +378,7 @@ int
 main(int           argc,
      const char ** argv) {
 
-    struct cmdlineInfo cmdline;
+    struct CmdlineInfo cmdline;
     FILE * ifP;
     struct pam inPam;
     const char * command;
@@ -394,12 +394,12 @@ main(int           argc,
                            cmdline.verbose, &ifP);
     else
         ifP = pm_openr(cmdline.inputFileName);
-        
+
     command = pamtogifCommand(argv[0], cmdline);
 
     if (cmdline.verbose)
         pm_message("Executing shell command '%s'", command);
-    
+
     pipeToPamtogif = popen(command, "w");
 
     if (pipeToPamtogif == NULL)
@@ -421,3 +421,6 @@ main(int           argc,
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtoilbm.c b/converter/ppm/ppmtoilbm.c
index ad07f9fb..f9672733 100644
--- a/converter/ppm/ppmtoilbm.c
+++ b/converter/ppm/ppmtoilbm.c
@@ -483,7 +483,7 @@ encodeRow(FILE *    const outfile,
     int plane, bytes;
     long retbytes = 0;
 
-    bytes = RowBytes(cols);
+    bytes = ilbm_rowByteCt(cols);
 
     /* Encode and write raw bytes in plane-interleaved form. */
     for( plane = 0; plane < nPlanes; plane++ ) {
@@ -1145,7 +1145,7 @@ ppmToHam(FILE *  const ifP,
     nPlanes = hamplanes;
     cmapsize = colors * 3;
 
-    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * RowBytes(cols);
+    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * ilbm_rowByteCt(cols);
     if( DO_COMPRESS ) {
         bodysize = doHamBody(ifP, NULL, cols, rows, maxval,
                                hammaxval, nPlanes, colormap, colors);
@@ -1276,7 +1276,7 @@ ppmToDeep(FILE * const ifP,
 
     nPlanes = 3*bitspercolor;
 
-    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * RowBytes(cols);
+    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * ilbm_rowByteCt(cols);
     if( DO_COMPRESS ) {
         bodysize = doDeepBody(ifP, NULL, cols, rows, maxval, bitspercolor);
         if( bodysize > oldsize )
@@ -1389,7 +1389,7 @@ ppmToDcol(FILE *        const ifP,
 
     nPlanes = dcol->r + dcol->g + dcol->b;
 
-    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * RowBytes(cols);
+    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * ilbm_rowByteCt(cols);
     if( DO_COMPRESS ) {
         bodysize = doDcolBody(ifP, NULL, cols, rows, maxval, dcol);
         if( bodysize > oldsize )
@@ -1563,7 +1563,7 @@ ppmToStd(FILE *  const ifP,
     if( sortcmap )
         ppm_sortcolorrow(colormap, colors, PPM_STDSORT);
 
-    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * RowBytes(cols);
+    bodysize = oldsize = rows * TOTALPLANES(nPlanes) * ilbm_rowByteCt(cols);
     if( DO_COMPRESS ) {
         bodysize = doStdBody(ifP, NULL, cols, rows, maxval, colormap,
                              colors, nPlanes);
@@ -2274,11 +2274,13 @@ main(int argc, char ** argv) {
 
     if (mode != MODE_CMAP) {
         unsigned int i;
-        MALLOCARRAY_NOFAIL(coded_rowbuf, RowBytes(cols));
-        for (i = 0; i < RowBytes(cols); ++i)
+        MALLOCARRAY_NOFAIL(coded_rowbuf, ilbm_rowByteCt(cols));
+        for (i = 0; i < ilbm_rowByteCt(cols); ++i)
             coded_rowbuf[i] = 0;
         if (DO_COMPRESS)
-            pm_rlenc_allocoutbuf(&compr_rowbuf, RowBytes(cols), PM_RLE_PACKBITS);
+            pm_rlenc_allocoutbuf(&compr_rowbuf,
+                                 ilbm_rowByteCt(cols),
+                                 PM_RLE_PACKBITS);
     }
 
     switch (mode) {
diff --git a/converter/ppm/ppmtolj.c b/converter/ppm/ppmtolj.c
index 7ed814ed..e2e03ac5 100644
--- a/converter/ppm/ppmtolj.c
+++ b/converter/ppm/ppmtolj.c
@@ -10,13 +10,12 @@
 ** implied warranty.
 */
 
+#include <stdbool.h>
+#include <limits.h>
 #include <string.h>
 
 #include "ppm.h"
 
-static int compress_row_delta (unsigned char *op, unsigned char *prev_op, 
-                               unsigned char *cp, int bufsize);
-
 #define C_RESET                 "\033E"
 #define C_PRESENTATION          "\033*r%dF"
 #define C_PRESENTATION_LOGICAL  0
@@ -44,103 +43,269 @@ static int compress_row_delta (unsigned char *op, unsigned char *prev_op,
 #define C_Y_OFFSET              "\033*b%dY"
 
 
+
+static void
+printHeader(FILE *       const ofP,
+            int          const resets,
+            bool         const floating,
+            int          const resolution,
+            unsigned int const rows,
+            unsigned int const cols,
+            int          const mode,
+            int          const gamma) {
+
+    char const CID[6] =  { 0, 3, 0, 8, 8, 8 };
+        /*data for the configure image data command*/
+
+    if (resets & 0x1) {
+        /* Printer reset. */
+        fprintf(ofP, C_RESET);
+    }
+
+    if (!floating) {
+        /* Ensure top margin is zero */
+        fprintf(ofP, "\033&l0E");
+    }
+
+    /*Set Presentation mode*/
+    fprintf(ofP, C_PRESENTATION, C_PRESENTATION_PHYSICAL);
+    /* Set the resolution */
+    fprintf(ofP, C_RESOLUTION, resolution);
+    /* Set raster height*/
+    fprintf(ofP, C_IMAGE_HEIGHT, rows);
+    /* Set raster width*/
+    fprintf(ofP, C_IMAGE_WIDTH, cols);
+    /* set left margin to current x pos*/
+    /*(void) fprintf(ofP, C_LEFT_MARGIN, 1);*/
+    /* set the correct color mode */
+    fprintf(ofP, C_CONFIG_IMAGE_DATA);
+    fwrite(CID, 1, 6, ofP);
+    /* Start raster graphics */
+    fprintf(ofP, C_BEGIN_RASTER, C_BEGIN_RASTER_CUR);  /*posscale);*/
+    /* set Y offset to 0 */
+    fprintf(ofP, C_Y_OFFSET, 0);
 /*
- * delta encoding. 
- */
-/*
-op row buffer
-prev_op     previous row buffer
-bufsize     length of row
-cp          buffer for compressed data
+    if (xoff)
+        fprintf(ofP, C_MOVE_X, xoff);
+    if (yoff)
+        fprintf(ofP, C_MOVE_Y, yoff);
 */
+    /* Set raster compression */
+    fprintf(ofP, C_TRANS_MODE, mode);
+
+    if (gamma)
+        fprintf(ofP, C_GAMMA,   gamma);
+}
+
+
+
 static int
-compress_row_delta(op, prev_op, cp, bufsize)
-unsigned char *op, *prev_op, *cp;
-int bufsize;
-{
-    int burstStart, burstEnd, burstCode, mustBurst, ptr, skip, skipped, code;
-    int deltaBufferIndex = 0;
-    if (memcmp(op, prev_op , bufsize/*rowBufferIndex*/) == 0) 
+compressRowDelta(unsigned char * const op,
+                 unsigned char * const prevOp,
+                 unsigned char * const cp,
+                 unsigned int    const bufsize) {
+/*----------------------------------------------------------------------------
+
+  delta encoding.
+
+
+  op:      row buffer
+  prevOp:  previous row buffer
+  bufsize: length of row
+  cp:       buffer for compressed data
+-----------------------------------------------------------------------------*/
+    int burstStart, burstEnd, burstCode, ptr, skipped, code;
+    bool mustBurst;
+    int deltaBufferIndex;
+
+    if (memcmp(op, prevOp , bufsize/*rowBufferIndex*/) == 0)
         return 0; /* exact match, no deltas required */
 
-    ptr = 0;
-    skipped = 0;
-    burstStart = -1;
-    burstEnd = -1;
-    mustBurst = 0;
-    while (ptr < bufsize/*rowBufferIndex*/) 
-    {
-        skip = 0;
-        if (ptr == 0 || skipped == 30 || op[ptr] != prev_op[ptr] ||
-            (burstStart != -1 && ptr == bufsize - 1)) 
-        {
+    deltaBufferIndex = 0;  /* initial value */
+    ptr = 0;               /* initial value */
+    skipped = 0;           /* initial value */
+    burstStart = -1;       /* initial value */
+    burstEnd = -1;         /* initial value */
+    mustBurst = false;     /* initial value */
+
+    while (ptr < bufsize/*rowBufferIndex*/) {
+        bool mustSkip;
+
+        mustSkip = false;  /* initial assumption */
+
+        if (ptr == 0 || skipped == 30 || op[ptr] != prevOp[ptr] ||
+            (burstStart != -1 && ptr == bufsize - 1)) {
             /* we want to output this byte... */
-            if (burstStart == -1) 
-            {
+            if (burstStart == -1) {
                 burstStart = ptr;
             }
-            if (ptr - burstStart == 7 || ptr == bufsize - 1) 
-            {
+            if (ptr - burstStart == 7 || ptr == bufsize - 1) {
                 /* we have to output it now... */
                 burstEnd = ptr;
-                mustBurst = 1;
+                mustBurst = true;
             }
-        } 
-        else 
-        {
+        } else {
             /* duplicate byte, we can skip it */
-            if (burstStart != -1) 
+            if (burstStart != -1)
             {
                 burstEnd = ptr - 1;
-                mustBurst = 1;
+                mustBurst = true;
             }
-            skip = 1;
+            mustSkip = true;
         }
-        if (mustBurst) 
-        {
+        if (mustBurst) {
             burstCode = burstEnd - burstStart; /* 0-7 means 1-8 bytes follow */
             code = (burstCode << 5) | skipped;
             cp[deltaBufferIndex++] = (char) code;
-            memcpy(cp+deltaBufferIndex, op+burstStart, burstCode + 1);
+            memcpy(cp + deltaBufferIndex, op + burstStart, burstCode + 1);
             deltaBufferIndex += burstCode + 1;
             burstStart = -1;
             burstEnd = -1;
-            mustBurst = 0;
+            mustBurst = false;
             skipped = 0;
         }
-        if (skip) 
-        {
-            skipped ++;
-        }
-        ptr ++;
+        if (mustSkip)
+            ++skipped;
+        ++ptr;
     }
     return deltaBufferIndex;
 }
 
 
-int main(int argc, char *argv[]) {
+
+static void
+printTrailer(FILE * const ofP,
+             int    const resets) {
+
+    fprintf(ofP, C_END_RASTER, C_END_RASTER_UNUSED);
+
+    if (resets & 0x2) {
+        /* Printer reset. */
+        fprintf(ofP, C_RESET);
+    }
+}
+
+
+
+static void
+printRaster(FILE *       const ifP,
+            unsigned int const rows,
+            unsigned int const cols,
+            int          const maxval,
+            int          const format,
+            int          const mode,
+            FILE *       const ofP) {
+
+    unsigned char * obuf; /* malloc'ed */
+    unsigned char * cbuf; /* malloc'ed */
+    unsigned char * previousObuf;  /* malloc'ed */
+    unsigned int uncompOutRowSz;
+    unsigned int outRowSz;
+    int currentmode;
     pixel * pixelrow;
-    FILE *ifp;
-    int argn, rows, cols, r, c, k;
-    pixval maxval;
-    unsigned char *obuf, *op, *cbuf, *previous_obuf;
-    int format;
-    int gamma = 0;
-    int mode = C_TRANS_MODE_STD;
-    int currentmode = 0;
-    int floating = 0;  /* suppress the ``ESC & l 0 E'' ? */
-    int resets = 3;    /* bit mask for when to emit printer reset seq */
+    unsigned int row;
 
-    int resolution = C_RESOLUTION_300DPI;
+    pixelrow = ppm_allocrow(cols);
 
-    char CID[6] =  { 0, 3, 0, 8, 8, 8 }; 
-        /*data for the configure image data command*/
+    if (cols > UINT_MAX/6) {
+        /* We may need a row buffer of up to cols * 6 bytes for compression */
+        pm_error("Image is uncomputably wide (%u columns)", cols);
+    }
+
+    obuf = (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char));
+    cbuf = (unsigned char *) pm_allocrow(cols * 6, sizeof(unsigned char));
+
+    if (mode == C_TRANS_MODE_DELTA) {
+        previousObuf =
+            (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char));
+        memset(previousObuf, 0, cols * 3);
+    } else
+        previousObuf = NULL;
+
+    currentmode = mode;  /* initial value */
+
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
+        const unsigned char * op;
+
+        ppm_readppmrow(ifP, pixelrow, cols, maxval, format);
+
+        /* get a row of data with 3 bytes per pixel */
+        for (col = 0; col < cols; ++col) {
+            obuf[3*col + 0] = (PPM_GETR(pixelrow[col])*255)/maxval;
+            obuf[3*col + 1] = (PPM_GETG(pixelrow[col])*255)/maxval;
+            obuf[3*col + 2] = (PPM_GETB(pixelrow[col])*255)/maxval;
+        }
+        uncompOutRowSz = 3 * cols;
+
+        /*compress the row if required*/
+        switch (mode) {
+        case C_TRANS_MODE_STD: /*no compression*/
+            op = obuf;
+            outRowSz = uncompOutRowSz;
+            break;
+        case C_TRANS_MODE_DELTA: {   /*delta compression*/
+            int const deltasize =
+                compressRowDelta(obuf, previousObuf, cbuf, uncompOutRowSz);
+
+            int newmode;
+
+            newmode = 0;  /* initial value */
+
+            if (deltasize >= uncompOutRowSz) {
+                /*normal is best?*/
+                op = obuf;
+                outRowSz = uncompOutRowSz;
+            } else {
+                /*delta is best*/
+                op = cbuf;
+                outRowSz = deltasize;
+                newmode = C_TRANS_MODE_DELTA;
+            }
+            memcpy(previousObuf, obuf, cols*3);
+
+            if (currentmode != newmode) {
+                fprintf(ofP, C_TRANS_MODE, newmode);
+                currentmode = newmode;
+            }
+        }
+        }
+        fprintf(ofP, C_SEND_ROW, outRowSz);
+        fwrite(op, 1, outRowSz, ofP);
+    }
+    free(cbuf);
+    free(obuf);
+    if (previousObuf)
+        free(previousObuf);
+    ppm_freerow(pixelrow);
+}
+
+
+
+int
+main(int argc, const char **argv) {
+    FILE * ifP;
+    int argn, rows, cols;
+    pixval maxval;
+    int format;
+    int gamma;
+    int mode;
+    bool floating;
+        /* suppress the ``ESC & l 0 E'' ? */
+    int resets;
+        /* bit mask for when to emit printer reset seq */
+    int resolution;
 
     const char * const usage = "[-noreset][-float][-delta][-gamma <val>] [-resolution N] "
         "[ppmfile]\n\tresolution = [75|100|150|300|600] (dpi)";
 
-    ppm_init( &argc, argv );
+    pm_proginit(&argc, argv);
 
+    gamma = 0; /* initial value */
+    mode = C_TRANS_MODE_STD;  /* initial value */
+    resolution = C_RESOLUTION_300DPI;  /* initial value */
+    floating = false;  /* initial value */
+    resets = 0x3;  /* initial value */
     argn = 1;
     while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
     {
@@ -159,9 +324,9 @@ int main(int argc, char *argv[]) {
         else if (pm_keymatch(argv[argn],"-delta",2))
             mode = C_TRANS_MODE_DELTA;
         else if (pm_keymatch(argv[argn],"-float",2))
-            floating = 1;
+            floating = true;
         else if (pm_keymatch(argv[argn],"-noreset",2))
-            resets = 0;
+            resets = 0x0;
 
         else
             pm_usage( usage );
@@ -170,128 +335,28 @@ int main(int argc, char *argv[]) {
 
     if ( argn < argc )
     {
-        ifp = pm_openr( argv[argn] );
+        ifP = pm_openr( argv[argn] );
         ++argn;
     }
     else
-        ifp = stdin;
+        ifP = stdin;
 
     if ( argn != argc )
         pm_usage( usage );
 
-    ppm_readppminit( ifp, &cols, &rows, &maxval, &format );
-    pixelrow = ppm_allocrow( cols );
+    ppm_readppminit(ifP, &cols, &rows, &maxval, &format);
 
-    obuf = (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char));
-    cbuf = (unsigned char *) pm_allocrow(cols * 6, sizeof(unsigned char));
-    if (mode == C_TRANS_MODE_DELTA)
-    {
-        previous_obuf = 
-            (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char));
-        memset(previous_obuf, 0, cols * 3);
-    }
+    printHeader(stdout, resets, floating, resolution, rows, cols,
+                mode, gamma);
 
-    if(resets & 1)
-    {
-        /* Printer reset. */
-        printf(C_RESET);
-    }
+    printRaster(ifP, rows, cols, maxval, format, mode, stdout);
 
-    if(!floating)
-    {
-        /* Ensure top margin is zero */
-        printf("\033&l0E");
-    }
+    printTrailer(stdout, resets);
 
-    /*Set Presentation mode*/
-    (void) printf(C_PRESENTATION, C_PRESENTATION_PHYSICAL);
-    /* Set the resolution */
-    (void) printf(C_RESOLUTION, resolution);
-    /* Set raster height*/
-    (void) printf(C_IMAGE_HEIGHT, rows);
-    /* Set raster width*/
-    (void) printf(C_IMAGE_WIDTH, cols);
-    /* set left margin to current x pos*/
-    /*(void) printf(C_LEFT_MARGIN, 1);*/
-    /* set the correct color mode */
-    (void) printf(C_CONFIG_IMAGE_DATA);
-    (void) fwrite(CID, 1, 6, stdout);
-    /* Start raster graphics */
-    (void) printf(C_BEGIN_RASTER, C_BEGIN_RASTER_CUR);  /*posscale);*/
-    /* set Y offset to 0 */
-    (void) printf(C_Y_OFFSET, 0);
-/*  
-    if (xoff)
-        (void) printf(C_MOVE_X, xoff);
-    if (yoff)
-        (void) printf(C_MOVE_Y, yoff);
-*/
-    /* Set raster compression */
-    (void) printf(C_TRANS_MODE, mode);
-    currentmode = mode;
-    
-    if(gamma)
-        (void) printf(C_GAMMA,   gamma);
-    
-    for (r = 0; r < rows; r++)
-    {
-        ppm_readppmrow(ifp, pixelrow, cols, maxval, format);
-
-        /* get a row of data with 3 bytes per pixel */
-        for (c = 0, op = &obuf[-1]; c < cols; c++)
-        {
-            ++op;
-            *op = (PPM_GETR(pixelrow[c])*255)/maxval;
-            ++op;
-            *op = (PPM_GETG(pixelrow[c])*255)/maxval;
-            ++op;
-            *op = (PPM_GETB(pixelrow[c])*255)/maxval;
-        }
-        ++op;
-        k = op - obuf; /*size of row*/
-        /*compress the row if required*/
-        if(mode == C_TRANS_MODE_STD)
-        {/*no compression*/
-            op = obuf;
-        }
+    pm_close(ifP);
 
-        if(mode ==  C_TRANS_MODE_DELTA)
-        {/*delta compression*/
-            int newmode = 0;
-            int deltasize = 
-                compress_row_delta(obuf, previous_obuf, cbuf, cols*3);
-            if(deltasize >= k)/*normal is best?*/
-            {
-                op = obuf;
-            }
-            else /*delta is best*/
-            {
-                k = deltasize;
-                op = cbuf;
-                newmode = C_TRANS_MODE_DELTA;
-            }
-            memcpy(previous_obuf, obuf, cols*3);
-
-            if(currentmode != newmode)
-            {
-                (void) printf(C_TRANS_MODE, newmode);
-                currentmode = newmode;
-            }
-        }
+    return 0;
+}
 
-        (void) printf(C_SEND_ROW, k);
-        (void) fwrite(op, 1, k, stdout);
-        
-    }
 
-    (void) printf(C_END_RASTER, C_END_RASTER_UNUSED);
-    if(resets & 2)
-    {
-        /* Printer reset. */
-        printf(C_RESET);
-    }
-    pm_close( ifp );
-    ppm_freerow(pixelrow);
 
-    return 0;
-}
diff --git a/converter/ppm/ppmtomitsu.test b/converter/ppm/ppmtomitsu.test
deleted file mode 100644
index f574d927..00000000
--- a/converter/ppm/ppmtomitsu.test
+++ /dev/null
@@ -1,12 +0,0 @@
-echo Test 1.  Should print 3110813682 101562
-./ppmtomitsu ../../testimg.ppm | cksum 
-echo Test 2.  Should print 239186803 34399
-pnmquant 100 ../../testimg.ppm | ./ppmtomitsu | cksum 
-echo Test 3.  Should print 3201293405 310
-./ppmtomitsu ../../testgrid.pbm | cksum 
-echo Test 4.  Should print 3354679572 752
-./ppmtomitsu -tiny ../../testgrid.pbm | cksum 
-echo Test 5.  Should print 3999654426 101549
-./ppmtomitsu -tiny ../../testimg.ppm | cksum 
-echo Test 2.  Should print 3078685526 101549
-pnmquant 100 ../../testimg.ppm | ./ppmtomitsu -tiny | cksum 
diff --git a/converter/ppm/ppmtompeg/bframe.c b/converter/ppm/ppmtompeg/bframe.c
index f5009d6c..fb546cc0 100644
--- a/converter/ppm/ppmtompeg/bframe.c
+++ b/converter/ppm/ppmtompeg/bframe.c
@@ -94,7 +94,7 @@ extern Block **dct, **dctr, **dctb;
 
 static void
 zeroMotion(motion * const motionP) {
-    
+
     motionP->fwd.y = motionP->fwd.x = motionP->bwd.y = motionP->bwd.x = 0;
 }
 
@@ -218,14 +218,14 @@ ComputeBDiffDCTs(MpegFrame * const current,
                  int *       const patternP) {
 
     Block motionBlock;
-    
+
     if (*patternP & 0x20) {
         boolean significantDiff;
         ComputeBMotionBlock(prev, next, by, bx, mode, motion,
                             &motionBlock, LUM_BLOCK);
         ComputeDiffDCTBlock(current->y_blocks[by][bx], dct[by][bx],
                             motionBlock, &significantDiff);
-        if (!significantDiff) 
+        if (!significantDiff)
             *patternP ^=  0x20;
     }
 
@@ -235,7 +235,7 @@ ComputeBDiffDCTs(MpegFrame * const current,
                             &motionBlock, LUM_BLOCK);
         ComputeDiffDCTBlock(current->y_blocks[by][bx+1], dct[by][bx+1],
                             motionBlock, &significantDiff);
-        if (!significantDiff) 
+        if (!significantDiff)
             *patternP ^=  0x10;
     }
 
@@ -348,7 +348,7 @@ ComputeBlockColorDiff(Block current,
 
     unsigned int y;
     int diffTotal;
-    
+
     diffTotal = 0;
 
     for (y = 0; y < 8; ++y) {
@@ -433,7 +433,7 @@ MotionSufficient(MpegFrame *      const curr,
                         &mColorBlock, CB_BLOCK);
     colorErr += ComputeBlockColorDiff(curr->cr_blocks[by/2][bx/2],
                                       mColorBlock);
-    
+
     return (colorErr < 256); /* lumErr checked above */
 }
 
@@ -464,7 +464,7 @@ initializeStats(struct stats * const statsP) {
 
 
 static void
-checkSpecifics(MpegFrame *      const curr, 
+checkSpecifics(MpegFrame *      const curr,
                int              const mbAddress,
                int              const QScale,
                boolean *        const skipItP,
@@ -519,9 +519,9 @@ checkSpecifics(MpegFrame *      const curr,
 
 static void
 makeNonSkipBlock(int              const y,
-                 int              const x, 
-                 MpegFrame *      const curr, 
-                 MpegFrame *      const prev, 
+                 int              const x,
+                 MpegFrame *      const curr,
+                 MpegFrame *      const prev,
                  MpegFrame *      const next,
                  bool             const specificsOn,
                  int              const mbAddress,
@@ -556,7 +556,7 @@ makeNonSkipBlock(int              const y,
                                  &motion, mode);
         }
         /* STEP 2:  INTRA OR NON-INTRA CODING */
-        if (IntraPBAllowed && 
+        if (IntraPBAllowed &&
             DoBIntraCode(curr, prev, next, y, x, mode, motion)) {
             /* output I-block inside a B-frame */
             ++statsP->IBlocks;
@@ -565,7 +565,7 @@ makeNonSkipBlock(int              const y,
             dct_data[y][x].useMotion = NO_MOTION;
             *oldModeP = MOTION_FORWARD;
             /* calculate forward dct's */
-            if (collect_quant && (collect_quant_detailed & 1)) 
+            if (collect_quant && (collect_quant_detailed & 1))
                 fprintf(collect_quant_fp, "l\n");
             mp_fwd_dct_block2(curr->y_blocks[y][x], dct[y][x]);
             mp_fwd_dct_block2(curr->y_blocks[y][x+1], dct[y][x+1]);
@@ -574,9 +574,9 @@ makeNonSkipBlock(int              const y,
             if (collect_quant && (collect_quant_detailed & 1)) {
                 fprintf(collect_quant_fp, "c\n");
             }
-            mp_fwd_dct_block2(curr->cb_blocks[y>>1][x>>1], 
+            mp_fwd_dct_block2(curr->cb_blocks[y>>1][x>>1],
                               dctb[y>>1][x>>1]);
-            mp_fwd_dct_block2(curr->cr_blocks[y>>1][x>>1], 
+            mp_fwd_dct_block2(curr->cr_blocks[y>>1][x>>1],
                               dctr[y>>1][x>>1]);
 
         } else { /* dct P/Bi/B block */
@@ -608,9 +608,9 @@ makeNonSkipBlock(int              const y,
             default:
                 pm_error("INTERNAL ERROR:  Illegal mode: %d", mode);
             }
-        
+
             ComputeBDiffDCTs(curr, prev, next, y, x, mode, motion, &pattern);
-        
+
             dct_data[y][x].pattern = pattern;
             dct_data[y][x].useMotion = MOTION;
             if ( computeMVHist ) {
@@ -622,7 +622,7 @@ makeNonSkipBlock(int              const y,
                 assert(motion.bwd.y + searchRangeB + 1 >= 0);
                 assert(motion.bwd.x + searchRangeB + 1 <= 2*searchRangeB + 2);
                 assert(motion.bwd.y + searchRangeB + 1 <= 2*searchRangeB + 2);
-                
+
                 ++bfmvHistogram[motion.fwd.x + searchRangeB + 1]
                     [motion.fwd.y + searchRangeB + 1];
                 ++bbmvHistogram[motion.bwd.x + searchRangeB + 1]
@@ -649,9 +649,9 @@ makeNonSkipBlock(int              const y,
  *
  *===========================================================================*/
 void
-GenBFrame(BitBucket * const bb, 
-          MpegFrame * const curr, 
-          MpegFrame * const prev, 
+GenBFrame(BitBucket * const bb,
+          MpegFrame * const curr,
+          MpegFrame * const prev,
           MpegFrame * const next) {
 
     FlatBlock fba[6], fb[6];
@@ -704,7 +704,7 @@ GenBFrame(BitBucket * const bb,
     if (bitstreamMode == FIXED_RATE) {
         targetRateControl(curr);
     }
- 
+
     QScale = GetBQScale();
     Mhead_GenPictureHeader(bb, B_FRAME, curr->id, fCodeB);
     /* Check for Qscale change */
@@ -751,7 +751,7 @@ GenBFrame(BitBucket * const bb,
     mbAddress = 0;
 
     /* Start with zero motion assumption */
-    zeroMotion(&motion); 
+    zeroMotion(&motion);
     zeroMotion(&oldMotion);
     zeroMotion(&motionRem);
     zeroMotion(&motionQuot);
@@ -759,7 +759,7 @@ GenBFrame(BitBucket * const bb,
     /* find motion vectors and do dcts */
     /* In this first loop, all MVs are in half-pixel scope, (if FULL
        is set then they will be multiples of 2).  This is not true in
-       the second loop. 
+       the second loop.
     */
     for (y = 0;  y < lastBlockY;  y += 2) {
         for (x = 0;  x < lastBlockX;  x += 2) {
@@ -772,14 +772,14 @@ GenBFrame(BitBucket * const bb,
                     currentBlock.l[iy][ix] = (int16)curr->orig_y[fy+iy][fx+ix];
                 }
             }
-        
+
             if (slicePos == 0) {
                 zeroMotion(&oldMotion);
                 oldMode = MOTION_FORWARD;
                 lastIntra = TRUE;
             }
 
-            /* STEP 1:  Select Forward, Backward, or Interpolated motion 
+            /* STEP 1:  Select Forward, Backward, or Interpolated motion
                vectors */
             /* see if old motion is good enough */
             /* but force last block to be non-skipped */
@@ -795,7 +795,7 @@ GenBFrame(BitBucket * const bb,
                  (! lastIntra) &&
                  (BSkipBlocks) ) {
                 make_skip_block =
-                    MotionSufficient(curr, &currentBlock, 
+                    MotionSufficient(curr, &currentBlock,
                                      prev, next, y, x, oldMode, oldMotion);
             } else
                 make_skip_block = FALSE;
@@ -830,7 +830,7 @@ GenBFrame(BitBucket * const bb,
     if ( (slicePos == 0) && (mbAddress != 0) ) {
       if (specificsOn) {
         /* Make sure no slice Qscale change */
-        newQScale = 
+        newQScale =
             SpecLookup(curr->id,1,mbAddress/blocksPerSlice, &info, QScale);
         if (newQScale != -1) QScale = newQScale;
       }
@@ -858,7 +858,7 @@ GenBFrame(BitBucket * const bb,
         QScale = newQScale;
       }
     }
- 
+
     if (specificsOn) {
       newQScale = SpecLookup(curr->id, 2, mbAddress, &info, QScale);
       if (newQScale != -1) {
@@ -871,12 +871,12 @@ GenBFrame(BitBucket * const bb,
       mbAddrInc = 1;
       stats.IBits += (bb->cumulativeBits - stats.totalBits);
       stats.totalBits = bb->cumulativeBits;
-          
+
       /* reset because intra-coded */
       zeroMotion(&oldMotion);
       oldMode = MOTION_FORWARD;
       lastIntra = TRUE;
-          
+
       if ( printSNR ) {
         /* need to decode block we just encoded */
         /* and reverse the DCT transform */
@@ -896,14 +896,14 @@ GenBFrame(BitBucket * const bb,
     } else if (dct_data[y][x].useMotion == SKIP) {
       ++stats.Skipped;
       mbAddrInc++;
-          
+
       /* decode skipped block */
       if (printSNR) {
           struct motion motion;
-        
+
           for (idx = 0; idx < 6; ++idx)
-              memset((char *)dec[idx], 0, sizeof(Block)); 
-        
+              memset((char *)dec[idx], 0, sizeof(Block));
+
           if (pixelFullSearch) {
               motion.fwd.y = 2 * oldMotion.fwd.y;
               motion.fwd.x = 2 * oldMotion.fwd.x;
@@ -911,7 +911,7 @@ GenBFrame(BitBucket * const bb,
               motion.bwd.x = 2 * oldMotion.bwd.x;
           } else
               motion = oldMotion;
-          
+
           /* now add the motion block */
           AddBMotionBlock(dec[0], prev->decoded_y,
                           next->decoded_y, y, x, mode, motion);
@@ -927,7 +927,7 @@ GenBFrame(BitBucket * const bb,
           AddBMotionBlock(dec[5], prev->decoded_cr,
                           next->decoded_cr, y/2, x/2, mode,
                           halfMotion(motion));
-        
+
           /* now, unblockify */
           BlockToData(curr->decoded_y, dec[0], y, x);
           BlockToData(curr->decoded_y, dec[1], y, x+1);
@@ -937,9 +937,9 @@ GenBFrame(BitBucket * const bb,
           BlockToData(curr->decoded_cr, dec[5], y/2, x/2);
       }
     } else   /* B block */ {
-        int const fCode = fCodeB;   
+        int const fCode = fCodeB;
         int pattern;
-        
+
         pattern = dct_data[y][x].pattern;
         motion.fwd.y = dct_data[y][x].fmotionY;
         motion.fwd.x = dct_data[y][x].fmotionX;
@@ -948,7 +948,7 @@ GenBFrame(BitBucket * const bb,
 
         if (pixelFullSearch)
             motion = halfMotion(motion);
-          
+
         /* create flat blocks and update pattern if necessary */
     calc_blocks:
         /* Note DoQuant references QScale, overflowChange, overflowValue,
@@ -962,7 +962,7 @@ GenBFrame(BitBucket * const bb,
 
         motionForward  = (dct_data[y][x].mode != MOTION_BACKWARD);
         motionBackward = (dct_data[y][x].mode != MOTION_FORWARD);
-        
+
         /* Encode Vectors */
         if (motionForward) {
             /* transform the fMotion vector into the appropriate values */
@@ -974,7 +974,7 @@ GenBFrame(BitBucket * const bb,
                                FORW_F, fCode);
             oldMotion.fwd = motion.fwd;
         }
-          
+
         if (motionBackward) {
             /* transform the bMotion vector into the appropriate values */
             offsetY = motion.bwd.y - oldMotion.bwd.y;
@@ -984,9 +984,9 @@ GenBFrame(BitBucket * const bb,
                                BACK_F, fCode);
             oldMotion.bwd = motion.bwd;
         }
-          
+
         oldMode = dct_data[y][x].mode;
-          
+
         if (printSNR) { /* Need to decode */
             if (pixelFullSearch) {
                 motion.fwd.x *= 2; motion.fwd.y *= 2;
@@ -1030,7 +1030,7 @@ GenBFrame(BitBucket * const bb,
         y_dc_pred = cr_dc_pred = cb_dc_pred = 128;
         lastIntra = FALSE;
         mode = dct_data[y][x].mode;
-        
+
         /*      DBG_PRINT(("MB Header(%d,%d)\n", x, y));  */
         Mhead_GenMBHeader(
             bb, 3 /* pict_code_type */, mbAddrInc /* addr_incr */,
@@ -1049,7 +1049,7 @@ GenBFrame(BitBucket * const bb,
             pattern /* mb_pattern */, FALSE /* mb_intra */);
 
         mbAddrInc = 1;
-          
+
         /* now output the difference */
         {
             unsigned int x;
@@ -1058,7 +1058,7 @@ GenBFrame(BitBucket * const bb,
                     Mpost_RLEHuffPBlock(fba[x], bb);
             }
         }
-          
+
         switch (mode) {
         case MOTION_FORWARD:
             bframeStats.BFOBits += (bb->cumulativeBits - stats.totalBits);
@@ -1072,10 +1072,10 @@ GenBFrame(BitBucket * const bb,
         default:
             pm_error("PROGRAMMER ERROR:  Illegal mode: %d", mode);
       }
-      
+
       stats.BBits += (bb->cumulativeBits - stats.totalBits);
       stats.totalBits = bb->cumulativeBits;
-    
+
       if (overflowChange) {
         /* undo an overflow-caused Qscale change */
         overflowChange = FALSE;
@@ -1091,7 +1091,7 @@ GenBFrame(BitBucket * const bb,
       rc_blockStart = bb->cumulativeBits;
       MB_RateOut(TYPE_BFRAME);
     }
-    
+
       }
     }
 
@@ -1100,22 +1100,22 @@ GenBFrame(BitBucket * const bb,
       totalSNR += snr[0];
       totalPSNR += psnr[0];
     }
-    
+
     Mhead_GenSliceEnder(bb);
     /*   Rate Control  */
     if (bitstreamMode == FIXED_RATE) {
       updateRateControl(TYPE_BFRAME);
     }
-    
+
     endTime = time_elapsed();
     totalTime += (endTime-startTime);
-    
+
     if ( showBitRatePerFrame ) {
       /* ASSUMES 30 FRAMES PER SECOND */
       fprintf(bitRateFile, "%5d\t%8d\n", curr->id,
           30*(bb->cumulativeBits-totalFrameBits));
     }
-    
+
     if ( frameSummary && !realQuiet) {
       fprintf(stdout, "FRAME %d (B):  "
               "I BLOCKS: %5d;  B BLOCKS: %5d   SKIPPED: %5d (%ld seconds)\n",
@@ -1127,7 +1127,7 @@ GenBFrame(BitBucket * const bb,
             curr->id, snr[0], snr[1], snr[2],
             psnr[0], psnr[1], psnr[2]);
     }
-    
+
     bframeStats.FrameBits += (bb->cumulativeBits-totalFrameBits);
     bframeStats.BIBlocks += stats.IBlocks;
     bframeStats.BBBlocks += stats.BBlocks;
@@ -1208,8 +1208,8 @@ BFrameTotalTime(void) {
 
 
 void
-ShowBFrameSummary(unsigned int const inputFrameBits, 
-                  unsigned int const totalBits, 
+ShowBFrameSummary(unsigned int const inputFrameBits,
+                  unsigned int const totalBits,
                   FILE *       const fpointer) {
 
     if (bframeStats.Frames > 0) {
@@ -1234,13 +1234,13 @@ ShowBFrameSummary(unsigned int const inputFrameBits,
                     "  B types:   %5d     (%4d bpb) "
                     "forw  %5d (%4d bpb) back   %5d (%4d bpb) bi\n",
                     bframeStats.BFOBlocks,
-                    (bframeStats.BFOBlocks==0) ? 
+                    (bframeStats.BFOBlocks==0) ?
                         0 : bframeStats.BFOBits/bframeStats.BFOBlocks,
                     bframeStats.BBABlocks,
-                    (bframeStats.BBABlocks==0) ? 
+                    (bframeStats.BBABlocks==0) ?
                         0 : bframeStats.BBABits/bframeStats.BBABlocks,
                     bframeStats.BINBlocks,
-                    (bframeStats.BINBlocks==0) ? 
+                    (bframeStats.BINBlocks==0) ?
                         0 : bframeStats.BINBits/bframeStats.BINBlocks);
         } else
             fprintf(fpointer, "  B Blocks:  %5d\n", 0);
@@ -1251,7 +1251,7 @@ ShowBFrameSummary(unsigned int const inputFrameBits,
                 "(%5d bpf)     (%2.1f%% of total)\n",
                 bframeStats.Frames, bframeStats.FrameBits,
                 bframeStats.FrameBits/bframeStats.Frames,
-                100.0*(float)bframeStats.FrameBits/(float)totalBits);        
+                100.0*(float)bframeStats.FrameBits/(float)totalBits);
         fprintf(fpointer, "  Compression:  %3d:1     (%9.4f bpp)\n",
                 bframeStats.Frames*inputFrameBits/bframeStats.FrameBits,
                 24.0*(float)bframeStats.FrameBits/
@@ -1312,7 +1312,7 @@ ComputeBMotionLumBlock(MpegFrame * const prev,
 
         ComputeMotionLumBlock(prev, by, bx, motion.fwd, &prevBlock);
         ComputeMotionLumBlock(next, by, bx, motion.bwd, &nextBlock);
-        
+
         for (y = 0; y < 16; ++y) {
             unsigned int x;
             for (x = 0; x < 16; ++x)
diff --git a/converter/ppm/ppmtompeg/bitio.c b/converter/ppm/ppmtompeg/bitio.c
index 3812bc39..79c9f36f 100644
--- a/converter/ppm/ppmtompeg/bitio.c
+++ b/converter/ppm/ppmtompeg/bitio.c
@@ -106,10 +106,10 @@ Dump(BitBucket * const bbPtr) {
         for (i = 0; i <= ptr->currword; ++i)
             buffer[i] = pm_bigendFromUint32(ptr->bits[i]);
 
-        nitems = fwrite(buffer, sizeof(buffer[0]), ptr->currword + 1, 
+        nitems = fwrite(buffer, sizeof(buffer[0]), ptr->currword + 1,
                         bbPtr->filePtr);
         if (nitems != ptr->currword+1) {
-            fprintf(stderr, 
+            fprintf(stderr,
                     "Whoa!  Trouble writing %u words (wrote %u words)!  "
                     "Game over, dude!\n",
                     ptr->currword+1, nitems);
@@ -170,7 +170,7 @@ Bitio_New(FILE * const filePtr) {
     bbPtr->firstPtr->bitsleft = MAXBITS_PER_BUCKET;
     bbPtr->firstPtr->bitsleftcur = 32;
     bbPtr->firstPtr->currword = 0;
-    memset((char *)bbPtr->firstPtr->bits, 0, 
+    memset((char *)bbPtr->firstPtr->bits, 0,
            sizeof(uint32) * WORDS_PER_BUCKET);
 
     return bbPtr;
@@ -182,7 +182,7 @@ BitBucket *
 Bitio_New_Filename(const char * const fileName) {
 
     FILE * outputFile;
-    
+
     outputFile = fopen(fileName, "wb");
     if (outputFile == NULL)
         pm_error("Could not open output file '%s'.  "
@@ -232,14 +232,14 @@ Bitio_Free(BitBucket * const bbPtr) {
  *
  *===========================================================================*/
 void
-Bitio_Write(BitBucket * const bbPtr, 
-            uint32      const bits_arg, 
+Bitio_Write(BitBucket * const bbPtr,
+            uint32      const bits_arg,
             int         const nbits) {
 
     register struct bitBucket *lastPtr, *newPtr;
     register int delta;
     uint32 bits;
-    
+
     bits=bits_arg;
     assert(nbits <= 32 && nbits >= 0);
 
@@ -261,7 +261,7 @@ Bitio_Write(BitBucket * const bbPtr,
          * there's not enough room in the current bucket, so we're
          * going to have to allocate another bucket
          */
-        newPtr = lastPtr->nextPtr = (struct bitBucket *) 
+        newPtr = lastPtr->nextPtr = (struct bitBucket *)
             malloc(sizeof(struct bitBucket));
         ERRCHK(newPtr, "malloc");
         newPtr->nextPtr = NULL;
@@ -302,7 +302,7 @@ Bitio_Write(BitBucket * const bbPtr,
              */
             lastPtr->bits[lastPtr->currword] |= (bits >> delta);
             lastPtr->currword++;
-            lastPtr->bits[lastPtr->currword] = 
+            lastPtr->bits[lastPtr->currword] =
                 (bits & lower_mask[delta]) << (32 - delta);
             lastPtr->bitsleftcur = 32 - delta;
         } else {
@@ -371,12 +371,12 @@ Bitio_Flush(BitBucket * const bbPtr) {
             if (nitems != numWords) {
                 if (ferror(bbPtr->filePtr))
                     pm_error("Error writing %u words to flush a bit bucket.  "
-                             "fwrite() gives errno %d (%s)", 
+                             "fwrite() gives errno %d (%s)",
                              numWords, errno, strerror(errno));
                 else
                     pm_error("Problem writing %u words "
                              "to flush a bit bucket.  "
-                             "Only %d words transferred.", 
+                             "Only %d words transferred.",
                              numWords, nitems);
             }
 
@@ -439,7 +439,7 @@ Bitio_Close(BitBucket * const bbPtr) {
  *
  *===========================================================================*/
 void
-Bitio_WriteToSocket(BitBucket * const bbPtr, 
+Bitio_WriteToSocket(BitBucket * const bbPtr,
                     int         const socket) {
 
     struct bitBucket *ptr, *tempPtr;
diff --git a/converter/ppm/ppmtompeg/block.c b/converter/ppm/ppmtompeg/block.c
index 913518c4..23396b4c 100644
--- a/converter/ppm/ppmtompeg/block.c
+++ b/converter/ppm/ppmtompeg/block.c
@@ -106,7 +106,7 @@ ComputeDiffDCTs(MpegFrame * const current,
                 int         const bx,
                 vector      const m,
                 int *       const patternP) {
-    
+
     Block motionBlock;
 
     if (collect_quant && (collect_quant_detailed & 1))
@@ -203,14 +203,14 @@ computePrevFyFx(MpegFrame * const prevFrame,
         if (yHalf) {
             if (m.y < 0)
                 --*fyP;
-        
+
             *prevP = prevFrame->halfBoth;
         } else
             *prevP = prevFrame->halfX;
     } else if (yHalf) {
         if (m.y < 0)
             --*fyP;
-        
+
         *prevP = prevFrame->halfY;
     } else
         *prevP = prevFrame->ref_y;
@@ -263,7 +263,7 @@ ComputeMotionBlock(uint8 ** const prev,
 
         if (m.x < 0)
             --fx;
-    
+
         for (y = 0; y < 8; ++y) {
             int16 * const destPtr = (*motionBlockP)[y];
             uint8 * const srcPtr  = &(prev[fy+y][fx]);
@@ -278,7 +278,7 @@ ComputeMotionBlock(uint8 ** const prev,
         unsigned int y;
         if (m.x < 0)
             --fx;
-        
+
         for (y = 0; y < 8; ++y) {
             int16 * const destPtr = (*motionBlockP)[y];
             uint8 * const srcPtr  = &(prev[fy+y][fx]);
@@ -410,7 +410,7 @@ LumBlockMAD(const LumBlock * const currentBlockP,
  *  return the MAD of the currentBlock and the motion-compensated block
  *      (without TUNEing)
  *
- *  (by, bx) is the location of the block in the frame 
+ *  (by, bx) is the location of the block in the frame
  *  (block number coordinates).  'm' is the motion of the block in pixels.
  *  The moved block must be wholly within the frame.
  *
@@ -452,7 +452,7 @@ LumMotionError(const LumBlock * const currentBlockP,
             const int32 * const cacross = currentBlockP->l[y];
             uint8 *       const across  = &prev[fy+y][fx];
             unsigned int x;
-            
+
             for (x = 0; x < 16; ++x) {
                 int32 const localDiff = across[x]-cacross[x];
                 diff += ABS(localDiff);
@@ -461,14 +461,14 @@ LumMotionError(const LumBlock * const currentBlockP,
                 return diff;
         }
         break;
-      
+
     case LOCAL_DCT: {
         Block     dctdiff[4], dctquant[4];
         FlatBlock quant;
         int x, i, tmp;
         int distortion=0, datarate=0;
         int pq = GetPQScale();
-      
+
         for (y = 0;  y < 16;  ++y) {
             const int32 * const cacross = currentBlockP->l[y];
             uint8 * const across = &(prev[fy+y][fx]);
@@ -489,7 +489,7 @@ LumMotionError(const LumBlock * const currentBlockP,
                 datarate += CalcRLEHuffLength(quant);
             }
         }
-      
+
         /* Calculate distortion */
         for (y = 0;  y < 16;  ++y) {
             const int32 * const cacross = currentBlockP->l[y];
@@ -510,12 +510,12 @@ LumMotionError(const LumBlock * const currentBlockP,
         extern int32 niqtable[];
         int pq = niqtable[0]*GetPQScale();
         unsigned int y;
-        
+
         for (y = 0; y < 16; ++y) {
             const int32 * const cacross = currentBlockP->l[y];
             uint8 * const across = &(prev[fy+y][fx]);
             unsigned int x;
-            
+
             for (x = 0; x < 16; ++x) {
                 int32 const localDiff = across[x]-cacross[x];
                 diff += localDiff;
@@ -598,7 +598,7 @@ LumAddMotionError(const LumBlock * const currentBlockP,
         if (diff > bestSoFar)
             return diff;
     }
-    
+
     /* This is what's happening:
      *
      *  ComputeMotionLumBlock(prevFrame, by, bx, my, mx, lumMotionBlock);
@@ -855,7 +855,7 @@ BlockifyFrame(MpegFrame * const frameP) {
  * but leave it here anyway for clarity
  *
  * (startY, startX) = (0,0) for A....(0,1) for B...(1,0) for C...(1,1) for D
- *  
+ *
  */
 void
 ComputeSubSampledMotionLumBlock(MpegFrame * const prevFrame,
@@ -889,7 +889,7 @@ ComputeSubSampledMotionLumBlock(MpegFrame * const prevFrame,
         if ( my < 0 ) {
         fy--;
         }
-        
+
         prev = prevFrame->halfBoth;
     } else {
         prev = prevFrame->halfX;
@@ -974,7 +974,7 @@ LumMotionErrorSubSampled(LumBlock    const currentBlock,
         if ( my < 0 ) {
         fy--;
         }
-        
+
         prev = prevFrame->halfBoth;
     } else {
         prev = prevFrame->halfX;
diff --git a/converter/ppm/ppmtompeg/combine.c b/converter/ppm/ppmtompeg/combine.c
index c00f9c71..afc3572d 100644
--- a/converter/ppm/ppmtompeg/combine.c
+++ b/converter/ppm/ppmtompeg/combine.c
@@ -112,7 +112,7 @@ appendSpecifiedGopFiles(struct inputSource * const inputSourceP,
 
             ifP = fopen(fileName, "rb");
             if (ifP == NULL)
-                pm_message("ERROR:  Couldn't read file '%s'.  retry %u", 
+                pm_message("ERROR:  Couldn't read file '%s'.  retry %u",
                            fileName, nAttempts);
         }
         if (ifP) {
@@ -125,7 +125,7 @@ appendSpecifiedGopFiles(struct inputSource * const inputSourceP,
         pm_strfree(fileName);
         pm_strfree(inputFileName);
     }
-} 
+}
 
 
 
@@ -135,20 +135,20 @@ appendDefaultGopFiles(const char * const outputFileName,
 
     unsigned int fileSeq;
     bool endOfFiles;
-    
+
     for (fileSeq = 0, endOfFiles = FALSE; !endOfFiles; ++fileSeq) {
         const char * fileName;
         FILE * ifP;
 
         pm_asprintf(&fileName, "%s.gop.%u", outputFileName, fileSeq);
-        
+
         ifP = fopen(fileName, "rb");
         if (ifP == NULL)
             endOfFiles = TRUE;
         else {
             if (!realQuiet)
                 pm_message("appending file:  %s", fileName);
-            
+
             AppendFile(ofP, ifP);
         }
         pm_strfree(fileName);
@@ -159,7 +159,7 @@ appendDefaultGopFiles(const char * const outputFileName,
 
 void
 GOPsToMPEG(struct inputSource * const inputSourceP,
-           const char *         const outputFileName, 
+           const char *         const outputFileName,
            FILE *               const ofP) {
 /*----------------------------------------------------------------------------
    Combine individual GOPs (one per file) into a single MPEG sequence file.
@@ -174,13 +174,13 @@ GOPsToMPEG(struct inputSource * const inputSourceP,
         if (Fsize_x == 0 || Fsize_y == 0)
             Fsize_Note(0, x, y);
     }
-    
+
     bb = Bitio_New(ofP);
 
     Mhead_GenSequenceHeader(bb, Fsize_x, Fsize_y, /* pratio */ aspectRatio,
                             /* pict_rate */ frameRate, /* bit_rate */ -1,
                             /* buf_size */ -1, /*c_param_flag */ 1,
-                            /* iq_matrix */ customQtable, 
+                            /* iq_matrix */ customQtable,
                             /* niq_matrix */ customNIQtable,
                             /* ext_data */ NULL, /* ext_data_size */ 0,
                             /* user_data */ NULL, /* user_data_size */ 0);
@@ -228,16 +228,16 @@ makeGOPHeader(FILE *       const outputFileP,
                        tc_hrs, tc_min, tc_sec, tc_pict,
                        closed, /* broken_link */ 0,
                        /* ext_data */ NULL, /* ext_data_size */ 0,
-                       /* user_data */ NULL, 
+                       /* user_data */ NULL,
                        /* user_data_size */ 0);
     Bitio_Flush(bbP);
     SetGOPStartTime(frameNumber);
-}        
+}
 
 
 
 void
-FramesToMPEG(FILE *               const outputFile, 
+FramesToMPEG(FILE *               const outputFile,
              void *               const inputHandle,
              fileAcquisitionFn          acquireInputFile,
              fileDispositionFn          disposeInputFile) {
@@ -292,7 +292,7 @@ FramesToMPEG(FILE *               const outputFile,
     frameNumber = 0;
 
     makeGOPHeader(outputFile, totalFramesSent, frameNumber, seqWithinGop);
-    
+
     while (inputLeft) {
         if (FType_Type(frameNumber) != 'b') {
             pastRefNum = futureRefNum;
@@ -318,7 +318,7 @@ FramesToMPEG(FILE *               const outputFile,
                 /* now, output the B-frames */
                 if (pastRefNum != -1) {
                     unsigned int bNum;
-                    
+
                     for (bNum = pastRefNum+1; bNum < futureRefNum; ++bNum) {
                         acquireInputFile(inputHandle, bNum, &inputFile);
 
@@ -326,7 +326,7 @@ FramesToMPEG(FILE *               const outputFile,
                             AppendFile(outputFile, inputFile);
 
                             disposeInputFile(inputHandle, bNum);
-            
+
                             ++seqWithinGop;
                             IncrementTCTime();
                         }
diff --git a/converter/ppm/ppmtompeg/file.c b/converter/ppm/ppmtompeg/file.c
index 223170a4..b81e8077 100644
--- a/converter/ppm/ppmtompeg/file.c
+++ b/converter/ppm/ppmtompeg/file.c
@@ -121,7 +121,7 @@ ChangeDirectory(ClientData nulldata, Tcl_Interp *interp, int argc,
         fprintf(stderr, "can't open '%s'\n", currentPath);
         return TCL_OK;  /* shouldn't, really */
     }
-    
+
     return TCL_OK;
 }
 
@@ -164,7 +164,7 @@ ListDirectory(ClientData nulldata, Tcl_Interp *interp, int argc,
     while ((dp = readdir(dfd)) != NULL) {
         strcpy(restPtr, dp->d_name);
         stat(fullName, &stbuf);
-        
+
         if (dp->d_name[0] != '.') {
             if (S_ISDIR(stbuf.st_mode)) {
                 sprintf(fileName[fileCount], "%s/", dp->d_name);
@@ -263,7 +263,7 @@ SetBrowseGlob(ClientData nulldata, Tcl_Interp *interp,
         return TCL_OK;
     }
 
-    Tcl_AppendResult(interp, 
+    Tcl_AppendResult(interp,
                      "wrong args: should be \"", argv[0]," string\"",
                      NULL);
     return TCL_ERROR;
diff --git a/converter/ppm/ppmtompeg/frametype.c b/converter/ppm/ppmtompeg/frametype.c
index debefcdc..78e324d0 100644
--- a/converter/ppm/ppmtompeg/frametype.c
+++ b/converter/ppm/ppmtompeg/frametype.c
@@ -1,18 +1,18 @@
 /*===========================================================================*
- * frametype.c								     *
- *									     *
- *	procedures to keep track of frame types (I, P, B)		     *
- *									     *
- * EXPORTED PROCEDURES:							     *
- *	FType_Type						             *
- *	FType_FutureRef						             *
- *	FType_PastRef						             *
- *									     *
- * SYNOPSIS								     *
- *	FType_Type	returns the type of the given numbered frame	     *
- *	FType_FutureRef	returns the number of the future reference frame     *
- *	FType_PastRef	returns the number of the past reference frame	     *
- *									     *
+ * frametype.c                                                               *
+ *                                                                           *
+ *      procedures to keep track of frame types (I, P, B)                    *
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
+ *      FType_Type                                                           *
+ *      FType_FutureRef                                                      *
+ *      FType_PastRef                                                        *
+ *                                                                           *
+ * SYNOPSIS                                                                  *
+ *      FType_Type      returns the type of the given numbered frame         *
+ *      FType_FutureRef returns the number of the future reference frame     *
+ *      FType_PastRef   returns the number of the past reference frame       *
+ *                                                                           *
  * 00.12.07 change malloc from frameTable to calloc to fix bug
  *===========================================================================*/
 
@@ -72,9 +72,9 @@ extern char * framePattern;
  *
  * FType_Type
  *
- *	returns the type of the given numbered frame
+ *      returns the type of the given numbered frame
  *
- * RETURNS:	the type
+ * RETURNS:     the type
  *
  * SIDE EFFECTS:    none
  *
@@ -161,9 +161,9 @@ FType_FutureRef(unsigned int const currFrameNum) {
  *
  * FType_PastRef
  *
- *	returns the number of the past reference frame
+ *      returns the number of the past reference frame
  *
- * RETURNS:	the number
+ * RETURNS:     the number
  *
  * SIDE EFFECTS:    none
  *
@@ -172,8 +172,8 @@ int
 FType_PastRef(currFrameNum)
     int currFrameNum;
 {
-    int	    index;
-    int	    pastIndex;
+    int     index;
+    int     pastIndex;
 
     if (use_cache) {
       return frameTable[currFrameNum].prev->number;
@@ -182,7 +182,7 @@ FType_PastRef(currFrameNum)
       pastIndex = frameTable[index].prev->number;
 
       return currFrameNum -
-	(((index-pastIndex)+framePatternLen) % framePatternLen);
+        (((index-pastIndex)+framePatternLen) % framePatternLen);
     }
 }
 
@@ -191,9 +191,9 @@ FType_PastRef(currFrameNum)
  *
  * SetFramePattern
  *
- *	set the IPB pattern; calls ComputeFrameTable to set up table
+ *      set the IPB pattern; calls ComputeFrameTable to set up table
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    framePattern, framePatternLen, frameTable
  *
@@ -264,8 +264,8 @@ ComputeFrameTable(unsigned int const numFramesArg) {
   'numFrames' == 0 means number of frames is not known at this time.
 -----------------------------------------------------------------------------*/
     int index;
-    FrameTable	*lastIP, *firstB, *secondIP;
-    FrameTable	*ptr;
+    FrameTable  *lastIP, *firstB, *secondIP;
+    FrameTable  *ptr;
     char typ;
     int table_size;
 
@@ -286,14 +286,14 @@ ComputeFrameTable(unsigned int const numFramesArg) {
         typ = FType_Type(index);
         frameTable[index].typ = typ;
         switch( typ ) {
-	    case 'i':
+            case 'i':
             ptr = firstB;
             while ( ptr != NULL ) {
                 ptr->next = &(frameTable[index]);
                 ptr = ptr->nextOutput;
             }
             frameTable[index].nextOutput = firstB;
-            frameTable[index].prev = lastIP;	/* for freeing */
+            frameTable[index].prev = lastIP;    /* for freeing */
             if ( lastIP != NULL ) {
                 lastIP->next = &(frameTable[index]);
                 if ( secondIP == NULL ) {
@@ -303,7 +303,7 @@ ComputeFrameTable(unsigned int const numFramesArg) {
             lastIP = &(frameTable[index]);
             firstB = NULL;
             break;
-	    case 'p':
+            case 'p':
             ptr = firstB;
             while ( ptr != NULL ) {
                 ptr->next = &(frameTable[index]);
@@ -320,7 +320,7 @@ ComputeFrameTable(unsigned int const numFramesArg) {
             lastIP = &(frameTable[index]);
             firstB = NULL;
             break;
-	    case 'b':
+            case 'b':
             if ( (index+1 == framePatternLen) ||
                  (FType_Type(index+1) != 'b') ) {
                 frameTable[index].nextOutput = NULL;
@@ -332,11 +332,11 @@ ComputeFrameTable(unsigned int const numFramesArg) {
                 firstB = &(frameTable[index]);
             }
             break;
-	    default:
-	        fprintf(stderr, "Programmer Error in ComputeFrameTable (%d)\n",
+            default:
+                fprintf(stderr, "Programmer Error in ComputeFrameTable (%d)\n",
                     framePattern[index]);
-	        exit(1);
-	        break;
+                exit(1);
+                break;
         }
     }
 
diff --git a/converter/ppm/ppmtompeg/fsize.c b/converter/ppm/ppmtompeg/fsize.c
index 3808405c..84772719 100644
--- a/converter/ppm/ppmtompeg/fsize.c
+++ b/converter/ppm/ppmtompeg/fsize.c
@@ -1,17 +1,17 @@
 /*===========================================================================*
- * fsize.c								     *
- *									     *
- *	procedures to keep track of frame size				     *
- *									     *
- * EXPORTED PROCEDURES:							     *
- *	Fsize_Reset							     *
- *	Fsize_Note							     *
- *	Fsize_Validate							     *
- *									     *
- * EXPORTED VARIABLES:							     *
- *	Fsize_x								     *
- *	Fsize_y								     *
- *									     *
+ * fsize.c                                                                   *
+ *                                                                           *
+ *      procedures to keep track of frame size                               *
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
+ *      Fsize_Reset                                                          *
+ *      Fsize_Note                                                           *
+ *      Fsize_Validate                                                       *
+ *                                                                           *
+ * EXPORTED VARIABLES:                                                       *
+ *      Fsize_x                                                              *
+ *      Fsize_y                                                              *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -60,9 +60,9 @@ int Fsize_y = 0;
  *
  * Fsize_Reset
  *
- *	reset the frame size to 0
+ *      reset the frame size to 0
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    Fsize_x, Fsize_y
  *
@@ -78,9 +78,9 @@ Fsize_Reset(void) {
  *
  * Fsize_Validate
  *
- *	make sure that the x, y values are 16-pixel aligned
+ *      make sure that the x, y values are 16-pixel aligned
  *
- * RETURNS:	modifies the x, y values to 16-pixel alignment
+ * RETURNS:     modifies the x, y values to 16-pixel alignment
  *
  * SIDE EFFECTS:    none
  *
@@ -98,9 +98,9 @@ Fsize_Validate(int * const xP,
  *
  * Fsize_Note
  *
- *	note the given frame size and modify the global values as appropriate
+ *      note the given frame size and modify the global values as appropriate
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    Fsize_x, Fsize_y
  *
@@ -122,13 +122,13 @@ Fsize_Note(int          const id,
 
 #ifdef BLEAH
     if (Fsize_x == 0) {
-	Fsize_x = width;
-	Fsize_y = height;
-	Fsize_Validate(&Fsize_x, &Fsize_y);
+        Fsize_x = width;
+        Fsize_y = height;
+        Fsize_Validate(&Fsize_x, &Fsize_y);
     } else if (width < Fsize_x || height < Fsize_y) {
-	fprintf(stderr, "Frame %d: wrong size: (%d,%d).  Should be greater or equal to: (%d,%d)\n",
-		id, width, height, Fsize_x, Fsize_y);
-	exit(1);
+        fprintf(stderr, "Frame %d: wrong size: (%d,%d).  Should be greater or equal to: (%d,%d)\n",
+                id, width, height, Fsize_x, Fsize_y);
+        exit(1);
     }
 #endif
 }
diff --git a/converter/ppm/ppmtompeg/gethostname_win32.c b/converter/ppm/ppmtompeg/gethostname_win32.c
index e37fbb37..b831e22d 100644
--- a/converter/ppm/ppmtompeg/gethostname_win32.c
+++ b/converter/ppm/ppmtompeg/gethostname_win32.c
@@ -90,13 +90,13 @@ get_string_version(push_string_t *str)
     if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
     {
         osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
-        if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) 
+        if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
             return FALSE;
     }
 
     /* Call GetNativeSystemInfo if available; GetSystemInfo otherwise. */
     pGNSI = (PGNSI)
-            GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), 
+            GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
             "GetNativeSystemInfo");
     if (NULL != pGNSI)
         pGNSI(&si);
@@ -254,7 +254,7 @@ get_string_version(push_string_t *str)
             pushString(str, "Microsoft Windows 2000 ");
             if (osvi.wProductType == VER_NT_WORKSTATION)
                 pushString(str, "Professional ");
-            else 
+            else
             if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
                 pushString(str, "Datacenter Server ");
             else
@@ -288,7 +288,7 @@ get_string_version(push_string_t *str)
             }
         }
         /* Test for specific product on Windows NT 4.0 SP5 and earlier */
-        else  
+        else
         {
             HKEY hKey;
             TCHAR szProductType[BUFSIZE];
@@ -321,9 +321,9 @@ get_string_version(push_string_t *str)
         }
 
         /* Display service pack (if any) and build number. */
-        if (osvi.dwMajorVersion == 4 && 
+        if (osvi.dwMajorVersion == 4 &&
             lstrcmpi(osvi.szCSDVersion, TEXT("Service Pack 6")) == 0)
-        { 
+        {
             HKEY hKey;
             LONG lRet;
 
@@ -332,7 +332,7 @@ get_string_version(push_string_t *str)
                 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"),
                 0, KEY_QUERY_VALUE, &hKey );
             if( lRet == ERROR_SUCCESS )
-                pushString(str, "Service Pack 6a (Build %d)\n", osvi.dwBuildNumber & 0xFFFF );         
+                pushString(str, "Service Pack 6a (Build %d)\n", osvi.dwBuildNumber & 0xFFFF );
             else
                 /* Windows NT 4.0 prior to SP6a */
                 pushString(str, "%s (Build %d)\n", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
@@ -358,7 +358,7 @@ get_string_version(push_string_t *str)
             pushString(str, "Microsoft Windows 98");
             if (osvi.szCSDVersion[1]=='A' || osvi.szCSDVersion[1]=='B')
                 pushString(str, " SE");
-        } 
+        }
         else
         if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
             pushString(str, "Microsoft Windows Millennium Edition\n");
@@ -368,7 +368,7 @@ get_string_version(push_string_t *str)
         pushString(str, "Microsoft Win32s\n");
         break;
     }
-    return TRUE; 
+    return TRUE;
 }
 
 const char *
diff --git a/converter/ppm/ppmtompeg/headers/all.h b/converter/ppm/ppmtompeg/headers/all.h
index 8f095d8e..242ffe98 100644
--- a/converter/ppm/ppmtompeg/headers/all.h
+++ b/converter/ppm/ppmtompeg/headers/all.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * all.h								     *
- *									     *
- *	stuff included from ALL source files				     *
- *									     *
+ * all.h                                                                     *
+ *                                                                           *
+ *      stuff included from ALL source files                                 *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -26,7 +26,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /u/smoot/md/mpeg_encode/headers/RCS/all.h,v 1.9 1995/06/05 21:11:06 smoot Exp $
  *  $Log: all.h,v $
  * Revision 1.9  1995/06/05  21:11:06  smoot
diff --git a/converter/ppm/ppmtompeg/headers/bitio.h b/converter/ppm/ppmtompeg/headers/bitio.h
index 931bcdd9..c74116f5 100644
--- a/converter/ppm/ppmtompeg/headers/bitio.h
+++ b/converter/ppm/ppmtompeg/headers/bitio.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * bitio.h								     *
- *									     *
- *	bitwise input/output						     *
- *									     *
+ * bitio.h                                                                   *
+ *                                                                           *
+ *      bitwise input/output                                                 *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -26,7 +26,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/charlie-brown/project/mm/mpeg/mpeg_dist/mpeg_encode/headers/RCS/bitio.h,v 1.8 1995/01/19 23:54:37 eyhung Exp $
  *  $Log: bitio.h,v $
  * Revision 1.8  1995/01/19  23:54:37  eyhung
@@ -70,9 +70,9 @@
  *===========*/
 
 #define WORDS_PER_BUCKET 128
-#define MAXBITS_PER_BUCKET	(WORDS_PER_BUCKET * 32)
-#define	MAX_BUCKETS	128
-#define MAX_BITS	MAX_BUCKETS*MAXBITS_PER_BUCKET
+#define MAXBITS_PER_BUCKET      (WORDS_PER_BUCKET * 32)
+#define MAX_BUCKETS     128
+#define MAX_BITS        MAX_BUCKETS*MAXBITS_PER_BUCKET
 
 
 /*=======================*
@@ -87,8 +87,8 @@ typedef struct bitBucket {
 
 typedef struct _BitBucket {
     int totalbits;
-    int	cumulativeBits;
-    int	bitsWritten;
+    int cumulativeBits;
+    int bitsWritten;
     FILE    *filePtr;
     ActualBucket *firstPtr;
     ActualBucket *lastPtr;
@@ -99,20 +99,20 @@ typedef struct _BitBucket {
  * MACROS *
  *========*/
 
-#define	SET_ITH_BIT(bits, i)	(bits |= (1 << (i)))
-#define	GET_ITH_BIT(bits, i)	(bits & (1 << (i)))
+#define SET_ITH_BIT(bits, i)    (bits |= (1 << (i)))
+#define GET_ITH_BIT(bits, i)    (bits & (1 << (i)))
 
 
 /*===============================*
  * EXTERNAL PROCEDURE prototypes *
  *===============================*/
 
-void	    
+void
 Bitio_Free(BitBucket * const bbPtr);
 
 void
-Bitio_Write(BitBucket * const bbPtr, 
-            uint32      const bits, 
+Bitio_Write(BitBucket * const bbPtr,
+            uint32      const bits,
             int         const nbits);
 
 void
@@ -131,7 +131,7 @@ void
 Bitio_Close(BitBucket * const bbPtr);
 
 void
-Bitio_WriteToSocket(BitBucket * const bbPtr, 
+Bitio_WriteToSocket(BitBucket * const bbPtr,
                     int         const socket);
 
 #endif /* BIT_IO_INCLUDED */
diff --git a/converter/ppm/ppmtompeg/headers/byteorder.h b/converter/ppm/ppmtompeg/headers/byteorder.h
index e2d8030c..9376b576 100644
--- a/converter/ppm/ppmtompeg/headers/byteorder.h
+++ b/converter/ppm/ppmtompeg/headers/byteorder.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * byteorder.h								     *
- *									     *
- *	stuff to handle different byte order				     *
- *									     *
+ * byteorder.h                                                               *
+ *                                                                           *
+ *      stuff to handle different byte order                                 *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -26,7 +26,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /u/smoot/md/mpeg_encode/headers/RCS/byteorder.h,v 1.3 1995/01/19 23:54:39 eyhung Exp $
  *  $Log: byteorder.h,v $
  * Revision 1.3  1995/01/19  23:54:39  eyhung
@@ -60,17 +60,17 @@
      * constant; thus, this is not for general use, but works with bitio.c
      */
 #define htonl(x)    \
-    ((((unsigned char *)(&x))[0] << 24) |	\
-     (((unsigned char *)(&x))[1] << 16) |	\
-     (((unsigned char *)(&x))[2] << 8) |	\
+    ((((unsigned char *)(&x))[0] << 24) |       \
+     (((unsigned char *)(&x))[1] << 16) |       \
+     (((unsigned char *)(&x))[2] << 8) |        \
      (((unsigned char *)(&x))[3]))
 #define ntohl(x)    htonl(x)
 #define htons(x)    \
-    ((((unsigned char *)(&x))[0] << 8) |	\
+    ((((unsigned char *)(&x))[0] << 8) |        \
      ((unsigned char *)(&x))[1])
 #define ntohs(x)    htons(x)
 #else
-    /* let in.h handle it, if possible */		   
+    /* let in.h handle it, if possible */
 #include <sys/types.h>
 #if !defined(WIN32) || defined(__CYGWIN__)
 #include <netinet/in.h>
diff --git a/converter/ppm/ppmtompeg/headers/combine.h b/converter/ppm/ppmtompeg/headers/combine.h
index e28c6dee..c99d9dbe 100644
--- a/converter/ppm/ppmtompeg/headers/combine.h
+++ b/converter/ppm/ppmtompeg/headers/combine.h
@@ -2,7 +2,7 @@ struct inputSource;
 
 void
 GOPsToMPEG(struct inputSource * const inputSourceP,
-           const char *         const outputFileName, 
+           const char *         const outputFileName,
            FILE *               const outputFilePtr);
 
 typedef void (*fileAcquisitionFn)(void *       const handle,
@@ -14,7 +14,7 @@ typedef void (*fileDispositionFn)(void *       const handle,
                                   unsigned int const frameNumber);
 
 void
-FramesToMPEG(FILE *               const outputFile, 
+FramesToMPEG(FILE *               const outputFile,
              void *               const inputHandle,
              fileAcquisitionFn          acquireInputFile,
              fileDispositionFn          disposeInputFile);
diff --git a/converter/ppm/ppmtompeg/headers/dct.h b/converter/ppm/ppmtompeg/headers/dct.h
index 3b824cf0..3c4780cd 100644
--- a/converter/ppm/ppmtompeg/headers/dct.h
+++ b/converter/ppm/ppmtompeg/headers/dct.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * dct.h								     *
- *									     *
- *	DCT procedures							     *
- *									     *
+ * dct.h                                                                     *
+ *                                                                           *
+ *      DCT procedures                                                       *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -43,7 +43,7 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
 typedef DCTELEM DCTBLOCK_2D[DCTSIZE][DCTSIZE];
 
 
-/*  
+/*
  *  from mfwddct.c:
  */
 void init_fdct (void);
diff --git a/converter/ppm/ppmtompeg/headers/frame.h b/converter/ppm/ppmtompeg/headers/frame.h
index e1f587a2..993359bc 100644
--- a/converter/ppm/ppmtompeg/headers/frame.h
+++ b/converter/ppm/ppmtompeg/headers/frame.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * frame.h								     *
- *									     *
- *	basic frames procedures						     *
- *									     *
+ * frame.h                                                                   *
+ *                                                                           *
+ *      basic frames procedures                                              *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -40,9 +40,9 @@
 /*===========*
  * CONSTANTS *
  *===========*/
-#define TYPE_IFRAME	2
-#define TYPE_PFRAME	3
-#define TYPE_BFRAME	4
+#define TYPE_IFRAME     2
+#define TYPE_PFRAME     3
+#define TYPE_BFRAME     4
 
 
 /*=======================*
@@ -54,11 +54,11 @@ typedef struct mpegFrame {
     char    inputFileName[256];
     int id;           /* the frame number -- starts at 0 */
     bool inUse;
-	   /* this frame is currently being used (if not, any data here can be
+           /* this frame is currently being used (if not, any data here can be
           thrashed)
        */
 
-    /*  
+    /*
      *  now, the YCrCb data.  All pixel information is stored in unsigned
      *  8-bit pieces.  We separate y, cr, and cb because cr and cb are
      *  subsampled by a factor of 2.
@@ -68,16 +68,16 @@ typedef struct mpegFrame {
     uint8_t **orig_y, **orig_cr, **orig_cb;
 
     /* now, the decoded data -- relevant only if
-     *	    referenceFrame == DECODED_FRAME
+     *      referenceFrame == DECODED_FRAME
      *
-     * if decoded_y is NULL, then decoded_cr, decoded_cb are undefined 
+     * if decoded_y is NULL, then decoded_cr, decoded_cb are undefined
      */
     uint8_t **decoded_y, **decoded_cr, **decoded_cb;
 
     /* reference data */
     uint8_t **ref_y, **ref_cr, **ref_cb;
 
-    /*  
+    /*
      *  these are the Blocks which will ultimately compose MacroBlocks.
      *  A Block is in a format that mp_fwddct() can crunch.
      *  if y_blocks is NULL, then cr_blocks, cb_blocks are undefined
@@ -92,8 +92,8 @@ typedef struct mpegFrame {
     bool   halfComputed;        /* TRUE iff half-pixels already computed */
 
     struct mpegFrame *next;  /* points to the next B-frame to be encoded, if
-		       * stdin is used as the input. 
-		       */
+                       * stdin is used as the input.
+                       */
 } MpegFrame;
 
 
diff --git a/converter/ppm/ppmtompeg/headers/frames.h b/converter/ppm/ppmtompeg/headers/frames.h
index 2ec11d69..9108ac21 100644
--- a/converter/ppm/ppmtompeg/headers/frames.h
+++ b/converter/ppm/ppmtompeg/headers/frames.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * frames.h                                  
- *                                       
- *  stuff dealing with frames                        
- *                                       
+ * frames.h
+ *
+ *  stuff dealing with frames
+ *
  *===========================================================================*/
 
 #ifndef FRAMES_INCLUDED
@@ -72,7 +72,7 @@ typedef struct FrameTableStruct {
     int number;
 
     int bFrameNumber;       /* actual frame number, if a b-frame */
-    
+
 } FrameTable;
 
 
@@ -234,13 +234,13 @@ float
 BFrameTotalTime(void);
 
 void
-ShowPFrameSummary(unsigned int const inputFrameBits, 
-                  unsigned int const totalBits, 
+ShowPFrameSummary(unsigned int const inputFrameBits,
+                  unsigned int const totalBits,
                   FILE *       const fpointer);
 
 void
-ShowBFrameSummary(unsigned int const inputFrameBits, 
-                  unsigned int const totalBits, 
+ShowBFrameSummary(unsigned int const inputFrameBits,
+                  unsigned int const totalBits,
                   FILE *       const fpointer);
 
 /*==================*
@@ -291,7 +291,7 @@ extern int TIME_RATE;
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/picasso/project/mpeg/mpeg_dist/mpeg_encode/headers/RCS/frames.h,v 1.13 1995/08/15 23:43:04 smoot Exp $
  *  $Log: frames.h,v $
  *  Revision 1.13  1995/08/15 23:43:04  smoot
diff --git a/converter/ppm/ppmtompeg/headers/frametype.h b/converter/ppm/ppmtompeg/headers/frametype.h
index 33b604e6..3e319c40 100644
--- a/converter/ppm/ppmtompeg/headers/frametype.h
+++ b/converter/ppm/ppmtompeg/headers/frametype.h
@@ -7,7 +7,7 @@ FType_Type(unsigned int const frameNum);
 unsigned int
 FType_FutureRef(unsigned int const currFrameNum);
 
-int	FType_PastRef (int currFrameNum);
+int     FType_PastRef (int currFrameNum);
 
 void SetFramePattern(const char * const pattern);
 
diff --git a/converter/ppm/ppmtompeg/headers/fsize.h b/converter/ppm/ppmtompeg/headers/fsize.h
index 6a1c910e..5f57e4f2 100644
--- a/converter/ppm/ppmtompeg/headers/fsize.h
+++ b/converter/ppm/ppmtompeg/headers/fsize.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * fsize.h								     *
- *									     *
- *	procedures to deal with frame size				     *
- *									     *
+ * fsize.h                                                                   *
+ *                                                                           *
+ *      procedures to deal with frame size                                   *
+ *                                                                           *
  *===========================================================================*/
 
 /*
diff --git a/converter/ppm/ppmtompeg/headers/general.h b/converter/ppm/ppmtompeg/headers/general.h
index 59c33c73..45d3db17 100644
--- a/converter/ppm/ppmtompeg/headers/general.h
+++ b/converter/ppm/ppmtompeg/headers/general.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * general.h								     *
- *									     *
- *	very general stuff						     *
- *									     *
+ * general.h                                                                 *
+ *                                                                           *
+ *      very general stuff                                                   *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -26,7 +26,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/picasso/project/mpeg/mpeg_dist/mpeg_encode/headers/RCS/general.h,v 1.7 1995/08/04 23:34:13 smoot Exp $
  *  $Log: general.h,v $
  *  Revision 1.7  1995/08/04 23:34:13  smoot
@@ -62,7 +62,7 @@
  * if your /usr/include headers do not have these, then pass -DMISSING_PROTOS
  * to your compiler
  *
- */ 
+ */
 #ifdef MISSING_PROTOS
 int fprintf();
 int fwrite();
@@ -114,7 +114,7 @@ int pclose();
 typedef int boolean;
 
 /* In the following, we need the "signed" in order to make these typedefs
-   match those in AIX system header files.  Otherwise, compile fails on 
+   match those in AIX system header files.  Otherwise, compile fails on
    AIX.  2000.09.11.
 */
 typedef unsigned char uint8;
@@ -139,10 +139,10 @@ typedef signed short int16;
 */
 
     /* LONG_32 should only be defined iff
-     *	    1) long's are 32 bits and
-     *	    2) int's are not
+     *      1) long's are 32 bits and
+     *      2) int's are not
      */
-#ifdef LONG_32		
+#ifdef LONG_32
 typedef unsigned long uint32;
 typedef long int32;
 #else
diff --git a/converter/ppm/ppmtompeg/headers/huff.h b/converter/ppm/ppmtompeg/headers/huff.h
index a6379248..8b46a8b8 100644
--- a/converter/ppm/ppmtompeg/headers/huff.h
+++ b/converter/ppm/ppmtompeg/headers/huff.h
@@ -19,18 +19,18 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/charlie-brown/project/mm/mpeg/mpeg_dist/mpeg_encode/headers/RCS/huff.h,v 1.3 1995/01/19 23:54:51 eyhung Exp $
  */
 
-/*  
+/*
  *  THIS FILE WAS ORIGINALLY MACHINE GENERATED
  */
 
 #include "general.h"
 
-#define HUFF_MAXRUN	32
-#define HUFF_MAXLEVEL	41
+#define HUFF_MAXRUN     32
+#define HUFF_MAXLEVEL   41
 
 extern int huff_maxlevel[];
 extern uint32 *huff_table[];
diff --git a/converter/ppm/ppmtompeg/headers/iframe.h b/converter/ppm/ppmtompeg/headers/iframe.h
index c4f77c74..fb8d508c 100644
--- a/converter/ppm/ppmtompeg/headers/iframe.h
+++ b/converter/ppm/ppmtompeg/headers/iframe.h
@@ -19,7 +19,7 @@ int
 GetIQScale(void);
 
 void
-GenIFrame(BitBucket * const bb, 
+GenIFrame(BitBucket * const bb,
           MpegFrame * const current);
 
 void
@@ -30,8 +30,8 @@ IFrameTotalTime(void);
 
 
 void
-ShowIFrameSummary(unsigned int const inputFrameBits, 
-                  unsigned int const totalBits, 
+ShowIFrameSummary(unsigned int const inputFrameBits,
+                  unsigned int const totalBits,
                   FILE *       const fpointer);
 
 void
diff --git a/converter/ppm/ppmtompeg/headers/mheaders.h b/converter/ppm/ppmtompeg/headers/mheaders.h
index edd9552d..43df26a5 100644
--- a/converter/ppm/ppmtompeg/headers/mheaders.h
+++ b/converter/ppm/ppmtompeg/headers/mheaders.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * mheaders.h								     *
- *									     *
- *	MPEG headers							     *
- *									     *
+ * mheaders.h                                                                *
+ *                                                                           *
+ *      MPEG headers                                                         *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -26,7 +26,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/picasso/project/mm/mpeg/mpeg_dist/mpeg_encode/headers/RCS/mheaders.h,v 1.4 1995/03/27 19:29:24 smoot Exp $
  *  $Log: mheaders.h,v $
  * Revision 1.4  1995/03/27  19:29:24  smoot
@@ -61,40 +61,40 @@
  * EXTERNAL PROCEDURE prototypes *
  *===============================*/
 
-void	SetGOPStartTime (int index);
+void    SetGOPStartTime (int index);
 
 void
-Mhead_GenSequenceHeader(BitBucket *   const bbPtr, 
-                        uint32        const hsize, 
+Mhead_GenSequenceHeader(BitBucket *   const bbPtr,
+                        uint32        const hsize,
                         uint32        const vsize,
-                        int32         const pratio, 
-                        int32         const pict_rate, 
+                        int32         const pratio,
+                        int32         const pict_rate,
                         int32         const bit_rate_arg,
-                        int32         const buf_size_arg, 
-                        int32         const c_param_flag_arg, 
-                        const int32 * const iq_matrix, 
+                        int32         const buf_size_arg,
+                        int32         const c_param_flag_arg,
+                        const int32 * const iq_matrix,
                         const int32 * const niq_matrix,
-                        uint8 *       const ext_data, 
-                        int32         const ext_data_size, 
+                        uint8 *       const ext_data,
+                        int32         const ext_data_size,
                         uint8 *       const user_data,
                         int32         const user_data_size);
 
-void	Mhead_GenSequenceEnder (BitBucket *bbPtr);
-void	Mhead_GenGOPHeader (BitBucket *bbPtr,
-	   int32 drop_frame_flag,
+void    Mhead_GenSequenceEnder (BitBucket *bbPtr);
+void    Mhead_GenGOPHeader (BitBucket *bbPtr,
+           int32 drop_frame_flag,
            int32 tc_hrs, int32 tc_min,
            int32 tc_sec, int32 tc_pict,
            int32 closed_gop, int32 broken_link,
            uint8 *ext_data, int32 ext_data_size,
            uint8 *user_data, int32 user_data_size);
-void	Mhead_GenPictureHeader (BitBucket *bbPtr, int frameType,
-					    int pictCount, int f_code);
-void	Mhead_GenSliceHeader (BitBucket *bbPtr, uint32 slicenum,
-					  uint32 qscale, uint8 *extra_info,
-					  uint32 extra_info_size);
-void	Mhead_GenSliceEnder (BitBucket *bbPtr);
-void	Mhead_GenMBHeader (BitBucket *bbPtr,
-	  uint32 pict_code_type, uint32 addr_incr,
+void    Mhead_GenPictureHeader (BitBucket *bbPtr, int frameType,
+                                            int pictCount, int f_code);
+void    Mhead_GenSliceHeader (BitBucket *bbPtr, uint32 slicenum,
+                                          uint32 qscale, uint8 *extra_info,
+                                          uint32 extra_info_size);
+void    Mhead_GenSliceEnder (BitBucket *bbPtr);
+void    Mhead_GenMBHeader (BitBucket *bbPtr,
+          uint32 pict_code_type, uint32 addr_incr,
           uint32 q_scale,
           uint32 forw_f_code, uint32 back_f_code,
           uint32 horiz_forw_r, uint32 vert_forw_r,
diff --git a/converter/ppm/ppmtompeg/headers/motion_search.h b/converter/ppm/ppmtompeg/headers/motion_search.h
index d00509c4..0cb5370b 100644
--- a/converter/ppm/ppmtompeg/headers/motion_search.h
+++ b/converter/ppm/ppmtompeg/headers/motion_search.h
@@ -40,7 +40,7 @@ if ( stepSize == 2 ) { \
     rightMY++;      \
     rightMX++;      \
     }
-    
+
 #define VALID_MOTION(m)   \
 (((m).y >= leftMY) && ((m).y < rightMY) &&   \
  ((m).x >= leftMX) && ((m).x < rightMX) )
@@ -50,9 +50,9 @@ if ( stepSize == 2 ) { \
  * EXTERNAL PROCEDURE prototypes *
  *===============================*/
 
-void 
+void
 SetPSearchAlg(const char * const alg);
-void 
+void
 SetBSearchAlg(const char * const alg);
 const char *
 BSearchName(void);
@@ -94,9 +94,9 @@ PTwoLevelSearch(const LumBlock * const currentBlockP,
                 int              const searchRange);
 void
 PMotionSearch(const LumBlock * const currentBlockP,
-              MpegFrame *      const prev, 
+              MpegFrame *      const prev,
               int              const by,
-              int              const bx, 
+              int              const bx,
               vector *         const motionP);
 
 void
@@ -129,7 +129,7 @@ extern int psearchAlg;
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/picasso/project/mpeg/mpeg_dist/mpeg_encode/headers/RCS/search.h,v 1.6 1995/08/15 23:43:36 smoot Exp $
  *  $Log: search.h,v $
  *  Revision 1.6  1995/08/15 23:43:36  smoot
diff --git a/converter/ppm/ppmtompeg/headers/mpeg.h b/converter/ppm/ppmtompeg/headers/mpeg.h
index fbfaaf2c..d258cde4 100644
--- a/converter/ppm/ppmtompeg/headers/mpeg.h
+++ b/converter/ppm/ppmtompeg/headers/mpeg.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * mpeg.h								     *
- *									     *
- *	no comment							     *
- *									     *
+ * mpeg.h                                                                    *
+ *                                                                           *
+ *      no comment                                                           *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -47,13 +47,13 @@ enum frameContext {CONTEXT_WHOLESTREAM, CONTEXT_GOP, CONTEXT_JUSTFRAMES};
 
 void
 GenMPEGStream(struct inputSource * const inputSourceP,
-              enum frameContext    const context, 
-              unsigned int         const frameStart, 
-              unsigned int         const frameEnd, 
-              int32                const qtable[], 
-              int32                const niqtable[], 
+              enum frameContext    const context,
+              unsigned int         const frameStart,
+              unsigned int         const frameEnd,
+              int32                const qtable[],
+              int32                const niqtable[],
               bool                 const childProcess,
-              FILE *               const ofp, 
+              FILE *               const ofp,
               const char *         const outputFileName,
               bool                 const wantVbvUnderflowWarning,
               bool                 const wantVbvOverflowWarning,
@@ -61,38 +61,38 @@ GenMPEGStream(struct inputSource * const inputSourceP,
               unsigned int *       const totalBitsP);
 
 void
-PrintStartStats(time_t               const startTime, 
+PrintStartStats(time_t               const startTime,
                 bool                 const specificFrames,
-                unsigned int         const firstFrame, 
+                unsigned int         const firstFrame,
                 unsigned int         const lastFrame,
                 struct inputSource * const inputSourceP);
 
 void
 PrintEndStats(time_t       const startTime,
               time_t       const endTime,
-              unsigned int const inputFrameBits, 
+              unsigned int const inputFrameBits,
               unsigned int const totalBits);
 
 void
-ComputeGOPFrames(int            const whichGOP, 
-                 unsigned int * const firstFrameP, 
-                 unsigned int * const lastFrameP, 
+ComputeGOPFrames(int            const whichGOP,
+                 unsigned int * const firstFrameP,
+                 unsigned int * const lastFrameP,
                  unsigned int   const numFrames);
 
-extern void	IncrementTCTime (void);
+extern void     IncrementTCTime (void);
 void SetReferenceFrameType(const char * const type);
 
 boolean
 NonLocalRefFrame(int     const id);
 
 void
-ReadDecodedRefFrame(MpegFrame *  const frameP, 
+ReadDecodedRefFrame(MpegFrame *  const frameP,
                     unsigned int const frameNumber);
 
 void
 SetBitRateFileName(const char * const fileName);
 
-extern void	SetFrameRate (void);
+extern void     SetFrameRate (void);
 
 
 /*==================*
@@ -100,11 +100,11 @@ extern void	SetFrameRate (void);
  *==================*/
 
 extern MpegFrame *frameMemory[3];
-extern int32	  tc_hrs, tc_min, tc_sec, tc_pict, tc_extra;
-extern int	  totalFramesSent;
-extern int	  gopSize;
-extern char	 *framePattern;
-extern int	  framePatternLen;
+extern int32      tc_hrs, tc_min, tc_sec, tc_pict, tc_extra;
+extern int        totalFramesSent;
+extern int        gopSize;
+extern char      *framePattern;
+extern int        framePatternLen;
 extern int32 qtable[];
 extern int32 niqtable[];
 extern int32 *customQtable;
diff --git a/converter/ppm/ppmtompeg/headers/mproto.h b/converter/ppm/ppmtompeg/headers/mproto.h
index 5b003b2e..22b3ba2b 100644
--- a/converter/ppm/ppmtompeg/headers/mproto.h
+++ b/converter/ppm/ppmtompeg/headers/mproto.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * mproto.h								     *
- *									     *
- *	basically a lot of miscellaneous prototypes			     *
- *									     *
+ * mproto.h                                                                  *
+ *                                                                           *
+ *      basically a lot of miscellaneous prototypes                          *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -26,7 +26,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/picasso/project/mm/mpeg/mpeg_dist/mpeg_encode/headers/RCS/mproto.h,v 1.12 1995/03/29 20:14:29 smoot Exp $
  *  $Log: mproto.h,v $
  * Revision 1.12  1995/03/29  20:14:29  smoot
@@ -82,7 +82,7 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
  * EXTERNAL PROCEDURE prototypes *
  *===============================*/
 
-/*  
+/*
  *  from mbasic.c:
  */
 void mp_reset (void);
@@ -90,13 +90,13 @@ void mp_free (MpegFrame *mf);
 MpegFrame *mp_new (int fnumber, char type, MpegFrame *oldFrame);
 void mp_ycc_calc (MpegFrame *mf);
 void mp_dct_blocks (MpegFrame *mf);
-void	AllocDecoded (MpegFrame *frame);
+void    AllocDecoded (MpegFrame *frame);
 
-/*  
+/*
  *  from moutput.c:
  */
 boolean mp_quant_zig_block (Block in, FlatBlock out, int qscale, int iblock);
-void	UnQuantZig (FlatBlock in, Block out, int qscale, boolean iblock);
+void    UnQuantZig (FlatBlock in, Block out, int qscale, boolean iblock);
 void mp_rle_huff_block (FlatBlock in, BitBucket *out);
 void mp_rle_huff_pblock (FlatBlock in, BitBucket *out);
 void mp_create_blocks (MpegFrame *mf);
@@ -104,12 +104,12 @@ void mp_create_blocks (MpegFrame *mf);
 
 
 
-void	ReadEYUV (MpegFrame * mf, FILE *fpointer, int width,
-			    int height);
-boolean	ReadPPM (MpegFrame *mf, FILE *fpointer);
+void    ReadEYUV (MpegFrame * mf, FILE *fpointer, int width,
+                            int height);
+boolean ReadPPM (MpegFrame *mf, FILE *fpointer);
 void PPMtoYCC (MpegFrame * mf);
 
-void	ComputeHalfPixelData (MpegFrame *frame);
+void    ComputeHalfPixelData (MpegFrame *frame);
 void mp_validate_size (int *x, int *y);
 void AllocYCC (MpegFrame * mf);
 
diff --git a/converter/ppm/ppmtompeg/headers/mtypes.h b/converter/ppm/ppmtompeg/headers/mtypes.h
index a44ce680..bf56a110 100644
--- a/converter/ppm/ppmtompeg/headers/mtypes.h
+++ b/converter/ppm/ppmtompeg/headers/mtypes.h
@@ -1,7 +1,7 @@
 /*===========================================================================*
  * mtypes.h
  *
- *	MPEG data types
+ *      MPEG data types
  *
  *===========================================================================*/
 
@@ -18,12 +18,12 @@
  * CONSTANTS *
  *===========*/
 
-#define TYPE_BOGUS	0   /* for the header of the circular list */
-#define TYPE_VIRGIN	1
+#define TYPE_BOGUS      0   /* for the header of the circular list */
+#define TYPE_VIRGIN     1
 
-#define STATUS_EMPTY	0
-#define STATUS_LOADED	1
-#define STATUS_WRITTEN	2
+#define STATUS_EMPTY    0
+#define STATUS_LOADED   1
+#define STATUS_WRITTEN  2
 
 
 typedef struct vector {
@@ -40,15 +40,15 @@ typedef struct motion {
  * TYPE DEFINITIONS *
  *==================*/
 
-/*  
+/*
  *  your basic Block type
  */
 typedef int16_t Block[DCTSIZE][DCTSIZE];
 typedef int16_t FlatBlock[DCTSIZE_SQ];
-typedef	struct {
+typedef struct {
     int32_t l[2*DCTSIZE][2*DCTSIZE];
 } LumBlock;
-typedef	int32_t ChromBlock[DCTSIZE][DCTSIZE];
+typedef int32_t ChromBlock[DCTSIZE][DCTSIZE];
 
 /*========*
  * MACROS *
diff --git a/converter/ppm/ppmtompeg/headers/opts.h b/converter/ppm/ppmtompeg/headers/opts.h
index 1756334e..887c9723 100644
--- a/converter/ppm/ppmtompeg/headers/opts.h
+++ b/converter/ppm/ppmtompeg/headers/opts.h
@@ -23,7 +23,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/picasso/project/mpeg/mpeg_dist/mpeg_encode/headers/RCS/opts.h,v 1.3 1995/08/15 23:43:43 smoot Exp $
  *  $Log: opts.h,v $
  *  Revision 1.3  1995/08/15 23:43:43  smoot
@@ -109,10 +109,10 @@ extern int LaplaceNum, LaplaceCnum;
 extern boolean BSkipBlocks;
 
 /* Procedures Prototypes */
-int	GetIQScale (void);
-int	GetPQScale (void);
-int	GetBQScale (void);
-void	Tune_Init (void);
+int     GetIQScale (void);
+int     GetPQScale (void);
+int     GetBQScale (void);
+void    Tune_Init (void);
 int     CalcRLEHuffLength (FlatBlock in);
 void    ParseTuneParam(const char * const charPtr);
 int     mse (Block blk1, Block blk2);
diff --git a/converter/ppm/ppmtompeg/headers/parallel.h b/converter/ppm/ppmtompeg/headers/parallel.h
index 0a31fac2..b5407cea 100644
--- a/converter/ppm/ppmtompeg/headers/parallel.h
+++ b/converter/ppm/ppmtompeg/headers/parallel.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * parallel.h          
- *                     
- *  parallel encoding  
- *                     
+ * parallel.h
+ *
+ *  parallel encoding
+ *
  *===========================================================================*/
 
 /*
@@ -42,33 +42,33 @@ struct inputSource;
 
 void
 MasterServer(struct inputSource * const inputSourceP,
-             const char *         const paramFileName, 
+             const char *         const paramFileName,
              const char *         const outputFileName);
 
 void
-NotifyMasterDone(const char * const hostName, 
-                 int          const portNum, 
-                 int          const machineNumber, 
-                 unsigned int const seconds, 
+NotifyMasterDone(const char * const hostName,
+                 int          const portNum,
+                 int          const machineNumber,
+                 unsigned int const seconds,
                  boolean *    const moreWorkToDoP,
                  int *        const frameStartP,
                  int *        const frameEndP);
 
 void
 IoServer(struct inputSource * const inputSourceP,
-         const char *         const parallelHostName, 
+         const char *         const parallelHostName,
          int                  const portNum);
 
 void
-CombineServer(int          const numInputFiles, 
-              const char * const masterHostName, 
+CombineServer(int          const numInputFiles,
+              const char * const masterHostName,
               int          const masterPortNum,
               const char*  const outputFileName);
 
 void
-DecodeServer(int          const numInputFiles, 
-             const char * const decodeFileName, 
-             const char * const parallelHostName, 
+DecodeServer(int          const numInputFiles,
+             const char * const decodeFileName,
+             const char * const parallelHostName,
              int          const portNum);
 
 void
@@ -91,20 +91,20 @@ SetIOConvert(boolean const separate);
 void
 SetRemoteShell(const char * const shell);
 
-void 
+void
 NotifyDecodeServerReady(int const id);
 
-void 
+void
 WaitForDecodedFrame(int id);
 
-void 
+void
 SendDecodedFrame(MpegFrame * const frameP);
 
-void 
+void
 GetRemoteDecodedRefFrame(MpegFrame * const frameP,
                          int         const frameNumber);
 
-void 
+void
 SetParallelPerfect(boolean val);
 
 
diff --git a/converter/ppm/ppmtompeg/headers/param.h b/converter/ppm/ppmtompeg/headers/param.h
index 46a544b3..103f03b5 100644
--- a/converter/ppm/ppmtompeg/headers/param.h
+++ b/converter/ppm/ppmtompeg/headers/param.h
@@ -33,7 +33,7 @@ struct params {
 
 
 void
-ReadParamFile(const char *         const fileName, 
+ReadParamFile(const char *         const fileName,
               majorProgramFunction const function,
               struct params *      const paramP);
 
diff --git a/converter/ppm/ppmtompeg/headers/postdct.h b/converter/ppm/ppmtompeg/headers/postdct.h
index 3f3b51fe..e426f05a 100644
--- a/converter/ppm/ppmtompeg/headers/postdct.h
+++ b/converter/ppm/ppmtompeg/headers/postdct.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * postdct.h								     *
- *									     *
- *	MPEG post-DCT processing					     *
- *									     *
+ * postdct.h                                                                 *
+ *                                                                           *
+ *      MPEG post-DCT processing                                             *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -30,10 +30,10 @@
 
 
 int     Mpost_QuantZigBlock (Block in, FlatBlock out, int qscale, int iblock);
-void	Mpost_UnQuantZigBlock (FlatBlock in, Block out,
+void    Mpost_UnQuantZigBlock (FlatBlock in, Block out,
                                int qscale, boolean iblock);
-void	Mpost_RLEHuffIBlock (FlatBlock in, BitBucket *out);
-void	Mpost_RLEHuffPBlock (FlatBlock in, BitBucket *out);
+void    Mpost_RLEHuffIBlock (FlatBlock in, BitBucket *out);
+void    Mpost_RLEHuffPBlock (FlatBlock in, BitBucket *out);
 
 #define MPOST_ZERO 0
 #define MPOST_NON_ZERO 1
diff --git a/converter/ppm/ppmtompeg/headers/psocket.h b/converter/ppm/ppmtompeg/headers/psocket.h
index 214f5dce..26e11db2 100644
--- a/converter/ppm/ppmtompeg/headers/psocket.h
+++ b/converter/ppm/ppmtompeg/headers/psocket.h
@@ -22,8 +22,8 @@ WriteBytes(int             const fd,
            unsigned int    const nbyte);
 
 void
-ConnectToSocket(const char *      const machineName, 
-                int               const portNum, 
+ConnectToSocket(const char *      const machineName,
+                int               const portNum,
                 struct hostent ** const hostEnt,
                 int *             const socketFdP,
                 const char **     const errorP);
diff --git a/converter/ppm/ppmtompeg/headers/rate.h b/converter/ppm/ppmtompeg/headers/rate.h
index a5f5076f..d11a4b77 100644
--- a/converter/ppm/ppmtompeg/headers/rate.h
+++ b/converter/ppm/ppmtompeg/headers/rate.h
@@ -1,22 +1,22 @@
 /*===========================================================================*
- * rate.h								     *
- *									     *
- *	Procedures concerned with rate control
- *									     *
- * EXPORTED PROCEDURES:							     *
+ * rate.h                                                                    *
+ *                                                                           *
+ *      Procedures concerned with rate control
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
  *  getRateMode()
  *  setBitRate()
  *  getBitRate()
  *  setBufferSize()
  *  getBufferSize()
- *	initRateControl()
- *	targetRateControl()
- * 	updateRateControl()
- *	MB_RateOut()
- *									     *
+ *      initRateControl()
+ *      targetRateControl()
+ *      updateRateControl()
+ *      MB_RateOut()
+ *                                                                           *
  *===========================================================================*/
 
-/* 	COPYRIGHT INFO HERE	*/
+/*      COPYRIGHT INFO HERE     */
 
 #define VARIABLE_RATE 0
 #define FIXED_RATE 1
@@ -41,7 +41,7 @@ extern int rc_quantOverride;
  *
  * initRateControl
  *
- *	initialize the allocation parameters.
+ *      initialize the allocation parameters.
  *===========================================================================*/
 int
 initRateControl(bool const wantUnderflowWarning,
@@ -64,7 +64,7 @@ targetRateControl(MpegFrame * const frameP);
  * MB_RateOut
  *
  *      Prints out sampling of MB rate control data.  Every "nth" block
- *	stats are printed, with "n" controlled by global RC_MB_SAMPLE_RATE
+ *      stats are printed, with "n" controlled by global RC_MB_SAMPLE_RATE
  *
  * RETURNS:     nothing
  *===========================================================================*/
@@ -137,7 +137,7 @@ extern void SetRateControl (char *charPtr);
  *
  * RETURNS:     nothing
  *===========================================================================*/
-extern void 
+extern void
 setBufferSize(const char * const charPtr);
 
 
@@ -164,7 +164,7 @@ extern int getBufferSize (void);
  *
  * SIDE EFFECTS:   global variables
  *===========================================================================*/
-extern void 
+extern void
 setBitRate(const char * const charPtr);
 
 
diff --git a/converter/ppm/ppmtompeg/headers/readframe.h b/converter/ppm/ppmtompeg/headers/readframe.h
index 3a6876b1..3c203e8a 100644
--- a/converter/ppm/ppmtompeg/headers/readframe.h
+++ b/converter/ppm/ppmtompeg/headers/readframe.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * readframe.h								     *
- *									     *
- *	stuff dealing with reading frames				     *
- *									     *
+ * readframe.h                                                               *
+ *                                                                           *
+ *      stuff dealing with reading frames                                    *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -32,15 +32,15 @@
  * CONSTANTS *
  *===========*/
 
-#define	PPM_FILE_TYPE	    0
-#define YUV_FILE_TYPE	    2
-#define ANY_FILE_TYPE	    3
-#define BASE_FILE_TYPE	    4
-#define PNM_FILE_TYPE	    5
-#define SUB4_FILE_TYPE	    6
-#define JPEG_FILE_TYPE	    7
+#define PPM_FILE_TYPE       0
+#define YUV_FILE_TYPE       2
+#define ANY_FILE_TYPE       3
+#define BASE_FILE_TYPE      4
+#define PNM_FILE_TYPE       5
+#define SUB4_FILE_TYPE      6
+#define JPEG_FILE_TYPE      7
 #define JMOVIE_FILE_TYPE    8
-#define Y_FILE_TYPE	    9
+#define Y_FILE_TYPE         9
 
 
 struct inputSource;
@@ -52,7 +52,7 @@ ReadFrameFile(MpegFrame *  const frameP,
               bool *       const eofP);
 
 void
-ReadFrame(MpegFrame *          const frameP, 
+ReadFrame(MpegFrame *          const frameP,
           struct inputSource * const inputSourceP,
           unsigned int         const frameNumber,
           const char *         const conversion,
@@ -62,8 +62,8 @@ FILE *
 ReadIOConvert(struct inputSource * const inputSourceP,
               unsigned int         const frameNumber);
 
-extern void	SetFileType(const char * const conversion);
-extern void	SetFileFormat(const char * const format);
-extern void	SetResize(bool const set);
+extern void     SetFileType(const char * const conversion);
+extern void     SetFileFormat(const char * const format);
+extern void     SetResize(bool const set);
 
-extern int	baseFormat;
+extern int      baseFormat;
diff --git a/converter/ppm/ppmtompeg/headers/rgbtoycc.h b/converter/ppm/ppmtompeg/headers/rgbtoycc.h
index 52159963..d7aa017c 100644
--- a/converter/ppm/ppmtompeg/headers/rgbtoycc.h
+++ b/converter/ppm/ppmtompeg/headers/rgbtoycc.h
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * rgbtoycc.h								     *
- *									     *
- *	Procedures to convert from RGB space to YUV space		     *
- *									     *
+ * rgbtoycc.h                                                                *
+ *                                                                           *
+ *      Procedures to convert from RGB space to YUV space                    *
+ *                                                                           *
  *===========================================================================*/
 
 /*
diff --git a/converter/ppm/ppmtompeg/headers/specifics.h b/converter/ppm/ppmtompeg/headers/specifics.h
index 4f5c7074..552193d8 100644
--- a/converter/ppm/ppmtompeg/headers/specifics.h
+++ b/converter/ppm/ppmtompeg/headers/specifics.h
@@ -1,5 +1,3 @@
-
-
 /*===========*
  * TYPES     *
  *===========*/
@@ -19,7 +17,7 @@ typedef struct detail_def {
 }  Slice_Specifics;
 
 typedef struct fsl_def {
-  int framenum; 
+  int framenum;
   int frametype;
   char qscale;
   Slice_Specifics *slc;
@@ -28,8 +26,8 @@ typedef struct fsl_def {
 } FrameSpecList;
 
 
-void	Specifics_Init (void);
+void    Specifics_Init (void);
 int     SpecLookup (int fn, int typ, int num,
-			    BlockMV **info, int start_qs);
+                            BlockMV **info, int start_qs);
 int SpecTypeLookup (int fn);
 
diff --git a/converter/ppm/ppmtompeg/huff.c b/converter/ppm/ppmtompeg/huff.c
index f2be16ef..565a2f0e 100644
--- a/converter/ppm/ppmtompeg/huff.c
+++ b/converter/ppm/ppmtompeg/huff.c
@@ -19,24 +19,38 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/charlie-brown/project/mm/mpeg/mpeg_dist/mpeg_encode/RCS/huff.c,v 1.6 1995/01/19 23:07:39 eyhung Exp $
  */
 
-/*  
+/*
  *  THIS FILE WAS ORIGINALLY MACHINE GENERATED
  */
 #include "general.h"
 #include "mtypes.h"
 #include "huff.h"
 
-int huff_maxlevel[32] = { 41, 19, 6, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
+int huff_maxlevel[32] = { 41, 19, 6, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
+                           3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+                           2, 2, 2 };
+
+uint32 huff_table0[41] = { 0x0, 0x6, 0x8, 0xa, 0xc, 0x4c, 0x42, 0x14,
+                           0x3a, 0x30, 0x26, 0x20, 0x34, 0x32, 0x30,
+                           0x2e, 0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34,
+                           0x32, 0x30, 0x2e, 0x2c, 0x2a, 0x28, 0x26,
+                           0x24, 0x22, 0x20, 0x30, 0x2e, 0x2c, 0x2a,
+                           0x28, 0x26, 0x24, 0x22, 0x20 };
+
+int huff_bits0[41] = { 0, 3, 5, 6, 8, 9, 9, 11, 13, 13, 13, 13, 14, 14,
+                      14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+                      15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16 };
 
-uint32 huff_table0[41] = { 0x0, 0x6, 0x8, 0xa, 0xc, 0x4c, 0x42, 0x14, 0x3a, 0x30, 0x26, 0x20, 0x34, 0x32, 0x30, 0x2e, 0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20, 0x30, 0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20 };
-int huff_bits0[41] = { 0, 3, 5, 6, 8, 9, 9, 11, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16 };
+uint32 huff_table1[19] = { 0x0, 0x6, 0xc, 0x4a, 0x18, 0x36, 0x2c,
+                          0x2a, 0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34,
+                          0x32, 0x26, 0x24, 0x22, 0x20 };
 
-uint32 huff_table1[19] = { 0x0, 0x6, 0xc, 0x4a, 0x18, 0x36, 0x2c, 0x2a, 0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x26, 0x24, 0x22, 0x20 };
-int huff_bits1[19] = { 0, 4, 7, 9, 11, 13, 14, 14, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17 };
+int huff_bits1[19] = { 0, 4, 7, 9, 11, 13, 14, 14, 16, 16, 16, 16, 16,
+                      16, 16, 17, 17, 17, 17 };
 
 uint32 huff_table2[6] = { 0x0, 0xa, 0x8, 0x16, 0x28, 0x28 };
 int huff_bits2[6] = { 0, 5, 8, 11, 13, 14 };
@@ -128,5 +142,18 @@ int huff_bits30[2] = { 0, 17 };
 uint32 huff_table31[2] = { 0x0, 0x36 };
 int huff_bits31[2] = { 0, 17 };
 
-uint32 *huff_table[32] = { huff_table0, huff_table1, huff_table2, huff_table3, huff_table4, huff_table5, huff_table6, huff_table7, huff_table8, huff_table9, huff_table10, huff_table11, huff_table12, huff_table13, huff_table14, huff_table15, huff_table16, huff_table17, huff_table18, huff_table19, huff_table20, huff_table21, huff_table22, huff_table23, huff_table24, huff_table25, huff_table26, huff_table27, huff_table28, huff_table29, huff_table30, huff_table31 };
-int *huff_bits[32] = { huff_bits0, huff_bits1, huff_bits2, huff_bits3, huff_bits4, huff_bits5, huff_bits6, huff_bits7, huff_bits8, huff_bits9, huff_bits10, huff_bits11, huff_bits12, huff_bits13, huff_bits14, huff_bits15, huff_bits16, huff_bits17, huff_bits18, huff_bits19, huff_bits20, huff_bits21, huff_bits22, huff_bits23, huff_bits24, huff_bits25, huff_bits26, huff_bits27, huff_bits28, huff_bits29, huff_bits30, huff_bits31 };
+uint32 *huff_table[32] = { huff_table0, huff_table1, huff_table2,
+    huff_table3, huff_table4, huff_table5, huff_table6, huff_table7,
+    huff_table8, huff_table9, huff_table10, huff_table11, huff_table12,
+    huff_table13, huff_table14, huff_table15, huff_table16, huff_table17,
+    huff_table18, huff_table19, huff_table20, huff_table21, huff_table22,
+    huff_table23, huff_table24, huff_table25, huff_table26, huff_table27,
+    huff_table28, huff_table29, huff_table30, huff_table31 };
+
+int *huff_bits[32] = { huff_bits0, huff_bits1, huff_bits2, huff_bits3,
+    huff_bits4, huff_bits5, huff_bits6, huff_bits7, huff_bits8, huff_bits9,
+    huff_bits10, huff_bits11, huff_bits12, huff_bits13, huff_bits14,
+    huff_bits15, huff_bits16, huff_bits17, huff_bits18, huff_bits19,
+    huff_bits20, huff_bits21, huff_bits22, huff_bits23, huff_bits24,
+    huff_bits25, huff_bits26, huff_bits27, huff_bits28, huff_bits29,
+    huff_bits30, huff_bits31 };
diff --git a/converter/ppm/ppmtompeg/iframe.c b/converter/ppm/ppmtompeg/iframe.c
index 66f5ea3b..81ff0ec0 100644
--- a/converter/ppm/ppmtompeg/iframe.c
+++ b/converter/ppm/ppmtompeg/iframe.c
@@ -239,7 +239,7 @@ void
 SetBlocksPerSlice(void) {
 
     int     totalBlocks;
-    
+
     totalBlocks = (Fsize_y>>4)*(Fsize_x>>4);
 
     if ( slicesPerFrame > totalBlocks ) {
@@ -296,7 +296,7 @@ CalcDistortion(MpegFrame * const current,
     Block decblk;
     FlatBlock fblk;
     int datarate = 0;
-  
+
     for (qscale = 1; qscale < 32; qscale ++) {
         distort = 0;
         datarate = 0;
@@ -361,7 +361,7 @@ CalcDistortion(MpegFrame * const current,
  *
  *===========================================================================*/
 void
-GenIFrame(BitBucket * const bb, 
+GenIFrame(BitBucket * const bb,
           MpegFrame * const current) {
 
     int x, y;
@@ -391,25 +391,25 @@ GenIFrame(BitBucket * const bb,
             lastIFrame = current->id;
         } else {
             /* ASSUMES 30 FRAMES PER SECOND */
-    
+
             if (! realQuiet) {
                 fprintf(stdout, "I-to-I (frames %5d to %5d) bitrate:  %8d\n",
                         lastIFrame, current->id-1,
                         ((bb->cumulativeBits-lastNumBits)*30)/
                         (current->id-lastIFrame));
             }
-    
+
             fprintf(bitRateFile, "I-to-I (frames %5d to %5d) bitrate:  %8d\n",
                     lastIFrame, current->id-1,
                     ((bb->cumulativeBits-lastNumBits)*30)/
                     (current->id-lastIFrame));
-            lastNumBits = bb->cumulativeBits;       
+            lastNumBits = bb->cumulativeBits;
             lastIFrame = current->id;
         }
     }
-    
+
     startTime = time_elapsed();
-    
+
     Frame_AllocBlocks(current);
     BlockifyFrame(current);
 
@@ -435,13 +435,13 @@ GenIFrame(BitBucket * const bb,
         }
     }
     Mhead_GenSliceHeader(bb, 1, QScale, NULL, 0);
-    
+
     if ( referenceFrame == DECODED_FRAME ) {
         Frame_AllocDecoded(current, TRUE);
     } else if ( printSNR ) {
         Frame_AllocDecoded(current, FALSE);
     }
-    
+
     y_dc_pred = cr_dc_pred = cb_dc_pred = 128;
     totalBits = bb->cumulativeBits;
     mbAddress = 0;
@@ -449,24 +449,24 @@ GenIFrame(BitBucket * const bb,
     /* DCT the macroblocks */
     for (y = 0;  y < (Fsize_y >> 3);  y += 2) {
         for (x = 0;  x < (Fsize_x >> 3);  x += 2) {
-            if (collect_quant && (collect_quant_detailed & 1)) 
+            if (collect_quant && (collect_quant_detailed & 1))
                 fprintf(collect_quant_fp, "l\n");
             if (DoLaplace) {LaplaceCnum = 0;}
             mp_fwd_dct_block2(current->y_blocks[y][x], dct[y][x]);
             mp_fwd_dct_block2(current->y_blocks[y][x+1], dct[y][x+1]);
             mp_fwd_dct_block2(current->y_blocks[y+1][x], dct[y+1][x]);
             mp_fwd_dct_block2(current->y_blocks[y+1][x+1], dct[y+1][x+1]);
-            if (collect_quant && (collect_quant_detailed & 1)) 
+            if (collect_quant && (collect_quant_detailed & 1))
                 fprintf(collect_quant_fp, "c\n");
             if (DoLaplace) {LaplaceCnum = 1;}
-            mp_fwd_dct_block2(current->cb_blocks[y>>1][x>>1], 
+            mp_fwd_dct_block2(current->cb_blocks[y>>1][x>>1],
                               dctb[y>>1][x>>1]);
             if (DoLaplace) {LaplaceCnum = 2;}
-            mp_fwd_dct_block2(current->cr_blocks[y>>1][x>>1], 
+            mp_fwd_dct_block2(current->cr_blocks[y>>1][x>>1],
                               dctr[y>>1][x>>1]);
         }
     }
-    
+
     if (DoLaplace)
         CalcLambdas();
 
@@ -474,13 +474,13 @@ GenIFrame(BitBucket * const bb,
         for (x = 0;  x < (Fsize_x >> 3);  x += 2) {
             /* Check for Qscale change */
             if (specificsOn) {
-                newQScale = 
+                newQScale =
                     SpecLookup(current->id, 2, mbAddress, &info, QScale);
                 if (newQScale != -1) {
                     QScale = newQScale;
                 }
             }
-    
+
             /*  Determine if new Qscale needed for Rate Control purposes  */
             if (bitstreamMode == FIXED_RATE) {
                 rc_blockStart = bb->cumulativeBits;
@@ -493,20 +493,20 @@ GenIFrame(BitBucket * const bb,
                     QScale = newQScale;
                 }
             }
-    
+
             if ( (mbAddress % blocksPerSlice == 0) && (mbAddress != 0) ) {
                 /* create a new slice */
                 if (specificsOn) {
                     /* Make sure no slice Qscale change */
                     newQScale = SpecLookup(current->id, 1,
-                                           mbAddress/blocksPerSlice, &info, 
+                                           mbAddress/blocksPerSlice, &info,
                                            QScale);
                     if (newQScale != -1) QScale = newQScale;
                 }
                 Mhead_GenSliceEnder(bb);
                 Mhead_GenSliceHeader(bb, 1+(y>>1), QScale, NULL, 0);
                 y_dc_pred = cr_dc_pred = cb_dc_pred = 128;
-      
+
                 GEN_I_BLOCK(I_FRAME, current, bb, 1+(x>>1), QScale);
             } else {
                 GEN_I_BLOCK(I_FRAME, current, bb, 1, QScale);
@@ -515,23 +515,23 @@ GenIFrame(BitBucket * const bb,
             if (WriteDistortionNumbers) {
                 CalcDistortion(current, y, x);
             }
-    
+
             if ( decodeRefFrames ) {
                 /* now, reverse the DCT transform */
                 LaplaceCnum = 0;
                 for ( index = 0; index < 6; index++ ) {
                     if (!DoLaplace) {
-                        Mpost_UnQuantZigBlock(fb[index], dec[index], QScale, 
+                        Mpost_UnQuantZigBlock(fb[index], dec[index], QScale,
                                               TRUE);
                     } else {
                         if (index == 4) {LaplaceCnum = 1;}
                         if (index == 5) {LaplaceCnum = 2;}
-                        Mpost_UnQuantZigBlockLaplace(fb[index], dec[index], 
+                        Mpost_UnQuantZigBlockLaplace(fb[index], dec[index],
                                                      QScale, TRUE);
                     }
-                    mpeg_jrevdct((int16 *)dec[index]);      
+                    mpeg_jrevdct((int16 *)dec[index]);
                 }
-      
+
                 /* now, unblockify */
                 BlockToData(current->decoded_y, dec[0], y, x);
                 BlockToData(current->decoded_y, dec[1], y, x+1);
@@ -540,7 +540,7 @@ GenIFrame(BitBucket * const bb,
                 BlockToData(current->decoded_cb, dec[4], y>>1, x>>1);
                 BlockToData(current->decoded_cr, dec[5], y>>1, x>>1);
             }
-    
+
             numBlocks++;
             mbAddress++;
             /*   Rate Control */
@@ -551,43 +551,43 @@ GenIFrame(BitBucket * const bb,
             }
         }
     }
-    
+
     if ( printSNR ) {
         BlockComputeSNR(current,snr,psnr);
         totalSNR += snr[0];
         totalPSNR += psnr[0];
     }
-    
+
     numBits += (bb->cumulativeBits-totalBits);
-    
+
     DBG_PRINT(("End of frame\n"));
-    
+
     Mhead_GenSliceEnder(bb);
     /*   Rate Control  */
     if (bitstreamMode == FIXED_RATE) {
         updateRateControl(TYPE_IFRAME);
     }
-    
+
     endTime = time_elapsed();
     totalTime += (endTime-startTime);
-    
+
     numFrameBits += (bb->cumulativeBits-totalFrameBits);
-    
+
     if ( showBitRatePerFrame ) {
         /* ASSUMES 30 FRAMES PER SECOND */
         fprintf(bitRateFile, "%5d\t%8d\n", current->id,
                 30*(bb->cumulativeBits-totalFrameBits));
     }
-    
+
     if ( frameSummary && !realQuiet ) {
-        
+
         /* ASSUMES 30 FRAMES PER SECOND */
-        fprintf(stdout, 
-                "FRAME %d (I):  %ld seconds  (%d bits/s output)\n", 
+        fprintf(stdout,
+                "FRAME %d (I):  %ld seconds  (%d bits/s output)\n",
                 current->id, (long)((endTime-startTime)/TIME_RATE),
                 30*(bb->cumulativeBits-totalFrameBits));
         if ( printSNR ) {
-            fprintf(stdout, 
+            fprintf(stdout,
                     "FRAME %d:  SNR:  %.1f\t%.1f\t%.1f\t"
                     "PSNR:  %.1f\t%.1f\t%.1f\n",
                         current->id, snr[0], snr[1], snr[2],
@@ -628,8 +628,8 @@ IFrameTotalTime(void) {
 
 
 void
-ShowIFrameSummary(unsigned int const inputFrameBits, 
-                  unsigned int const totalBits, 
+ShowIFrameSummary(unsigned int const inputFrameBits,
+                  unsigned int const totalBits,
                   FILE *       const fpointer) {
 /*----------------------------------------------------------------------------
    Print out statistics on all I frames.
@@ -697,12 +697,12 @@ EncodeYDC(int32       const dc_term,
 
     ydiff = (dc_term - (*pred_term));
     if (ydiff > 255) {
-#ifdef BLEAH 
+#ifdef BLEAH
       fprintf(stdout, "TRUNCATED\n");
 #endif
     ydiff = 255;
     } else if (ydiff < -255) {
-#ifdef BLEAH 
+#ifdef BLEAH
       fprintf(stdout, "TRUNCATED\n");
 #endif
     ydiff = -255;
@@ -753,12 +753,12 @@ EncodeCDC(int32       const dc_term,
     cdiff = (dc_term - (*pred_term));
     if (cdiff > 255) {
 #ifdef BLEAH
-        fprintf(stdout, "TRUNCATED\n"); 
+        fprintf(stdout, "TRUNCATED\n");
 #endif
         cdiff = 255;
     } else if (cdiff < -255) {
 #ifdef BLEAH
-        fprintf(stdout, "TRUNCATED\n"); 
+        fprintf(stdout, "TRUNCATED\n");
 #endif
         cdiff = -255;
     }
@@ -789,21 +789,21 @@ BlockComputeSNR(MpegFrame * const current,
     int32 varDiff[3];
     double    ratio[3];
     double    total[3];
-    uint8 **origY=current->orig_y, **origCr=current->orig_cr, 
+    uint8 **origY=current->orig_y, **origCr=current->orig_cr,
         **origCb=current->orig_cb;
-    uint8 **newY=current->decoded_y, **newCr=current->decoded_cr, 
+    uint8 **newY=current->decoded_y, **newCr=current->decoded_cr,
         **newCb=current->decoded_cb;
     static int32       **SignalY,  **NoiseY;
     static int32       **SignalCb, **NoiseCb;
     static int32       **SignalCr, **NoiseCr;
     static short   ySize[3], xSize[3];
     static boolean needs_init=TRUE;
-  
+
     /* Init */
     if (needs_init) {
         int ysz = (Fsize_y>>3) * sizeof(int32 *);
         int xsz = (Fsize_x>>3);
-    
+
         needs_init = FALSE;
         for (y=0; y<3; y++) {
             varDiff[y] = ratio[y] = total[y] = 0.0;
@@ -817,7 +817,7 @@ BlockComputeSNR(MpegFrame * const current,
         NoiseCb  = (int32 **) malloc(ysz);
         SignalCr = (int32 **) malloc(ysz);
         NoiseCr  = (int32 **) malloc(ysz);
-        if (SignalY == NULL || NoiseY == NULL || SignalCr == NULL || 
+        if (SignalY == NULL || NoiseY == NULL || SignalCr == NULL ||
             NoiseCb == NULL || SignalCb == NULL || NoiseCr == NULL) {
             fprintf(stderr, "Out of memory in BlockComputeSNR\n");
             exit(-1);
@@ -840,7 +840,7 @@ BlockComputeSNR(MpegFrame * const current,
             memset((char *) &SignalCr[y][0], 0, (xSize[0]>>3) * 4);
         }
     }
-  
+
     /* find all the signal and noise */
     for (y = 0; y < ySize[0]; y++) {
         for (x = 0; x < xSize[0]; x++) {
@@ -863,7 +863,7 @@ BlockComputeSNR(MpegFrame * const current,
             tempInt = origCr[y][x];
             SignalCr[y>>3][x>>3] += tempInt*tempInt;
         }}
-  
+
     /* Now sum up that noise */
     for(y=0; y<Fsize_y>>4; y++){
         for(x=0; x<Fsize_x>>4; x++){
@@ -874,7 +874,7 @@ BlockComputeSNR(MpegFrame * const current,
         }
         if (printMSE) puts("");
     }
-  
+
     /* Now look at those ratios! */
     for(y=0; y<Fsize_y>>4; y++){
         for(x=0; x<Fsize_x>>4; x++){
@@ -882,7 +882,7 @@ BlockComputeSNR(MpegFrame * const current,
             ratio[1] += (double)SignalCb[y][x]/(double)varDiff[1];
             ratio[2] += (double)SignalCr[y][x]/(double)varDiff[2];
         }}
-  
+
     for (x=0; x<3; x++) {
         snr[x] = 10.0 * log10(ratio[x]);
         psnr[x] = 20.0 * log10(255.0/sqrt((double)varDiff[x]/
diff --git a/converter/ppm/ppmtompeg/input.c b/converter/ppm/ppmtompeg/input.c
index 4266d39b..e12b0d4c 100644
--- a/converter/ppm/ppmtompeg/input.c
+++ b/converter/ppm/ppmtompeg/input.c
@@ -1,16 +1,16 @@
 /*===========================================================================*
- * input.c              
- *                      
+ * input.c
+ *
  *  Stuff for getting the raw frame input for the program
- *                                    
+ *
  *===========================================================================*/
 
 /* COPYRIGHT INFORMATION IS AT THE END OF THIS FILE */
 
 #define _XOPEN_SOURCE 1
-    /* This makes sure popen() is in stdio.h.  In GNU libc 2.1.3, 
+    /* This makes sure popen() is in stdio.h.  In GNU libc 2.1.3,
      _POSIX_C_SOURCE = 2 is sufficient, but on AIX 4.3, the higher level
-     _XOPEN_SOURCE is required.  2000.09.09 
+     _XOPEN_SOURCE is required.  2000.09.09
     */
 
 
@@ -31,7 +31,7 @@
 #include "jpeg.h"
 #include "input.h"
 
-extern boolean realQuiet;	/* TRUE = no messages to stdout */
+extern boolean realQuiet;       /* TRUE = no messages to stdout */
 
 struct InputFileEntry {
     char    left[256];
@@ -57,11 +57,11 @@ GetNthInputFileName(struct inputSource * const inputSourceP,
 /*----------------------------------------------------------------------------
    Return the file name of the Nth input file.
 -----------------------------------------------------------------------------*/
-    static int	lastN = 0, lastMapN = 0, lastSoFar = 0;
-    int	    mapN;
+    static int  lastN = 0, lastMapN = 0, lastSoFar = 0;
+    int     mapN;
     int     index;
-    int	    soFar;
-    int	    numPadding;
+    int     soFar;
+    int     numPadding;
     struct InputFileEntry * mapNEntryP;
 
     assert(!inputSourceP->stdinUsed);
@@ -84,7 +84,7 @@ GetNthInputFileName(struct inputSource * const inputSourceP,
     }
 
     mapN = index;
-    
+
     mapNEntryP = inputSourceP->inputFileEntries[mapN];
 
     index = mapNEntryP->startID + mapNEntryP->skip*(n - soFar);
@@ -93,7 +93,7 @@ GetNthInputFileName(struct inputSource * const inputSourceP,
 
     if (numPadding != -1) {
         char    numBuffer[33];
-        int	    loop;
+        int         loop;
 
         sprintf(numBuffer, "%32d", index);
         for (loop = 32-numPadding; loop < 32; ++loop) {
@@ -159,26 +159,26 @@ ReadNthFrame(struct inputSource * const inputSourceP,
 void
 JM2JPEG(struct inputSource * const inputSourceP) {
     char full_path[1024];
-    char inter_file[1024]; 
+    char inter_file[1024];
     int ci;
-    
+
     for(ci = 0; ci < inputSourceP->numInputFileEntries; ci++) {
         inter_file[0] = '\0';
         full_path[0] = '\0';
         strcpy(full_path, currentPath);
-    
+
         if (!inputSource.stdinUsed) {
             strcat(full_path, "/");
             strcat(full_path, inputSourceP->inputFileEntries[ci]->left);
             strcpy(inter_file,full_path);
-    
+
             if (!realQuiet)
                 fprintf(stdout, "Extracting JPEG's in the JMOVIE from %s\n",
                         full_path);
-    
+
             JMovie2JPEG(full_path,
                         inter_file,
-                        inputSourceP->inputFileEntries[ci]->startID, 
+                        inputSourceP->inputFileEntries[ci]->startID,
                         inputSourceP->inputFileEntries[ci]->endID);
         } else
             pm_error("ERROR: Cannot use JMovie format on Standard Input");
@@ -200,7 +200,7 @@ SkipSpacesTabs(const char * const start) {
 
 
 static void
-processGlob(const char *            const input, 
+processGlob(const char *            const input,
             struct InputFileEntry * const inputFileEntryP) {
 
     const char *globPtr;
@@ -208,10 +208,10 @@ processGlob(const char *            const input,
     char    left[256], right[256];
     char    leftNumText[256], rightNumText[256];
     char    skipNumText[256];
-    int	    leftNum, rightNum;
-    int	    skipNum;
+    int     leftNum, rightNum;
+    int     skipNum;
     boolean padding;
-    int	    numPadding = 0;
+    int     numPadding = 0;
 
     inputFileEntryP->glob = TRUE;
     inputFileEntryP->repeat = FALSE;
@@ -229,13 +229,13 @@ processGlob(const char *            const input,
     *charPtr = '\0';
 
     if (*globPtr == '\0') {
-        fprintf(stderr, 
+        fprintf(stderr,
                 "WARNING: expanding non-star regular expression\n");
         inputFileEntryP->repeat = TRUE;
         globPtr = input;
         charPtr = left;
         /* recopy left of whitespace */
-        while ( (*globPtr != '\0') && (*globPtr != '*') && 
+        while ( (*globPtr != '\0') && (*globPtr != '*') &&
                 (*globPtr != ' ')  && (*globPtr != '\t')) {
             *charPtr = *globPtr;
             charPtr++;
@@ -256,11 +256,11 @@ processGlob(const char *            const input,
         }
         *charPtr = '\0';
     }
-      
+
     globPtr = SkipSpacesTabs(globPtr);
 
     if ( *globPtr != '[' ) {
-        fprintf(stderr, 
+        fprintf(stderr,
                 "ERROR:  "
                 "Invalid input file expansion expression (no '[')\n");
         exit(1);
@@ -277,7 +277,7 @@ processGlob(const char *            const input,
     *charPtr = '\0';
 
     if ( *globPtr != '-' ) {
-        fprintf(stderr, 
+        fprintf(stderr,
                 "ERROR:  "
                 "Invalid input file expansion expression (no '-')\n");
         exit(1);
@@ -293,7 +293,7 @@ processGlob(const char *            const input,
     }
     *charPtr = '\0';
     if ( atoi(rightNumText) < atoi(leftNumText) ) {
-        fprintf(stderr, 
+        fprintf(stderr,
                 "ERROR:  "
                 "Beginning of input range is higher than end.\n");
         exit(1);
@@ -302,7 +302,7 @@ processGlob(const char *            const input,
 
     if ( *globPtr != ']' ) {
         if ( *globPtr != '+' ) {
-            fprintf(stderr, 
+            fprintf(stderr,
                     "ERROR:  "
                     "Invalid input file expansion expression "
                     "(no ']')\n");
@@ -320,7 +320,7 @@ processGlob(const char *            const input,
         *charPtr = '\0';
 
         if ( *globPtr != ']' ) {
-            fprintf(stderr, 
+            fprintf(stderr,
                     "ERROR:  Invalid input file expansion expression "
                     "(no ']')\n");
             exit(1);
@@ -344,7 +344,7 @@ processGlob(const char *            const input,
     inputFileEntryP->startID = leftNum;
     inputFileEntryP->endID = rightNum;
     inputFileEntryP->skip = skipNum;
-    inputFileEntryP->numFiles = 
+    inputFileEntryP->numFiles =
         (rightNum-leftNum+1)/skipNum;
     strcpy(inputFileEntryP->left, left);
     strcpy(inputFileEntryP->right, right);
@@ -357,7 +357,7 @@ processGlob(const char *            const input,
 
 
 
-static void processJmovie(const char *            const input, 
+static void processJmovie(const char *            const input,
                           struct InputFileEntry * const inputFileEntryP) {
     FILE    *jmovie;
     char    full_path[1024];
@@ -365,19 +365,19 @@ static void processJmovie(const char *            const input,
     inputFileEntryP->glob = TRUE;
     full_path[0] = '\0';
     strcpy(full_path, currentPath);
-    
+
     strcat(full_path, "/");
     strcat(full_path, input);
-    jmovie = fopen(input, "rb"); 
-    
+    jmovie = fopen(input, "rb");
+
     if (jmovie == NULL) {
-        perror (input); 
+        perror (input);
         exit (1);
     }
-    
+
     fseek (jmovie, (8*sizeof(char)), 0);
     fseek (jmovie, (2*sizeof(int)), 1);
-    
+
     if (fread(&(inputFileEntryP->numFiles),
               sizeof(int), 1, jmovie) != 1) {
         perror ("Error in reading number of frames in JMOVIE");
@@ -391,11 +391,11 @@ static void processJmovie(const char *            const input,
     inputFileEntryP->endID = (inputFileEntryP->numFiles-1);
     inputFileEntryP->skip = 1;
     if (! realQuiet) {
-        fprintf (stdout, 
-                 "Encoding all %d frames from JMOVIE.\n", 
+        fprintf (stdout,
+                 "Encoding all %d frames from JMOVIE.\n",
                  inputFileEntryP->endID);
     }
-} 
+}
 
 
 
@@ -428,19 +428,19 @@ AddInputFiles(struct inputSource * const inputSourceP,
     if (currentIndex >= inputSourceP->ifArraySize) {
         /* Get more space */
         inputSourceP->ifArraySize += INPUT_ENTRY_BLOCK_SIZE;
-        REALLOCARRAY_NOFAIL(inputSourceP->inputFileEntries, 
+        REALLOCARRAY_NOFAIL(inputSourceP->inputFileEntries,
                             inputSourceP->ifArraySize);
     }
     MALLOCVAR_NOFAIL(inputSourceP->inputFileEntries[currentIndex]);
     currentEntryP = inputSourceP->inputFileEntries[currentIndex];
 
-    if (input[strlen(input)-1] == ']') 
+    if (input[strlen(input)-1] == ']')
         processGlob(input, currentEntryP);
     else {
         strcpy(currentEntryP->left, input);
-        if (baseFormat == JMOVIE_FILE_TYPE) 
+        if (baseFormat == JMOVIE_FILE_TYPE)
             processJmovie(input, currentEntryP);
-        else 
+        else
             processSimpleFileName(input, currentEntryP);
     }
     inputSourceP->numInputFiles += currentEntryP->numFiles;
@@ -472,7 +472,7 @@ CreateInputSource(struct inputSource ** const inputSourcePP) {
     inputSourceP->ifArraySize = 1;
     inputSourceP->numInputFiles = 0;
     MALLOCARRAY_NOFAIL(inputSourceP->inputFileEntries, 1);
-    
+
     *inputSourcePP = inputSourceP;
 }
 
diff --git a/converter/ppm/ppmtompeg/jrevdct.c b/converter/ppm/ppmtompeg/jrevdct.c
index dd1f9fff..ebadb997 100644
--- a/converter/ppm/ppmtompeg/jrevdct.c
+++ b/converter/ppm/ppmtompeg/jrevdct.c
@@ -16,7 +16,7 @@
  * 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.
- * 
+ *
  * I've made lots of modifications to attempt to take advantage of the
  * sparse nature of the DCT matrices we're getting.  Although the logic
  * is cumbersome, it's straightforward and the resulting code is much
@@ -85,10 +85,10 @@
 #ifdef EIGHT_BIT_SAMPLES
 #define PASS1_BITS  2
 #else
-#define PASS1_BITS  1		/* lose a little precision to avoid overflow */
+#define PASS1_BITS  1           /* lose a little precision to avoid overflow */
 #endif
 
-#define ONE	((int32) 1)
+#define ONE     ((int32) 1)
 
 #define CONST_SCALE (ONE << CONST_BITS)
 
@@ -99,7 +99,7 @@
  */
 
 /* Actually FIX is no longer used, we precomputed them all */
-#define FIX(x)	((int32) ((x) * CONST_SCALE + 0.5)) 
+#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
@@ -120,22 +120,22 @@
  */
 
 #ifdef EIGHT_BIT_SAMPLES
-#ifdef SHORTxSHORT_32		/* may work if 'int' is 32 bits */
+#ifdef SHORTxSHORT_32           /* may work if 'int' is 32 bits */
 #define MULTIPLY(var,const)  (((INT16) (var)) * ((INT16) (const)))
 #endif
-#ifdef SHORTxLCONST_32		/* known to work with Microsoft C 6.0 */
+#ifdef SHORTxLCONST_32          /* known to work with Microsoft C 6.0 */
 #define MULTIPLY(var,const)  (((INT16) (var)) * ((int32) (const)))
 #endif
 #endif
 
-#ifndef MULTIPLY		/* default definition */
+#ifndef MULTIPLY                /* default definition */
 #define MULTIPLY(var,const)  ((var) * (const))
 #endif
 
 
-/* 
+/*
   Unlike our decoder where we approximate the FIXes, we need to use exact
-ones here or successive P-frames will drift too much with Reference frame coding 
+ones here or successive P-frames will drift too much with Reference frame coding
 */
 #define FIX_0_211164243 1730
 #define FIX_0_275899380 2260
@@ -194,7 +194,7 @@ mpeg_jrevdct_quick(data)
   register DCTELEM *dataptr;
   int rowctr;
   SHIFT_TEMPS
-   
+
   /* Pass 1: process rows. */
   /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
   /* furthermore, we scale the results by 2**PASS1_BITS. */
@@ -217,17 +217,17 @@ mpeg_jrevdct_quick(data)
     if ((d1 == 0) && (idataptr[1] | idataptr[2] | idataptr[3]) == 0) {
       /* AC terms all zero */
       if (d0) {
-	  /* Compute a 32 bit value to assign. */
-	  DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
-	  register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
-	  
-	  idataptr[0] = v;
-	  idataptr[1] = v;
-	  idataptr[2] = v;
-	  idataptr[3] = v;
+          /* Compute a 32 bit value to assign. */
+          DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
+          register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
+
+          idataptr[0] = v;
+          idataptr[1] = v;
+          idataptr[2] = v;
+          idataptr[3] = v;
       }
-      
-      dataptr += DCTSIZE;	/* advance pointer to next row */
+
+      dataptr += DCTSIZE;       /* advance pointer to next row */
       continue;
     }
     d2 = dataptr[2];
@@ -241,180 +241,180 @@ mpeg_jrevdct_quick(data)
     /* The rotator is sqrt(2)*c(-6). */
 {
     if (d6) {
-	if (d4) {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = d4 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp2 - tmp0;
-		    tmp12 = -(tmp0 + tmp2);
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = d4 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp2 - tmp0;
-		    tmp12 = -(tmp0 + tmp2);
-		}
-	    }
-	} else {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = d0 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp0 + tmp2;
-		    tmp12 = tmp0 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp10 = tmp3;
-		    tmp13 = -tmp3;
-		    tmp11 = tmp2;
-		    tmp12 = -tmp2;
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = d0 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp0 + tmp2;
-		    tmp12 = tmp0 - tmp2;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp10 = tmp3;
-		    tmp13 = -tmp3;
-		    tmp11 = tmp2;
-		    tmp12 = -tmp2;
-		}
-	    }
-	}
+        if (d4) {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = d4 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp2 - tmp0;
+                    tmp12 = -(tmp0 + tmp2);
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = d4 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp2 - tmp0;
+                    tmp12 = -(tmp0 + tmp2);
+                }
+            }
+        } else {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = d0 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp0 + tmp2;
+                    tmp12 = tmp0 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp10 = tmp3;
+                    tmp13 = -tmp3;
+                    tmp11 = tmp2;
+                    tmp12 = -tmp2;
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = d0 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp0 + tmp2;
+                    tmp12 = tmp0 - tmp2;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp10 = tmp3;
+                    tmp13 = -tmp3;
+                    tmp11 = tmp2;
+                    tmp12 = -tmp2;
+                }
+            }
+        }
     } else {
-	if (d4) {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = d4 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp2 - tmp0;
-		    tmp12 = -(tmp0 + tmp2);
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-		    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = d4 << CONST_BITS;
-		    tmp11 = tmp12 = -tmp10;
-		}
-	    }
-	} else {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = d0 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp0 + tmp2;
-		    tmp12 = tmp0 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp10 = tmp3;
-		    tmp13 = -tmp3;
-		    tmp11 = tmp2;
-		    tmp12 = -tmp2;
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */
-		    tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */
-		    tmp10 = tmp13 = tmp11 = tmp12 = 0;
-		}
-	    }
-	}
+        if (d4) {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = d4 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp2 - tmp0;
+                    tmp12 = -(tmp0 + tmp2);
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
+                    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = d4 << CONST_BITS;
+                    tmp11 = tmp12 = -tmp10;
+                }
+            }
+        } else {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = d0 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp0 + tmp2;
+                    tmp12 = tmp0 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp10 = tmp3;
+                    tmp13 = -tmp3;
+                    tmp11 = tmp2;
+                    tmp12 = -tmp2;
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */
+                    tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */
+                    tmp10 = tmp13 = tmp11 = tmp12 = 0;
+                }
+            }
+        }
       }
 
     /* Odd part per figure 8; the matrix is unitary and hence its
@@ -422,259 +422,259 @@ mpeg_jrevdct_quick(data)
      */
 
     if (d7) {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(d7 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 = z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z3;
-		    tmp1 += z4;
-		    tmp2 = z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 = z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z3 = d7 + d3;
-		    
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    tmp2 = MULTIPLY(d3, FIX_0_509795579);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z5 = MULTIPLY(z3, FIX_1_175875602);
-		    z3 = MULTIPLY(-z3, FIX_0_785694958);
-		    
-		    tmp0 += z3;
-		    tmp1 = z2 + z5;
-		    tmp2 += z3;
-		    tmp3 = z1 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z5 = MULTIPLY(z1, FIX_1_175875602);
-
-		    z1 = MULTIPLY(z1, FIX_0_275899380);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp0 = MULTIPLY(-d7, FIX_1_662939225); 
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
-		    tmp0 += z1;
-		    tmp1 = z4 + z5;
-		    tmp2 = z3 + z5;
-		    tmp3 += z1;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
-		    tmp1 = MULTIPLY(d7, FIX_1_175875602);
-		    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
-		    tmp3 = MULTIPLY(d7, FIX_0_275899380);
-		}
-	    }
-	}
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(d7 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 = z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z3;
+                    tmp1 += z4;
+                    tmp2 = z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 = z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z3 = d7 + d3;
+
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    tmp2 = MULTIPLY(d3, FIX_0_509795579);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z5 = MULTIPLY(z3, FIX_1_175875602);
+                    z3 = MULTIPLY(-z3, FIX_0_785694958);
+
+                    tmp0 += z3;
+                    tmp1 = z2 + z5;
+                    tmp2 += z3;
+                    tmp3 = z1 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z5 = MULTIPLY(z1, FIX_1_175875602);
+
+                    z1 = MULTIPLY(z1, FIX_0_275899380);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp0 = MULTIPLY(-d7, FIX_1_662939225);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+                    tmp3 = MULTIPLY(d1, FIX_1_111140466);
+
+                    tmp0 += z1;
+                    tmp1 = z4 + z5;
+                    tmp2 = z3 + z5;
+                    tmp3 += z1;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
+                    tmp1 = MULTIPLY(d7, FIX_1_175875602);
+                    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
+                    tmp3 = MULTIPLY(d7, FIX_0_275899380);
+                }
+            }
+        }
     } else {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-		    
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 = z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    
-		    z5 = MULTIPLY(z2, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_1_662939225);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z2 = MULTIPLY(-z2, FIX_1_387039845);
-		    tmp2 = MULTIPLY(d3, FIX_1_111140466);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    
-		    tmp0 = z3 + z5;
-		    tmp1 += z2;
-		    tmp2 += z2;
-		    tmp3 = z4 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
-		    z4 = d5 + d1;
-		    
-		    z5 = MULTIPLY(z4, FIX_1_175875602);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    tmp3 = MULTIPLY(d1, FIX_0_601344887);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(z4, FIX_0_785694958);
-		    
-		    tmp0 = z1 + z5;
-		    tmp1 += z4;
-		    tmp2 = z2 + z5;
-		    tmp3 += z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d5, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_0_275899380);
-		    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
-		    tmp3 = MULTIPLY(d5, FIX_0_785694958);
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
-		    z5 = d1 + d3;
-		    tmp3 = MULTIPLY(d1, FIX_0_211164243);
-		    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
-		    z1 = MULTIPLY(d1, FIX_1_061594337);
-		    z2 = MULTIPLY(-d3, FIX_2_172734803);
-		    z4 = MULTIPLY(z5, FIX_0_785694958);
-		    z5 = MULTIPLY(z5, FIX_1_175875602);
-		    
-		    tmp0 = z1 - z4;
-		    tmp1 = z2 + z4;
-		    tmp2 += z5;
-		    tmp3 += z5;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
-		    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
-		    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
-		    tmp3 = MULTIPLY(d3, FIX_1_175875602);
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d1, FIX_0_275899380);
-		    tmp1 = MULTIPLY(d1, FIX_0_785694958);
-		    tmp2 = MULTIPLY(d1, FIX_1_175875602);
-		    tmp3 = MULTIPLY(d1, FIX_1_387039845);
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = tmp1 = tmp2 = tmp3 = 0;
-		}
-	    }
-	}
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
+
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 = z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+
+                    z5 = MULTIPLY(z2, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_1_662939225);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z2 = MULTIPLY(-z2, FIX_1_387039845);
+                    tmp2 = MULTIPLY(d3, FIX_1_111140466);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+
+                    tmp0 = z3 + z5;
+                    tmp1 += z2;
+                    tmp2 += z2;
+                    tmp3 = z4 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
+                    z4 = d5 + d1;
+
+                    z5 = MULTIPLY(z4, FIX_1_175875602);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    tmp3 = MULTIPLY(d1, FIX_0_601344887);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(z4, FIX_0_785694958);
+
+                    tmp0 = z1 + z5;
+                    tmp1 += z4;
+                    tmp2 = z2 + z5;
+                    tmp3 += z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d5, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_0_275899380);
+                    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
+                    tmp3 = MULTIPLY(d5, FIX_0_785694958);
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
+                    z5 = d1 + d3;
+                    tmp3 = MULTIPLY(d1, FIX_0_211164243);
+                    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
+                    z1 = MULTIPLY(d1, FIX_1_061594337);
+                    z2 = MULTIPLY(-d3, FIX_2_172734803);
+                    z4 = MULTIPLY(z5, FIX_0_785694958);
+                    z5 = MULTIPLY(z5, FIX_1_175875602);
+
+                    tmp0 = z1 - z4;
+                    tmp1 = z2 + z4;
+                    tmp2 += z5;
+                    tmp3 += z5;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
+                    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
+                    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
+                    tmp3 = MULTIPLY(d3, FIX_1_175875602);
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d1, FIX_0_275899380);
+                    tmp1 = MULTIPLY(d1, FIX_0_785694958);
+                    tmp2 = MULTIPLY(d1, FIX_1_175875602);
+                    tmp3 = MULTIPLY(d1, FIX_1_387039845);
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = tmp1 = tmp2 = tmp3 = 0;
+                }
+            }
+        }
     }
 }
     /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
@@ -688,7 +688,7 @@ mpeg_jrevdct_quick(data)
     dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
     dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
 
-    dataptr += DCTSIZE;		/* advance pointer to next row */
+    dataptr += DCTSIZE;         /* advance pointer to next row */
   }
 
   /* Pass 2: process columns. */
@@ -717,464 +717,464 @@ mpeg_jrevdct_quick(data)
     /* Even part: reverse the even part of the forward DCT. */
     /* The rotator is sqrt(2)*c(-6). */
     if (d6) {
-	if (d4) {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = d4 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp2 - tmp0;
-		    tmp12 = -(tmp0 + tmp2);
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = d4 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp2 - tmp0;
-		    tmp12 = -(tmp0 + tmp2);
-		}
-	    }
-	} else {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = d0 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp0 + tmp2;
-		    tmp12 = tmp0 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp10 = tmp3;
-		    tmp13 = -tmp3;
-		    tmp11 = tmp2;
-		    tmp12 = -tmp2;
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = d0 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp0 + tmp2;
-		    tmp12 = tmp0 - tmp2;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp10 = tmp3;
-		    tmp13 = -tmp3;
-		    tmp11 = tmp2;
-		    tmp12 = -tmp2;
-		}
-	    }
-	}
+        if (d4) {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = d4 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp2 - tmp0;
+                    tmp12 = -(tmp0 + tmp2);
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = d4 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp2 - tmp0;
+                    tmp12 = -(tmp0 + tmp2);
+                }
+            }
+        } else {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = d0 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp0 + tmp2;
+                    tmp12 = tmp0 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp10 = tmp3;
+                    tmp13 = -tmp3;
+                    tmp11 = tmp2;
+                    tmp12 = -tmp2;
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = d0 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp0 + tmp2;
+                    tmp12 = tmp0 - tmp2;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp10 = tmp3;
+                    tmp13 = -tmp3;
+                    tmp11 = tmp2;
+                    tmp12 = -tmp2;
+                }
+            }
+        }
     } else {
-	if (d4) {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = d4 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp2 - tmp0;
-		    tmp12 = -(tmp0 + tmp2);
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-		    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = d4 << CONST_BITS;
-		    tmp11 = tmp12 = -tmp10;
-		}
-	    }
-	} else {
-	    if (d2) {
-		if (d0) {
-		    /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = d0 << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp0 + tmp2;
-		    tmp12 = tmp0 - tmp2;
-		} else {
-		    /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp10 = tmp3;
-		    tmp13 = -tmp3;
-		    tmp11 = tmp2;
-		    tmp12 = -tmp2;
-		}
-	    } else {
-		if (d0) {
-		    /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */
-		    tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS;
-		} else {
-		    /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */
-		    tmp10 = tmp13 = tmp11 = tmp12 = 0;
-		}
-	    }
-	}
+        if (d4) {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = d4 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp2 - tmp0;
+                    tmp12 = -(tmp0 + tmp2);
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
+                    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = d4 << CONST_BITS;
+                    tmp11 = tmp12 = -tmp10;
+                }
+            }
+        } else {
+            if (d2) {
+                if (d0) {
+                    /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = d0 << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp0 + tmp2;
+                    tmp12 = tmp0 - tmp2;
+                } else {
+                    /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp10 = tmp3;
+                    tmp13 = -tmp3;
+                    tmp11 = tmp2;
+                    tmp12 = -tmp2;
+                }
+            } else {
+                if (d0) {
+                    /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */
+                    tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS;
+                } else {
+                    /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */
+                    tmp10 = tmp13 = tmp11 = tmp12 = 0;
+                }
+            }
+        }
     }
 
     /* Odd part per figure 8; the matrix is unitary and hence its
      * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.
      */
     if (d7) {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z1 = d7;
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z2 = d5;
-		    z3 = d7;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 = z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z3;
-		    tmp1 += z4;
-		    tmp2 = z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 = z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z3 = d7 + d3;
-		    
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    tmp2 = MULTIPLY(d3, FIX_0_509795579);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z5 = MULTIPLY(z3, FIX_1_175875602);
-		    z3 = MULTIPLY(-z3, FIX_0_785694958);
-		    
-		    tmp0 += z3;
-		    tmp1 = z2 + z5;
-		    tmp2 += z3;
-		    tmp3 = z1 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z5 = MULTIPLY(z1, FIX_1_175875602);
-
-		    z1 = MULTIPLY(z1, FIX_0_275899380);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp0 = MULTIPLY(-d7, FIX_1_662939225); 
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
-		    tmp0 += z1;
-		    tmp1 = z4 + z5;
-		    tmp2 = z3 + z5;
-		    tmp3 += z1;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
-		    tmp1 = MULTIPLY(d7, FIX_1_175875602);
-		    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
-		    tmp3 = MULTIPLY(d7, FIX_0_275899380);
-		}
-	    }
-	}
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z1 = d7;
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z2 = d5;
+                    z3 = d7;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 = z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z3;
+                    tmp1 += z4;
+                    tmp2 = z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 = z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z3 = d7 + d3;
+
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    tmp2 = MULTIPLY(d3, FIX_0_509795579);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z5 = MULTIPLY(z3, FIX_1_175875602);
+                    z3 = MULTIPLY(-z3, FIX_0_785694958);
+
+                    tmp0 += z3;
+                    tmp1 = z2 + z5;
+                    tmp2 += z3;
+                    tmp3 = z1 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z5 = MULTIPLY(z1, FIX_1_175875602);
+
+                    z1 = MULTIPLY(z1, FIX_0_275899380);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp0 = MULTIPLY(-d7, FIX_1_662939225);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+                    tmp3 = MULTIPLY(d1, FIX_1_111140466);
+
+                    tmp0 += z1;
+                    tmp1 = z4 + z5;
+                    tmp2 = z3 + z5;
+                    tmp3 += z1;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
+                    tmp1 = MULTIPLY(d7, FIX_1_175875602);
+                    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
+                    tmp3 = MULTIPLY(d7, FIX_0_275899380);
+                }
+            }
+        }
     } else {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-		    
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 = z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    
-		    z5 = MULTIPLY(z2, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_1_662939225);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z2 = MULTIPLY(-z2, FIX_1_387039845);
-		    tmp2 = MULTIPLY(d3, FIX_1_111140466);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    
-		    tmp0 = z3 + z5;
-		    tmp1 += z2;
-		    tmp2 += z2;
-		    tmp3 = z4 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
-		    z4 = d5 + d1;
-		    
-		    z5 = MULTIPLY(z4, FIX_1_175875602);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    tmp3 = MULTIPLY(d1, FIX_0_601344887);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(z4, FIX_0_785694958);
-		    
-		    tmp0 = z1 + z5;
-		    tmp1 += z4;
-		    tmp2 = z2 + z5;
-		    tmp3 += z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d5, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_0_275899380);
-		    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
-		    tmp3 = MULTIPLY(d5, FIX_0_785694958);
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
-		    z5 = d1 + d3;
-		    tmp3 = MULTIPLY(d1, FIX_0_211164243);
-		    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
-		    z1 = MULTIPLY(d1, FIX_1_061594337);
-		    z2 = MULTIPLY(-d3, FIX_2_172734803);
-		    z4 = MULTIPLY(z5, FIX_0_785694958);
-		    z5 = MULTIPLY(z5, FIX_1_175875602);
-		    
-		    tmp0 = z1 - z4;
-		    tmp1 = z2 + z4;
-		    tmp2 += z5;
-		    tmp3 += z5;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
-		    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
-		    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
-		    tmp3 = MULTIPLY(d3, FIX_1_175875602);
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d1, FIX_0_275899380);
-		    tmp1 = MULTIPLY(d1, FIX_0_785694958);
-		    tmp2 = MULTIPLY(d1, FIX_1_175875602);
-		    tmp3 = MULTIPLY(d1, FIX_1_387039845);
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = tmp1 = tmp2 = tmp3 = 0;
-		}
-	    }
-	}
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
+
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 = z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+
+                    z5 = MULTIPLY(z2, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_1_662939225);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z2 = MULTIPLY(-z2, FIX_1_387039845);
+                    tmp2 = MULTIPLY(d3, FIX_1_111140466);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+
+                    tmp0 = z3 + z5;
+                    tmp1 += z2;
+                    tmp2 += z2;
+                    tmp3 = z4 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
+                    z4 = d5 + d1;
+
+                    z5 = MULTIPLY(z4, FIX_1_175875602);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    tmp3 = MULTIPLY(d1, FIX_0_601344887);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(z4, FIX_0_785694958);
+
+                    tmp0 = z1 + z5;
+                    tmp1 += z4;
+                    tmp2 = z2 + z5;
+                    tmp3 += z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d5, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_0_275899380);
+                    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
+                    tmp3 = MULTIPLY(d5, FIX_0_785694958);
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
+                    z5 = d1 + d3;
+                    tmp3 = MULTIPLY(d1, FIX_0_211164243);
+                    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
+                    z1 = MULTIPLY(d1, FIX_1_061594337);
+                    z2 = MULTIPLY(-d3, FIX_2_172734803);
+                    z4 = MULTIPLY(z5, FIX_0_785694958);
+                    z5 = MULTIPLY(z5, FIX_1_175875602);
+
+                    tmp0 = z1 - z4;
+                    tmp1 = z2 + z4;
+                    tmp2 += z5;
+                    tmp3 += z5;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
+                    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
+                    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
+                    tmp3 = MULTIPLY(d3, FIX_1_175875602);
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d1, FIX_0_275899380);
+                    tmp1 = MULTIPLY(d1, FIX_0_785694958);
+                    tmp2 = MULTIPLY(d1, FIX_1_175875602);
+                    tmp3 = MULTIPLY(d1, FIX_1_387039845);
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = tmp1 = tmp2 = tmp3 = 0;
+                }
+            }
+        }
     }
 
     /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
 
     dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3,
-					   CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3,
-					   CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2,
-					   CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2,
-					   CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1,
-					   CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1,
-					   CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0,
-					   CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0,
-					   CONST_BITS+PASS1_BITS+3);
-    
-    dataptr++;			/* advance pointer to next column */
+                                           CONST_BITS+PASS1_BITS+3);
+
+    dataptr++;                  /* advance pointer to next column */
   }
 }
 
@@ -1222,7 +1222,7 @@ static double itrans_coef[8][8];
 
 void init_idctref() {
 /*----------------------------------------------------------------------------
-   initialize DCT coefficient matrix 
+   initialize DCT coefficient matrix
 -----------------------------------------------------------------------------*/
     unsigned int freq;
 
@@ -1258,7 +1258,7 @@ int16 *block;
       tmp[8*i+j] = partial_product;
     }
 
-  /* Transpose operation is integrated into address mapping by switching 
+  /* Transpose operation is integrated into address mapping by switching
      loop order of i and j */
 
   for (j=0; j<8; j++)
diff --git a/converter/ppm/ppmtompeg/memory.c b/converter/ppm/ppmtompeg/memory.c
index f117994a..0ebe4686 100644
--- a/converter/ppm/ppmtompeg/memory.c
+++ b/converter/ppm/ppmtompeg/memory.c
@@ -44,28 +44,28 @@
  *
  */
 
-long	totalMemory = 0;
-long	maxMemory = 0;
+long    totalMemory = 0;
+long    maxMemory = 0;
 
 
-char	*MemAlloc(size_t size)
+char    *MemAlloc(size_t size)
 {
     totalMemory += (long)size;
     if ( totalMemory > maxMemory )
     {
-	maxMemory = totalMemory;
+        maxMemory = totalMemory;
     }
 
     return malloc(size);
 }
 
-void	MemFree(char *ptr, long bytes)
+void    MemFree(char *ptr, long bytes)
 {
     totalMemory -= bytes;
     free(ptr);
 }
 
-void	PrintMaxMemory(void)
+void    PrintMaxMemory(void)
 {
     fprintf(stdout, "MMMMM-----MAX MEMORY-----MMMMM = %ld\n", maxMemory);
 }
diff --git a/converter/ppm/ppmtompeg/mfwddct.c b/converter/ppm/ppmtompeg/mfwddct.c
index 9381e51c..8b379cd8 100644
--- a/converter/ppm/ppmtompeg/mfwddct.c
+++ b/converter/ppm/ppmtompeg/mfwddct.c
@@ -1,4 +1,3 @@
-
 /*
  * mfwddct.c (derived from jfwddct.c, which carries the following info)
  *
@@ -51,10 +50,10 @@
 #ifdef EIGHT_BIT_SAMPLES
 #define LG2_DCT_SCALE 16
 #else
-#define LG2_DCT_SCALE 15	/* lose a little precision to avoid overflow */
+#define LG2_DCT_SCALE 15        /* lose a little precision to avoid overflow */
 #endif
 
-#define ONE	((int32) 1)
+#define ONE     ((int32) 1)
 
 #define DCT_SCALE (ONE << LG2_DCT_SCALE)
 
@@ -66,7 +65,7 @@
 #define OVERSHIFT(x)  ((x) <<= LG2_OVERSCALE)
 
 /* Scale a fractional constant by DCT_SCALE */
-#define FIX(x)	((int32) ((x) * DCT_SCALE + 0.5))
+#define FIX(x)  ((int32) ((x) * DCT_SCALE + 0.5))
 
 /* Scale a fractional constant by DCT_SCALE/OVERSCALE */
 /* Such a constant can be multiplied with an overscaled input */
@@ -81,7 +80,7 @@
 
 /* Take a value scaled by DCT_SCALE and round to integer scaled by OVERSCALE */
 #define UNFIXO(x)  RIGHT_SHIFT((x) + (ONE << (LG2_DCT_SCALE-1-LG2_OVERSCALE)),\
-			       LG2_DCT_SCALE-LG2_OVERSCALE)
+                               LG2_DCT_SCALE-LG2_OVERSCALE)
 
 /* Here are the constants we need */
 /* SIN_i_j is sine of i*pi/j, scaled by DCT_SCALE */
@@ -162,11 +161,11 @@ Block block, dest;
         s += trans_coef[i][k] * tmp[8*k+j];
 
       if (collect_quant) {
-	fprintf(collect_quant_fp, "%d %f\n", 8*i+j, s);
-      } 
+        fprintf(collect_quant_fp, "%d %f\n", 8*i+j, s);
+      }
       if (DoLaplace) {
-	L1[LaplaceCnum][i*8+j] += s*s;
-	L2[LaplaceCnum][i*8+j] += s;
+        L1[LaplaceCnum][i*8+j] += s*s;
+        L2[LaplaceCnum][i*8+j] += s;
       }
 
 
@@ -206,8 +205,8 @@ mp_fwd_dct_fast(data2d, dest2d)
  */
 
 {
-    int16 *data = (int16 *) data2d;	/* this algorithm wants
-					 * a 1-d array */
+    int16 *data = (int16 *) data2d;     /* this algorithm wants
+                                         * a 1-d array */
     int16 *dest = (int16 *) dest2d;
     int pass, rowctr;
     register int16 *inptr, *outptr;
@@ -216,15 +215,15 @@ mp_fwd_dct_fast(data2d, dest2d)
 
 #ifdef ndef
     {
-	int y;
-
-	printf("fwd_dct (beforehand):\n");
-	for (y = 0; y < 8; y++)
-	    printf("%4d %4d %4d %4d %4d %4d %4d %4d\n",
-		   data2d[y][0], data2d[y][1],
-		   data2d[y][2], data2d[y][3],
-		   data2d[y][4], data2d[y][5],
-		   data2d[y][6], data2d[y][7]);
+        int y;
+
+        printf("fwd_dct (beforehand):\n");
+        for (y = 0; y < 8; y++)
+            printf("%4d %4d %4d %4d %4d %4d %4d %4d\n",
+                   data2d[y][0], data2d[y][1],
+                   data2d[y][2], data2d[y][3],
+                   data2d[y][4], data2d[y][5],
+                   data2d[y][6], data2d[y][7]);
     }
 #endif
 
@@ -238,90 +237,90 @@ mp_fwd_dct_fast(data2d, dest2d)
      * array indexing.
      */
 
-    inptr = data;		/* initialize pointers for first pass */
+    inptr = data;               /* initialize pointers for first pass */
     outptr = workspace;
     for (pass = 1; pass >= 0; pass--) {
-	for (rowctr = DCTSIZE - 1; rowctr >= 0; rowctr--) {
-	    /*
-	     * many tmps have nonoverlapping lifetime -- flashy
-	     * register colorers should be able to do this lot
-	     * very well
-	     */
-	    int32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-	    int32 tmp10, tmp11, tmp12, tmp13;
-	    int32 tmp14, tmp15, tmp16, tmp17;
-	    int32 tmp25, tmp26;
-	    /* SHIFT_TEMPS */
-
-	    /* temp0 through tmp7:  -512 to +512 */
-	    /* if I-block, then -256 to +256 */
-	    tmp0 = inptr[7] + inptr[0];
-	    tmp1 = inptr[6] + inptr[1];
-	    tmp2 = inptr[5] + inptr[2];
-	    tmp3 = inptr[4] + inptr[3];
-	    tmp4 = inptr[3] - inptr[4];
-	    tmp5 = inptr[2] - inptr[5];
-	    tmp6 = inptr[1] - inptr[6];
-	    tmp7 = inptr[0] - inptr[7];
-
-	    /* tmp10 through tmp13:  -1024 to +1024 */
-	    /* if I-block, then -512 to +512 */
-	    tmp10 = tmp3 + tmp0;
-	    tmp11 = tmp2 + tmp1;
-	    tmp12 = tmp1 - tmp2;
-	    tmp13 = tmp0 - tmp3;
-
-	    outptr[0] = (int16) UNFIXH((tmp10 + tmp11) * SIN_1_4);
-	    outptr[DCTSIZE * 4] =
+        for (rowctr = DCTSIZE - 1; rowctr >= 0; rowctr--) {
+            /*
+             * many tmps have nonoverlapping lifetime -- flashy
+             * register colorers should be able to do this lot
+             * very well
+             */
+            int32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+            int32 tmp10, tmp11, tmp12, tmp13;
+            int32 tmp14, tmp15, tmp16, tmp17;
+            int32 tmp25, tmp26;
+            /* SHIFT_TEMPS */
+
+            /* temp0 through tmp7:  -512 to +512 */
+            /* if I-block, then -256 to +256 */
+            tmp0 = inptr[7] + inptr[0];
+            tmp1 = inptr[6] + inptr[1];
+            tmp2 = inptr[5] + inptr[2];
+            tmp3 = inptr[4] + inptr[3];
+            tmp4 = inptr[3] - inptr[4];
+            tmp5 = inptr[2] - inptr[5];
+            tmp6 = inptr[1] - inptr[6];
+            tmp7 = inptr[0] - inptr[7];
+
+            /* tmp10 through tmp13:  -1024 to +1024 */
+            /* if I-block, then -512 to +512 */
+            tmp10 = tmp3 + tmp0;
+            tmp11 = tmp2 + tmp1;
+            tmp12 = tmp1 - tmp2;
+            tmp13 = tmp0 - tmp3;
+
+            outptr[0] = (int16) UNFIXH((tmp10 + tmp11) * SIN_1_4);
+            outptr[DCTSIZE * 4] =
             (int16) UNFIXH((tmp10 - tmp11) * COS_1_4);
-	    outptr[DCTSIZE * 2] =
+            outptr[DCTSIZE * 2] =
             (int16) UNFIXH(tmp13 * COS_1_8 + tmp12 * SIN_1_8);
-	    outptr[DCTSIZE * 6] =
+            outptr[DCTSIZE * 6] =
             (int16) UNFIXH(tmp13 * SIN_1_8 - tmp12 * COS_1_8);
 
-	    tmp16 = UNFIXO((tmp6 + tmp5) * SIN_1_4);
-	    tmp15 = UNFIXO((tmp6 - tmp5) * COS_1_4);
+            tmp16 = UNFIXO((tmp6 + tmp5) * SIN_1_4);
+            tmp15 = UNFIXO((tmp6 - tmp5) * COS_1_4);
 
-	    OVERSHIFT(tmp4);
-	    OVERSHIFT(tmp7);
+            OVERSHIFT(tmp4);
+            OVERSHIFT(tmp7);
 
-	    /*
-	     * tmp4, tmp7, tmp15, tmp16 are overscaled by
-	     * OVERSCALE
-	     */
+            /*
+             * tmp4, tmp7, tmp15, tmp16 are overscaled by
+             * OVERSCALE
+             */
 
-	    tmp14 = tmp4 + tmp15;
-	    tmp25 = tmp4 - tmp15;
-	    tmp26 = tmp7 - tmp16;
-	    tmp17 = tmp7 + tmp16;
+            tmp14 = tmp4 + tmp15;
+            tmp25 = tmp4 - tmp15;
+            tmp26 = tmp7 - tmp16;
+            tmp17 = tmp7 + tmp16;
 
-	    outptr[DCTSIZE] =
+            outptr[DCTSIZE] =
             (int16) UNFIXH(tmp17 * OCOS_1_16 + tmp14 * OSIN_1_16);
-	    outptr[DCTSIZE * 7] =
+            outptr[DCTSIZE * 7] =
             (int16) UNFIXH(tmp17 * OCOS_7_16 - tmp14 * OSIN_7_16);
-	    outptr[DCTSIZE * 5] =
+            outptr[DCTSIZE * 5] =
             (int16) UNFIXH(tmp26 * OCOS_5_16 + tmp25 * OSIN_5_16);
-	    outptr[DCTSIZE * 3] =
+            outptr[DCTSIZE * 3] =
             (int16) UNFIXH(tmp26 * OCOS_3_16 - tmp25 * OSIN_3_16);
 
-	    inptr += DCTSIZE;	/* advance inptr to next row */
-	    outptr++;		/* advance outptr to next column */
-	}
-	/* end of pass; in case it was pass 1, set up for pass 2 */
-	inptr = workspace;
-	outptr = dest;
+            inptr += DCTSIZE;   /* advance inptr to next row */
+            outptr++;           /* advance outptr to next column */
+        }
+        /* end of pass; in case it was pass 1, set up for pass 2 */
+        inptr = workspace;
+        outptr = dest;
     }
 #ifdef ndef
     {
-	int y;
-
-	printf("fwd_dct (afterward):\n");
-	for (y = 0; y < 8; y++)
-	    printf("%4d %4d %4d %4d %4d %4d %4d %4d\n",
-		   dest2d[y][0], dest2d[y][1],
-		   dest2d[y][2], dest2d[y][3],
-		   dest2d[y][4], dest2d[y][5],
-		   dest2d[y][6], dest2d[y][7]);
+        int y;
+
+        printf("fwd_dct (afterward):\n");
+        for (y = 0; y < 8; y++)
+            printf("%4d %4d %4d %4d %4d %4d %4d %4d\n",
+                   dest2d[y][0], dest2d[y][1],
+                   dest2d[y][2], dest2d[y][3],
+                   dest2d[y][4], dest2d[y][5],
+                   dest2d[y][6], dest2d[y][7]);
     }
 #endif
 }
diff --git a/converter/ppm/ppmtompeg/mheaders.c b/converter/ppm/ppmtompeg/mheaders.c
index 98e1b063..7e5db6c1 100644
--- a/converter/ppm/ppmtompeg/mheaders.c
+++ b/converter/ppm/ppmtompeg/mheaders.c
@@ -1,17 +1,17 @@
 /*===========================================================================*
- * mheaders.c								     *
- *									     *
- *	Procedures to generate MPEG headers				     *
- *									     *
- * EXPORTED PROCEDURES:							     *
- *	Mhead_GenPictureHeader						     *
- *	Mhead_GenSequenceHeader						     *
- *	Mhead_GenSequenceEnder						     *
- *	Mhead_GenGOPHeader						     *
- *	Mhead_GenSliceHeader						     *
- *	Mhead_GenSliceEnder						     *
- *	Mhead_GenMBHeader						     *
- *									     *
+ * mheaders.c                                                                *
+ *                                                                           *
+ *      Procedures to generate MPEG headers                                  *
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
+ *      Mhead_GenPictureHeader                                               *
+ *      Mhead_GenSequenceHeader                                              *
+ *      Mhead_GenSequenceEnder                                               *
+ *      Mhead_GenGOPHeader                                                   *
+ *      Mhead_GenSliceHeader                                                 *
+ *      Mhead_GenSliceEnder                                                  *
+ *      Mhead_GenMBHeader                                                    *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -254,7 +254,7 @@ static uint32 mbPatTable[][2] = {
     {0x4, 8},
     {0x4, 9},
     {0x7, 3},
-    {0xa, 5},	/* grrr... 61, 62, 63 added - Kevin */
+    {0xa, 5},   /* grrr... 61, 62, 63 added - Kevin */
     {0x8, 5},
     {0xc, 6}
 };
@@ -270,9 +270,9 @@ static uint32 mbPatTable[][2] = {
 #define PICT_START_CODE 0x00000100
 #define SLICE_BASE_CODE 0x00000100
 
-#define SEQ_END_CODE	0x000001b7
+#define SEQ_END_CODE    0x000001b7
 
-/* not static anymore because information is used for computing frame rate 
+/* not static anymore because information is used for computing frame rate
  * and for statistics */
 const double VidRateNum[9]={1.0, 23.976, 24.0, 25.0, 29.97, 30.0,
                              50.0 ,59.94, 60.0};
@@ -286,10 +286,10 @@ const double VidRateNum[9]={1.0, 23.976, 24.0, 25.0, 29.97, 30.0,
  *
  * GenMBType
  *
- *	generate macroblock type with given attributes
- *	append result to the specified bitstream
+ *      generate macroblock type with given attributes
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -433,10 +433,10 @@ GenMBType(bbPtr, pict_code_type, mb_quant, motion_forw, motion_back,
  *
  * GenMotionCode
  *
- *	generate motion vector output with given value
- *	append result to the specified bitstream
+ *      generate motion vector output with given value
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -463,10 +463,10 @@ GenMotionCode(BitBucket * const bbPtr,
  *
  * GenBlockPattern
  *
- *	generate macroblock pattern output
- *	append result to the specified bitstream
+ *      generate macroblock pattern output
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -489,10 +489,10 @@ GenBlockPattern(bbPtr, mb_pattern)
  *
  * GenMBAddrIncr
  *
- *	generate macroblock address increment output
- *	append result to the specified bitstream
+ *      generate macroblock address increment output
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -516,10 +516,10 @@ GenMBAddrIncr(bbPtr, addr_incr)
  *
  * GenPictHead
  *
- *	generate picture header with given attributes
- *	append result to the specified bitstream
+ *      generate picture header with given attributes
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -557,7 +557,7 @@ GenPictHead(bbPtr, temp_ref, code_type, vbv_delay, full_pel_forw_flag,
     Bitio_Write(bbPtr, code_type, 3);
 
     /* vbv_delay. */
-    vbv_delay = 0xffff;		    /* see page 36 (section 2.4.3.4) */
+    vbv_delay = 0xffff;             /* see page 36 (section 2.4.3.4) */
     Bitio_Write(bbPtr, vbv_delay, 16);
 
     if ((code_type == 2) || (code_type == 3)) {
@@ -633,9 +633,9 @@ GenPictHead(bbPtr, temp_ref, code_type, vbv_delay, full_pel_forw_flag,
  *
  * SetGOPStartTime
  *
- *	sets the start frame of the GOP; to be used with GenPictureHeader
+ *      sets the start frame of the GOP; to be used with GenPictureHeader
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -653,10 +653,10 @@ SetGOPStartTime(index)
  *
  * Mhead_GenPictureHeader
  *
- *	generate picture header with given frame type and picture count
- *	append result to the specified bitstream
+ *      generate picture header with given frame type and picture count
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -668,23 +668,23 @@ Mhead_GenPictureHeader(bbPtr, frameType, pictCount, f_code)
     int pictCount;
     int f_code;
 {
-    int	    temporalRef;
+    int     temporalRef;
 
     if ( pictCount >= gopStartFrame ) {
-	temporalRef = (pictCount-gopStartFrame);
+        temporalRef = (pictCount-gopStartFrame);
     } else {
-	temporalRef = (pictCount-lastGOPStart);
+        temporalRef = (pictCount-lastGOPStart);
     }
     temporalRef = (temporalRef % 1024);
-	
+
     DBG_PRINT(("Picture Header\n"));
     GenPictHead(bbPtr, temporalRef, frameType,
-		0 /* vbv_delay */,
-		pixelFullSearch /* full_pel_forw_flag */,
-		f_code /* forw_f_code */,
-		pixelFullSearch /* full_pel_back_flag */,
-		f_code /* back_f_code */,
-		NULL, 0, NULL, 0, NULL, 0);
+                0 /* vbv_delay */,
+                pixelFullSearch /* full_pel_forw_flag */,
+                f_code /* forw_f_code */,
+                pixelFullSearch /* full_pel_back_flag */,
+                f_code /* back_f_code */,
+                NULL, 0, NULL, 0, NULL, 0);
 }
 
 
@@ -692,27 +692,27 @@ Mhead_GenPictureHeader(bbPtr, frameType, pictCount, f_code)
  *
  * Mhead_GenSequenceHeader
  *
- *	generate sequence header with given attributes
- *	append result to the specified bitstream
+ *      generate sequence header with given attributes
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
  *===========================================================================*/
 void
-Mhead_GenSequenceHeader(BitBucket *   const bbPtr, 
-                        uint32        const hsize, 
+Mhead_GenSequenceHeader(BitBucket *   const bbPtr,
+                        uint32        const hsize,
                         uint32        const vsize,
-                        int32         const pratio, 
-                        int32         const pict_rate, 
+                        int32         const pratio,
+                        int32         const pict_rate,
                         int32         const bit_rate_arg,
-                        int32         const buf_size_arg, 
-                        int32         const c_param_flag_arg, 
-                        const int32 * const iq_matrix, 
+                        int32         const buf_size_arg,
+                        int32         const c_param_flag_arg,
+                        const int32 * const iq_matrix,
                         const int32 * const niq_matrix,
-                        uint8 *       const ext_data, 
-                        int32         const ext_data_size, 
+                        uint8 *       const ext_data,
+                        int32         const ext_data_size,
                         uint8 *       const user_data,
                         int32         const user_data_size) {
 
@@ -774,7 +774,7 @@ Mhead_GenSequenceHeader(BitBucket *   const bbPtr,
         buf_size = buf_size_arg;
 
     buf_size = (buf_size + (16*1024 - 1)) / (16*1024);
-    if (buf_size>=0x400) 
+    if (buf_size>=0x400)
         buf_size=0x3ff;
     Bitio_Write(bbPtr, buf_size, 10);
 
@@ -853,10 +853,10 @@ Mhead_GenSequenceHeader(BitBucket *   const bbPtr,
  *
  * Mhead_GenSequenceEnder
  *
- *	generate sequence ender
- *	append result to the specified bitstream
+ *      generate sequence ender
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -873,18 +873,18 @@ Mhead_GenSequenceEnder(bbPtr)
  *
  * Mhead_GenGOPHeader
  *
- *	generate GOP header with specified attributes
- *	append result to the specified bitstream
+ *      generate GOP header with specified attributes
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
  *===========================================================================*/
 void
 Mhead_GenGOPHeader(bbPtr, drop_frame_flag, tc_hrs, tc_min, tc_sec, tc_pict,
-		   closed_gop, broken_link, ext_data, ext_data_size,
-		   user_data, user_data_size)
+                   closed_gop, broken_link, ext_data, ext_data_size,
+                   user_data, user_data_size)
     BitBucket *bbPtr;
     int32 drop_frame_flag;
     int32 tc_hrs;
@@ -903,13 +903,13 @@ Mhead_GenGOPHeader(bbPtr, drop_frame_flag, tc_hrs, tc_min, tc_sec, tc_pict,
     /* Write gop start code. */
     Bitio_Write(bbPtr, GOP_START_CODE, 32);
 
-		/* Construct and write timecode. */
+                /* Construct and write timecode. */
 
     /* Drop frame flag. */
     if (drop_frame_flag) {
-	Bitio_Write(bbPtr, 0x01, 1);
+        Bitio_Write(bbPtr, 0x01, 1);
     } else {
-	Bitio_Write(bbPtr, 0x00, 1);
+        Bitio_Write(bbPtr, 0x00, 1);
     }
 
     /* Time code hours. */
@@ -930,16 +930,16 @@ Mhead_GenGOPHeader(bbPtr, drop_frame_flag, tc_hrs, tc_min, tc_sec, tc_pict,
 
     /* Closed gop flag. */
     if (closed_gop) {
-	Bitio_Write(bbPtr, 0x01, 1);
+        Bitio_Write(bbPtr, 0x01, 1);
     } else {
-	Bitio_Write(bbPtr, 0x00, 1);
+        Bitio_Write(bbPtr, 0x00, 1);
     }
 
     /* Broken link flag. */
     if (broken_link) {
-	Bitio_Write(bbPtr, 0x01, 1);
+        Bitio_Write(bbPtr, 0x01, 1);
     } else {
-	Bitio_Write(bbPtr, 0x00, 1);
+        Bitio_Write(bbPtr, 0x00, 1);
     }
 
     /* next start code */
@@ -948,21 +948,21 @@ Mhead_GenGOPHeader(bbPtr, drop_frame_flag, tc_hrs, tc_min, tc_sec, tc_pict,
     /* Write ext data if present. */
 
     if (ext_data != NULL) {
-	Bitio_Write(bbPtr, EXT_START_CODE, 32);
+        Bitio_Write(bbPtr, EXT_START_CODE, 32);
 
-	for (i = 0; i < ext_data_size; i++) {
-	    Bitio_Write(bbPtr, ext_data[i], 8);
-	}
-	Bitio_BytePad(bbPtr);
+        for (i = 0; i < ext_data_size; i++) {
+            Bitio_Write(bbPtr, ext_data[i], 8);
+        }
+        Bitio_BytePad(bbPtr);
     }
     /* Write user data if present. */
     if (user_data != NULL) {
-	Bitio_Write(bbPtr, USER_START_CODE, 32);
+        Bitio_Write(bbPtr, USER_START_CODE, 32);
 
-	for (i = 0; i < user_data_size; i++) {
-	    Bitio_Write(bbPtr, user_data[i], 8);
-	}
-	Bitio_BytePad(bbPtr);
+        for (i = 0; i < user_data_size; i++) {
+            Bitio_Write(bbPtr, user_data[i], 8);
+        }
+        Bitio_BytePad(bbPtr);
     }
 }
 
@@ -971,10 +971,10 @@ Mhead_GenGOPHeader(bbPtr, drop_frame_flag, tc_hrs, tc_min, tc_sec, tc_pict,
  *
  * Mhead_GenSliceHeader
  *
- *	generate slice header with specified attributes
- *	append result to the specified bitstream
+ *      generate slice header with specified attributes
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -999,10 +999,10 @@ Mhead_GenSliceHeader(bbPtr, verticalPos, qscale, extra_info, extra_info_size)
     /* Extra bit slice info. */
 
     if (extra_info != NULL) {
-	for (i = 0; i < extra_info_size; i++) {
-	    Bitio_Write(bbPtr, 0x01, 1);
-	    Bitio_Write(bbPtr, extra_info[i], 8);
-	}
+        for (i = 0; i < extra_info_size; i++) {
+            Bitio_Write(bbPtr, 0x01, 1);
+            Bitio_Write(bbPtr, extra_info[i], 8);
+        }
     }
 
     /* extra_bit_slice */
@@ -1014,10 +1014,10 @@ Mhead_GenSliceHeader(bbPtr, verticalPos, qscale, extra_info, extra_info_size)
  *
  * Mhead_GenSliceEnder
  *
- *	generate slice ender
- *	append result to the specified bitstream
+ *      generate slice ender
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -1034,20 +1034,20 @@ Mhead_GenSliceEnder(bbPtr)
  *
  * Mhead_GenMBHeader
  *
- *	generate macroblock header with given attributes
- *	append result to the specified bitstream
+ *      generate macroblock header with given attributes
+ *      append result to the specified bitstream
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
  *===========================================================================*/
 void
 Mhead_GenMBHeader(bbPtr, pict_code_type, addr_incr, q_scale,
-		  forw_f_code, back_f_code, horiz_forw_r, vert_forw_r,
-		  horiz_back_r, vert_back_r, motion_forw, m_horiz_forw,
-		  m_vert_forw, motion_back, m_horiz_back, m_vert_back,
-		  mb_pattern, mb_intra)
+                  forw_f_code, back_f_code, horiz_forw_r, vert_forw_r,
+                  horiz_back_r, vert_back_r, motion_forw, m_horiz_forw,
+                  m_vert_forw, motion_back, m_horiz_back, m_vert_back,
+                  mb_pattern, mb_intra)
     BitBucket *bbPtr;
     uint32 pict_code_type;
     uint32 addr_incr;
@@ -1077,8 +1077,8 @@ if ( addr_incr != 1 )
 #endif
 
     while (addr_incr > 33) {
-	Bitio_Write(bbPtr, 0x008, 11);
-	addr_incr -= 33;
+        Bitio_Write(bbPtr, 0x008, 11);
+        addr_incr -= 33;
     }
 
     /* Generate addr incr code. */
@@ -1098,62 +1098,62 @@ if ( addr_incr != 1 )
 
     /* MB quant. */
     if (mb_quant) {
-	Bitio_Write(bbPtr, q_scale, 5);
+        Bitio_Write(bbPtr, q_scale, 5);
     }
     /* Forward predictive vector stuff. */
 
     if (motion_forw) {
-	int forw_f, forw_r_size;
-
-	forw_r_size = forw_f_code - 1;
-	forw_f = 1 << forw_r_size;	/* 1 > 0 */
-	if ((m_horiz_forw > 16*forw_f-1) || (m_horiz_forw < -16*forw_f)) {
-	  fprintf(stderr, "Illegal motion? %d %d\n", m_horiz_forw, 16*forw_f);
-	}
-	if ((m_vert_forw > 16*forw_f-1) || (m_vert_forw < -16*forw_f)) {
-	  fprintf(stderr, "Illegal motion? %d %d\n", m_vert_forw, 16*forw_f);
-	}
-	GenMotionCode(bbPtr, m_horiz_forw);
-
-	if ((forw_f != 1) && (m_horiz_forw != 0)) {
-	    Bitio_Write(bbPtr, horiz_forw_r, forw_r_size);
-	}
-	GenMotionCode(bbPtr, m_vert_forw);
-
-	if ((forw_f != 1) && (m_vert_forw != 0)) {
-	    Bitio_Write(bbPtr, vert_forw_r, forw_r_size);
-	}
+        int forw_f, forw_r_size;
+
+        forw_r_size = forw_f_code - 1;
+        forw_f = 1 << forw_r_size;      /* 1 > 0 */
+        if ((m_horiz_forw > 16*forw_f-1) || (m_horiz_forw < -16*forw_f)) {
+          fprintf(stderr, "Illegal motion? %d %d\n", m_horiz_forw, 16*forw_f);
+        }
+        if ((m_vert_forw > 16*forw_f-1) || (m_vert_forw < -16*forw_f)) {
+          fprintf(stderr, "Illegal motion? %d %d\n", m_vert_forw, 16*forw_f);
+        }
+        GenMotionCode(bbPtr, m_horiz_forw);
+
+        if ((forw_f != 1) && (m_horiz_forw != 0)) {
+            Bitio_Write(bbPtr, horiz_forw_r, forw_r_size);
+        }
+        GenMotionCode(bbPtr, m_vert_forw);
+
+        if ((forw_f != 1) && (m_vert_forw != 0)) {
+            Bitio_Write(bbPtr, vert_forw_r, forw_r_size);
+        }
     }
     /* Back predicted vector stuff. */
 
     if (motion_back) {
-	int back_f, back_r_size;
+        int back_f, back_r_size;
 
-	back_r_size = back_f_code - 1;
-	back_f = 1 << back_r_size;	/* 1 > 0 */
+        back_r_size = back_f_code - 1;
+        back_f = 1 << back_r_size;      /* 1 > 0 */
 
-	if ((m_horiz_back > 16*back_f-1) || (m_horiz_back < -16*back_f)) {
-	  fprintf(stderr, "Illegal motion? %d %d\n", m_horiz_back, 16*back_f);
-	}
-	if ((m_vert_back > 16*back_f-1) || (m_vert_back < -16*back_f)) {
-	  fprintf(stderr, "Illegal motion? %d %d\n", m_vert_back, 16*back_f);
-	}
+        if ((m_horiz_back > 16*back_f-1) || (m_horiz_back < -16*back_f)) {
+          fprintf(stderr, "Illegal motion? %d %d\n", m_horiz_back, 16*back_f);
+        }
+        if ((m_vert_back > 16*back_f-1) || (m_vert_back < -16*back_f)) {
+          fprintf(stderr, "Illegal motion? %d %d\n", m_vert_back, 16*back_f);
+        }
 
-	GenMotionCode(bbPtr, m_horiz_back);
+        GenMotionCode(bbPtr, m_horiz_back);
 
-	if ((back_f != 1) && (m_horiz_back != 0)) {
-	    Bitio_Write(bbPtr, horiz_back_r, back_r_size);
-	}
-	GenMotionCode(bbPtr, m_vert_back);
+        if ((back_f != 1) && (m_horiz_back != 0)) {
+            Bitio_Write(bbPtr, horiz_back_r, back_r_size);
+        }
+        GenMotionCode(bbPtr, m_vert_back);
 
-	if ((back_f != 1) && (m_vert_back != 0)) {
-	    Bitio_Write(bbPtr, vert_back_r, back_r_size);
-	}
+        if ((back_f != 1) && (m_vert_back != 0)) {
+            Bitio_Write(bbPtr, vert_back_r, back_r_size);
+        }
     }
     /* MB pattern. */
 
     if (mb_pattern) {
-	GenBlockPattern(bbPtr, mb_pattern);
+        GenBlockPattern(bbPtr, mb_pattern);
     }
 }
 
diff --git a/converter/ppm/ppmtompeg/moutput.c b/converter/ppm/ppmtompeg/moutput.c
index b682efab..765a2b6f 100644
--- a/converter/ppm/ppmtompeg/moutput.c
+++ b/converter/ppm/ppmtompeg/moutput.c
@@ -1,13 +1,13 @@
 /*===========================================================================*
- * moutput.c								     *
- *									     *
- *	Procedures concerned with quantization and RLE			     *
- *									     *
- * EXPORTED PROCEDURES:							     *
- *	mp_quant_zig_block						     *
- *	mp_rle_huff_block						     *
- *	mp_rle_huff_pblock						     *
- *									     *
+ * moutput.c                                                                 *
+ *                                                                           *
+ *      Procedures concerned with quantization and RLE                       *
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
+ *      mp_quant_zig_block                                                   *
+ *      mp_rle_huff_block                                                    *
+ *      mp_rle_huff_pblock                                                   *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -121,48 +121,48 @@ static int qtable[] =
  *=====================*/
 
 
-void	UnQuantZig(FlatBlock in, Block out, int qscale, boolean iblock)
+void    UnQuantZig(FlatBlock in, Block out, int qscale, boolean iblock)
 {
     register int index;
-    int	    start;
-    int	    position;
-    register int	    qentry;
-    int	    level, coeff;
+    int     start;
+    int     position;
+    register int            qentry;
+    int     level, coeff;
     register int16 temp;
 
     if ( iblock )
     {
-	((int16 *)out)[0] = (int16)(in[0]*qtable[0]);
+        ((int16 *)out)[0] = (int16)(in[0]*qtable[0]);
 
-	start = 1;
+        start = 1;
     }
     else
-	start = 0;
+        start = 0;
 
     for ( index = start; index < DCTSIZE_SQ; index++ )
     {
-	position = ZAG[index];
+        position = ZAG[index];
 
-	if (iblock)
-	    qentry = qtable[position] * qscale;
-	else
-	    qentry = 16 * qscale;
+        if (iblock)
+            qentry = qtable[position] * qscale;
+        else
+            qentry = 16 * qscale;
 
-	level = in[index];
+        level = in[index];
         coeff = (level * qentry) >> 3;
         if (level < 0) {
             coeff += (coeff & 1);
-	} else {
+        } else {
             coeff -= (coeff & 1);
-	}
+        }
 
-	((int16 *)out)[position] = coeff;
+        ((int16 *)out)[position] = coeff;
     }
 
 #ifdef BLEAH
     for ( index = 0; index < 64; index++ )
-	fprintf(stdout, "DCT[%d] = %d\n", index, 
-		((int16 *)out)[index]);
+        fprintf(stdout, "DCT[%d] = %d\n", index,
+                ((int16 *)out)[index]);
 #endif
 }
 
@@ -175,7 +175,7 @@ void	UnQuantZig(FlatBlock in, Block out, int qscale, boolean iblock)
  * Quantizes and zigzags a block -- removing information
  *
  * Results: TRUE iff resulting 'out' is non-zero, FALSE if all
- *	    zero
+ *          zero
  *
  * Side effects: Modifies the out block.
  *
@@ -192,56 +192,56 @@ boolean mp_quant_zig_block(Block in, FlatBlock out, int qscale, int iblock)
 
     DBG_PRINT(("mp_quant_zig_block...\n"));
     if (iblock) {
-	/*
-	 * the DC coefficient is handled specially -- it's not
-	 * sensitive to qscale, but everything else is
-	 */
-	temp = ((int16 *) in)[ZAG[0]];
-	qentry = qtable[ZAG[0]];
-	if (temp < 0) {
-	    temp = -temp;
-	    temp += qentry >> 1;
-	    temp /= qentry;
-	    temp = -temp;
-	} else {
-	    temp += qentry >> 1;
-	    temp /= qentry;
-	}
-	if ( temp != 0 )
-	    nonZero = TRUE;
-	out[0] = temp;
-	start = 1;
+        /*
+         * the DC coefficient is handled specially -- it's not
+         * sensitive to qscale, but everything else is
+         */
+        temp = ((int16 *) in)[ZAG[0]];
+        qentry = qtable[ZAG[0]];
+        if (temp < 0) {
+            temp = -temp;
+            temp += qentry >> 1;
+            temp /= qentry;
+            temp = -temp;
+        } else {
+            temp += qentry >> 1;
+            temp /= qentry;
+        }
+        if ( temp != 0 )
+            nonZero = TRUE;
+        out[0] = temp;
+        start = 1;
     } else
-	start = 0;
+        start = 0;
 
     for (i = start; i < DCTSIZE_SQ; i++) {
-	x = ZAG[i] % 8;
-	y = ZAG[i] / 8;
-	temp = in[y][x];
-	DBG_PRINT(("    in[%d][%d] = %d;  ", y, x, temp));
-
-	if (iblock)
-	    qentry = qtable[ZAG[i]] * qscale;
-	else
-	    qentry = 16 * qscale;
-
-	DBG_PRINT(("quantized with %d = ", qentry));
-
-	if (temp < 0) {
-	    temp = -temp;
-	    temp *= 8;
-	    temp += qentry >> 1;
-	    temp /= qentry;
-	    temp = -temp;
-	} else {
-	    temp *= 8;
-	    temp += qentry >> 1;
-	    temp /= qentry;
-	}
-	if ( temp != 0 )
-	    nonZero = TRUE;
-	out[i] = temp;
-	DBG_PRINT(("%d\n", temp));
+        x = ZAG[i] % 8;
+        y = ZAG[i] / 8;
+        temp = in[y][x];
+        DBG_PRINT(("    in[%d][%d] = %d;  ", y, x, temp));
+
+        if (iblock)
+            qentry = qtable[ZAG[i]] * qscale;
+        else
+            qentry = 16 * qscale;
+
+        DBG_PRINT(("quantized with %d = ", qentry));
+
+        if (temp < 0) {
+            temp = -temp;
+            temp *= 8;
+            temp += qentry >> 1;
+            temp /= qentry;
+            temp = -temp;
+        } else {
+            temp *= 8;
+            temp += qentry >> 1;
+            temp /= qentry;
+        }
+        if ( temp != 0 )
+            nonZero = TRUE;
+        out[i] = temp;
+        DBG_PRINT(("%d\n", temp));
     }
 
     return nonZero;
@@ -263,7 +263,7 @@ boolean mp_quant_zig_block(Block in, FlatBlock out, int qscale, int iblock)
  * --------------------------------------------------------------
  */
 
-void	mp_rle_huff_block(FlatBlock in, BitBucket *out)
+void    mp_rle_huff_block(FlatBlock in, BitBucket *out)
 {
     register int i;
     register int nzeros = 0;
@@ -277,61 +277,61 @@ void	mp_rle_huff_block(FlatBlock in, BitBucket *out)
      * specially, elsewhere.  Not here.
      */
     for (i = 1; i < DCTSIZE_SQ; i++) {
-	cur = in[i];
-	acur = ABS(cur);
-	if (cur) {
-	    if (nzeros < HUFF_MAXRUN && acur < huff_maxlevel[nzeros]) {
-	        /*
-		 * encode using the Huffman tables
-		 */
-
-		DBG_PRINT(("rle_huff %02d: Run %02d, Level %02d\n", i, nzeros, cur));
-		assert(cur);
-
-		code = (huff_table[nzeros])[acur];
-		nbits = (huff_bits[nzeros])[acur];
-
-		assert(nbits);
-
-		if (cur < 0)
-		    code |= 1;	/* the sign bit */
-		Bitio_Write(out, code, nbits);
-	    } else {
-		/*
-		 * encode using the escape code
-		 */
-		DBG_PRINT(("Escape\n"));
-		Bitio_Write(out, 0x1, 6);	/* ESCAPE */
-		DBG_PRINT(("Run Length\n"));
-		Bitio_Write(out, nzeros, 6);	/* Run-Length */
-
-		assert(cur != 0);
-
-		/*
-	         * this shouldn't happen, but the other
-	         * choice is to bomb out and dump core...
-	         */
-		if (cur < -255)
-		    cur = -255;
-		else if (cur > 255)
-		    cur = 255;
-
-		DBG_PRINT(("Level\n"));
-		if (acur < 128) {
-		    Bitio_Write(out, cur, 8);
-		} else {
-		    if (cur < 0) {
-			Bitio_Write(out, 0x8001 + cur + 255, 16);
-		    } else
-			Bitio_Write(out, cur, 16);
-		}
-	    }
-	    nzeros = 0;
-	} else
-	    nzeros++;
+        cur = in[i];
+        acur = ABS(cur);
+        if (cur) {
+            if (nzeros < HUFF_MAXRUN && acur < huff_maxlevel[nzeros]) {
+                /*
+                 * encode using the Huffman tables
+                 */
+
+                DBG_PRINT(("rle_huff %02d: Run %02d, Level %02d\n", i, nzeros, cur));
+                assert(cur);
+
+                code = (huff_table[nzeros])[acur];
+                nbits = (huff_bits[nzeros])[acur];
+
+                assert(nbits);
+
+                if (cur < 0)
+                    code |= 1;  /* the sign bit */
+                Bitio_Write(out, code, nbits);
+            } else {
+                /*
+                 * encode using the escape code
+                 */
+                DBG_PRINT(("Escape\n"));
+                Bitio_Write(out, 0x1, 6);       /* ESCAPE */
+                DBG_PRINT(("Run Length\n"));
+                Bitio_Write(out, nzeros, 6);    /* Run-Length */
+
+                assert(cur != 0);
+
+                /*
+                 * this shouldn't happen, but the other
+                 * choice is to bomb out and dump core...
+                 */
+                if (cur < -255)
+                    cur = -255;
+                else if (cur > 255)
+                    cur = 255;
+
+                DBG_PRINT(("Level\n"));
+                if (acur < 128) {
+                    Bitio_Write(out, cur, 8);
+                } else {
+                    if (cur < 0) {
+                        Bitio_Write(out, 0x8001 + cur + 255, 16);
+                    } else
+                        Bitio_Write(out, cur, 16);
+                }
+            }
+            nzeros = 0;
+        } else
+            nzeros++;
     }
     DBG_PRINT(("End of block\n"));
-    Bitio_Write(out, 0x2, 2);	/* end of block marker */
+    Bitio_Write(out, 0x2, 2);   /* end of block marker */
 }
 
 
@@ -349,7 +349,7 @@ void	mp_rle_huff_block(FlatBlock in, BitBucket *out)
  * --------------------------------------------------------------
  */
 
-void	mp_rle_huff_pblock(FlatBlock in, BitBucket *out)
+void    mp_rle_huff_pblock(FlatBlock in, BitBucket *out)
 {
     register int i;
     register int nzeros = 0;
@@ -363,80 +363,80 @@ void	mp_rle_huff_pblock(FlatBlock in, BitBucket *out)
      * yes, Virginia, we start at 0.
      */
     for (i = 0; i < DCTSIZE_SQ; i++) {
-	cur = in[i];
-	acur = ABS(cur);
-	if (cur) {
-	    if (nzeros < HUFF_MAXRUN && acur < huff_maxlevel[nzeros]) {
-	        /*
-		 * encode using the Huffman tables
-		 */
-
-		DBG_PRINT(("rle_huff %02d: Run %02d, Level %02d\n", i, nzeros, cur));
-		assert(cur);
-
-		if ( first_dct && (nzeros == 0) && (acur == 1) )
-		{
-		    /* actually, only needs = 0x2 */
-		    code = (cur == 1) ? 0x2 : 0x3;
-		    nbits = 2;
-		}
-		else
-		{
-		    code = (huff_table[nzeros])[acur];
-		    nbits = (huff_bits[nzeros])[acur];
-		}
-
-		assert(nbits);
-
-		if (cur < 0)
-		    code |= 1;	/* the sign bit */
-		Bitio_Write(out, code, nbits);
-		first_dct = FALSE;
-	    } else {
-		/*
-		 * encode using the escape code
-		 */
-		DBG_PRINT(("Escape\n"));
-		Bitio_Write(out, 0x1, 6);	/* ESCAPE */
-		DBG_PRINT(("Run Length\n"));
-		Bitio_Write(out, nzeros, 6);	/* Run-Length */
-
-		assert(cur != 0);
-
-		/*
-	         * this shouldn't happen, but the other
-	         * choice is to bomb out and dump core...
-	         */
-		if (cur < -255)
-		    cur = -255;
-		else if (cur > 255)
-		    cur = 255;
-
-		DBG_PRINT(("Level\n"));
-		if (acur < 128) {
-		    Bitio_Write(out, cur, 8);
-		} else {
-		    if (cur < 0) {
-			Bitio_Write(out, 0x8001 + cur + 255, 16);
-		    } else
-			Bitio_Write(out, cur, 16);
-		}
-
-		first_dct = FALSE;
-	    }
-	    nzeros = 0;
-	} else
-	    nzeros++;
+        cur = in[i];
+        acur = ABS(cur);
+        if (cur) {
+            if (nzeros < HUFF_MAXRUN && acur < huff_maxlevel[nzeros]) {
+                /*
+                 * encode using the Huffman tables
+                 */
+
+                DBG_PRINT(("rle_huff %02d: Run %02d, Level %02d\n", i, nzeros, cur));
+                assert(cur);
+
+                if ( first_dct && (nzeros == 0) && (acur == 1) )
+                {
+                    /* actually, only needs = 0x2 */
+                    code = (cur == 1) ? 0x2 : 0x3;
+                    nbits = 2;
+                }
+                else
+                {
+                    code = (huff_table[nzeros])[acur];
+                    nbits = (huff_bits[nzeros])[acur];
+                }
+
+                assert(nbits);
+
+                if (cur < 0)
+                    code |= 1;  /* the sign bit */
+                Bitio_Write(out, code, nbits);
+                first_dct = FALSE;
+            } else {
+                /*
+                 * encode using the escape code
+                 */
+                DBG_PRINT(("Escape\n"));
+                Bitio_Write(out, 0x1, 6);       /* ESCAPE */
+                DBG_PRINT(("Run Length\n"));
+                Bitio_Write(out, nzeros, 6);    /* Run-Length */
+
+                assert(cur != 0);
+
+                /*
+                 * this shouldn't happen, but the other
+                 * choice is to bomb out and dump core...
+                 */
+                if (cur < -255)
+                    cur = -255;
+                else if (cur > 255)
+                    cur = 255;
+
+                DBG_PRINT(("Level\n"));
+                if (acur < 128) {
+                    Bitio_Write(out, cur, 8);
+                } else {
+                    if (cur < 0) {
+                        Bitio_Write(out, 0x8001 + cur + 255, 16);
+                    } else
+                        Bitio_Write(out, cur, 16);
+                }
+
+                first_dct = FALSE;
+            }
+            nzeros = 0;
+        } else
+            nzeros++;
     }
 
     /* actually, should REALLY return FALSE and not use this! */
-    if ( first_dct )	/* have to give a first_dct even if all 0's */
+    if ( first_dct )    /* have to give a first_dct even if all 0's */
     {
-	fprintf(stdout, "HUFF called with all-zero coefficients\n");
-	fprintf(stdout, "exiting...\n");
-	exit(1);
+        fprintf(stdout, "HUFF called with all-zero coefficients\n");
+        fprintf(stdout, "exiting...\n");
+        exit(1);
     }
 
     DBG_PRINT(("End of block\n"));
-    Bitio_Write(out, 0x2, 2);	/* end of block marker */
+    Bitio_Write(out, 0x2, 2);   /* end of block marker */
 }
diff --git a/converter/ppm/ppmtompeg/mquant.c b/converter/ppm/ppmtompeg/mquant.c
index 1f8ca63a..99b1cb8e 100644
--- a/converter/ppm/ppmtompeg/mquant.c
+++ b/converter/ppm/ppmtompeg/mquant.c
@@ -17,14 +17,14 @@ static int qtable[][8] = {
  *
  * mp_quant_block --
  *
- *	Quantizes a block -- removing information
- *	It's safe for out == in.
+ *      Quantizes a block -- removing information
+ *      It's safe for out == in.
  *
  * Results:
- *	None.
+ *      None.
  *
  * Side effects:
- *	Modifies the out block.
+ *      Modifies the out block.
  *
  *--------------------------------------------------------------
  */
@@ -32,13 +32,13 @@ void mp_quant_block(Block in, Block out) {
     int i;
 
     for(i=0;i<8;i++) {
-	out[i][0] = in[i][0] / qtable[i][0];
-	out[i][1] = in[i][1] / qtable[i][1];
-	out[i][2] = in[i][2] / qtable[i][2];
-	out[i][3] = in[i][3] / qtable[i][3];
-	out[i][4] = in[i][4] / qtable[i][4];
-	out[i][5] = in[i][5] / qtable[i][5];
-	out[i][6] = in[i][6] / qtable[i][6];
-	out[i][7] = in[i][7] / qtable[i][7];
+        out[i][0] = in[i][0] / qtable[i][0];
+        out[i][1] = in[i][1] / qtable[i][1];
+        out[i][2] = in[i][2] / qtable[i][2];
+        out[i][3] = in[i][3] / qtable[i][3];
+        out[i][4] = in[i][4] / qtable[i][4];
+        out[i][5] = in[i][5] / qtable[i][5];
+        out[i][6] = in[i][6] / qtable[i][6];
+        out[i][7] = in[i][7] / qtable[i][7];
     }
 }
diff --git a/converter/ppm/ppmtompeg/nojpeg.c b/converter/ppm/ppmtompeg/nojpeg.c
index 38c05a9e..5b86ab56 100644
--- a/converter/ppm/ppmtompeg/nojpeg.c
+++ b/converter/ppm/ppmtompeg/nojpeg.c
@@ -1,12 +1,12 @@
 /*===========================================================================*
- * nojpeg.c								     *
- *									     *
- *	procedures to deal with JPEG files				     *
- *									     *
- * EXPORTED PROCEDURES:							     *
- *	JMovie2JPEG							     *
- *      ReadJPEG							     *
- *									     *
+ * nojpeg.c                                                                  *
+ *                                                                           *
+ *      procedures to deal with JPEG files                                   *
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
+ *      JMovie2JPEG                                                          *
+ *      ReadJPEG                                                             *
+ *                                                                           *
  *===========================================================================*/
 
 /*
diff --git a/converter/ppm/ppmtompeg/noparallel.c b/converter/ppm/ppmtompeg/noparallel.c
index 6e6449a4..02c46a58 100644
--- a/converter/ppm/ppmtompeg/noparallel.c
+++ b/converter/ppm/ppmtompeg/noparallel.c
@@ -70,7 +70,7 @@ time_t  IOtime = 0;
 
 void
 IoServer(struct inputSource * const inputSourceP,
-         const char *         const parallelHostName, 
+         const char *         const parallelHostName,
          int                  const portNum) {
 
     pm_error("This version of Ppmtompeg cannot run an I/O server because "
@@ -102,7 +102,7 @@ SetRemoteShell(const char * const shell) {
 void
 NoteFrameDone(int const frameStart,
               int const frameEnd) {
-    fprintf(stdout, 
+    fprintf(stdout,
             "ERROR:  (NoteFrameDone) "
             "This machine can NOT run parallel version\n");
     exit(1);
@@ -151,7 +151,7 @@ WaitForOutputFile(int const number) {
 
 void
 MasterServer(struct inputSource * const inputSourceP,
-             const char *         const paramFileName, 
+             const char *         const paramFileName,
              const char *         const outputFileName) {
 
     pm_error("This version of Ppmtompeg cannot run a master server because "
@@ -161,8 +161,8 @@ MasterServer(struct inputSource * const inputSourceP,
 
 
 void
-CombineServer(int          const numFrames, 
-              const char * const masterHostName, 
+CombineServer(int          const numFrames,
+              const char * const masterHostName,
               int          const masterPortNum,
               const char*  const outputFileName) {
 
@@ -173,9 +173,9 @@ CombineServer(int          const numFrames,
 
 
 void
-DecodeServer(int          const numInputFiles, 
-             const char * const decodeFileName, 
-             const char * const masterHostName, 
+DecodeServer(int          const numInputFiles,
+             const char * const decodeFileName,
+             const char * const masterHostName,
              int          const masterPortNum) {
 
     pm_error("This version of Ppmtompeg cannot run a decode server because "
@@ -185,9 +185,9 @@ DecodeServer(int          const numInputFiles,
 
 
 void
-NotifyMasterDone(const char * const hostName, 
-                 int          const portNum, 
-                 int          const machineNumber, 
+NotifyMasterDone(const char * const hostName,
+                 int          const portNum,
+                 int          const machineNumber,
                  unsigned int const seconds,
                  boolean *    const moreWorkToDoP,
                  int *        const frameStartP,
diff --git a/converter/ppm/ppmtompeg/parallel.c b/converter/ppm/ppmtompeg/parallel.c
index 0fe635ed..b24764d6 100644
--- a/converter/ppm/ppmtompeg/parallel.c
+++ b/converter/ppm/ppmtompeg/parallel.c
@@ -12,6 +12,7 @@
  * HEADER FILES *
  *==============*/
 
+#define _C99_SOURCE  /* Make sure snprintf() is in stdio.h */
 #define _XOPEN_SOURCE 500 /* Make sure stdio.h contains pclose() */
 /* _ALL_SOURCE is needed on AIX to make the C library include the
    socket services (e.g. define struct sockaddr)
@@ -1341,12 +1342,12 @@ startCombineServer(const char * const encoderName,
     int          otherSock;
     const char * error;
 
-    pm_snprintf(command, sizeof(command),
-                "%s %s -max_machines %d -output_server %s %d %d %s",
-                encoderName,
-                debugMachines ? "-debug_machines" : "",
-                numMachines, masterHostName, masterPortNum,
-                numInputFiles, paramFileName);
+    snprintf(command, sizeof(command),
+             "%s %s -max_machines %d -output_server %s %d %d %s",
+             encoderName,
+             debugMachines ? "-debug_machines" : "",
+             numMachines, masterHostName, masterPortNum,
+             numInputFiles, paramFileName);
 
     machineDebug("MASTER: Starting combine server with shell command '%s'",
                  command);
@@ -1383,12 +1384,12 @@ startDecodeServer(const char * const encoderName,
     int          otherSock;
     const char * error;
 
-    pm_snprintf(command, sizeof(command),
-                "%s %s -max_machines %d -decode_server %s %d %d %s",
-                encoder_name,
-                debugMachines ? "-debug_machines" : "",
-                numMachines, masterHostName, masterPortNum,
-                numInputFiles, paramFileName);
+    snprintf(command, sizeof(command),
+             "%s %s -max_machines %d -decode_server %s %d %d %s",
+             encoder_name,
+             debugMachines ? "-debug_machines" : "",
+             numMachines, masterHostName, masterPortNum,
+             numInputFiles, paramFileName);
 
     machineDebug("MASTER: Starting decode server with shell command '%s'",
                  command);
@@ -1681,22 +1682,22 @@ startChildren(struct scheduler *   const schedulerP,
                 }
                 --childrenLeftCurrentIoServer;
             }
-            pm_snprintf(command, sizeof(command),
-                        "%s %s -l %s %s "
-                        "%s %s -child %s %d %d %d %d %d %d "
-                        "-frames %d %d %s",
-                        rsh,
-                        machineName[childNum], userName[childNum],
-                        beNice ? "nice" : "",
-                        executable[childNum],
-                        debugMachines ? "-debug_machines" : "",
-                        masterHostName, masterPortNum,
-                        remote[childNum] ? ioPortNum[numIoServers-1] : 0,
-                        combinePortNum, decodePortNum, childNum,
-                        remote[childNum] ? 1 : 0,
-                        startFrame, startFrame + nFrames - 1,
-                        remote[childNum] ?
-                          remoteParamFile[childNum] : paramFileName
+            snprintf(command, sizeof(command),
+                     "%s %s -l %s %s "
+                     "%s %s -child %s %d %d %d %d %d %d "
+                     "-frames %d %d %s",
+                     rsh,
+                     machineName[childNum], userName[childNum],
+                     beNice ? "nice" : "",
+                     executable[childNum],
+                     debugMachines ? "-debug_machines" : "",
+                     masterHostName, masterPortNum,
+                     remote[childNum] ? ioPortNum[numIoServers-1] : 0,
+                     combinePortNum, decodePortNum, childNum,
+                     remote[childNum] ? 1 : 0,
+                     startFrame, startFrame + nFrames - 1,
+                     remote[childNum] ?
+                     remoteParamFile[childNum] : paramFileName
                 );
 
             machineDebug("MASTER: Starting child server "
diff --git a/converter/ppm/ppmtompeg/pframe.c b/converter/ppm/ppmtompeg/pframe.c
index de91e32c..d61848b1 100644
--- a/converter/ppm/ppmtompeg/pframe.c
+++ b/converter/ppm/ppmtompeg/pframe.c
@@ -1,22 +1,22 @@
 /*===========================================================================*
- * pframe.c                                  
- *                                       
- *  Procedures concerned with generation of P-frames             
- *                                       
- * EXPORTED PROCEDURES:                              
- *  GenPFrame                                
- *  ResetPFrameStats                             
- *  ShowPFrameSummary                            
- *  EstimateSecondsPerPFrame                         
- *  ComputeHalfPixelData                             
- *  SetPQScale                               
- *  GetPQScale                               
- *                                                                           
- * NOTE:  when motion vectors are passed as arguments, they are passed as    
- *        twice their value.  In other words, a motion vector of (3,4) will  
- *        be passed as (6,8).  This allows half-pixel motion vectors to be   
- *        passed as integers.  This is true throughout the program.          
- *                                       
+ * pframe.c
+ *
+ *  Procedures concerned with generation of P-frames
+ *
+ * EXPORTED PROCEDURES:
+ *  GenPFrame
+ *  ResetPFrameStats
+ *  ShowPFrameSummary
+ *  EstimateSecondsPerPFrame
+ *  ComputeHalfPixelData
+ *  SetPQScale
+ *  GetPQScale
+ *
+ * NOTE:  when motion vectors are passed as arguments, they are passed as
+ *        twice their value.  In other words, a motion vector of (3,4) will
+ *        be passed as (6,8).  This allows half-pixel motion vectors to be
+ *        passed as integers.  This is true throughout the program.
+ *
  *===========================================================================*/
 
 /*==============*
@@ -101,7 +101,7 @@ ZeroMotionBetter(const LumBlock * const currentBlockP,
     int bestDiff;
     int CompareMode;
 
-    /* Junk needed to adapt for TUNEing */ 
+    /* Junk needed to adapt for TUNEing */
     CompareMode = SearchCompareMode;
     SearchCompareMode = DEFAULT_SEARCH;
     bestDiff = LumMotionError(currentBlockP, prev, by, bx, m, 0x7fffffff);
@@ -158,14 +158,14 @@ DoIntraCode(const LumBlock * const currentBlockP,
         for (x = 0; x < 16; ++x) {
             currPixel = currentBlockP->l[y][x];
             prevPixel = motionBlock.l[y][x];
-            
+
             sum += currPixel;
             varc += currPixel*currPixel;
-            
+
             vard += SQR(currPixel - prevPixel);
         }
     }
-    
+
     vard /= 256;     /* divide by 256; assumes mean is close to zero */
     varc = (varc/256) - (sum/256) * (sum/256);
 
@@ -217,11 +217,11 @@ ZeroMotionSufficient(const LumBlock * const currentBlockP,
 
     return (zeroDiff <= 256);
 }
-                 
 
 
-static void 
-computeCurrentBlock(MpegFrame * const current, 
+
+static void
+computeCurrentBlock(MpegFrame * const current,
                     int         const y,
                     int         const x,
                     LumBlock *  const currentBlockP) {
@@ -232,7 +232,7 @@ computeCurrentBlock(MpegFrame * const current,
     for ( iy = 0; iy < 16; iy++ ) {
         int ix;
         for ( ix = 0; ix < 16; ix++ ) {
-            currentBlockP->l[iy][ix] = 
+            currentBlockP->l[iy][ix] =
                 (int16)current->orig_y[fy+iy][fx+ix];
         }
     }
@@ -241,17 +241,17 @@ computeCurrentBlock(MpegFrame * const current,
 
 
 static void
-computeMotionVectors(bool             const specificsOn, 
+computeMotionVectors(bool             const specificsOn,
                      bool             const IntraPBAllowed,
-                     MpegFrame *      const current, 
+                     MpegFrame *      const current,
                      MpegFrame *      const prev,
                      int              const mbAddress,
                      BlockMV **       const infoP,
-                     int              const QScale, 
+                     int              const QScale,
                      const LumBlock * const currentBlockP,
-                     int              const y, 
+                     int              const y,
                      int              const x,
-                     bool *           const useMotionP, 
+                     bool *           const useMotionP,
                      vector *         const motionP) {
 
     bool useCached;
@@ -260,7 +260,7 @@ computeMotionVectors(bool             const specificsOn,
     /* See if we have a cached answer */
     if (specificsOn) {
         SpecLookup(current->id, 2, mbAddress, &info, QScale);
-        if (info != (BlockMV*)NULL) 
+        if (info != (BlockMV*)NULL)
             useCached = TRUE;
         else
             useCached = FALSE;
@@ -293,7 +293,7 @@ computeMotionVectors(bool             const specificsOn,
                 motionP->x = 0;
             } else
                 *motionP = motion;
-            if (IntraPBAllowed) 
+            if (IntraPBAllowed)
                 *useMotionP = !DoIntraCode(currentBlockP, prev, y, x, motion);
             else
                 *useMotionP = TRUE;
@@ -305,12 +305,12 @@ computeMotionVectors(bool             const specificsOn,
 
 
 static void
-calculateForwardDcts(MpegFrame * const current, 
+calculateForwardDcts(MpegFrame * const current,
                      int const y, int const x,
                      Block ** const dct) {
 
     /* calculate forward dct's */
-    if (collect_quant && (collect_quant_detailed & 1)) 
+    if (collect_quant && (collect_quant_detailed & 1))
         fprintf(collect_quant_fp, "l\n");
 
     mp_fwd_dct_block2(current->y_blocks[y][x], dct[y][x]);
@@ -318,7 +318,7 @@ calculateForwardDcts(MpegFrame * const current,
     mp_fwd_dct_block2(current->y_blocks[y+1][x], dct[y+1][x]);
     mp_fwd_dct_block2(current->y_blocks[y+1][x+1], dct[y+1][x+1]);
 
-    if (collect_quant && (collect_quant_detailed & 1)) 
+    if (collect_quant && (collect_quant_detailed & 1))
         fprintf(collect_quant_fp, "c\n");
 
     mp_fwd_dct_block2(current->cb_blocks[y/2][x/2], dctb[y/2][x/2]);
@@ -348,7 +348,7 @@ computeMotionAndDct(int         const lastBlockY,
     int mbAddress;
     int y;
 
-    mbAddress = 0;                        
+    mbAddress = 0;
 
     for (y = 0; y < lastBlockY; y += 2) {
         int x;
@@ -416,7 +416,7 @@ computeMotionAndDct(int         const lastBlockY,
  *===========================================================================*/
 void
 GenPFrame(BitBucket * const bb,
-          MpegFrame * const current, 
+          MpegFrame * const current,
           MpegFrame * const prev) {
 
     extern int **pmvHistogram;
@@ -469,12 +469,12 @@ GenPFrame(BitBucket * const bb,
     if (bitstreamMode == FIXED_RATE) {
         targetRateControl(current);
     }
- 
+
     Mhead_GenPictureHeader(bb, P_FRAME, current->id, fCodeP);
-    /* Check for Qscale change */  
+    /* Check for Qscale change */
     if (specificsOn) {
         /* Set a Qscale for this frame? */
-        newQScale = 
+        newQScale =
             SpecLookup(current->id, 0, 0 /* junk */, &info /*junk*/, QScale);
         if (newQScale != -1) {
             QScale = newQScale;
@@ -515,9 +515,9 @@ GenPFrame(BitBucket * const bb,
 
     computeMotionAndDct(lastBlockY, lastBlockX,
                         specificsOn, IntraPBAllowed, current, prev,
-                        &info, QScale, searchRangeP, dct, 
+                        &info, QScale, searchRangeP, dct,
                         &numPBlocks, &numIBlocks, pmvHistogram);
-    
+
     mbAddress = 0;
     for (y = 0; y < lastBlockY; y += 2) {
         for (x = 0; x < lastBlockX; x += 2) {
@@ -526,7 +526,7 @@ GenPFrame(BitBucket * const bb,
             if ( (slicePos == 0) && (mbAddress != 0) ) {
                 if (specificsOn) {
                     /* Make sure no slice Qscale change */
-                    newQScale = 
+                    newQScale =
                         SpecLookup(current->id, 1, mbAddress/blocksPerSlice,
                                    &info /*junk*/, QScale);
                     if (newQScale != -1) QScale = newQScale;
@@ -541,7 +541,7 @@ GenPFrame(BitBucket * const bb,
 
                 mbAddrInc = 1+(x>>1);
             }
-        
+
             /*  Determine if new Qscale needed for Rate Control purposes  */
             if (bitstreamMode == FIXED_RATE) {
                 rc_blockStart =  bb->cumulativeBits;
@@ -554,10 +554,10 @@ GenPFrame(BitBucket * const bb,
                     QScale = newQScale;
                 }
             }
-        
+
             /* Check for Qscale change */
             if (specificsOn) {
-                newQScale = 
+                newQScale =
                     SpecLookup(current->id, 2, mbAddress, &info, QScale);
                 if (newQScale != -1) {
                     QScale = newQScale;
@@ -607,7 +607,7 @@ GenPFrame(BitBucket * const bb,
                 motion.y = dct_data[y][x].fmotionY;
 
 #ifdef BLEAH
-                ComputeAndPrintPframeMAD(currentBlock, prev, y, x, motion, 
+                ComputeAndPrintPframeMAD(currentBlock, prev, y, x, motion,
                                          mbAddress);
 #endif
 
@@ -625,11 +625,11 @@ GenPFrame(BitBucket * const bb,
 
 #ifdef BLEAH
                 if ( (motion.x != 0) || (motion.y != 0) ) {
-                    fprintf(stdout, "FRAME (y, x)  %d, %d (block %d)\n", 
+                    fprintf(stdout, "FRAME (y, x)  %d, %d (block %d)\n",
                             y, x, mbAddress);
-                    fprintf(stdout, "motion.x = %d, motion.y = %d\n", 
+                    fprintf(stdout, "motion.x = %d, motion.y = %d\n",
                             motion.x, motion.y);
-                    fprintf(stdout, 
+                    fprintf(stdout,
                             "    mxq, mxr = %d, %d    myq, myr = %d, %d\n",
                             motionQuot.x, motionRem.x,
                             motionQuot.y, motionRem.y);
@@ -656,7 +656,7 @@ GenPFrame(BitBucket * const bb,
                 if ( decodeRefFrames) {
                     for ( index = 0; index < 6; index++ ) {
                         if ( pattern & (1 << (5-index))) {
-                            Mpost_UnQuantZigBlock(fba[index], dec[index], 
+                            Mpost_UnQuantZigBlock(fba[index], dec[index],
                                                   QScale, FALSE);
                             mpeg_jrevdct((int16 *)dec[index]);
                         } else {
@@ -671,7 +671,7 @@ GenPFrame(BitBucket * const bb,
                     AddMotionBlock(dec[3], prev->decoded_y, y+1, x+1, motion);
                     AddMotionBlock(dec[4], prev->decoded_cb, y/2, x/2,
                                    halfVector(motion));
-                    AddMotionBlock(dec[5], prev->decoded_cr, y/2, x/2, 
+                    AddMotionBlock(dec[5], prev->decoded_cr, y/2, x/2,
                                    halfVector(motion));
 
                     /* now, unblockify */
@@ -681,7 +681,7 @@ GenPFrame(BitBucket * const bb,
                     BlockToData(current->decoded_y, dec[3], y+1, x+1);
                     BlockToData(current->decoded_cb, dec[4], y/2, x/2);
                     BlockToData(current->decoded_cr, dec[5], y/2, x/2);
-                } 
+                }
 
                 if ((motion.x == 0) && (motion.y == 0)) {
                     if ( pattern == 0 ) {
@@ -698,65 +698,65 @@ GenPFrame(BitBucket * const bb,
                             numSkipped++;
                             numPBlocks--;
                         } else {        /* first/last macroblock */
-                            Mhead_GenMBHeader(bb, 2 /* pict_code_type */, 
+                            Mhead_GenMBHeader(bb, 2 /* pict_code_type */,
                                               mbAddrInc /* addr_incr */,
                                               QScale /* q_scale */,
-                                              fCode /* forw_f_code */, 
+                                              fCode /* forw_f_code */,
                                               1 /* back_f_code */,
-                                              motionRem.x /* horiz_forw_r */, 
+                                              motionRem.x /* horiz_forw_r */,
                                               motionRem.y /* vert_forw_r */,
-                                              0 /* horiz_back_r */, 
+                                              0 /* horiz_back_r */,
                                               0 /* vert_back_r */,
-                                              1 /* motion_forw */, 
+                                              1 /* motion_forw */,
                                               motionQuot.x /* m_horiz_forw */,
-                                              motionQuot.y /* m_vert_forw */, 
+                                              motionQuot.y /* m_vert_forw */,
                                               0 /* motion_back */,
-                                              0 /* m_horiz_back */, 
+                                              0 /* m_horiz_back */,
                                               0 /* m_vert_back */,
-                                              0 /* mb_pattern */, 
+                                              0 /* mb_pattern */,
                                               0 /* mb_intra */);
                             mbAddrInc = 1;
                         }
                     } else {
                         DBG_PRINT(("MB Header(%d,%d)\n", x, y));
-                        Mhead_GenMBHeader(bb, 2 /* pict_code_type */, 
+                        Mhead_GenMBHeader(bb, 2 /* pict_code_type */,
                                           mbAddrInc /* addr_incr */,
                                           QScale /* q_scale */,
-                                          fCode /* forw_f_code */, 
+                                          fCode /* forw_f_code */,
                                           1 /* back_f_code */,
-                                          0 /* horiz_forw_r */, 
+                                          0 /* horiz_forw_r */,
                                           0 /* vert_forw_r */,
-                                          0 /* horiz_back_r */, 
+                                          0 /* horiz_back_r */,
                                           0 /* vert_back_r */,
-                                          0 /* motion_forw */, 
+                                          0 /* motion_forw */,
                                           0 /* m_horiz_forw */,
-                                          0 /* m_vert_forw */, 
+                                          0 /* m_vert_forw */,
                                           0 /* motion_back */,
-                                          0 /* m_horiz_back */, 
+                                          0 /* m_horiz_back */,
                                           0 /* m_vert_back */,
-                                          pattern /* mb_pattern */, 
+                                          pattern /* mb_pattern */,
                                           0 /* mb_intra */);
                         mbAddrInc = 1;
                     }
                 } else {
                     /*      DBG_PRINT(("MB Header(%d,%d)\n", x, y));  */
-          
-                    Mhead_GenMBHeader(bb, 2 /* pict_code_type */, 
+
+                    Mhead_GenMBHeader(bb, 2 /* pict_code_type */,
                                       mbAddrInc /* addr_incr */,
                                       QScale /* q_scale */,
-                                      fCode /* forw_f_code */, 
+                                      fCode /* forw_f_code */,
                                       1 /* back_f_code */,
-                                      motionRem.x /* horiz_forw_r */, 
+                                      motionRem.x /* horiz_forw_r */,
                                       motionRem.y /* vert_forw_r */,
-                                      0 /* horiz_back_r */, 
+                                      0 /* horiz_back_r */,
                                       0 /* vert_back_r */,
-                                      1 /* motion_forw */, 
+                                      1 /* motion_forw */,
                                       motionQuot.x /* m_horiz_forw */,
-                                      motionQuot.y /* m_vert_forw */, 
+                                      motionQuot.y /* m_vert_forw */,
                                       0 /* motion_back */,
-                                      0 /* m_horiz_back */, 
+                                      0 /* m_horiz_back */,
                                       0 /* m_vert_back */,
-                                      pattern /* mb_pattern */, 
+                                      pattern /* mb_pattern */,
                                       0 /* mb_intra */);
                     mbAddrInc = 1;
                 }
@@ -832,7 +832,7 @@ GenPFrame(BitBucket * const bb,
     if ( frameSummary && (! realQuiet) ) {
         fprintf(stdout, "FRAME %d (P):  I BLOCKS:  %d;  "
                 "P BLOCKS:  %d   SKIPPED:  %d  (%ld seconds)\n",
-                current->id, numIBlocks, numPBlocks, numSkipped, 
+                current->id, numIBlocks, numPBlocks, numSkipped,
                 (long)(endTime-startTime)/TIME_RATE);
         if ( printSNR ) {
             fprintf(stdout, "FRAME %d:  SNR:  %.1f\t%.1f\t%.1f\t"
@@ -921,8 +921,8 @@ PFrameTotalTime(void) {
 
 
 void
-ShowPFrameSummary(unsigned int const inputFrameBits, 
-                  unsigned int const totalBits, 
+ShowPFrameSummary(unsigned int const inputFrameBits,
+                  unsigned int const totalBits,
                   FILE *       const fpointer) {
 
     if (numFrames > 0) {
diff --git a/converter/ppm/ppmtompeg/postdct.c b/converter/ppm/ppmtompeg/postdct.c
index 56a23de9..68712963 100644
--- a/converter/ppm/ppmtompeg/postdct.c
+++ b/converter/ppm/ppmtompeg/postdct.c
@@ -1,15 +1,15 @@
 /*===========================================================================*
- * postdct.c								     *
- *									     *
- *	Procedures concerned with MPEG post-DCT processing:		     *
- *	    quantization and RLE Huffman encoding			     *
- *									     *
- * EXPORTED PROCEDURES:							     *
- *	Mpost_QuantZigBlock						     *
- *	Mpost_RLEHuffIBlock						     *
- *	Mpost_RLEHuffPBlock						     *
- *	Mpost_UnQuantZigBlock						     *
- *									     *
+ * postdct.c                                                                 *
+ *                                                                           *
+ *      Procedures concerned with MPEG post-DCT processing:                  *
+ *          quantization and RLE Huffman encoding                            *
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
+ *      Mpost_QuantZigBlock                                                  *
+ *      Mpost_RLEHuffIBlock                                                  *
+ *      Mpost_RLEHuffPBlock                                                  *
+ *      Mpost_UnQuantZigBlock                                                *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -164,8 +164,8 @@ int32 niqtable[] = {
      16, 16, 16, 16, 16, 16, 16, 16
 };
 
-int32	*customQtable = NULL;
-int32	*customNIQtable = NULL;
+int32   *customQtable = NULL;
+int32   *customNIQtable = NULL;
 
 /*==================*
  * GLOBAL VARIABLES *
@@ -181,10 +181,10 @@ extern boolean realQuiet;
  *
  * Mpost_UnQuantZigBlock
  *
- *	unquantize and zig-zag (decode) a single block
- *	see section 2.4.4.1 of MPEG standard
+ *      unquantize and zig-zag (decode) a single block
+ *      see section 2.4.4.1 of MPEG standard
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -197,66 +197,66 @@ Mpost_UnQuantZigBlock(in, out, qscale, iblock)
     boolean iblock;
 {
     register int index;
-    int	    start;
-    int	    position;
-    register int	    qentry;
-    int	    level, coeff;
-    
+    int     start;
+    int     position;
+    register int            qentry;
+    int     level, coeff;
+
     if ( iblock ) {
-	/* qtable[0] must be 8 */
-	out[0][0] = (int16)(in[0] * 8);
+        /* qtable[0] must be 8 */
+        out[0][0] = (int16)(in[0] * 8);
 
-	/* don't need to do anything fancy here, because we saved orig
-	    value, not encoded dc value */
-	start = 1;
+        /* don't need to do anything fancy here, because we saved orig
+            value, not encoded dc value */
+        start = 1;
     } else {
-	start = 0;
+        start = 0;
     }
 
     for ( index = start;  index < DCTSIZE_SQ;  index++ ) {
-	position = ZAG[index];
-	level = in[index];
-
-	if (level == 0) {
-	  ((int16 *)out)[position] = 0;
-	  continue;
-	}
-
-
-	if ( iblock ) {
-	    qentry = qtable[position] * qscale;
-	    coeff = (level*qentry)/8;
-	    if ( (coeff & 1) == 0 ) {
-		if ( coeff < 0 ) {
-		    coeff++;
-		} else if ( coeff > 0 ) {
-		    coeff--;
-		}
-	    }
-	} else {
-	    qentry = niqtable[position] * qscale;
-	    if ( level == 0 ) {
-		coeff = 0;
-	    } else if ( level < 0 ) {
-		coeff = (((2*level)-1)*qentry) / 16;
-		if ( (coeff & 1) == 0 ) {
-		    coeff++;
-		}
-	    } else {
-		coeff = (((2*level)+1)*qentry) >> 4;
-		if ( (coeff & 1) == 0 ) {
-		    coeff--;
-		}
-	    }
-
-	    if ( coeff > 2047 ) {
-		coeff = 2047;
-	    } else if ( coeff < -2048 ) {
-		coeff = -2048;
-	    }
+        position = ZAG[index];
+        level = in[index];
+
+        if (level == 0) {
+          ((int16 *)out)[position] = 0;
+          continue;
+        }
+
+
+        if ( iblock ) {
+            qentry = qtable[position] * qscale;
+            coeff = (level*qentry)/8;
+            if ( (coeff & 1) == 0 ) {
+                if ( coeff < 0 ) {
+                    coeff++;
+                } else if ( coeff > 0 ) {
+                    coeff--;
+                }
+            }
+        } else {
+            qentry = niqtable[position] * qscale;
+            if ( level == 0 ) {
+                coeff = 0;
+            } else if ( level < 0 ) {
+                coeff = (((2*level)-1)*qentry) / 16;
+                if ( (coeff & 1) == 0 ) {
+                    coeff++;
+                }
+            } else {
+                coeff = (((2*level)+1)*qentry) >> 4;
+                if ( (coeff & 1) == 0 ) {
+                    coeff--;
+                }
+            }
+
+            if ( coeff > 2047 ) {
+                coeff = 2047;
+            } else if ( coeff < -2048 ) {
+                coeff = -2048;
+            }
         }
 
-	((int16 *)out)[position] = coeff;
+        ((int16 *)out)[position] = coeff;
     }
 }
 
@@ -265,9 +265,9 @@ Mpost_UnQuantZigBlock(in, out, qscale, iblock)
  *
  * Mpost_QuantZigBlock
  *
- *	quantize and zigzags a block
+ *      quantize and zigzags a block
  *
- * RETURNS:	MPOST_OVERFLOW if a generated value is outside |255|
+ * RETURNS:     MPOST_OVERFLOW if a generated value is outside |255|
  *              MPOST_ZERO     if all coeffs are zero
  *              MPOST_NON_ZERO otherwisw
  *
@@ -287,7 +287,7 @@ Mpost_QuantZigBlock(in, out, qscale, iblock)
   register int position;
   boolean nonZero = FALSE;
   boolean overflow = FALSE;
-  
+
   DBG_PRINT(("Mpost_QuantZigBlock...\n"));
   if (iblock) {
     /*
@@ -296,7 +296,7 @@ Mpost_QuantZigBlock(in, out, qscale, iblock)
      */
     temp = ((int16 *) in)[ZAG[0]];
     qentry = qtable[ZAG[0]];
-    
+
     if (temp < 0) {
       temp = -temp;
       temp += (qentry >> 1);
@@ -310,60 +310,60 @@ Mpost_QuantZigBlock(in, out, qscale, iblock)
       nonZero = TRUE;
     }
     out[0] = temp;
-    
+
     for (i = 1; i < DCTSIZE_SQ; i++) {
       position = ZAG[i];
       temp = ((int16 *) in)[position];
       qentry = qtable[position] * qscale;
-      
+
       /* see 1993 MPEG doc, section D.6.3.4 */
       if (temp < 0) {
-	temp = -temp;
-	temp = (temp << 3);	/* temp > 0 */
-	temp += (qentry >> 1);
-	temp /= qentry;
-	temp = -temp;
+        temp = -temp;
+        temp = (temp << 3);     /* temp > 0 */
+        temp += (qentry >> 1);
+        temp /= qentry;
+        temp = -temp;
       } else {
-	temp = (temp << 3);	/* temp > 0 */
-	temp += (qentry >> 1);
-	temp /= qentry;
+        temp = (temp << 3);     /* temp > 0 */
+        temp += (qentry >> 1);
+        temp /= qentry;
       }
-      
+
       if ( temp != 0 ) {
-	nonZero = TRUE;
-	out[i] = temp;
-	if (temp < -255) {
-	  temp = -255;
-	  overflow = TRUE;
-	} else if (temp > 255) {
-	  temp = 255;
-	  overflow = TRUE;
-	}
+        nonZero = TRUE;
+        out[i] = temp;
+        if (temp < -255) {
+          temp = -255;
+          overflow = TRUE;
+        } else if (temp > 255) {
+          temp = 255;
+          overflow = TRUE;
+        }
       } else out[i]=0;
     }
   } else {
     for (i = 0; i < DCTSIZE_SQ; i++) {
       position = ZAG[i];
       temp = ((int16 *) in)[position];
-      
+
       /* multiply by non-intra qtable */
       qentry = qscale * niqtable[position];
-      
+
       /* see 1993 MPEG doc, D.6.4.5 */
       temp *= 8;
-      temp /= qentry;	    /* truncation toward 0 -- correct */
-      
+      temp /= qentry;       /* truncation toward 0 -- correct */
+
       if ( temp != 0 ) {
-	nonZero = TRUE;
-	out[i] = temp;
-	if (temp < -255) {
-	  temp = -255;
-	  overflow = TRUE;
-	} else if (temp > 255) {
-	  temp = 255;
-	  overflow = TRUE;
-	}
-	
+        nonZero = TRUE;
+        out[i] = temp;
+        if (temp < -255) {
+          temp = -255;
+          overflow = TRUE;
+        } else if (temp > 255) {
+          temp = 255;
+          overflow = TRUE;
+        }
+
       } else out[i]=0;
     }
   }
@@ -379,9 +379,9 @@ Mpost_QuantZigBlock(in, out, qscale, iblock)
  *
  * Mpost_RLEHuffIBlock
  *
- *	generate the huffman bits from an I-block
+ *      generate the huffman bits from an I-block
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -403,60 +403,60 @@ Mpost_RLEHuffIBlock(in, out)
      * specially, elsewhere.  Not here.
      */
     for (i = 1; i < DCTSIZE_SQ; i++) {
-	cur = in[i];
-	acur = ABS(cur);
-	if (cur) {
-	    if ( (nzeros < HUFF_MAXRUN) && (acur < huff_maxlevel[nzeros])) {
-	        /*
-		 * encode using the Huffman tables
-		 */
-
-		DBG_PRINT(("rle_huff %02d.%02d: Run %02d, Level %4d\n", i,  ZAG[i], nzeros, cur));
-		code = (huff_table[nzeros])[acur];
-		nbits = (huff_bits[nzeros])[acur];
-
-		if (cur < 0) {
-		    code |= 1;	/* the sign bit */
-		}
-		Bitio_Write(out, code, nbits);
-	    } else {
-		/*
-		 * encode using the escape code
-		 */
-		DBG_PRINT(("Escape\n"));
-		Bitio_Write(out, 0x1, 6);	/* ESCAPE */
-		DBG_PRINT(("Run Length\n"));
-		Bitio_Write(out, nzeros, 6);	/* Run-Length */
-
-		/*
-	         * this shouldn't happen, but the other
-	         * choice is to bomb out and dump core...
-		 * Hmmm, seems to happen with small Qtable entries (1) -srs
-	         */
-		if (cur < -255) {
-		    cur = -255;
-		} else if (cur > 255) {
-		    cur = 255;
-		}
-
-		DBG_PRINT(("Level\n"));
-		if (acur < 128) {
-		    Bitio_Write(out, cur, 8);
-		} else {
-		    if (cur < 0) {
-			Bitio_Write(out, 0x8001 + cur + 255, 16);
-		    } else {
-			Bitio_Write(out, cur, 16);
-		    }
-		}
-	    }
-	    nzeros = 0;
-	} else {
-	    nzeros++;
-	}
+        cur = in[i];
+        acur = ABS(cur);
+        if (cur) {
+            if ( (nzeros < HUFF_MAXRUN) && (acur < huff_maxlevel[nzeros])) {
+                /*
+                 * encode using the Huffman tables
+                 */
+
+                DBG_PRINT(("rle_huff %02d.%02d: Run %02d, Level %4d\n", i,  ZAG[i], nzeros, cur));
+                code = (huff_table[nzeros])[acur];
+                nbits = (huff_bits[nzeros])[acur];
+
+                if (cur < 0) {
+                    code |= 1;  /* the sign bit */
+                }
+                Bitio_Write(out, code, nbits);
+            } else {
+                /*
+                 * encode using the escape code
+                 */
+                DBG_PRINT(("Escape\n"));
+                Bitio_Write(out, 0x1, 6);       /* ESCAPE */
+                DBG_PRINT(("Run Length\n"));
+                Bitio_Write(out, nzeros, 6);    /* Run-Length */
+
+                /*
+                 * this shouldn't happen, but the other
+                 * choice is to bomb out and dump core...
+                 * Hmmm, seems to happen with small Qtable entries (1) -srs
+                 */
+                if (cur < -255) {
+                    cur = -255;
+                } else if (cur > 255) {
+                    cur = 255;
+                }
+
+                DBG_PRINT(("Level\n"));
+                if (acur < 128) {
+                    Bitio_Write(out, cur, 8);
+                } else {
+                    if (cur < 0) {
+                        Bitio_Write(out, 0x8001 + cur + 255, 16);
+                    } else {
+                        Bitio_Write(out, cur, 16);
+                    }
+                }
+            }
+            nzeros = 0;
+        } else {
+            nzeros++;
+        }
     }
     DBG_PRINT(("End of block\n"));
-    Bitio_Write(out, 0x2, 2);	/* end of block marker */
+    Bitio_Write(out, 0x2, 2);   /* end of block marker */
 }
 
 
@@ -464,9 +464,9 @@ Mpost_RLEHuffIBlock(in, out)
  *
  * Mpost_RLEHuffPBlock
  *
- *	generate the huffman bits from an P-block
+ *      generate the huffman bits from an P-block
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -488,80 +488,80 @@ Mpost_RLEHuffPBlock(in, out)
      * yes, Virginia, we start at 0.
      */
     for (i = 0; i < DCTSIZE_SQ; i++) {
-	cur = in[i];
-	acur = ABS(cur);
-	if (cur) {
-	    if ((nzeros < HUFF_MAXRUN) && (acur < huff_maxlevel[nzeros])) {
-	        /*
-		 * encode using the Huffman tables
-		 */
-
-		DBG_PRINT(("rle_huff %02d.%02d: Run %02d, Level %4d\n", i, ZAG[i], nzeros, cur));
-		if ( first_dct && (nzeros == 0) && (acur == 1) ) {
-		    /* actually, only needs = 0x2 */
-		    code = (cur == 1) ? 0x2 : 0x3;
-		    nbits = 2;
-		} else {
-		    code = (huff_table[nzeros])[acur];
-		    nbits = (huff_bits[nzeros])[acur];
-		  }
-
-		assert(nbits);
-
-		if (cur < 0) {
-		    code |= 1;	/* the sign bit */
-		}
-		Bitio_Write(out, code, nbits);
-		first_dct = FALSE;
-	    } else {
-		/*
-		 * encode using the escape code
-		 */
-		DBG_PRINT(("Escape\n"));
-		Bitio_Write(out, 0x1, 6);	/* ESCAPE */
-		DBG_PRINT(("Run Length\n"));
-		Bitio_Write(out, nzeros, 6);	/* Run-Length */
-
-		/*
-	         * this shouldn't happen, but the other
-	         * choice is to bomb out and dump core...
-		 * Hmmm, seems to happen with small Qtable entries (1) -srs
-	         */
-		if (cur < -255) {
-		  cur = -255;
-		} else if (cur > 255) {
-		  cur = 255;
-		}
-
-		DBG_PRINT(("Level\n"));
-		if (acur < 128) {
-		    Bitio_Write(out, cur, 8);
-		} else {
-		    if (cur < 0) {
-			Bitio_Write(out, 0x8001 + cur + 255, 16);
-		    } else {
-			Bitio_Write(out, cur, 16);
-		    }
-		}
-
-		first_dct = FALSE;
-	    }
-	    nzeros = 0;
-	} else {
-	    nzeros++;
-	}
+        cur = in[i];
+        acur = ABS(cur);
+        if (cur) {
+            if ((nzeros < HUFF_MAXRUN) && (acur < huff_maxlevel[nzeros])) {
+                /*
+                 * encode using the Huffman tables
+                 */
+
+                DBG_PRINT(("rle_huff %02d.%02d: Run %02d, Level %4d\n", i, ZAG[i], nzeros, cur));
+                if ( first_dct && (nzeros == 0) && (acur == 1) ) {
+                    /* actually, only needs = 0x2 */
+                    code = (cur == 1) ? 0x2 : 0x3;
+                    nbits = 2;
+                } else {
+                    code = (huff_table[nzeros])[acur];
+                    nbits = (huff_bits[nzeros])[acur];
+                  }
+
+                assert(nbits);
+
+                if (cur < 0) {
+                    code |= 1;  /* the sign bit */
+                }
+                Bitio_Write(out, code, nbits);
+                first_dct = FALSE;
+            } else {
+                /*
+                 * encode using the escape code
+                 */
+                DBG_PRINT(("Escape\n"));
+                Bitio_Write(out, 0x1, 6);       /* ESCAPE */
+                DBG_PRINT(("Run Length\n"));
+                Bitio_Write(out, nzeros, 6);    /* Run-Length */
+
+                /*
+                 * this shouldn't happen, but the other
+                 * choice is to bomb out and dump core...
+                 * Hmmm, seems to happen with small Qtable entries (1) -srs
+                 */
+                if (cur < -255) {
+                  cur = -255;
+                } else if (cur > 255) {
+                  cur = 255;
+                }
+
+                DBG_PRINT(("Level\n"));
+                if (acur < 128) {
+                    Bitio_Write(out, cur, 8);
+                } else {
+                    if (cur < 0) {
+                        Bitio_Write(out, 0x8001 + cur + 255, 16);
+                    } else {
+                        Bitio_Write(out, cur, 16);
+                    }
+                }
+
+                first_dct = FALSE;
+            }
+            nzeros = 0;
+        } else {
+            nzeros++;
+        }
     }
 
     /* actually, should REALLY return FALSE and not use this! */
 
-    if ( first_dct ) {	/* have to give a first_dct even if all 0's */
-	fprintf(stderr, "HUFF called with all-zero coefficients\n");
-	fprintf(stderr, "exiting...\n");
-	exit(1);
+    if ( first_dct ) {  /* have to give a first_dct even if all 0's */
+        fprintf(stderr, "HUFF called with all-zero coefficients\n");
+        fprintf(stderr, "exiting...\n");
+        exit(1);
     }
 
     DBG_PRINT(("End of block\n"));
-    Bitio_Write(out, 0x2, 2);	/* end of block marker */
+    Bitio_Write(out, 0x2, 2);   /* end of block marker */
 }
 
 
@@ -569,9 +569,9 @@ Mpost_RLEHuffPBlock(in, out)
  *
  * CalcRLEHuffLength
  *
- *	count the huffman bits for an P-block
+ *      count the huffman bits for an P-block
  *
- * RETURNS:	number of bits
+ * RETURNS:     number of bits
  *
  * SIDE EFFECTS:    none
  *
@@ -587,40 +587,40 @@ CalcRLEHuffLength(in)
   register int nbits;
   register int countbits=0;
   boolean first_dct = TRUE;
-  
+
   for (i = 0; i < DCTSIZE_SQ; i++) {
     cur = in[i];
     acur = ABS(cur);
     if (cur) {
       if ((nzeros < HUFF_MAXRUN) && (acur < huff_maxlevel[nzeros])) {
-	/*
-	 * encode using the Huffman tables
-	 */
-
-	if ( first_dct && (nzeros == 0) && (acur == 1) ) {
-	  nbits = 2;
-	} else {
-	  nbits = (huff_bits[nzeros])[acur];
-	}
-	countbits += nbits;
-	first_dct = FALSE;
+        /*
+         * encode using the Huffman tables
+         */
+
+        if ( first_dct && (nzeros == 0) && (acur == 1) ) {
+          nbits = 2;
+        } else {
+          nbits = (huff_bits[nzeros])[acur];
+        }
+        countbits += nbits;
+        first_dct = FALSE;
       } else {
-	countbits += 12;	/* ESCAPE + runlength */
+        countbits += 12;        /* ESCAPE + runlength */
 
-	if (acur < 128) {
-	  countbits += 8;
-	} else {
-	  countbits += 16;
-	}
+        if (acur < 128) {
+          countbits += 8;
+        } else {
+          countbits += 16;
+        }
 
-	first_dct = FALSE;
+        first_dct = FALSE;
       }
       nzeros = 0;
     } else {
       nzeros++;
     }
   }
-  
+
   countbits += 2; /* end of block marker */
   return countbits;
 }
diff --git a/converter/ppm/ppmtompeg/ppmtompeg.c b/converter/ppm/ppmtompeg/ppmtompeg.c
index 837b1b9d..cc2cb27e 100644
--- a/converter/ppm/ppmtompeg/ppmtompeg.c
+++ b/converter/ppm/ppmtompeg/ppmtompeg.c
@@ -127,7 +127,7 @@ parseArgs(int     const argc,
     cmdlineP->outputFrames = 0;
     cmdlineP->maxMachines = MAXINT;
     cmdlineP->specificFrames = FALSE;
-    
+
     /* parse the arguments */
     idx = 1;
     while (idx < argc-1) {
@@ -143,10 +143,10 @@ parseArgs(int     const argc,
             } else
                 pm_error("Invalid -stat option");
         } else if (streq(argv[idx], "-gop")) {
-            if (cmdlineP->function != ENCODE_FRAMES || 
+            if (cmdlineP->function != ENCODE_FRAMES ||
                 cmdlineP->specificFrames)
                 pm_error("Invalid -gop option");
-            
+
             if (idx+1 < argc-1) {
                 whichGOP = atoi(argv[idx+1]);
                 idx += 2;
@@ -170,12 +170,12 @@ parseArgs(int     const argc,
                 cmdlineP->specificFrames = TRUE;
                 cmdlineP->frameStart = frameStart;
                 cmdlineP->frameEnd   = frameEnd;
-                
+
                 idx += 3;
             } else
                 pm_error("-frames needs to be followed by two values");
         } else if (streq(argv[idx], "-combine_gops")) {
-            if (cmdlineP->function != ENCODE_FRAMES || whichGOP != -1 || 
+            if (cmdlineP->function != ENCODE_FRAMES || whichGOP != -1 ||
                 cmdlineP->specificFrames) {
                 pm_error("Invalid -combine_gops option");
             }
@@ -345,7 +345,7 @@ announceJob(enum frameContext const context,
             combineDest = strdup("for delivery to combine server");
         else
             combineDest = strdup("");
-    
+
         pm_message("%s:  ENCODING FRAMES %u-%u to %s %s",
                    hostname, frameStart, frameEnd, outputDest, combineDest);
 
@@ -359,7 +359,7 @@ announceJob(enum frameContext const context,
 static void
 encodeSomeFrames(struct inputSource * const inputSourceP,
                  boolean              const childProcess,
-                 enum frameContext    const context, 
+                 enum frameContext    const context,
                  unsigned int         const frameStart,
                  unsigned int         const frameEnd,
                  int32                const qtable[],
@@ -370,7 +370,7 @@ encodeSomeFrames(struct inputSource * const inputSourceP,
                  bool                 const wantVbvOverflowWarning,
                  boolean              const printStats,
                  unsigned int *       const encodeTimeP) {
-    
+
     time_t framesTimeStart, framesTimeEnd;
     unsigned int inputFrameBits;
     unsigned int totalBits;
@@ -383,7 +383,7 @@ encodeSomeFrames(struct inputSource * const inputSourceP,
                         frameStart, frameEnd, inputSourceP);
 
     GenMPEGStream(inputSourceP, context, frameStart, frameEnd,
-                  qtable, niqtable, childProcess, ofp, outputFileName, 
+                  qtable, niqtable, childProcess, ofp, outputFileName,
                   wantVbvUnderflowWarning, wantVbvOverflowWarning,
                   &inputFrameBits, &totalBits);
 
@@ -396,7 +396,7 @@ encodeSomeFrames(struct inputSource * const inputSourceP,
                    hostname, frameStart, frameEnd, *encodeTimeP);
 
     if (printStats)
-        PrintEndStats(framesTimeStart, framesTimeEnd, 
+        PrintEndStats(framesTimeStart, framesTimeEnd,
                       inputFrameBits, totalBits);
 }
 
@@ -422,14 +422,14 @@ encodeFrames(struct inputSource * const inputSourceP,
   Encode the stream.  If 'specificFrames' is true, then encode frames
   'whichFrameStart' through 'whichFrameEnd' individually.  Otherwise,
   encode the entire input stream as a complete MPEG stream.
-  
+
   'childProcess' means to do it as a child process that is under the
   supervision of a master process and is possibly doing only part of
   a larger batch.
-  
+
   (If we had proper modularity, we wouldn't care, but parallel operation
   was glued on to this program after it was complete).
-  
+
   One thing we don't do when running as a child process is print
   statistics; our master will do that for the whole job.
 ----------------------------------------------------------------------------*/
@@ -442,7 +442,7 @@ encodeFrames(struct inputSource * const inputSourceP,
 
     if (whichGOP != -1) {
         /* He wants just one particular GOP from the middle of the movie. */
-        ComputeGOPFrames(whichGOP, &frameStart, &frameEnd, 
+        ComputeGOPFrames(whichGOP, &frameStart, &frameEnd,
                          inputSourceP->numInputFiles);
         context = CONTEXT_GOP;
     } else if (specificFrames) {
@@ -465,36 +465,36 @@ encodeFrames(struct inputSource * const inputSourceP,
         frameEnd   = inputSourceP->numInputFiles - 1;
         context = CONTEXT_WHOLESTREAM;
     }
-    
+
     printStats = !childProcess;
-    
+
     encodeSomeFrames(inputSourceP, childProcess, context, frameStart, frameEnd,
                      customQtable, customNIQtable,
-                     ofp, outputFileName, 
+                     ofp, outputFileName,
                      wantVbvUnderflowWarning, wantVbvOverflowWarning,
                      printStats,
                      &lastEncodeTime);
 
     if (childProcess) {
         boolean moreWorkToDo;
-        
+
         /* A child is not capable of generating GOP or stream headers */
         assert(context == CONTEXT_JUSTFRAMES);
-        
+
         moreWorkToDo = TRUE;  /* initial assumption */
         while (moreWorkToDo) {
             int nextFrameStart, nextFrameEnd;
 
-            NotifyMasterDone(masterHostname, masterPortNumber, machineNumber, 
+            NotifyMasterDone(masterHostname, masterPortNumber, machineNumber,
                              lastEncodeTime, &moreWorkToDo,
                              &nextFrameStart, &nextFrameEnd);
             if (moreWorkToDo)
-                encodeSomeFrames(inputSourceP, childProcess, 
-                                 CONTEXT_JUSTFRAMES, 
+                encodeSomeFrames(inputSourceP, childProcess,
+                                 CONTEXT_JUSTFRAMES,
                                  nextFrameStart, nextFrameEnd,
                                  customQtable, customNIQtable,
-                                 NULL, outputFileName, 
-                                 wantVbvUnderflowWarning, 
+                                 NULL, outputFileName,
+                                 wantVbvUnderflowWarning,
                                  wantVbvOverflowWarning,
                                  FALSE,
                                  &lastEncodeTime);
@@ -527,13 +527,13 @@ static void
 getUserFrameFile(void *       const handle,
                  unsigned int const frameNumber,
                  FILE **      const ifPP) {
-    
+
     struct inputSource * const inputSourceP = (struct inputSource *) handle;
 
     if (inputSourceP->stdinUsed)
         pm_error("You cannot combine frames from Standard Input.");
             /* Because Caller detects end of frames by EOF */
-    
+
     if (frameNumber >= inputSourceP->numInputFiles)
         *ifPP = NULL;
     else {
@@ -541,14 +541,14 @@ getUserFrameFile(void *       const handle,
         const char * inputFileName;
 
         GetNthInputFileName(inputSourceP, frameNumber, &inputFileName);
-        
+
         pm_asprintf(&fileName, "%s/%s", currentFramePath, inputFileName);
-        
+
         *ifPP = fopen(fileName, "rb");
         if (*ifPP == NULL)
             pm_error("Unable to open file '%s'.  Errno = %d (%s)",
                      fileName, errno, strerror(errno));
-        
+
         pm_strfree(inputFileName);
         pm_strfree(fileName);
     }
@@ -585,11 +585,11 @@ framePoolSize(bool const sequentialInput) {
         for ( idx = 0, bcount = 0; idx < strlen(framePattern); idx++) {
 
             /* counts the maximum number of B frames between two reference
-             * frames. 
+             * frames.
              */
-            
+
             switch( framePattern[idx] ) {
-            case 'b': 
+            case 'b':
                 bcount++;
                 break;
             case 'i':
@@ -599,12 +599,12 @@ framePoolSize(bool const sequentialInput) {
                 bcount = 0;
                 break;
             }
-            
+
             /* add 2 to hold the forward and past reference frames in addition
-             * to the maximum number of B's 
+             * to the maximum number of B's
              */
         }
-        
+
         numOfFrames += 2;
 
     } else {
@@ -656,22 +656,22 @@ main(int argc, char **argv) {
     Tune_Init();
     Frame_Init(framePoolSize(params.inputSourceP->stdinUsed));
 
-    if (specificsOn) 
+    if (specificsOn)
         Specifics_Init();
 
-    ComputeFrameTable(params.inputSourceP->stdinUsed ? 
+    ComputeFrameTable(params.inputSourceP->stdinUsed ?
                       0 : params.inputSourceP->numInputFiles);
 
     if (ioServer) {
-        IoServer(params.inputSourceP, cmdline.masterHostname, 
+        IoServer(params.inputSourceP, cmdline.masterHostname,
                  cmdline.masterPortNumber);
         return 0;
     } else if (outputServer) {
-        CombineServer(cmdline.outputFrames, 
+        CombineServer(cmdline.outputFrames,
                       cmdline.masterHostname, cmdline.masterPortNumber,
                       outputFileName);
     } else if (decodeServer) {
-        DecodeServer(cmdline.outputFrames, outputFileName, 
+        DecodeServer(cmdline.outputFrames, outputFileName,
                      cmdline.masterHostname, cmdline.masterPortNumber);
     } else {
         if (!cmdline.specificFrames &&
@@ -681,18 +681,18 @@ main(int argc, char **argv) {
                 pm_error("Could not open output file!");
         } else
             ofP = NULL;
-        
+
         if (cmdline.function == ENCODE_FRAMES) {
             if (numMachines == 0 || cmdline.specificFrames) {
                 encodeFrames(params.inputSourceP,
-                             cmdline.childProcess, 
+                             cmdline.childProcess,
                              cmdline.masterHostname, cmdline.masterPortNumber,
                              whichGOP, cmdline.specificFrames,
                              cmdline.frameStart, cmdline.frameEnd,
                              customQtable, customNIQtable,
                              ofP, outputFileName,
                              params.warnUnderflow, params.warnOverflow);
-                
+
             } else
                 runMaster(params.inputSourceP,
                           cmdline.paramFileName, outputFileName);
@@ -701,9 +701,9 @@ main(int argc, char **argv) {
         else if (cmdline.function == COMBINE_FRAMES)
             FramesToMPEG(ofP, params.inputSourceP,
                          &getUserFrameFile, &nullDisposeFile);
-    } 
+    }
     Frame_Exit();
-        
+
     pm_strfree(hostname);
 
     return 0;
diff --git a/converter/ppm/ppmtompeg/psearch.c b/converter/ppm/ppmtompeg/psearch.c
index e350137e..de3d3e26 100644
--- a/converter/ppm/ppmtompeg/psearch.c
+++ b/converter/ppm/ppmtompeg/psearch.c
@@ -1,8 +1,8 @@
 /*===========================================================================*
- * psearch.c                                     
- *                                       
- *  Procedures concerned with the P-frame motion search          
- *                                       
+ * psearch.c
+ *
+ *  Procedures concerned with the P-frame motion search
+ *
  *===========================================================================*/
 
 /*==============*
@@ -79,10 +79,10 @@ int psearchAlg;
  *
  *===========================================================================*/
 void
-PMotionSearch(const LumBlock * const currentBlockP, 
-              MpegFrame *      const prev, 
+PMotionSearch(const LumBlock * const currentBlockP,
+              MpegFrame *      const prev,
               int              const by,
-              int              const bx, 
+              int              const bx,
               vector *         const motionP) {
 
     /* CALL SEARCH PROCEDURE */
@@ -92,14 +92,14 @@ PMotionSearch(const LumBlock * const currentBlockP,
         PSubSampleSearch(currentBlockP, prev, by, bx, motionP, searchRangeP);
         break;
     case PSEARCH_EXHAUSTIVE:
-        PLocalSearch(currentBlockP, prev, by, bx, 
+        PLocalSearch(currentBlockP, prev, by, bx,
                      motionP, INT_MAX, searchRangeP);
         break;
     case PSEARCH_LOGARITHMIC:
         PLogarithmicSearch(currentBlockP, prev, by, bx, motionP, searchRangeP);
         break;
     case PSEARCH_TWOLEVEL:
-        PTwoLevelSearch(currentBlockP, prev, by, bx, 
+        PTwoLevelSearch(currentBlockP, prev, by, bx,
                         motionP, INT_MAX, searchRangeP);
         break;
     default:
@@ -122,7 +122,7 @@ PMotionSearch(const LumBlock * const currentBlockP,
  *===========================================================================*/
 void
 SetPixelSearch(const char * const searchType) {
-    if ( (strcmp(searchType, "FULL") == 0 ) || 
+    if ( (strcmp(searchType, "FULL") == 0 ) ||
          ( strcmp(searchType, "WHOLE") == 0 )) {
         pixelFullSearch = TRUE;
     } else if ( strcmp(searchType, "HALF") == 0 ) {
@@ -216,16 +216,16 @@ SetSearchRange(int const pixelsP, int const pixelsB) {
         int const max_search = max(searchRangeP, searchRangeB);
 
         int index;
-    
+
         pmvHistogram = (int **) malloc((2*searchRangeP+3)*sizeof(int *));
         bbmvHistogram = (int **) malloc((2*searchRangeB+3)*sizeof(int *));
         bfmvHistogram = (int **) malloc((2*searchRangeB+3)*sizeof(int *));
         for ( index = 0; index < 2*max_search+3; index++ ) {
-            pmvHistogram[index] = 
+            pmvHistogram[index] =
                 (int *) calloc(2*searchRangeP+3, sizeof(int));
-            bbmvHistogram[index] = 
+            bbmvHistogram[index] =
                 (int *) calloc(2*searchRangeB+3, sizeof(int));
-            bfmvHistogram[index] = 
+            bfmvHistogram[index] =
                 (int *) calloc(2*searchRangeB+3, sizeof(int));
         }
     }
@@ -269,12 +269,12 @@ MotionSearchPreComputation(MpegFrame * const frameP) {
  *===========================================================================*/
 int
 PSubSampleSearch(const LumBlock * const currentBlockP,
-                 MpegFrame *      const prev, 
+                 MpegFrame *      const prev,
                  int              const by,
                  int              const bx,
                  vector *         const motionP,
                  int              const searchRange) {
-    
+
     int my, mx;
     int bestBestDiff;
     int stepSize;
@@ -311,7 +311,7 @@ PSubSampleSearch(const LumBlock * const currentBlockP,
                     m.y = my; m.x = mx;
                     diff = LumMotionErrorA(currentBlockP, prev, by, bx, m,
                                            bestDiff[0]);
-                    
+
                     if (diff < bestDiff[0]) {
                         bestMY[0] = my;
                         bestMX[0] = mx;
@@ -330,9 +330,9 @@ PSubSampleSearch(const LumBlock * const currentBlockP,
                     int diff;
                     vector m;
                     m.y = my; m.x = mx;
-                    diff = LumMotionErrorB(currentBlockP, prev, by, bx, m, 
+                    diff = LumMotionErrorB(currentBlockP, prev, by, bx, m,
                                            bestDiff[1]);
-                    
+
                     if (diff < bestDiff[1]) {
                         bestMY[1] = my;
                         bestMX[1] = mx;
@@ -353,7 +353,7 @@ PSubSampleSearch(const LumBlock * const currentBlockP,
                     m.y = my; m.x = mx;
                     diff = LumMotionErrorC(currentBlockP, prev, by, bx, m,
                                            bestDiff[2]);
-                    
+
                     if (diff < bestDiff[2]) {
                         bestMY[2] = my;
                         bestMX[2] = mx;
@@ -374,7 +374,7 @@ PSubSampleSearch(const LumBlock * const currentBlockP,
                     m.y = my; m.x = mx;
                     diff = LumMotionErrorD(currentBlockP, prev, by, bx, m,
                                            bestDiff[3]);
-                    
+
                     if (diff < bestDiff[3]) {
                         bestMY[3] = my;
                         bestMX[3] = mx;
@@ -388,7 +388,7 @@ PSubSampleSearch(const LumBlock * const currentBlockP,
     /* first check old motion */
     if ((motionP->y >= leftMY) && (motionP->y < rightMY) &&
         (motionP->x >= leftMX) && (motionP->x < rightMX)) {
-        bestBestDiff = LumMotionError(currentBlockP, prev, by, bx, 
+        bestBestDiff = LumMotionError(currentBlockP, prev, by, bx,
                                       *motionP, INT_MAX);
     } else
         bestBestDiff = INT_MAX;
@@ -417,15 +417,15 @@ findBestSpaced(int              const minMY,
                int              const maxMY,
                int              const maxMX,
                int              const spacing,
-               const LumBlock * const currentBlockP, 
+               const LumBlock * const currentBlockP,
                MpegFrame *      const prev,
                int              const by,
                int              const bx,
-               int *            const bestDiffP, 
+               int *            const bestDiffP,
                vector *         const centerP) {
 /*----------------------------------------------------------------------------
-   Examine every 'spacing'th half-pixel within the rectangle 
-   ('minBoundX', 'minBoundY', 'maxBoundX', 'maxBoundY'), 
+   Examine every 'spacing'th half-pixel within the rectangle
+   ('minBoundX', 'minBoundY', 'maxBoundX', 'maxBoundY'),
 
    If one of the half-pixels examined has a lower "LumMotionError" value
    than *bestDiffP, update *bestDiffP to that value and update
@@ -446,9 +446,9 @@ findBestSpaced(int              const minMY,
             vector m;
 
             m.y = my; m.x = mx;
-            
+
             diff = LumMotionError(currentBlockP, prev, by, bx, m, *bestDiffP);
-            
+
             if (diff < *bestDiffP) {
                 *centerP   = m;
                 *bestDiffP = diff;
@@ -474,9 +474,9 @@ findBestSpaced(int              const minMY,
  *===========================================================================*/
 int
 PLogarithmicSearch(const LumBlock * const currentBlockP,
-                   MpegFrame *      const prev, 
+                   MpegFrame *      const prev,
                    int              const by,
-                   int              const bx, 
+                   int              const bx,
                    vector *         const motionP,
                    int              const searchRange) {
 
@@ -493,7 +493,7 @@ PLogarithmicSearch(const LumBlock * const currentBlockP,
         /* The difference between the current block and the block offset
            'motion' from it.
         */
-    
+
     COMPUTE_MOTION_BOUNDARY(by, bx, stepSize, minMY, minMX, maxMY, maxMX);
     minMX = max(minMX, - searchRange);
     minMY = max(minMY, - searchRange);
@@ -510,20 +510,20 @@ PLogarithmicSearch(const LumBlock * const currentBlockP,
 
     for (spacing = searchRange; spacing >= stepSize;) {
         if (stepSize == 2) {  /* make sure spacing is even */
-            if (spacing == 2) 
+            if (spacing == 2)
                 spacing = 0;
             else {
                 spacing = (spacing+1)/2;
-                if (spacing % 2 != 0) 
+                if (spacing % 2 != 0)
                     --spacing;
             }
         } else {
             if (spacing == 1) {
                 spacing = 0;
-            } else 
+            } else
                 spacing = (spacing + 1) / 2;
         }
-        if (spacing >= stepSize) 
+        if (spacing >= stepSize)
             findBestSpaced(minMY, minMX, maxMY, maxMX,
                            spacing, currentBlockP, prev, by, bx,
                            &bestDiff, &motion);
@@ -534,14 +534,14 @@ PLogarithmicSearch(const LumBlock * const currentBlockP,
         /* check old motion -- see if it's better */
         if ((motionP->y >= minMY) && (motionP->y < maxMY) &&
             (motionP->x >= minMX) && (motionP->x < maxMX)) {
-            diff = LumMotionError(currentBlockP, prev, by, bx, 
+            diff = LumMotionError(currentBlockP, prev, by, bx,
                                   *motionP, bestDiff);
-        } else 
+        } else
             diff = INT_MAX;
-        
+
         if (bestDiff < diff)
             *motionP = motion;
-        else 
+        else
             bestDiff = diff;
     }
 
@@ -563,7 +563,7 @@ PLogarithmicSearch(const LumBlock * const currentBlockP,
  *===========================================================================*/
 int
 PLocalSearch(const LumBlock * const currentBlockP,
-             MpegFrame *      const prev, 
+             MpegFrame *      const prev,
              int              const by,
              int              const bx,
              vector *         const motionP,
@@ -584,7 +584,7 @@ PLocalSearch(const LumBlock * const currentBlockP,
 
     /* try old motion vector first */
     if (VALID_MOTION(*motionP)) {
-        bestDiff = LumMotionError(currentBlockP, prev, by, bx, 
+        bestDiff = LumMotionError(currentBlockP, prev, by, bx,
                                   *motionP, bestSoFar);
 
         if (bestSoFar < bestDiff)
@@ -594,7 +594,7 @@ PLocalSearch(const LumBlock * const currentBlockP,
         bestDiff = bestSoFar;
     }
 
-    /* try a spiral pattern */    
+    /* try a spiral pattern */
     for (distance = stepSize; distance <= searchRange; distance += stepSize) {
         tempRightMY = MIN(distance, rightMY);
         tempRightMX = MIN(distance, rightMX);
@@ -607,11 +607,11 @@ PLocalSearch(const LumBlock * const currentBlockP,
                     if (mx >= leftMX) {
                         int diff;
                         vector m;
-                        
+
                         m.y = my; m.x = mx;
-                        diff = LumMotionError(currentBlockP, prev, by, bx, m, 
+                        diff = LumMotionError(currentBlockP, prev, by, bx, m,
                                               bestDiff);
-                        
+
                         if (diff < bestDiff) {
                             *motionP = m;
                             bestDiff = diff;
@@ -635,7 +635,7 @@ PLocalSearch(const LumBlock * const currentBlockP,
                         m.y = my; m.x = mx;
                         diff = LumMotionError(currentBlockP, prev, by, bx, m,
                                               bestDiff);
-                        
+
                         if (diff < bestDiff) {
                             *motionP = m;
                             bestDiff = diff;
@@ -664,9 +664,9 @@ PLocalSearch(const LumBlock * const currentBlockP,
  *===========================================================================*/
 int
 PTwoLevelSearch(const LumBlock * const currentBlockP,
-                MpegFrame *      const prev, 
+                MpegFrame *      const prev,
                 int              const by,
-                int              const bx, 
+                int              const bx,
                 vector *         const motionP,
                 int              const bestSoFar,
                 int              const searchRange) {
@@ -702,7 +702,7 @@ PTwoLevelSearch(const LumBlock * const currentBlockP,
 
     /* try old motion vector first */
     if (VALID_MOTION(*motionP)) {
-        bestDiff = LumMotionError(currentBlockP, prev, by, bx, 
+        bestDiff = LumMotionError(currentBlockP, prev, by, bx,
                                   *motionP, bestSoFar);
 
         if ( bestSoFar < bestDiff ) {
@@ -716,7 +716,7 @@ PTwoLevelSearch(const LumBlock * const currentBlockP,
     ++rightMY;
     ++rightMX;
 
-    /* try a spiral pattern */    
+    /* try a spiral pattern */
     for ( distance = 2; distance <= searchRange; distance += 2 ) {
         tempRightMY = MIN(distance, rightMY);
         tempRightMX = MIN(distance, rightMX);
@@ -729,9 +729,9 @@ PTwoLevelSearch(const LumBlock * const currentBlockP,
                     if (mx >= leftMX) {
                         vector m;
                         m.y = my; m.x = mx;
-                        diff = LumMotionError(currentBlockP, prev, by, bx, m, 
+                        diff = LumMotionError(currentBlockP, prev, by, bx, m,
                                               bestDiff);
-                        
+
                         if (diff < bestDiff) {
                             *motionP = m;
                             bestDiff = diff;
@@ -750,9 +750,9 @@ PTwoLevelSearch(const LumBlock * const currentBlockP,
                         int diff;
                         vector m;
                         m.y = my; m.x = mx;
-                        diff = LumMotionError(currentBlockP, prev, by, bx, m, 
+                        diff = LumMotionError(currentBlockP, prev, by, bx, m,
                                               bestDiff);
-                        
+
                         if ( diff < bestDiff ) {
                             *motionP = m;
                             bestDiff = diff;
@@ -952,7 +952,7 @@ ShowBFMVHistogram(fpointer)
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /u/smoot/md/mpeg_encode/RCS/psearch.c,v 1.9 1995/01/19 23:09:12 eyhung Exp $
  *  $Log: psearch.c,v $
  * Revision 1.9  1995/01/19  23:09:12  eyhung
diff --git a/converter/ppm/ppmtompeg/qtest.c b/converter/ppm/ppmtompeg/qtest.c
index b3d26593..85eda2c8 100644
--- a/converter/ppm/ppmtompeg/qtest.c
+++ b/converter/ppm/ppmtompeg/qtest.c
@@ -19,7 +19,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-/*  
+/*
  *  $Header: /n/charlie-brown/project/mm/mpeg/mpeg_dist/mpeg_encode/RCS/qtest.c,v 1.5 1995/01/19 23:09:15 eyhung Exp $
  *  $Log: qtest.c,v $
  * Revision 1.5  1995/01/19  23:09:15  eyhung
@@ -50,14 +50,14 @@ main()
     bb = new_bitbucket();
 
     for (i = 0; i < 8; i++)
-	for (j = 0; j < 8; j++)
-	    a[i][j] = rand() % 100;
+        for (j = 0; j < 8; j++)
+            a[i][j] = rand() % 100;
     mp_quant_zig_block(a, b, 1, 1);
     for (i = 0; i < 64; i++)
-	printf("%6d ", b[i]);
+        printf("%6d ", b[i]);
     printf("\n");
 
-    mp_rle_huff_block(b, bb);	/* intuititve names, huh? */
+    mp_rle_huff_block(b, bb);   /* intuititve names, huh? */
 
     printf("Huffman output is %d bits\n", bb->totalbits);
 }
diff --git a/converter/ppm/ppmtompeg/rate.c b/converter/ppm/ppmtompeg/rate.c
index 3fa41102..26c30ffe 100644
--- a/converter/ppm/ppmtompeg/rate.c
+++ b/converter/ppm/ppmtompeg/rate.c
@@ -1,9 +1,9 @@
 /*============================================================================*
- * rate.c								      *
- *									      *
- *	Procedures concerned with rate control                                *
- *									      *
- * EXPORTED PROCEDURES:							      *
+ * rate.c                                                                     *
+ *                                                                            *
+ *      Procedures concerned with rate control                                *
+ *                                                                            *
+ * EXPORTED PROCEDURES:                                                       *
  *      initRatecontrol()                                                     *
  *      targetRateControl()                                                   *
  *      updateRateControl()                                                   *
@@ -11,7 +11,7 @@
  *      needQScaleChange()                                                    *
  *      incNumBlocks()                                                        *
  *      incQuant()                                                            *
- *	incMacroBlockBits()                                                   *
+ *      incMacroBlockBits()                                                   *
  *      setPictureRate()                                                      *
  *      setBitRate()                                                          *
  *      getBitRate()                                                          *
@@ -19,7 +19,7 @@
  *      getBufferSize()                                                       *
  *                                                                            *
  * NOTES:                                                                     *
- *	Naming conventions follow those of MPEG-2 draft algorithm (chap. 10)  *
+ *      Naming conventions follow those of MPEG-2 draft algorithm (chap. 10)  *
  *============================================================================*/
 
 
@@ -73,7 +73,7 @@
  * GLOBAL VARIABLES *
  *==================*/
 
-#define MAX_BIT_RATE 104857600		/* 18 digit number in units of 400 */
+#define MAX_BIT_RATE 104857600          /* 18 digit number in units of 400 */
 #define MAX_BUFFER_SIZE 16760832        /* 10 digit number in units of 16k */
 #define DEFAULT_BUFFER_SIZE 327680      /* maximum for "constrained" bitstream */
 #define DEFAULT_VBV_FULLNESS 3          /* wait till 1/3 full */
@@ -82,9 +82,9 @@
 #define MAX_VBV_DELAY 32768             /* 16 digits */
 
 
-/*	  Variables from Parameter File */
+/*        Variables from Parameter File */
 
-static int	RateControlMode = VARIABLE_RATE;
+static int      RateControlMode = VARIABLE_RATE;
 static int32 buffer_size = DEFAULT_BUFFER_SIZE;
 static int32 bit_rate = -1;
 
@@ -94,9 +94,9 @@ static bool wantVbvOverflowWarning;
 /*   Variables for the VBV buffer defined in MPEG specs */
 static unsigned int VBV_remainingDelay;
     /* delay in units of 1/90000 seconds */
-static int32 VBV_buffer = 0;	  /* fullness of the theoretical VBV buffer */
+static int32 VBV_buffer = 0;      /* fullness of the theoretical VBV buffer */
 static int32 bufferFillRate = 0;    /* constant rate at which buffer filled */
-static int32 frameDelayIncrement = 0;	/* number of "delay" units/Frame */
+static int32 frameDelayIncrement = 0;   /* number of "delay" units/Frame */
 
 /*  Global complexity measure variables */
 static int Xi, Xp, Xb;  /*  Global complexity measure  */
@@ -108,7 +108,7 @@ static float Qi, Qp, Qb; /* avg quantizaton for last picture of type  */
 /*  Target bit allocations for each type of picture*/
 int Ti, Tp, Tb;
 
-int current_Tx;	/* allocation for current frame */
+int current_Tx; /* allocation for current frame */
 
 /*  Count of number of pictures of each type remaining */
 int GOP_X;
@@ -131,7 +131,7 @@ int rc_totalFrameBits;
 int rc_totalOverheadBits = 0;
 
 
-/*	Want to print out Macroblock info every Nth MB */
+/*      Want to print out Macroblock info every Nth MB */
 int RC_MB_SAMPLE_RATE = 0;
 
 static float Ki = .7;
@@ -150,23 +150,23 @@ static int d0_b;
 static int lastFrameVirtBuf;   /* fullness after last frame of this type */
 static int currentVirtBuf;     /* fullness during current encoding*/
 
-static int MB_cnt = -1;	       /* Number of MB's in picture */
+static int MB_cnt = -1;        /* Number of MB's in picture */
 
 static int rc_Q;               /* reference quantization parameter */
 
 static int reactionParameter;  /*  Reaction parameter */
 
-/*	Adaptive Quantization variables */
+/*      Adaptive Quantization variables */
 static int act_j;              /*  spatial activity measure */
 static float N_act;            /*  Normalized spacial activity */
-static int avg_act;	   /*  average activity value in last picture encoded */
-static int total_act_j;	       /*  Sum of activity values in current frame */
+static int avg_act;        /*  average activity value in last picture encoded */
+static int total_act_j;        /*  Sum of activity values in current frame */
 
-static int var_sblk;	       /* sub-block activity */
-static int P_mean;	       /* Mean value of pixels in 8x8 sub-block */
+static int var_sblk;           /* sub-block activity */
+static int P_mean;             /* Mean value of pixels in 8x8 sub-block */
 
-static int mquant;	       /* Raw Quantization value */
-static int Qscale;	       /* Clipped, truncated quantization value */
+static int mquant;             /* Raw Quantization value */
+static int Qscale;             /* Clipped, truncated quantization value */
 
 
 
@@ -177,7 +177,7 @@ static FILE *RC_FILE;
 
 static char rc_buffer[101];
 
-/*	EXTERNAL Variables  */
+/*      EXTERNAL Variables  */
 extern char *framePattern;
 extern int framePatternLen;
 
@@ -230,9 +230,9 @@ analyzePattern(const char *  const framePattern,
  *
  * initRateControl
  *
- *	initialize the allocation parameters.
+ *      initialize the allocation parameters.
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:   many global variables
  *
@@ -292,11 +292,11 @@ initRateControl(bool const wantUnderflowWarning,
     d0_p = (Kp * d0_i);
     d0_b = (Kb * d0_i);
 
-    lastFrameVirtBuf = d0_i;	/*  start with I Frame */
+    lastFrameVirtBuf = d0_i;    /*  start with I Frame */
     rc_Q = lastFrameVirtBuf  * 31 / reactionParameter;
 
     /*   init spatial activity measures */
-    avg_act = 400;		/* Suggested initial value */
+    avg_act = 400;              /* Suggested initial value */
     N_act = 1;
 
     mquant = rc_Q * N_act;
@@ -320,10 +320,10 @@ initRateControl(bool const wantUnderflowWarning,
  *
  * initGOPRateControl
  *
- *		(re)-initialize the RC for the a new Group of Pictures.
- *	New bit allocation, but carry over complexity measures.
+ *              (re)-initialize the RC for the a new Group of Pictures.
+ *      New bit allocation, but carry over complexity measures.
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:   many global variables
  *
@@ -585,9 +585,9 @@ updateRateControl(int const type) {
  * MB_RateOut
  *
  *      Prints out sampling of MB rate control data.  Every "nth" block
- *	stats are printed, with "n" controlled by global RC_MB_SAMPLE_RATE
- *	(NB. "skipped" blocks do not go through this function and thus do not
- *		show up in the sample )
+ *      stats are printed, with "n" controlled by global RC_MB_SAMPLE_RATE
+ *      (NB. "skipped" blocks do not go through this function and thus do not
+ *              show up in the sample )
  *
  * RETURNS:     nothing
  *
@@ -612,8 +612,8 @@ int type;
   pctUsed = (totalBits *100/current_Tx);
 
   sprintf(rc_buffer, "%3d  %5d %2d %3d %6d  %3d %6d   %2.2f   %6d %4d    %3d   %3d\n",
-	  (rc_numBlocks - 1), bitsThisMB, Qscale, mquant, currentVirtBuf,
-	  rc_Q, act_j, N_act, totalBits, bitsPerMB, pctUsed, pctDone);
+          (rc_numBlocks - 1), bitsThisMB, Qscale, mquant, currentVirtBuf,
+          rc_Q, act_j, N_act, totalBits, bitsPerMB, pctUsed, pctDone);
 #ifdef RC_STATS_FILE
   fprintf(RC_FILE, "%s", rc_buffer);
   fflush(RC_FILE);
@@ -651,7 +651,7 @@ void incNumBlocks(num)
  *
  * incMacroBlockBits()
  *
- *	Increments the number of Macro Block bits and the total of Frame
+ *      Increments the number of Macro Block bits and the total of Frame
  *  bits by the number passed.
  *
  * RETURNS:   nothing
@@ -672,7 +672,7 @@ void incMacroBlockBits(num)
 
 /*===========================================================================*
  *
- *   	needQScaleChange(current Q scale, 4 luminance blocks)
+ *      needQScaleChange(current Q scale, 4 luminance blocks)
  *
  *
  * RETURNS:     new Qscale
@@ -689,7 +689,7 @@ int needQScaleChange(oldQScale, blk0, blk1, blk2, blk3)
 {
 
   /*   One more MacroBlock seen */
-  rc_numBlocks++;		/* this notes each block num in MB */
+  rc_numBlocks++;               /* this notes each block num in MB */
 
   checkBufferFullness(oldQScale);
 
@@ -712,7 +712,7 @@ int needQScaleChange(oldQScale, blk0, blk1, blk2, blk3)
  * determineMBCount()
  *
  *      Determines number of Macro Blocks in frame from the frame sizes
- *	passed.
+ *      passed.
  *
  * RETURNS:     nothing
  *
@@ -766,7 +766,7 @@ void checkBufferFullness (oldQScale)
  * void checkSpatialActivity()
  *
  *      Calculates the spatial activity for the four luminance blocks of the
- *	macroblock.  Along with the normalized reference quantization parameter
+ *      macroblock.  Along with the normalized reference quantization parameter
  *  (rc_Q) , it determines the quantization factor for the next macroblock.
  *
  * RETURNS:     nothing
@@ -796,18 +796,18 @@ void checkSpatialActivity(blk0, blk1, blk2, blk3)
   blkArray[3] = (int16 *) blk3;
 
 
-  for (i =0; i < 4; i++) {	/* Compute the activity in each block */
+  for (i =0; i < 4; i++) {      /* Compute the activity in each block */
     curBlock = blkArray[i];
     blk_ptr = curBlock;
     P_mean = 0;
     /*  Find the mean pixel value */
     for (j=0; j < DCTSIZE_SQ; j ++) {
       P_mean += *(blk_ptr++);
-      /*			P_mean += curBlock[j];
-				if (curBlock[j] != *(blk_ptr++)) {
-				printf("ARRAY ERROR: block %d\n", j);
-				}
-				*/
+      /*                        P_mean += curBlock[j];
+                                if (curBlock[j] != *(blk_ptr++)) {
+                                printf("ARRAY ERROR: block %d\n", j);
+                                }
+                                */
     }
     P_mean /= DCTSIZE_SQ;
 
@@ -818,7 +818,7 @@ void checkSpatialActivity(blk0, blk1, blk2, blk3)
     for (j=0; j < DCTSIZE_SQ; j++) {
 #ifdef notdef
       if (curBlock[j] != *(blk_ptr++)) {
-	printf("ARRAY ERROR: block %d\n", j);
+        printf("ARRAY ERROR: block %d\n", j);
       }
       temp = curBlock[j] - P_mean;
 #endif
@@ -870,13 +870,13 @@ int getRateMode()
  *
  *      Checks the string parsed from the parameter file.  Verifies
  *  number and sets global values. MPEG standard specifies that bit rate
- *	be rounded up to nearest 400 bits/sec.
+ *      be rounded up to nearest 400 bits/sec.
  *
  * RETURNS:     nothing
  *
  * SIDE EFFECTS:   global variables
  *
- * NOTES:	Should this be in the 400-bit units used in sequence header?
+ * NOTES:       Should this be in the 400-bit units used in sequence header?
  *
  *===========================================================================*/
 void setBitRate (const char * const charPtr)
@@ -888,7 +888,7 @@ void setBitRate (const char * const charPtr)
     RateControlMode = FIXED_RATE;
   } else {
     printf("Parameter File Error:  invalid BIT_RATE: \"%s\", defaults to Variable ratemode\n",
-	   charPtr);
+           charPtr);
     RateControlMode = VARIABLE_RATE;
     bit_rate = -1;
   }
@@ -933,7 +933,7 @@ int getBitRate ()
  *
  * SIDE EFFECTS:   buffer_size global variable.
  *
- * NOTES:	The global is in bits, NOT the 16kb units used in sequence header
+ * NOTES:       The global is in bits, NOT the 16kb units used in sequence header
  *
  *===========================================================================*/
 void setBufferSize (const char * const charPtr)
@@ -948,7 +948,7 @@ void setBufferSize (const char * const charPtr)
   } else {
     buffer_size = DEFAULT_BUFFER_SIZE;
     printf("Parameter File Error:  invalid BUFFER_SIZE: \"%s\", defaults to : %d\n",
-	   charPtr, buffer_size);
+           charPtr, buffer_size);
   }
   DBG_PRINT(("Buffer size is: %d\n", buffer_size));
 }
diff --git a/converter/ppm/ppmtompeg/rgbtoycc.c b/converter/ppm/ppmtompeg/rgbtoycc.c
index 2dd1899a..9357c8d8 100644
--- a/converter/ppm/ppmtompeg/rgbtoycc.c
+++ b/converter/ppm/ppmtompeg/rgbtoycc.c
@@ -53,23 +53,23 @@ compute_mult_tables(const pixval maxval) {
 
     /* For speed, we do the arithmetic with eight tables that reduce a
        bunch of multiplications and divisions to a simple table lookup.
-       
+
        Because a large maxval could require a significant amount of
        table space, we allocate the space dynamically.
 
-       If we had to compute the tables for every frame, it wouldn't be 
+       If we had to compute the tables for every frame, it wouldn't be
        fast at all, but since all the frames normally have the same
        maxval, we only need to compute them once.  But just in case,
        we check each frame to see if it has a different maxval and
        recompute the tables if so.
     */
-    
+
     if (table_maxval != maxval) {
         /* We need to compute or re-compute the multiplication tables */
         if (table_maxval != 0) {
             free(mult299); free(mult587); free(mult114); free(mult16874);
-            free(mult33126); free(mult5); free(mult41869); free(mult08131);  
-        } 
+            free(mult33126); free(mult5); free(mult41869); free(mult08131);
+        }
         table_maxval = maxval;
 
         mult299   = malloc((table_maxval+1)*sizeof(float));
@@ -83,18 +83,18 @@ compute_mult_tables(const pixval maxval) {
 
         if (mult299 == NULL || mult587 == NULL || mult114 == NULL ||
             mult16874 == NULL || mult33126 == NULL || mult5 == NULL ||
-            mult41869 == NULL || mult08131 == NULL) 
+            mult41869 == NULL || mult08131 == NULL)
             pm_error("Unable to allocate storage for arithmetic tables.  "
                      "We need %d bytes, which is the maxval of the input "
                      "image, plus 1, "
-                     "times the storage size of a floating point value.", 
+                     "times the storage size of a floating point value.",
                      (unsigned)(8 * (table_maxval+1)*sizeof(float)));
 
         {
             int index;
 
             for (index = 0; index <= table_maxval; index++ ) {
-                mult299[index]   = index*0.29900  * 255 / table_maxval; 
+                mult299[index]   = index*0.29900  * 255 / table_maxval;
                 mult587[index]   = index*0.58700  * 255 / table_maxval;
                 mult114[index]   = index*0.11400  * 255 / table_maxval;
                 mult16874[index] = -0.16874*index * 255 / table_maxval;
@@ -195,9 +195,9 @@ PNMtoYUV(MpegFrame *  const frameP,
                      mult41869[PPM_GETG(src1[1])] +
                      mult08131[PPM_GETB(src1[1])]) / 4) + 128;
 
-            DBG_PRINT(("%3d,%3d: (%3d,%3d,%3d) --> (%3d,%3d,%3d)\n", 
-                       x, y, 
-                       PPM_GETR(*src0), PPM_GETG(*src0), PPM_GETB(*src0), 
+            DBG_PRINT(("%3d,%3d: (%3d,%3d,%3d) --> (%3d,%3d,%3d)\n",
+                       x, y,
+                       PPM_GETR(*src0), PPM_GETG(*src0), PPM_GETB(*src0),
                        *dy0, *dcb, *dcr));
         }
     }
diff --git a/converter/ppm/ppmtompeg/specifics.c b/converter/ppm/ppmtompeg/specifics.c
index bd74e805..e8597978 100644
--- a/converter/ppm/ppmtompeg/specifics.c
+++ b/converter/ppm/ppmtompeg/specifics.c
@@ -1,13 +1,13 @@
 /*===========================================================================*
- * specifics.c								     *
- *									     *
- *	basic procedures to deal with the specifics file                     *
- *									     *
- * EXPORTED PROCEDURES:							     *
- *	Specifics_Init							     *
+ * specifics.c                                                               *
+ *                                                                           *
+ *      basic procedures to deal with the specifics file                     *
+ *                                                                           *
+ * EXPORTED PROCEDURES:                                                      *
+ *      Specifics_Init                                                       *
  *      Spec_Lookup                                                          *
  *      SpecTypeLookup                                                       *
- *									     *
+ *                                                                           *
  *===========================================================================*/
 
 /*
@@ -69,7 +69,7 @@ void Parse_Specifics_File_v2 (FILE *fp);
 FrameSpecList *MakeFslEntry (void);
 void AddSlc (FrameSpecList *c,int snum, int qs);
 Block_Specifics *AddBs (FrameSpecList *c,int bnum,
-				    boolean rel, int qs);
+                                    boolean rel, int qs);
 FrameSpecList *MakeFslEntry (void);
 #define my_upper(c) (((c>='a') && (c<='z')) ? (c-'a'+'A') : c)
 #define CvtType(x) ReallyCvt(my_upper(x))
@@ -221,24 +221,24 @@ FILE *fp;
     case 'V':
       lp += 7;
       if (1 != sscanf(lp, "%d", &vers)) {
-	fprintf(stderr," Improper version line in specs file: %s\n", line);
+        fprintf(stderr," Improper version line in specs file: %s\n", line);
       } else {
-	switch (vers) {
-	case 1:
-	  version = vers;
-	  Parse_Specifics_File_v1(fp);
-	  break;
-	case 2:
-	  version = vers;
-	  Parse_Specifics_File_v2(fp);
-	  break;
-	default:
-	  fprintf(stderr, "Improper version line in specs file: %s\n", line);
-	  fprintf(stderr, "\tSpecifics file will be IGNORED.\n");
-	  specificsOn = FALSE;
-	  return;
-	  break;
-	}}
+        switch (vers) {
+        case 1:
+          version = vers;
+          Parse_Specifics_File_v1(fp);
+          break;
+        case 2:
+          version = vers;
+          Parse_Specifics_File_v2(fp);
+          break;
+        default:
+          fprintf(stderr, "Improper version line in specs file: %s\n", line);
+          fprintf(stderr, "\tSpecifics file will be IGNORED.\n");
+          specificsOn = FALSE;
+          return;
+          break;
+        }}
       break;
     default:
       fprintf(stderr, "Specifics file: What? *%s*\n", line);
@@ -271,9 +271,9 @@ FILE *fp;
       lp += 6;
       sscanf(lp, "%d %c %d", &fnum, &typ, &qs);
       if (current->framenum != -1) {
-	new=MakeFslEntry();
-	current->next = new;
-	current = new;
+        new=MakeFslEntry();
+        current->next = new;
+        current = new;
       }
       current->framenum = fnum;
       current->frametype = CvtType(typ);
@@ -581,8 +581,8 @@ int start_qs;
     found_it = FALSE;
     while (tmp != (FrameSpecList *) NULL) {
       if (tmp->framenum == fn) {
-	found_it = TRUE;
-	break;
+        found_it = TRUE;
+        break;
       } else tmp = tmp->next;
     }
     if (!found_it) return -1;
@@ -591,20 +591,20 @@ int start_qs;
     if (last->framenum != fn) { /* cache miss! */
       /* first check if it is next */
       if ((last->next != (FrameSpecList *) NULL) &&
-	  (last->next->framenum == fn)) {
-	last = last->next;
+          (last->next->framenum == fn)) {
+        last = last->next;
       } else {
-	/* if not next, check from the start.
-	   (this allows people to put frames out of order,even
-	   though the spec doesn't allow it.) */
-	tmp = fsl;
-	found_it = FALSE;
-	while (tmp != (FrameSpecList *) NULL) {
-	  if (tmp->framenum==fn) {found_it = TRUE; break;}
-	  tmp = tmp->next;
-	}
-	if (!found_it) return -1;
-	last = tmp;
+        /* if not next, check from the start.
+           (this allows people to put frames out of order,even
+           though the spec doesn't allow it.) */
+        tmp = fsl;
+        found_it = FALSE;
+        while (tmp != (FrameSpecList *) NULL) {
+          if (tmp->framenum==fn) {found_it = TRUE; break;}
+          tmp = tmp->next;
+        }
+        if (!found_it) return -1;
+        last = tmp;
       }
     }
   }
@@ -634,10 +634,10 @@ int start_qs;
     for (sptr = last->slc; sptr != (Slice_Specifics *) NULL; sptr = sptr->next) {
       if (sptr->num == num) {
 #ifdef BLEAH
-	printf("QSchange Slice %d.%d to %d\n", fn, num, sptr->qscale);
+        printf("QSchange Slice %d.%d to %d\n", fn, num, sptr->qscale);
 #endif
-	if (sptr->qscale == 0) return -1;
-	return sptr->qscale;
+        if (sptr->qscale == 0) return -1;
+        return sptr->qscale;
       }
     }
     break;
@@ -649,30 +649,30 @@ int start_qs;
     }
     for (bptr=last->bs; bptr != (Block_Specifics *) NULL; bptr=bptr->next) {
       if (bptr->num == num) {
-	int new_one;
+        int new_one;
 #ifdef BLEAH
-	printf("QSchange Block %d.%d to %d\n", fn, num, bptr->qscale);
+        printf("QSchange Block %d.%d to %d\n", fn, num, bptr->qscale);
 #endif
-	*info = bptr->mv;
-	if (bptr->relative) {
-	  if (bptr->qscale == 0) {
-	    /* Do nothing! */
-	    new_one = start_qs;
-	  } else {
-	    new_one = start_qs + bptr->qscale + leftovers;
-	    if (new_one < 1) {
-	      leftovers = new_one - 1;
-	      new_one = 1;
-	    } else if (new_one > 31) {
-	      leftovers = new_one - 31;
-	      new_one = 31;
-	    } else leftovers = 0;
-	  }}
-	else {
-	  new_one = bptr->qscale;
-	  leftovers = 0;
-	}
-	return new_one;
+        *info = bptr->mv;
+        if (bptr->relative) {
+          if (bptr->qscale == 0) {
+            /* Do nothing! */
+            new_one = start_qs;
+          } else {
+            new_one = start_qs + bptr->qscale + leftovers;
+            if (new_one < 1) {
+              leftovers = new_one - 1;
+              new_one = 1;
+            } else if (new_one > 31) {
+              leftovers = new_one - 31;
+              new_one = 31;
+            } else leftovers = 0;
+          }}
+        else {
+          new_one = bptr->qscale;
+          leftovers = 0;
+        }
+        return new_one;
       }
     }
     break;
diff --git a/converter/ppm/ppmtompeg/subsample.c b/converter/ppm/ppmtompeg/subsample.c
index 69401a1d..93b76db0 100644
--- a/converter/ppm/ppmtompeg/subsample.c
+++ b/converter/ppm/ppmtompeg/subsample.c
@@ -67,14 +67,14 @@ computePrevFyFx(MpegFrame * const prevFrame,
         if (yHalf) {
             if (m.y < 0)
                 --*fyP;
-        
+
             *prevP = prevFrame->halfBoth;
         } else
             *prevP = prevFrame->halfX;
     } else if (yHalf) {
         if (m.y < 0)
             --*fyP;
-        
+
         *prevP = prevFrame->halfY;
     } else
         *prevP = prevFrame->ref_y;
@@ -185,7 +185,7 @@ LumMotionErrorB(const LumBlock * const currentBlockP,
     computePrevFyFx(prevFrame, by, bx, m, &prev, &fy, &fx);
 
     diff = 0;  /* initial value */
-    
+
     for (rowNumber = 0; rowNumber < 16; rowNumber +=2) {
         uint8 *       const macross    = &(prev[fy + rowNumber][fx]);
         const int32 * const currentRow = currentBlockP->l[rowNumber];
@@ -226,7 +226,7 @@ LumMotionErrorC(const LumBlock * const currentBlockP,
     computePrevFyFx(prevFrame, by, bx, m, &prev, &fy, &fx);
 
     diff = 0;  /* initial value */
-    
+
     for (rowNumber = 1; rowNumber < 16; rowNumber +=2) {
         uint8 *       const macross    = &(prev[fy + rowNumber][fx]);
         const int32 * const currentRow = currentBlockP->l[rowNumber];
diff --git a/converter/ppm/ppmtosixel.c b/converter/ppm/ppmtosixel.c
index 5f361e45..4fdf6a66 100644
--- a/converter/ppm/ppmtosixel.c
+++ b/converter/ppm/ppmtosixel.c
@@ -1,4 +1,4 @@
-/* ppmtosix.c - read a portable pixmap and produce a color sixel file
+/* ppmtosix.c - read a PPM and produce a color sixel file
 **
 ** Copyright (C) 1991 by Rick Vinci.
 **
@@ -8,208 +8,308 @@
 ** copyright notice and this permission notice appear in supporting
 ** documentation.  This software is provided "as is" without express or
 ** implied warranty.
+**
+** "-7bit" option added August 2023 by Scott Pakin <scott+pbm@pakin.org>.
 */
 
+#include "pm_c_util.h"
+#include "mallocvar.h"
+#include "shhopt.h"
 #include "ppm.h"
 
-static void WriteHeader ARGS((void));
-static void WriteColorMap 
-  ARGS((colorhist_vector chv, int colors, pixval maxval));
-static void WriteRawImage ARGS((colorhash_table cht, int rows, int cols));
-static void WritePackedImage ARGS((colorhash_table cht, int rows, int cols));
-static void WriteEnd ARGS((void));
-#define MAXVAL 100
-#define MAXCOLORS 256
+static unsigned int const SIXEL_MAXVAL = 100;
+static unsigned int const MAXCOLORCT = 256;
 
-#define DCS '\220'   /* Device Control String */
-#define ST  '\234'   /* String Terminator */
-#define CSI '\233'   /* Control String Introducer */
-#define ESC '\033'   /* Escape character */
+static const char * const sixel = "@ACGO_";
 
-static pixel** pixels;   /* stored ppm pixmap input */
-static colorhash_table cht;
-int margin;
+/* Named escape sequences */
+typedef struct {
+  const char * DCS;   /* Device Control String */
+  const char * ST;    /* String Terminator */
+  const char * CSI;   /* Control String Introducer */
+  const char * ESC;   /* Escape character */
+} EscapeSequenceSet;
 
 
 
-int
-main( argc, argv )
-    int argc;
-    char* argv[];
-{
-    FILE* ifp;
-    int argn, rows, cols, colors;
-    int raw;
-    pixval maxval;
-    colorhist_vector chv;
-    const char* const usage = "[-raw] [-margin] [ppmfile]";
-
-
-    ppm_init( &argc, argv );
-
-    argn = 1;
-    raw = 0;
-    margin = 0;
-
-    /* Parse args. */
-    while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
-	{
-	if ( pm_keymatch( argv[argn], "-raw", 2 ) )
-	    raw = 1;
-	else if ( pm_keymatch( argv[argn], "-margin", 2 ) )
-	    margin = 1;
-	else
-	    pm_usage( usage );
-	++argn;
-	}
-
-    if ( argn < argc )
-	{
-	ifp = pm_openr( argv[argn] );
-	++argn;
-	}
-    else
-	ifp = stdin;
-
-    if ( argn != argc )
-	pm_usage( usage );
-
-    /* Read in the whole ppmfile. */
-    pixels = ppm_readppm( ifp, &cols, &rows, &maxval );
-    pm_close( ifp );
-
-    /* Print a warning if we could lose accuracy when rescaling colors. */
-    if ( maxval > MAXVAL )
-	pm_message(
-	    "maxval is not %d - automatically rescaling colors", MAXVAL );
-
-    /* Figure out the colormap. */
-    pm_message( "computing colormap..." );
-    chv = ppm_computecolorhist( pixels, cols, rows, MAXCOLORS, &colors );
-    if ( chv == (colorhist_vector) 0 )
-	pm_error( "too many colors - try doing a 'pnmquant %d'", MAXCOLORS );
-    pm_message( "%d colors found", colors );
-
-    /* Make a hash table for fast color lookup. */
-    cht = ppm_colorhisttocolorhash( chv, colors );
-
-    WriteHeader();
-    WriteColorMap( chv, colors, maxval );
-    if ( raw == 1 )
-	WriteRawImage( cht, rows, cols );
-    else
-	WritePackedImage( cht, rows, cols );
-    WriteEnd();
+enum Charwidth {CHARWIDTH_8BIT, CHARWIDTH_7BIT};
 
-    /* If the program failed, it previously aborted with nonzero completion
-       code, via various function calls.
+struct CmdlineInfo {
+    /* All the information the user supplied in the command line, in a form
+       easy for the program to use.
     */
-    return 0;
+    const char *   inputFileName;
+    unsigned int   raw;
+    unsigned int   margin;
+    enum Charwidth charWidth;
+};
+
+
+
+static EscapeSequenceSet
+escapeSequenceSet(enum Charwidth const charWidth) {
+
+    EscapeSequenceSet eseqs;
+
+    switch (charWidth) {
+    case CHARWIDTH_8BIT: {
+        eseqs.DCS = "\220";
+        eseqs.ST  = "\234";
+        eseqs.CSI = "\233";
+        eseqs.ESC = "\033";
+    } break;
+    case CHARWIDTH_7BIT: {
+        eseqs.DCS = "\033P";
+        eseqs.ST  = "\033\\";
+        eseqs.CSI = "\033[";
+        eseqs.ESC = "\033";
+    } break;
+    }
+    return eseqs;
 }
 
 
 
 static void
-WriteHeader()
-    {
-    if ( margin == 1 )
-	printf( "%c%d;%ds", CSI, 14, 72 );
-    printf( "%c", DCS );  /* start with Device Control String */
-    printf( "0;0;8q" );   /* Horizontal Grid Size at 1/90" and graphics On */
-    printf( "\"1;1\n" );  /* set aspect ratio 1:1 */
-    }
+parseCommandLine(int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
+/*----------------------------------------------------------------------------
+   Parse the program arguments (given by argc and argv) into a form
+   the program can deal with more easily -- a cmdline_info structure.
+   If the syntax is invalid, issue a message and exit the program via
+   pm_error().
+
+   Note that the file spec array we return is stored in the storage that
+   was passed to us as the argv array.
+-----------------------------------------------------------------------------*/
+    optEntry * option_def;  /* malloc'ed */
+    optStruct3 opt;  /* set by OPTENT3 */
+    unsigned int option_def_index;
+
+    unsigned int opt7Bit;
+
+    MALLOCARRAY_NOFAIL(option_def, 100);
+
+    option_def_index = 0;   /* incremented by OPTENT3 */
+    OPTENT3(0,   "raw",      OPT_FLAG,
+            NULL,                       &cmdlineP->raw, 0);
+    OPTENT3(0,   "margin",   OPT_FLAG,
+            NULL,                       &cmdlineP->margin, 0);
+    OPTENT3(0,   "7bit",     OPT_FLAG,
+            NULL,                       &opt7Bit, 0);
+
+    opt.opt_table = option_def;
+    opt.short_allowed = false; /* We have no short (old-fashioned) options */
+    opt.allowNegNum = false;   /* We have no parms that are negative numbers */
+
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
+        /* Uses and sets argc, argv, and some of *cmdlineP and others. */
+
+    cmdlineP->charWidth = opt7Bit ? CHARWIDTH_7BIT : CHARWIDTH_8BIT;
+
+    if (argc-1 == 0)
+        cmdlineP->inputFileName = "-";
+    else if (argc-1 != 1)
+        pm_error("Program takes zero or one argument (filename).  You "
+                 "specified %d", argc-1);
+    else
+        cmdlineP->inputFileName = argv[1];
+
+    free(option_def);
+}
 
 
 
 static void
-WriteColorMap( colorhist_vector chv, int colors, pixval maxval )
-    {
-    register int colornum;
-    pixel p;
-
-    for ( colornum = 0; colornum < colors ; ++colornum )
-	{
-	p = chv[colornum].color;
-	if ( maxval != MAXVAL )
-	    PPM_DEPTH( p, p, maxval, MAXVAL );
-	printf( "#%d;2;%d;%d;%d", colornum,
-	    (int) PPM_GETR( p ), (int) PPM_GETG( p ), (int) PPM_GETB( p ) );
-	}
-    printf( "\n" );
+writePackedImage(pixel **        const pixels,
+                 unsigned int    const rows,
+                 unsigned int    const cols,
+                 colorhash_table const cht) {
+
+    unsigned int row;
+
+    for (row = 0; row < rows; ++row) {
+
+        unsigned int const b = row % 6;
+
+        unsigned int repeatCt;
+        unsigned int col;
+
+        repeatCt = 1;
+
+        for (col = 0; col < cols; ++col) {
+            const pixel * const thisRow = pixels[row];
+
+            unsigned int const thisColorIdx =
+                ppm_lookupcolor(cht, &thisRow[col]);
+
+            if (col == cols - 1)   /* last pixel in row */
+                if (repeatCt == 1)
+                    printf("#%d%c", thisColorIdx, sixel[b]);
+                else
+                    printf("#%d!%d%c", thisColorIdx, repeatCt, sixel[b]);
+            else {  /* not last pixel in row */
+                unsigned int const nextColorIdx =
+                    ppm_lookupcolor(cht, &thisRow[col+1]);
+                if (thisColorIdx == nextColorIdx)
+                    ++repeatCt;
+                else {
+                    if (repeatCt == 1)
+                        printf("#%d%c", thisColorIdx, sixel[b]);
+                    else {
+                        printf("#%d!%d%c", thisColorIdx, repeatCt, sixel[b]);
+                        repeatCt = 1;
+                    }
+                }
+            }
+        }
+        printf( "$\n" );   /* Carriage Return */
+
+        if (b == 5)
+            printf("-\n");   /* Line Feed (one sixel height) */
     }
+}
 
 
 
 static void
-WriteRawImage( cht, rows, cols )
-    colorhash_table cht;
-    int rows, cols;
-    {
-    int rownum, colnum, b;
-    const char* sixel = "@ACGO_";
-    register pixel* pP;
-
-    for ( rownum = 0; rownum < rows; ++rownum )
-	{
-	b = rownum % 6;
-	for ( colnum = 0, pP = pixels[rownum]; colnum < cols; ++colnum, ++pP )
-	    printf( "#%d%c", ppm_lookupcolor(cht, pP), sixel[b] );
-	printf( "$\n" );   /* Carriage Return */
-	if ( b == 5 )
-	    printf( "-\n" );   /* Line Feed (one sixel height) */
-	}
+writeHeader(bool              const wantMargin,
+            EscapeSequenceSet const eseqs) {
+
+    if (wantMargin)
+        printf("%s%d;%ds", eseqs.CSI, 14, 72);
+
+    printf("%s", eseqs.DCS);  /* start with Device Control String */
+
+    printf("0;0;8q");   /* Horizontal Grid Size at 1/90" and graphics On */
+
+    printf("\"1;1\n");  /* set aspect ratio 1:1 */
+}
+
+
+
+static void
+writeColorMap(colorhist_vector const chv,
+              unsigned int     const colorCt,
+              pixval           const maxval) {
+
+    unsigned int colorIdx;
+
+    for (colorIdx = 0; colorIdx < colorCt ; ++colorIdx) {
+        pixel const p = chv[colorIdx].color;
+
+        pixel scaledColor;
+
+        if (maxval == SIXEL_MAXVAL)
+            scaledColor = p;
+        else
+            PPM_DEPTH(scaledColor, p, maxval, SIXEL_MAXVAL);
+
+        printf("#%d;2;%d;%d;%d", colorIdx,
+               PPM_GETR(scaledColor),
+               PPM_GETG(scaledColor),
+               PPM_GETB(scaledColor));
     }
+    printf("\n");
+}
 
 
 
 static void
-WritePackedImage( cht, rows, cols )
-    colorhash_table cht;
-    int rows, cols;
-    {
-    int rownum, colnum, b, repeat, thiscolor, nextcolor;
-    const char* sixel = "@ACGO_";
-    register pixel* pP;
-
-    for ( rownum = 0; rownum < rows; ++rownum )
-	{
-	b = rownum % 6;
-	repeat = 1;
-	for ( colnum = 0, pP = pixels[rownum]; colnum < cols; ++colnum, ++pP )
-	    {
-	    thiscolor = ppm_lookupcolor(cht, pP);
-	    if ( colnum == cols -1 )   /* last pixel in row */
-		if ( repeat == 1 )
-		    printf( "#%d%c", thiscolor, sixel[b] );
-		else
-		    printf( "#%d!%d%c", thiscolor, repeat, sixel[b] );
-	    else   /* not last pixel in row */
-		{
-		nextcolor =  ppm_lookupcolor(cht, pP+1);
-		if ( thiscolor == nextcolor )
-		    ++repeat;
-		else
-		    if ( repeat == 1 )
-			printf( "#%d%c", thiscolor, sixel[b] );
-		    else
-		    {
-		    printf( "#%d!%d%c", thiscolor, repeat, sixel[b] );
-		    repeat = 1;
-		    }
-		}
-	    }   /* end column loop */
-	printf( "$\n" );   /* Carriage Return */
-	if ( b == 5 )
-	    printf( "-\n" );   /* Line Feed (one sixel height) */
-	}
+writeRawImage(pixel **        const pixels,
+              unsigned int    const rows,
+              unsigned int    const cols,
+              colorhash_table const cht) {
+
+    unsigned int row;
+
+    for (row = 0; row < rows; ++row) {
+        pixel * const thisRow = pixels[row];
+        unsigned int const b = row % 6;
+
+        unsigned int col;
+
+        for (col = 0; col < cols; ++col)
+            printf("#%d%c", ppm_lookupcolor(cht, &thisRow[col]), sixel[b]);
+
+        printf("$\n");   /* Carriage Return */
+
+        if (b == 5)
+            printf("-\n");   /* Line Feed (one sixel height) */
     }
+}
 
 
 
 static void
-WriteEnd()
-    {
-    if ( margin == 1 )
-	printf ( "%c%d;%ds", CSI, 1, 80 );
-    printf( "%c\n", ST );
+writeEnd(bool              const wantMargin,
+         EscapeSequenceSet const eseqs) {
+
+    if (wantMargin)
+        printf ("%s%d;%ds", eseqs.CSI, 1, 80);
+
+    printf("%s\n", eseqs.ST);
+}
+
+
+
+int
+main(int argc, const char ** argv) {
+
+    struct CmdlineInfo cmdline;
+    FILE * ifP;
+    int rows, cols;
+    pixval maxval;
+    int colorCt;
+    pixel ** pixels;
+    colorhist_vector chv;
+        /* List of colors in the image, indexed by colormap index */
+    colorhash_table cht;
+        /* Hash table for fast colormap index lookup */
+    EscapeSequenceSet eseqs;
+        /* The escape sequences we use in our output for various functions */
+
+    pm_proginit(&argc, argv);
+
+    parseCommandLine(argc, argv, &cmdline);
+
+    ifP = pm_openr(cmdline.inputFileName);
+
+    pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
+
+    if (maxval > SIXEL_MAXVAL) {
+        pm_message(
+            "maxval of input is not the sixel maxval (%u) - "
+            "rescaling to fewer colors", SIXEL_MAXVAL);
     }
+
+    pm_message("computing colormap...");
+    chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORCT, &colorCt);
+    if (!chv)
+        pm_error("too many colors - try 'pnmquant %u'", MAXCOLORCT);
+
+    pm_message("%d colors found", colorCt);
+
+    cht = ppm_colorhisttocolorhash(chv, colorCt);
+
+    eseqs = escapeSequenceSet(cmdline.charWidth);
+
+    writeHeader(!!cmdline.margin, eseqs);
+
+    writeColorMap(chv, colorCt, maxval);
+
+    if (cmdline.raw)
+        writeRawImage(pixels, rows, cols, cht);
+    else
+        writePackedImage(pixels, rows, cols, cht);
+
+    writeEnd(!!cmdline.margin, eseqs);
+
+    /* If the program failed, it previously aborted with nonzero completion
+       code, via various function calls.
+    */
+    return 0;
+}
+
+
+
diff --git a/doc/HISTORY b/doc/HISTORY
index ce7e957e..a0b1a61b 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,14 +4,44 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
-23.09.24 BJH  Release 11.03.06
+23.09.27 BJH  Release 11.04.00
 
-              pbmtoxbm: Fix spurious output with really wide rows.
+              pamaddnoise: add -salt.
+
+              pamaddnoise: reject options that aren't meaningful for the type
+              of noise specified rather than just ignore them.
+
+              ppmtosixel: Add -7bit, so it works on more terminals, including
+              xterms.  Thanks Scott Pakin.
+
+              g3topbm: Add -correctlong
+
+              build: Add COMPILED_BY environment variable to control the
+              "compiled by" value from --version common option.  This helps
+              with creating reproducible builds.
 
-23.09.06 BJH  Release 11.03.05
+              pnmtojpeg: minor improvement to error messages about bad files.
+
+              pammixmulti: Remove disclaimer of patent license.
+
+              pamstack: Fix bug: acts like -firstmaxval specified when it
+              wasn't.  Introduced in Netpbm 11.03 (June 2023).
+
+              pamstack: Fix -lcmmaxval: chooses wrong maxval.  Always
+              broken (-lcmmaxval was new in Netpbm 11.03 (June 2023)).
+
+              pamstack: Fail gracefully when total number of planes is too
+              large for unsigned integer.  Always broken (Pamstack was new in
+              Netpbm 10.0 (June 2002).
 
               pamtosvg: fix hang.
 
+              ppmfade: fix "file not found" crash for most fade modes.
+              Introduced in Netpbm 10.98 (March 2022).
+
+              ppmfade: fix incorrect block mode fade.  Always broken
+              (ppmfade was new in Netpbm 8.4 (April 2000)).
+
               pamaddnoise: fix very incorrect noise added for all types.
               Introduced in Netpbm 10.94 (March 2021).
 
@@ -21,35 +51,32 @@ CHANGE HISTORY
               ppmrough: fix excessive roughness.  Introduced in Netpbm 10.94
               (March 2021).
 
-23.08.20 BJH  Release 11.03.04
-
               pgmtexture: Fix buffer overflow with maxval > 255.  Always
               broken.  Maxvals > 255 were possible starting in Netpbm 9.0
               (April 2000).
 
-23.08.18 BJH  Release 11.03.03
+              pgmtexture: Fix bug: ignores -d.  Introduced in Netpbm 10.56
+              (September 2011).
 
-              ppmfade: fix "file not found" crash for most fade modes.
-              Introduced in Netpbm 10.98 (March 2022).
+              xwdtopnm Fix spurious output with really wide/deep rows.
 
-              ppmfade: fix incorrect block mode fade.  Always broken
-              (ppmfade was new in Netpbm 8.4 (April 2000)).
+              imgtoppm: Fix spurious output with really wide/deep rows.
 
-              pamstack: Fail gracefully when total number of planes is too
-              large for unsigned integer.  Always broken (Pamstack was new in
-              Netpbm 10.0 (June 2002).
+              pbmtopgm: Fix error message for excessive -width.
+
+              pbmtoxbm: Fix spurious output with really wide rows.
 
-23.08.05 BJH  Release 11.03.02
+              tifftopnm: Fix incorrect output with insanely wide/deep rows.
 
-              Fix -lcmmaxval fix in 11.03.01.
+              thinkjettopbm: Fix incorrect output with insanely wide rows.
 
-23.08.02 BJH  Release 11.03.01
+              ybmtopbm: Fix incorrect output with insanely wide rows.
 
-              pamstack: fix bug: acts like -firstmaxval specified when it
-              wasn't.  Introduced in Netpbm 11.03 (June 2023).
+              pjtoppm: Fix incorrect output with insanely large number of rows.
 
-              pamstack: fix -lcmmaxval: chooses wrong maxval.  Always
-              broken (-lcmmaxval was new in Netpbm 11.03 (June 2023)).
+              library: add check of maxval for computable size.
+
+              Build: Include LDFLAGS in link of shared library.
 
 23.06.28 BJH  Release 11.03.00
 
@@ -387,7 +414,7 @@ CHANGE HISTORY
               ppmshift: Add -seed .
 
               pamaddnoise: Fix incorrect output for -type poisson.  Always
-              broken.  (pamaddnoise's precursor pnmaddnoies was new to Netpbm
+              broken.  (pamaddnoise's precursor pnmaddnoise was new to Netpbm
               in Netpbm 10.29 (August 2005)).
 
               pamaddnoise: fix bug: garbage output with -type impulse.  Always
diff --git a/doc/INSTALL b/doc/INSTALL
index c20d372e..0d49f441 100644
--- a/doc/INSTALL
+++ b/doc/INSTALL
@@ -109,8 +109,8 @@ If you use the 'configure' program, be sure to edit config.mk _after_ you
 run 'configure', since 'configure' generates config.mk.
 
 
-COMPILED-IN BUILD DATETIME
---------------------------
+COMPILED-IN BUILD DATETIME AND USER
+-----------------------------------
 
 By default, the Netpbm build system builds the datetime that you built it
 into libnetpbm, so the --version global command line option can display it.
@@ -137,6 +137,13 @@ The name and meaning of the environment variable is taken from a standard
 described at https://reproducible-builds.org/specs/source-date-epoch/ on March
 16, 2017.
 
+Likewise, the Netpbm build system builds the identity of the party who did the
+build in libnetpbm.  This is normally a userid, the output of the 'whoami'
+program, unless overridden by USER or LOGNAME environment variables.  You can
+also override 'whoami', USER, and LOGNAME with the COMPILED_BY environment
+variable.  This value is just for display, so it need not be a userid; any
+single word that does not contain quotation marks is acceptable.
+
 
 AUTOMATING THE BUILD
 --------------------
@@ -162,6 +169,12 @@ contents.  You can also run Configure interactively and use its output
 as an example.
 
 
+COMPILER REQUIREMENTS
+---------------------
+
+The compiler must be able to compile C99 code.
+
+
 THE PREREQUISITE LIBRARIES
 --------------------------
 
diff --git a/doc/Netpbm.programming b/doc/Netpbm.programming
deleted file mode 100644
index c4d38ed4..00000000
--- a/doc/Netpbm.programming
+++ /dev/null
@@ -1,425 +0,0 @@
-This file is an attempt to give some basic guidelines for those who
-wish to write new Netpbm programs.  The guidelines ensure:
-
-  A) Your program functions consistently with the rest of the package.
-
-  B) Your program works in myriad environments on which you can't test it.
-
-  C) You don't miss an important detail of the Netpbm formats.
-
-  D) Your program is immune to small changes in the Netpbm formats.
-
-The easiest way to write your own Netpbm program is to take an
-existing one, similar to the one you want to write, and to modify
-it.  This saves a lot of time, and ensures conformity with these rules.
-But pick a recent one (check the file modification date and the
-doc/HISTORY file), because many things you see in old programs are
-grandfathered in.  Pamtopnm is good example of a thoroughly modern
-Netpbm program.  Pamcut is another good one.
-
-
-COLLECTION PARAMETERS
----------------------
-
-The philosophy that guides what goes into Netpbm and what doesn't is
-one of maximum distribution of function.  Contributions to Netpbm are
-refused very rarely, and usually because there is already some better
-way to do what the contribution attempts to do, so that the
-contribution would just make the package more confusing and thus
-harder to use.  The second most common reason for declining a
-contribution is that it falls well outside Netpbm's scope.  That too
-would make the package more confusing and thus harder to use.
-
-"Nobody will use that" is not a reason for leaving something out of
-Netpbm.
-
-"That's different from how other Netpbm programs work" is similarly 
-not an excuse for refusing distribution of a feature.  (But it's a
-good reason to accept a change to make a feature consistent!)
-
-The standard for adding something to Netpbm isn't that it be perfect,
-or even a net improvement.  The standard is that it not make Netpbm
-worse.  Poor quality additions are made all the time, because a
-program that doesn't work well is usually no worse than no program at
-all.
-
-
-DEVELOPMENT PROCESS
--------------------
-
-Just email your code to the Netpbm maintainer.  Base it on the most recent
-Netpbm Development release if possible.
-
-The preferred form for changes to existing files is a unified diff patch --
-the conventional Unix means of communicating code changes.  A Subversion
-'svn diff' creates that easily.
-
-You should update or create documentation too.  But if you don't, the Netpbm
-maintainer will do the update before releasing your code.  The source files
-for the documentation are the HTML files in the 'userguide' directory of the
-Netpbm Subversion repository: https://svn.code.sf.net/p/netpbm/code/userguide.
-The identical files are at http://netpbm.sourceforge.net/doc/ .
-
-There are some automated tests in the package - shell scripts in files
-named such as "pbmtog3.test".  You can use those to verify your
-changes.  You should also add to these tests and create new ones.  But
-most developers don't.
-
-As you code and test, do 'make dep' to create the header file dependency files
-(depend.mk).  Do it after 'configure' and every time you change the
-dependencies.  If you don't, 'make' won't know to recompile things when you
-change the header files.  For the convenience of users who are just building,
-and not changing anything, the make files do work without a 'make dep', but do
-so by automatically generating empty depend.mk files.  This is not what you
-want as a developer.
-
-
-CODING GUIDELINES
------------------
-
-The Netpbm maintainer accepts programs that do not meet these guidelines,
-so don't feel you need to hold back a contribution because you wrote it
-before you read these.
-
-* See the Netpbm library documentation to see what library functions
-  you should be using and how.  You can find it at:
-
-  http://netpbm.sourceforge.net/doc/libnetpbm.html
-
-* See the specifications of the Netpbm formats at:
-
-  http://netpbm.sourceforge.net/doc/pbm.html
-  http://netpbm.sourceforge.net/doc/pgm.html
-  http://netpbm.sourceforge.net/doc/ppm.html
-  http://netpbm.sourceforge.net/doc/pam.html
-
-  but don't depend very much on these; use the library functions
-  instead to read and write the image files.
-
-* You should try to use the "pam" library functions, which are newer than the
-  "pbm", "pgm", and "pnm" ones.  The "pam" functions read and write all four
-  Netpbm formats and make code easier to write and to read.
-
-* A new program should generate PAM output.  Note that any program that uses
-  the modern Netpbm library can read PAM even if it was designed for the older
-  formats.  For other programs, one can convert PAM to the older formats
-  with 'pamtopnm'.
-
-* If your program involves transparency (alpha masks), you have two
-  alternatives.  The older method is to use a separate PGM file for the
-  alpha mask, in the style of Pngtopnm/Pnmtopng and Giftopnm/Pnmtogif,
-  and use command syntax like those programs.  See the PGM format spec
-  for details.
-  
-  A newer method involves a PAM image with an alpha plane (tuple type
-  RGB_ALPHA, etc.).  This is preferred because it's easier for users
-  to pipe stuff around.  Pamtotga is an example of this.
-
-* Declare all your symbols except 'main' as static so that they won't
-  cause problems to other programs when you do a "merge build" of 
-  Netpbm.
-
-* Always start the code in main() with a call to pm_proginit().
-
-* Use shhopt for option processing.  i.e. call optParseOptions3().
-  This is really easy if you just copy the parseCommandLine() function
-  and struct cmdlineInfo declaration from pamcut.c and adapt it to 
-  your program. 
-
-  When you do this, you get a command line syntax consistent with all the
-  other Netpbm programs, you save coding time and debugging time, and it
-  is trivial to add options later on.
-
-  Do not use shhopt's short option alternative unless you need to be
-  compatible with another program that has short options.  Short
-  options are traditional one-character Unix options, which can be
-  stacked up like "foo -cderx myfile", and they are far too unfriendly
-  to be accepted by the Netpbm philosophy.  Note that long options in
-  shhopt can always be abbreviated to the shortest unique prefix, even
-  one character.
-
-  In messages and examples in documentation, always refer to an option
-  by its full name, not the abbreviation you usually use.  E.g. if you have
-  a "-width" option which can be abbreviated "-w", don't use -w in 
-  documentation.  -width is far clearer.
-  
-* Use pm_error() and pm_message() for error messages and other messages.
-  Note that the universal -quiet option (processed by p?m_init()) causes
-  messages issued via pm_message() to be suppressed.  And that's what
-  Netpbm's architecture requires.
-
-* The argument to pm_error() and pm_message() is a string of text, not
-  a formatted message.  Don't put newlines or other formatting characters
-  in it.  These subroutines are designed to be flexible in how they issue
-  the messages.
-
-* Use MALLOCARRAY() to allocate space for an array and MALLOCVAR to allocate
-  space for a non-array variable.  In fact, you usually want to save some
-  programming tedium and use the NOFAIL versions of these (they never fail
-  because they abort the program if memory is not available).  These avoid
-  array bounds violations.
-
-* Use pm_tmpfile() to make a temporary file.  This avoids races that can
-  be used to compromise security.
-
-* Properly use maxvals.  As explained in the format specifications, every
-  sample value in an image must be interpreted relative to the image's
-  maxval.  For example, a pixel with value 24 in an image with maxval 24
-  is the same brightness as a pixel with value 255 in an image with a
-  maxval of 255.
-
-  255 is a popular maxval (use the PPM_MAXMAXVAL etc. macros) because it
-  makes samples fit in a single byte and at one time was the maximum 
-  possible maxval in the format.
-
-  Note that the Pamdepth program converts an image from one maxval to another.
-
-* Don't include extra function.  If you can already do something by 
-  piping the input or output of your program through another Netpbm
-  program, don't make an option on your program to do it.  That's the
-  Netpbm philosophy -- simple building blocks.
-
-  Similarly, if your program does two things which would be useful
-  separately, write two programs and advise users to pipe them
-  together.  Or add a third program that simply runs the first two.
-
-* Your program should, if appropriate, allow the user to use Standard
-  Input and Output for images.  This is because Netpbm users commonly
-  use pipes.  As an alternative to Standard Input, the user should be able
-  to name the input file as a non-option program argument.  But the user
-  should not be able to name the output file if Standard Output is
-  feasible.  That's just the Netpbm tradition.
-
-* Don't forget to write a proper html documentation page.  Get an
-  example to use as a template from
-  <http://netpbm.sourceforge.net/doc/directory.html>.
-
-* No Netpbm source code may contain tab characters.  If you
-  generate such a file, the Netpbm maintainer will convert it to spaces
-  and possibly change all your indenting at the same time.  Tabs are not
-  appropriate for code that multiple people must edit because they don't
-  necessarily look the same in every editing environment, and in most
-  editing environments, you can't even tell which spaces are actually in
-  the file and which came from the editor, expanding tabs.  Spaces, on
-  the other hand, look the same for everyone.  Modern editors let you
-  compose code just as easily with spaces as with tabs.
-
-* Limit your C code to original ANSI C.  Not C99.  Not C89.  Not C++.  Don't
-  use // for comments or put declarations in the interior of a block.
-  Interpreted languages are OK, with Perl being preferred.
-
-* Make output invariant with input.  The program should produce the same output
-  when fed the same input.  This helps with testing and also reduces the chance
-  of bugs being encountered randomly.
-
-  This is an issue when there are "don't care" bits in the output.  You should
-  normally make those zero.
-
-  The valgrind utility helps you identify instances of undefined bits and
-  bytes getting to output.
-
-  A common place to find "don't care" bits is padding at the end of a raster
-  row.  You can use pbm_cleanrowend_packed() to clear padding bits when you
-  use pbm_writepbmrow_packed().
-
-  Some programs are designed to produce random output.  For those, include a
-  -seed option to specify the seed of the random number generator so that a
-  tester can make the output predictable.
-
-
-* Never assume that input will be valid; make sure your program can
-  handle corrupt input gracefully.
-
-  Watch out for arithmetic overflows caused by large numbers in the input.
-
-  Be careful when writing decoders.  Make sure that corruptions in the
-  input image do not cause buffer overruns.
-
-
-
-
-DISCONTINUED CODING GUIDELINES
-------------------------------
-
-Here are some things you will see in old Netpbm programs, but they are
-obsolete and you shouldn't propagate them into a new program:
-
-* Use of pbm_init(), pgm_init(), ppm_init(), and pnm_init().  We use
-  pm_proginit() now.
-
-* Tolerating non-standard C libraries.  You may assume all users have
-  ANSI and POSIX compliant C libraries.  E.g. use strrchr() and forget
-  about rindex().
-
-* pm_keymatch() for option processing.  Use shhopt instead, as described
-  above.
-
-* optParseOptions() and optParseOptions2().  These are obsoleted
-  by optParseOptions3(), which is easier to use and more powerful.
-
-* K&R C function declarations.  Always use ANSI function declarations
-  exclusively (e.g. use 
-
-      void foo(int arg1){} 
-
-  instead of 
-
-       void foo(arg1)
-           int arg1;
-           {}
-
-* for (col=0, xP = row; col < cols; col++, xP++)
-      foo(*xP);
-
-  This was done in the days before optimizing compilers because it ran faster
-  than the more readable:
-
-    for (col=0; col < cols; col++)
-        foo(row[col]);
-
-  Now, just use the latter.
-
-
-CODING STYLE
-------------
-
-We do not generally mandate any basic coding style in these
-guidelines.  Where you put your braces is a matter of personal style
-and other people working with your code will just have to live with
-it.  However, people working with your code might just recode it into
-another style if it makes it easier for them to read the code and
-have confidence in their changes.
-
-But if you have no preference, the following is what the Netpbm
-maintainer currently prefers.  Essentially, it is clean, elegant
-computer science-type code rather than brute force engineering-type
-code.  Modular and structured above all.
-
-* No gotos.  This includes all variations of goto:  break, continue, leave,
-  mid-function return.  An exception: aborting the entire program in the 
-  middle of something is allowed.
-
-* No functions with side effects.  This is a tough one, since
-  functions with side effects is highly traditional C.  In fact, the
-  creators of C didn't even have a concept of a subroutine.  However,
-  the average human brain, especially one trained in math, cannot
-  easily follow code where a function both computes a value and does
-  other stuff.
-  
-  For the purpose of this discussion, we say that a C function whose return
-  type is void is not a "function," but a "subroutine."
-
-  So a function should never change anything in the program.  All it does
-  is compute a value.
-
-  Where you have to call an external function that has side effects (virtually
-  anything in the standard C library, for example), put it in a simple
-  assignment function that captures its return value and otherwise consider
-  it a subroutine:
-
-    rc = fopen(...)
-    if (rc ...)
-
-* No reuse of variables.  Most variables should be set at most once.
-  Don't say "A is 5" and then later on, "no, A is 6."  A reader
-  should be able to take that first "A is 5" as a statement of fact
-  and not hunt for all the places it might be contradicted.  A
-  variable that represents the state of execution of an algorithm is an
-  obvious exception.
-
-  Use "const" everywhere you possibly can.
-
-  Especially never modify the argument of a function.  All function arguments
-  should be "const".
-
-  Don't use initializers except for with constants.  The first value a
-  variable has is a property of the algorithm that uses the variable, not of
-  the variable.  A reader expects to see the whole algorithm in one place, as
-  opposed to having part of it hidden in the declaration of the algorithm
-  variables.
-
-* Avoid global variables.  Sometimes, a value is truly global and
-  passing it as a parameter just muddies the code.  But most of the
-  time, any external value to which a function refers should be one of
-  its arguments.  
-
-  Declare a variable in the most local scope possible.
-
-  Global constants are OK.
-
-* Do not use static variables, except for global constants.
-
-* Keep subroutines small.  Generally under 50 lines.  But if the
-  routine is a long sequence of simple, similar things, it's OK for it
-  run on ad infinitem.
-
-* Use the type "bool" for boolean variables.  "bool" is defined in Netpbm
-  headers.  Use TRUE and FALSE as its values.
-
-* Do not say "if (a)" when you mean "if (a != 0)".  Use "if (a)" only if a is
-  a boolean variable.  Or where it's defined so that zero is a special value
-  that means "doesn't exist".
-
-* Do multiword variable names in camel case: "multiWordName".  Underscores
-  waste valuable screen real estate.
-
-* If a variable's value is a pointer to something, it's name should reflect
-  that, as opposed to lying and saying the value is the thing pointed to.  A
-  "P" on the end is the conventional way to say "pointer to."  E.g. if a
-  variable's value is a pointer to a color value, name it "colorP", not
-  "color".
-
-* A variable that represents the number of widgets should be "widgetCt",
-  ("widget count"), not "widgets".  The latter should represent the actual
-  widgets instead.
-
-* Put "const" as close as possible to the thing that is constant.
-  "int const width", not "const int width".  When pointers to
-  constants are involved, it makes it much easier to read.
-
-* Free something in the same subroutine that allocates it.  Have exactly 
-  one free per allocate (this comes naturally if you eliminate gotos).
-
-* Dynamically allocate buffers, for example raster buffers, rather than use
-  automatic variables.  Accidentally overrunning an automatic variable,
-  typically stored on the stack, is much more dangerous than overrunning a
-  variable stored in the heap.
-
-* Use pm_asprintf() to compose strings, instead of sprintf(), strcat(), and
-  strcpy().  pm_asprintf() is essentially the same as GNU asprintf(), i.e.
-  sprintf(), except it dynamically allocates the result memory.  This
-  effortlessly makes it impossible to overrun the result buffer.  Use
-  pm_strfree() to free the result memory.  You usually need not worry about
-  the pathological case that there is no memory available for the result,
-  because in that case, pm_asprintf() returns a constant string "OUT OF MEMORY"
-  and in most cases, that won't cause a disaster - just incorrect behavior that
-  is reasonable in the face of such a pathological situation.
-
-* Do not use the "register" qualifier of a variable.
-
-
-MISCELLANEOUS
--------------
-
-Object code immutability across compilations
---------------------------------------------
-
-In a normal build process the same source code always produces the same object
-code.  (Of course this depends on your compiler and its settings: if your
-compiler writes time stamps into the objects, they will naturally be different
-with each compilation.)
-
-The file lib/compile.h has a time stamp which gets written into libnetpbm.a
-and libnetpbm.so .  This will affect individual binary executables if they are
-statically linked.
-
-If compile.h does not exist it will be created by the program
-buildtools/stamp-date.  Once created, compile.h will stay unchanged until you
-do "make clean".
-
-If you make alterations to source which are entirely cosmetic (for example,
-changes to comments or amount of indentation) and need to confirm that the
-actual program logic is not affected, compare the object files.  If you need
-to compare library files (or for some reason, statically linked binaries) make
-sure that the same compile.h is used throughout.
-
diff --git a/editor/pamaddnoise.c b/editor/pamaddnoise.c
index e585700b..b662aa96 100644
--- a/editor/pamaddnoise.c
+++ b/editor/pamaddnoise.c
@@ -39,8 +39,14 @@
 #include "pam.h"
 
 static double const EPSILON = 1.0e-5;
-static double const SALT_RATIO = 0.5;
 
+static double const SIGMA1_DEFAULT  = 4.0;
+static double const SIGMA2_DEFAULT  = 20.0;
+static double const MGSIGMA_DEFAULT = 0.5;
+static double const LSIGMA_DEFAULT  = 10.0;
+static double const TOLERANCE_DEFAULT  = 0.10;
+static double const SALT_RATIO_DEFAULT = 0.5;
+static double const LAMBDA_DEFAULT  = 12.0;
 
 
 enum NoiseType {
@@ -70,6 +76,7 @@ struct CmdlineInfo {
     float sigma1;
     float sigma2;
     float tolerance;
+    float saltRatio;
 };
 
 
@@ -115,7 +122,7 @@ parseCommandLine(int argc, const char ** const argv,
     unsigned int option_def_index;
 
     unsigned int typeSpec, lambdaSpec, lsigmaSpec, mgsigmaSpec,
-        sigma1Spec, sigma2Spec, toleranceSpec;
+      sigma1Spec, sigma2Spec, toleranceSpec, saltRatioSpec;
 
     const char * type;
 
@@ -138,6 +145,8 @@ parseCommandLine(int argc, const char ** const argv,
             &sigma2Spec,         0);
     OPTENT3(0,   "tolerance",       OPT_FLOAT,    &cmdlineP->tolerance,
             &toleranceSpec,      0);
+    OPTENT3(0,   "salt",            OPT_FLOAT,    &cmdlineP->saltRatio,
+            &saltRatioSpec,      0);
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -151,42 +160,82 @@ parseCommandLine(int argc, const char ** const argv,
     else
         cmdlineP->noiseType = typeFmName(type);
 
-    if (sigma1Spec && cmdlineP->noiseType != NOISETYPE_GAUSSIAN)
-        pm_error("-sigma1 is valid only with -type=gaussian");
+    if (sigma1Spec) {
+        if (cmdlineP->noiseType != NOISETYPE_GAUSSIAN)
+            pm_error("-sigma1 is valid only with -type=gaussian");
+        else if (cmdlineP->sigma1 < 0)
+            pm_error("-sigma1 value must be non-negative.  You specified %f",
+                     cmdlineP->sigma1);
+    }
 
-    if (sigma2Spec && cmdlineP->noiseType != NOISETYPE_GAUSSIAN)
-        pm_error("-sigma2 is valid only with -type=gaussian");
+    if (sigma2Spec) {
+        if (cmdlineP->noiseType != NOISETYPE_GAUSSIAN)
+            pm_error("-sigma2 is valid only with -type=gaussian");
+        else if (cmdlineP->sigma2 < 0)
+            pm_error("-sigma2 value must be non-negative.  You specified %f",
+                     cmdlineP->sigma2);
+    }
 
-    if (mgsigmaSpec &&
-        cmdlineP->noiseType != NOISETYPE_MULTIPLICATIVE_GAUSSIAN)
-        pm_error("-mgsigma is valid only with -type=multiplicative_guassian");
+    if (mgsigmaSpec) {
+        if (cmdlineP->noiseType != NOISETYPE_MULTIPLICATIVE_GAUSSIAN)
+            pm_error("-mgsigma is valid only with -type=multiplicative_guassian");
+        else if (cmdlineP->mgsigma < 0)
+            pm_error("-mgsigma value must be non-negative.  You specified %f",
+                     cmdlineP->mgsigma);
+    }
 
-    if (toleranceSpec && cmdlineP->noiseType != NOISETYPE_IMPULSE)
-        pm_error("-tolerance is valid only with -type=impulse");
+    if (toleranceSpec) {
+        if (cmdlineP->noiseType != NOISETYPE_IMPULSE)
+            pm_error("-tolerance is valid only with -type=impulse");
+        else if (cmdlineP->tolerance < 0 || cmdlineP->tolerance > 1.0)
+            pm_error("-tolerance value must be between 0.0 and 1.0.  "
+                     "You specified %f",  cmdlineP->tolerance);
+    }
 
-    if (lsigmaSpec && cmdlineP->noiseType != NOISETYPE_LAPLACIAN)
+    if (saltRatioSpec) {
+        if (cmdlineP->noiseType != NOISETYPE_IMPULSE)
+            pm_error("-salt is valid only with -type=impulse");
+        else if (cmdlineP->saltRatio < 0 || cmdlineP->saltRatio > 1.0)
+            pm_error("-salt value must be between 0.0 and 1.0.  "
+                     "You specified %f",  cmdlineP->saltRatio);
+    }
+
+    if (lsigmaSpec) {
+        if (cmdlineP->noiseType != NOISETYPE_LAPLACIAN)
         pm_error("-lsigma is valid only with -type=laplacian");
+        else if (cmdlineP->lsigma <= 0)
+            pm_error("-lsigma value must be positive.  You specified %f",
+                     cmdlineP->lsigma);
+    }
 
-    if (lambdaSpec && cmdlineP->noiseType != NOISETYPE_POISSON)
+    if (lambdaSpec) {
+        if (cmdlineP->noiseType != NOISETYPE_POISSON)
         pm_error("-lambda is valid only with -type=poisson");
+        else if (cmdlineP->lambda <= 0)
+            pm_error("-lambda value must be positive.  You specified %f",
+                     cmdlineP->lambda);
+    }
 
     if (!lambdaSpec)
-        cmdlineP->lambda = 12.0;
+        cmdlineP->lambda = LAMBDA_DEFAULT;
 
     if (!lsigmaSpec)
-        cmdlineP->lsigma = 10.0;
+        cmdlineP->lsigma = LSIGMA_DEFAULT;
 
     if (!mgsigmaSpec)
-        cmdlineP->mgsigma = 0.5;
+        cmdlineP->mgsigma = MGSIGMA_DEFAULT;
 
     if (!sigma1Spec)
-        cmdlineP->sigma1 = 4.0;
+        cmdlineP->sigma1 = SIGMA1_DEFAULT;
 
     if (!sigma2Spec)
-        cmdlineP->sigma2 = 20.0;
+        cmdlineP->sigma2 = SIGMA2_DEFAULT;
 
     if (!toleranceSpec)
-        cmdlineP->tolerance = 0.10;
+        cmdlineP->tolerance = TOLERANCE_DEFAULT;
+
+    if (!saltRatioSpec)
+        cmdlineP->saltRatio = SALT_RATIO_DEFAULT;
 
     if (!cmdlineP->seedSpec)
         cmdlineP->seed = pm_randseed();
@@ -441,7 +490,7 @@ main(int argc, const char ** argv) {
                     addImpulseNoise(inpam.maxval,
                                     tuplerow[col][plane],
                                     &newtuplerow[col][plane],
-                                    cmdline.tolerance, SALT_RATIO,
+                                    cmdline.tolerance, cmdline.saltRatio,
                                     &randSt);
                    break;
 
diff --git a/editor/pamedge.c b/editor/pamedge.c
index f4384535..ca742573 100644
--- a/editor/pamedge.c
+++ b/editor/pamedge.c
@@ -30,7 +30,7 @@ writeBlackRow(struct pam * const pamP) {
             tuplerow[col][plane] = 0;
     }
     pnm_writepamrow(pamP, tuplerow);
-} 
+}
 
 
 
@@ -92,12 +92,12 @@ computeOneRow(struct pam * const inpamP,
         orow[0][plane] = 0;
 
         for (col = 1; col < inpamP->width - 1; ++col) {
-            double const grad1 = 
+            double const grad1 =
                 1 * horizGradient(row0, col, plane) +
                 2 * horizGradient(row1, col, plane) +
                 1 * horizGradient(row2, col, plane);
 
-            double const grad2 = 
+            double const grad2 =
                 horizAvg(row2, col, plane) - horizAvg(row0, col, plane);
 
             double const gradient = sqrt(SQR(grad1) + SQR(grad2));
@@ -163,7 +163,7 @@ main(int argc, const char ** argv) {
 
     pm_proginit(&argc, argv);
 
-    if (argc-1 == 1) 
+    if (argc-1 == 1)
         ifP = pm_openr(argv[1]);
     else if (argc-1 == 0)
         ifP = stdin;
diff --git a/editor/pammasksharpen.c b/editor/pammasksharpen.c
index 6e34ab20..1e3dee32 100644
--- a/editor/pammasksharpen.c
+++ b/editor/pammasksharpen.c
@@ -7,8 +7,8 @@ struct cmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char * inputFilespec;  
-    const char * maskFilespec;  
+    const char * inputFilespec;
+    const char * maskFilespec;
     unsigned int verbose;
     float        sharpness;
     float        threshold;
@@ -31,7 +31,7 @@ parseCommandLine(int argc, const char ** const argv,
     unsigned int option_def_index;
 
     unsigned int sharpSpec, thresholdSpec;
-    
+
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENTRY */
@@ -75,13 +75,13 @@ parseCommandLine(int argc, const char ** const argv,
             cmdlineP->inputFilespec = "-";
         else {
             cmdlineP->inputFilespec = argv[2];
-        
+
             if (argc-1 > 2)
                 pm_error("There are at most two arguments:  mask file name "
                          "and input file name.  You specified %d", argc-1);
         }
     }
-}        
+}
 
 
 
@@ -98,7 +98,7 @@ sharpened(sample const inputSample,
 
     if (abs(edgeness) > threshold) {
         float const rawResult = inputSample + edgeness * sharpness;
-        
+
         retval = MIN(maxval, (unsigned)MAX(0, (int)(rawResult+0.5)));
     } else
         retval = inputSample;
@@ -125,9 +125,9 @@ main(int argc, const char * *argv) {
         /* Magnitude of difference between image and unsharp mask below
            which they will be considered identical.
         */
-    
+
     pm_proginit(&argc, argv);
-    
+
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFilespec);
@@ -136,7 +136,7 @@ main(int argc, const char * *argv) {
     pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
     pnm_readpaminit(maskfP, &maskpam, PAM_STRUCT_SIZE(tuple_type));
 
-    if (inpam.width  != maskpam.width || 
+    if (inpam.width  != maskpam.width ||
         inpam.height != maskpam.height ||
         inpam.depth  != maskpam.depth)
         pm_error("The mask image must be the same dimensions as the "
@@ -165,10 +165,10 @@ main(int argc, const char * *argv) {
         unsigned int col;
         pnm_readpamrow(&inpam,   inputTuplerow);
         pnm_readpamrow(&maskpam, maskTuplerow);
-        
+
         for (col = 0; col < outpam.width; ++col) {
             unsigned int plane;
-            
+
             for (plane = 0; plane < outpam.depth; ++plane) {
                 outputTuplerow[col][plane] =
                     sharpened(inputTuplerow[col][plane],
@@ -187,6 +187,6 @@ main(int argc, const char * *argv) {
     pnm_freepamrow(inputTuplerow);
     pnm_freepamrow(maskTuplerow);
     pnm_freepamrow(outputTuplerow);
-    
+
     return 0;
 }
diff --git a/editor/pammixmulti.c b/editor/pammixmulti.c
index 2b45d807..27390ec6 100644
--- a/editor/pammixmulti.c
+++ b/editor/pammixmulti.c
@@ -307,29 +307,6 @@ blendTuplesAverage(struct ProgramState * const stateP,
 
 
 
-#if 0
-static void
-randomNormal2(double *           const r1P,
-              double *           const r2P,
-              struct pm_randSt * const randStP) {
-/*----------------------------------------------------------------------------
-  Return two normally distributed random numbers.
------------------------------------------------------------------------------*/
-    double u1, u2;
-
-    do {
-        u1 = drand48(randStP);
-        u2 = drand48(randStP);
-    }
-    while (u1 <= DBL_EPSILON);
-
-    *r1P = sqrt(-2.0*log(u1)) * cos(2.0*M_PI*u2);
-    *r2P = sqrt(-2.0*log(u1)) * sin(2.0*M_PI*u2);
-}
-#endif
-
-
-
 static void
 precomputeImageWeights(struct ProgramState * const stateP,
                        double                const sigma) {
@@ -530,34 +507,34 @@ main(int argc, const char * argv[]) {
 
 /*  COPYRIGHT LICENSE and WARRANTY DISCLAIMER
 
-Copyright (c) 2018 Scott Pakin
+Copyright (c) 2018-2023 Scott Pakin
 All rights reserved
 
 Redistribution and use in source and binary forms, with or without
-modification, are permitted (subject to the limitations in the disclaimer
-below) provided that the following conditions are met:
-
-  Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-
-  Redistributions in binary form must reproduce the above copyright notice,
-  this list of conditions and the following disclaimer in the documentation
-  and/or other materials provided with the distribution.
-
-  Neither the names of the oopyright owners nor the names of its contributors
-  may be used to endorse or promote products derived from this software
-  without specific prior written permission.
-
-  NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
-  THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
-  NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+“AS IS†AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
diff --git a/editor/pamperspective.c b/editor/pamperspective.c
index a8b1cf8f..487025bc 100644
--- a/editor/pamperspective.c
+++ b/editor/pamperspective.c
@@ -154,7 +154,7 @@ typedef struct {
 
 
 /* The collection of properties that correspond to the four specified
-   vertices 
+   vertices
 */
 
 typedef struct {
@@ -172,18 +172,18 @@ typedef struct {
      center of projection, that is the pixel the camera "looks at".  It
      turned out, maybe surprisingly, that this does not have any
      effect. So now this center is moved to (0,0).
-     
+
      Another original plan was to correct the output parameters
      depending on the lengths of the paralellograms sides or its
      angles.  This is, however, not possible without knowing something
      like the camera angle or focal length (in pixels).
   */
-  
+
   /* The coefficients for the map from output to world coordinates.
 
      The actual mapping is
      u,v -> (ax+bx*u+cx*v, ay+by*u+cy*v, az+bz*u+cz*v)
-  */     
+  */
   number ax,bx,cx, ay,by,cy, az,bz,cz;
 
 } world_data;
@@ -331,7 +331,7 @@ parseFloat(const char * const text) {
     char * end;
     number num;
     char * buffer;
-    
+
     buffer = strdup(text);
     if (!buffer)
         pm_error("Out of memory");
@@ -432,7 +432,7 @@ static void parse_include_points(const char * const include_opt,
              sem_seek++);
 
         hit_end = (*sem_seek == '\0');
-            
+
         *sem_seek = '\0';
         parse_include_point(cursor, include_pointsP);
 
@@ -735,15 +735,15 @@ static void determine_world_parallelogram (world_data *const world,
                                            const option *const options)
 /*----------------------------------------------------------------------------
   Construct xw_ul,...,zw_lr from xi_ul,...,yi_lr
-     
+
   This is a solution of a linear equation system.
-  
+
   We first solve 4 equations for 4 variables (the 4 z-coordinates):
   Each z-coordinate determines the corresponding x- and y-coordinates
   in a linear fashion, where the coefficients are taken from the image
   coordinates.  This corresponds to the fact that a point of an image
   determines a line in the world.
-  
+
   3 equations state that the 4 points form a parallelogram.  The 4th
   equation is for normalization and states that the center of the
   parallelogram has a z-coordinate of 1.
@@ -948,7 +948,7 @@ static number norm_side (number const x1, number const y1, number const z1,
   This is similar to norm_vector. But now the norm of the derivative
   is computed at both endpoints of the movement and the maximum is
   returned.
-  
+
   Why do we do this? The return value n is in fact the maximum of the
   norm of the derivative ALONG the movement. So we know that if we
   divide the movement into at least n steps, we will encounter every
@@ -1022,7 +1022,7 @@ static void determine_coefficients_lattice (world_data *const world,
                                             const option *const options)
 /*----------------------------------------------------------------------------
   Constructs ax,...,cz from xw_ul,...,zw_lr
-     
+
   The calculations assume lattice coordinates, that is the point ul
   corresponds to the upper left corner of the pixel (0,0) and the
   point lr corresponds to the lower left corner of the pixel
@@ -1052,7 +1052,7 @@ static void determine_coefficients_pixel (world_data *const world,
                                           const option *const options)
 /*----------------------------------------------------------------------------
   Constructs ax,...,cz from xw_ul,...,zw_lr
-     
+
   The calculations assume pixel coordinates, that is the point ul
   corresponds to the center of the pixel (0,0) and the point lr
   corresponds to the center of the pixel (width-1,height-1)
@@ -1086,7 +1086,7 @@ static void determine_coefficients_pixel (world_data *const world,
 
 static void
 outpixelToInPos(int                const outCol,
-                int                const outRow, 
+                int                const outRow,
                 number *           const inColP,
                 number *           const inRowP,
                 const world_data * const worldP) {
@@ -1149,7 +1149,7 @@ boundedRow(int                const unboundedRow,
    It doesn't work because the actual image generation produces rows
    in the middle that are derived from lines in the input quadrilateral
    with greater slope than either the top or bottom edge.  I.e. to
-   compute one output row, it needs more rows of input than this 
+   compute one output row, it needs more rows of input than this
    calculation provides.
 
    I don't know if that means the computation of the output is wrong
@@ -1162,7 +1162,7 @@ boundedRow(int                const unboundedRow,
 
    - Bryan Henderson 08.07.27.
 */
-   
+
 
 static unsigned int
 windowHeight(const world_data * const worldP,
@@ -1177,7 +1177,7 @@ windowHeight(const world_data * const worldP,
     yur = outpixelToInRow(outpamP->width-1, 0, worldP);
     yll = outpixelToInRow(0, outpamP->height-1, worldP);
     ylr = outpixelToInRow(outpamP->width-1, outpamP->height-1, worldP);
-    
+
     y_min = MIN(MIN(yul, yur), MIN(yll, ylr));
     numRows = MAX(MAX(diff(yul, yur),
                       diff(yll, ylr)),
@@ -1210,7 +1210,7 @@ windowHeight(const world_data * const worldP,
 
     unsigned int outRow;
     unsigned int maxRowWindowHeight;
-    
+
     maxRowWindowHeight = 1;  /* initial value */
 
     for (outRow = 0; outRow < outpamP->height; ++outRow) {
@@ -1220,12 +1220,12 @@ windowHeight(const world_data * const worldP,
             boundedRow(outpixelToInRow(leftCol, outRow, worldP), outpamP);
         unsigned int const rghtInRow =
             boundedRow(outpixelToInRow(rghtCol, outRow, worldP), outpamP);
-        
+
         unsigned int const rowWindowHeight = distance(leftInRow, rghtInRow);
 
         maxRowWindowHeight = MAX(maxRowWindowHeight, rowWindowHeight);
     }
-    
+
     /* We add 2 for rounding */
 
     return maxRowWindowHeight + 2;
@@ -1297,7 +1297,7 @@ buffer_getRow(buffer *     const bufferP,
     n = bufferP->nextImageRow - imageRow;
 
     assert(n <= bufferP->numRows);
-    
+
     if (n <= bufferP->nextBufferRow)
         bufferRow = bufferP->nextBufferRow - n;
     else
@@ -1328,7 +1328,7 @@ buffer_term(buffer * const bufferP) {
 
     for (i = 0; i < bufferP->numRows; ++i)
         pnm_freepamrow(bufferP->rows[i]);
-    
+
     free(bufferP->rows);
 }
 
@@ -1412,7 +1412,7 @@ takeNearest(tuple  const dest,
 
 
 static void
-linearInterpolation(tuple  const dest, 
+linearInterpolation(tuple  const dest,
                     number const x,
                     number const y) {
 
diff --git a/editor/pamrecolor.c b/editor/pamrecolor.c
index 86c1965c..60ed29a4 100644
--- a/editor/pamrecolor.c
+++ b/editor/pamrecolor.c
@@ -1,4 +1,3 @@
-
 /* ----------------------------------------------------------------------
  *
  * Replace every pixel in an image with one of equal luminance
diff --git a/editor/pamwipeout.c b/editor/pamwipeout.c
index 0fff3fca..5510c22e 100644
--- a/editor/pamwipeout.c
+++ b/editor/pamwipeout.c
@@ -34,12 +34,12 @@ struct cmdlineInfo {
 
 
 static void
-parseCommandLine(int                        argc, 
+parseCommandLine(int                        argc,
                  const char **              argv,
                  struct cmdlineInfo * const cmdlineP ) {
 /*----------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -59,9 +59,9 @@ parseCommandLine(int                        argc,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "lr",     OPT_FLAG,   NULL,                  
+    OPTENT3(0, "lr",     OPT_FLAG,   NULL,
             &lr,       0);
-    OPTENT3(0, "tb",     OPT_FLAG,   NULL,                  
+    OPTENT3(0, "tb",     OPT_FLAG,   NULL,
             &tb,       0);
 
     opt.opt_table = option_def;
@@ -75,7 +75,7 @@ parseCommandLine(int                        argc,
         pm_error("You must specify either -lr or -tb");
     else if (lr && tb)
         pm_error("You may not specify both -lr and -tb");
-    else 
+    else
         cmdlineP->direction = lr ? DIR_LR : DIR_TB;
 
 
@@ -93,8 +93,8 @@ parseCommandLine(int                        argc,
 
 
 
-static void 
-wipeImgByRow (struct pam const inpam, 
+static void
+wipeImgByRow (struct pam const inpam,
               tuple **   const tuples) {
 
     double const h = (double) inpam.height;
@@ -120,9 +120,9 @@ wipeImgByRow (struct pam const inpam,
 
 
 
-static void 
-wipeRowByCol(struct pam const inpam, 
-             tuple **   const tuples, 
+static void
+wipeRowByCol(struct pam const inpam,
+             tuple **   const tuples,
              tuple *    const tuplerow) {
 
     double const w = (double) inpam.width;
@@ -153,16 +153,16 @@ wipeoutTb(FILE * const ifP,
 
     struct pam inpam, outpam;
     tuple ** tuples;
-    
+
     tuples = pnm_readpam(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
-    outpam = inpam; 
+    outpam = inpam;
     outpam.file = ofP;
 
     wipeImgByRow(inpam, tuples);
 
     pnm_writepam(&outpam, tuples);
-       
+
     pnm_freepamarray(tuples, &inpam);
 }
 
@@ -171,7 +171,7 @@ wipeoutTb(FILE * const ifP,
 static void
 wipeoutLr(FILE * const ifP,
           FILE * const ofP) {
-    
+
     /* left-right we can read row-by-row */
 
     struct pam inpam, outpam;
diff --git a/editor/pgmdeshadow.c b/editor/pgmdeshadow.c
index 2c3a90f8..42f94254 100644
--- a/editor/pgmdeshadow.c
+++ b/editor/pgmdeshadow.c
@@ -117,7 +117,7 @@ initializeDeshadowMarker(gray **      const inputPixels,
 -----------------------------------------------------------------------------*/
     { /* Make middle white */
         unsigned int row;
-        
+
         for (row = 1; row < rows-1; ++row) {
             unsigned int col;
             for (col = 1; col < cols-1; ++col)
@@ -154,7 +154,7 @@ min5(gray const a,
      gray const c,
      gray const d,
      gray const e) {
-    
+
     return MIN(a,MIN(b,MIN(c,MIN(d,e))));
 }
 
@@ -229,16 +229,16 @@ estimateBackground(gray **      const inputPixels,
                     stable = FALSE;
                 } else
                     markerPixels[row][col] = inputPixels[row][col];
-            }       
+            }
         }
         /* scan in anti-raster order */
-        
+
         for (row = rows-2; row >= 0; --row) {
             int col;
             for (col = cols-2; col > 0; --col) {
                 gray const minpixel =
                     minSouthwestPixel(markerPixels, col, row);
-                
+
                 if (minpixel > inputPixels[row][col]) {
                     markerPixels[row][col] = minpixel;
                     stable = FALSE;
@@ -285,7 +285,7 @@ divide(gray **      const dividendPixels,
                     quotient =
                         MIN(maxval,
                             maxval * (dividend + dividend/2) / divisor);
-            }        
+            }
             dividendPixels[row][col] = quotient;
         }
     }
@@ -307,9 +307,9 @@ deshadow(gray **      const inputPixels,
     markerPixels = pgm_allocarray(cols, rows);
 
     initializeDeshadowMarker(inputPixels, markerPixels, cols, rows, maxval);
-    
+
     estimateBackground(inputPixels, markerPixels, cols, rows, maxval);
-    
+
     divide(inputPixels, markerPixels, cols, rows, maxval);
 
     pgm_freearray(markerPixels, rows);
@@ -331,12 +331,12 @@ main(int argc, char* argv[]) {
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFileName);
-    
+
     pixels = pgm_readpgm(ifP, &cols, &rows, &maxval);
     pm_close(ifP);
-    
+
     deshadow(pixels, cols, rows, maxval);
-    
+
     pgm_writepgm(stdout, pixels, cols, rows, maxval, 0);
 
     pgm_freearray(pixels, rows);
diff --git a/editor/pgmenhance.c b/editor/pgmenhance.c
index 83670568..23cfbb9e 100644
--- a/editor/pgmenhance.c
+++ b/editor/pgmenhance.c
@@ -77,7 +77,7 @@ main(int argc, char * argv[] ) {
         thisrow = nextrow;
         nextrow = temprow;
         pgm_readpgmrow( ifp, nextrow, cols, maxval, format );
-        
+
         newrow[0] = thisrow[0];
         for (col = 1; col < cols - 1; col++) {
             /* Compute the sum of the neighborhood. */
@@ -102,7 +102,7 @@ main(int argc, char * argv[] ) {
         pgm_writepgmrow( stdout, newrow, cols, maxval, 0 );
     }
     pm_close( ifp );
-    
+
     /* Last row. */
     pgm_writepgmrow( stdout, nextrow, cols, maxval, 0 );
 
diff --git a/editor/pgmmedian.c b/editor/pgmmedian.c
index 9cebeac8..60605713 100644
--- a/editor/pgmmedian.c
+++ b/editor/pgmmedian.c
@@ -55,7 +55,7 @@ static int const forceplain = 0;
 /* Global variables common to each median sort routine. */
 static gray ** grays;
     /* The convolution buffer.  This is a circular buffer that contains the
-       rows of the input image that are being convolved into the current 
+       rows of the input image that are being convolved into the current
        output row.
     */
 static gray * grayrow;
diff --git a/editor/pnmalias.c b/editor/pnmalias.c
index 36b41ce4..51a71312 100644
--- a/editor/pnmalias.c
+++ b/editor/pnmalias.c
@@ -43,23 +43,23 @@ main(int argc, char * argv[] ) {
 
     while ( argn < argc && argv[argn][0] == '-' )
         {
-        if ( pm_keymatch( argv[argn], "-fgcolor", 3 ) ) 
+        if ( pm_keymatch( argv[argn], "-fgcolor", 3 ) )
         {
-        if ( ++argn >= argc ) 
+        if ( ++argn >= argc )
         pm_usage( usage );
-        else 
+        else
         fgcolorppm = ppm_parsecolor( argv[argn], PPM_MAXMAXVAL );
         }
-        else if ( pm_keymatch( argv[argn], "-bgcolor", 3 ) ) 
+        else if ( pm_keymatch( argv[argn], "-bgcolor", 3 ) )
         {
-        if ( ++argn >= argc ) 
+        if ( ++argn >= argc )
         pm_usage( usage );
-        else 
+        else
         bgcolorppm = ppm_parsecolor( argv[argn], PPM_MAXMAXVAL );
         }
-        else if ( pm_keymatch( argv[argn], "-weight", 2 ) ) 
+        else if ( pm_keymatch( argv[argn], "-weight", 2 ) )
         {
-        if ( ++argn >= argc ) 
+        if ( ++argn >= argc )
         pm_usage( usage );
         else if ( sscanf( argv[argn], "%lf", &weight ) != 1 )
             pm_usage( usage );
@@ -103,7 +103,7 @@ main(int argc, char * argv[] ) {
     fmask[5] = fmask[6] = fmask[7] = fmask[8] = ( 1.0 - weight ) / 8.0;
 
     pnm_readpnminit( ifp, &cols, &rows, &maxval, &format );
-   
+
     xelrow[0] = pnm_allocrow( cols );
     xelrow[1] = pnm_allocrow( cols );
     xelrow[2] = pnm_allocrow( cols );
@@ -120,29 +120,29 @@ main(int argc, char * argv[] ) {
     }
 
     /* Figure out foreground pixel value if none was given */
-    if (PPM_GETR(fgcolorppm) == 0 && PPM_GETG(fgcolorppm) == 0 && 
+    if (PPM_GETR(fgcolorppm) == 0 && PPM_GETG(fgcolorppm) == 0 &&
         PPM_GETB(fgcolorppm) == 0 ) {
         if ( PNM_FORMAT_TYPE(newformat) == PGM_TYPE )
             PNM_ASSIGN1( fgcolor, newmaxval );
-        else 
+        else
             PPM_ASSIGN( fgcolor, newmaxval, newmaxval, newmaxval );
     } else {
         if ( PNM_FORMAT_TYPE(newformat) == PGM_TYPE )
             PNM_ASSIGN1( fgcolor, PPM_GETR( fgcolorppm ) );
-        else 
+        else
             fgcolor = fgcolorppm;
     }
 
-    if (PPM_GETR(bgcolorppm) != 0 || PPM_GETG(bgcolorppm) != 0 || 
+    if (PPM_GETR(bgcolorppm) != 0 || PPM_GETG(bgcolorppm) != 0 ||
         PPM_GETB(bgcolorppm) != 0 ) {
         if ( PNM_FORMAT_TYPE(newformat) == PGM_TYPE )
             PNM_ASSIGN1( bgcolor, PPM_GETR( bgcolorppm) );
-        else 
+        else
             bgcolor = bgcolorppm;
     } else {
         if ( PNM_FORMAT_TYPE(newformat) == PGM_TYPE )
             PNM_ASSIGN1( bgcolor, 0 );
-        else 
+        else
             PPM_ASSIGN( bgcolor, 0, 0, 0 );
     }
 
@@ -158,9 +158,9 @@ main(int argc, char * argv[] ) {
 
         pnm_readpnmrow( ifp, xelrow[(row+1)%3], cols, newmaxval, format );
         newxelrow[0] = xelrow[row%3][0];
-        
+
         for ( col = 1, xpP = (xelrow[(row-1)%3] + 1), xP = (xelrow[row%3] + 1),
-                  xnP = (xelrow[(row+1)%3] + 1), nxP = (newxelrow+1); 
+                  xnP = (xelrow[(row+1)%3] + 1), nxP = (newxelrow+1);
               col < cols - 1; ++col, ++xpP, ++xP, ++xnP, ++nxP ) {
 
             int fgflag, bgflag;
@@ -168,28 +168,28 @@ main(int argc, char * argv[] ) {
             /* Reset flags if anti-aliasing is to be done on foreground
              * or background pixels only */
             if ( ( bgonly && PNM_EQUAL( *xP, fgcolor ) ) ||
-                 ( fgonly && PNM_EQUAL( *xP, bgcolor ) ) ) 
+                 ( fgonly && PNM_EQUAL( *xP, bgcolor ) ) )
                 bgflag = fgflag = 0;
             else {
                 /* Do anti-aliasing here: see if pixel is at the border of a
                  * background or foreground stepwise side */
-                bgflag = 
+                bgflag =
                     (PNM_EQUAL(*xpP,bgcolor) && PNM_EQUAL(*(xP+1),bgcolor)) ||
                     (PNM_EQUAL(*(xP+1),bgcolor) && PNM_EQUAL(*xnP,bgcolor)) ||
                     (PNM_EQUAL(*xnP,bgcolor) && PNM_EQUAL(*(xP-1),bgcolor)) ||
                     (PNM_EQUAL(*(xP-1),bgcolor) && PNM_EQUAL(*xpP,bgcolor));
-                fgflag = 
+                fgflag =
                     (PNM_EQUAL(*xpP,fgcolor) && PNM_EQUAL(*(xP+1),fgcolor)) ||
                     (PNM_EQUAL(*(xP+1),fgcolor) && PNM_EQUAL(*xnP,fgcolor)) ||
                     (PNM_EQUAL(*xnP,fgcolor) && PNM_EQUAL(*(xP-1),fgcolor)) ||
-                    (PNM_EQUAL(*(xP-1),fgcolor) && PNM_EQUAL(*xpP,fgcolor)); 
+                    (PNM_EQUAL(*(xP-1),fgcolor) && PNM_EQUAL(*xpP,fgcolor));
             }
-            if ( ( bgflag && bgalias ) || ( fgflag && fgalias ) || 
+            if ( ( bgflag && bgalias ) || ( fgflag && fgalias ) ||
                  ( bgflag && fgflag ) )
-                switch( PNM_FORMAT_TYPE( newformat ) ) {   
+                switch( PNM_FORMAT_TYPE( newformat ) ) {
                 case PGM_TYPE:
                     value = PNM_GET1(*(xpP-1)) * fmask[0] +
-                        PNM_GET1(*(xpP  )) * fmask[1] + 
+                        PNM_GET1(*(xpP  )) * fmask[1] +
                         PNM_GET1(*(xpP+1)) * fmask[2] +
                         PNM_GET1(*(xP -1)) * fmask[3] +
                         PNM_GET1(*(xP   )) * fmask[4] +
@@ -202,7 +202,7 @@ main(int argc, char * argv[] ) {
                     break;
                 default:
                     valuer= PPM_GETR(*(xpP-1)) * fmask[0] +
-                        PPM_GETR(*(xpP  )) * fmask[1] + 
+                        PPM_GETR(*(xpP  )) * fmask[1] +
                         PPM_GETR(*(xpP+1)) * fmask[2] +
                         PPM_GETR(*(xP -1)) * fmask[3] +
                         PPM_GETR(*(xP   )) * fmask[4] +
@@ -212,7 +212,7 @@ main(int argc, char * argv[] ) {
                         PPM_GETR(*(xnP+1)) * fmask[8] +
                         0.5;
                     valueg= PPM_GETG(*(xpP-1)) * fmask[0] +
-                        PPM_GETG(*(xpP  )) * fmask[1] + 
+                        PPM_GETG(*(xpP  )) * fmask[1] +
                         PPM_GETG(*(xpP+1)) * fmask[2] +
                         PPM_GETG(*(xP -1)) * fmask[3] +
                         PPM_GETG(*(xP   )) * fmask[4] +
@@ -222,7 +222,7 @@ main(int argc, char * argv[] ) {
                         PPM_GETG(*(xnP+1)) * fmask[8] +
                         0.5;
                     valueb= PPM_GETB(*(xpP-1)) * fmask[0] +
-                        PPM_GETB(*(xpP  )) * fmask[1] + 
+                        PPM_GETB(*(xpP  )) * fmask[1] +
                         PPM_GETB(*(xpP+1)) * fmask[2] +
                         PPM_GETB(*(xP -1)) * fmask[3] +
                         PPM_GETB(*(xP   )) * fmask[4] +
@@ -241,9 +241,9 @@ main(int argc, char * argv[] ) {
         newxelrow[cols-1] = xelrow[row%3][cols-1];
         pnm_writepnmrow( stdout, newxelrow, cols, newmaxval, newformat, 0 );
     }
-        
+
     pnm_writepnmrow( stdout, xelrow[row%3], cols, newmaxval, newformat, 0 );
-    
+
     pm_close( ifp );
     exit ( 0 );
 }
diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c
index e10e138b..9b8dcdac 100644
--- a/editor/pnmgamma.c
+++ b/editor/pnmgamma.c
@@ -80,13 +80,13 @@ interpretOldArguments(int                  const argc,
         cmdlineP->ggamma = atof(argv[2]);
         cmdlineP->bgamma = atof(argv[3]);
         cmdlineP->filespec = argv[4];
-    } else 
+    } else
         pm_error("Wrong number of arguments.  "
                  "You may have 0, 1, or 3 gamma values "
                  "plus zero or one filename");
-        
-    if (cmdlineP->rgamma <= 0.0 || 
-        cmdlineP->ggamma <= 0.0 || 
+
+    if (cmdlineP->rgamma <= 0.0 ||
+        cmdlineP->ggamma <= 0.0 ||
         cmdlineP->bgamma <= 0.0 )
         pm_error("Invalid gamma value.  Must be positive floating point "
                  "number.");
@@ -106,7 +106,7 @@ getGammaFromOpts(struct cmdlineInfo * const cmdlineP,
     if (gammaSpec)
         if (gammaOpt < 0.0)
             pm_error("Invalid gamma value %f.  Must be positive.", gammaOpt);
-    
+
     if (rgammaSpec) {
         if (cmdlineP->rgamma < 0.0)
             pm_error("Invalid red gamma value %f.  Must be positive.",
@@ -114,17 +114,17 @@ getGammaFromOpts(struct cmdlineInfo * const cmdlineP,
     } else {
         if (gammaSpec)
             cmdlineP->rgamma = gammaOpt;
-        else 
+        else
             cmdlineP->rgamma = defaultGamma;
     }
     if (ggammaSpec) {
-        if (cmdlineP->ggamma < 0.0) 
+        if (cmdlineP->ggamma < 0.0)
             pm_error("Invalid green gamma value %f.  Must be positive.",
                      cmdlineP->ggamma);
     } else {
         if (gammaSpec)
             cmdlineP->ggamma = gammaOpt;
-        else 
+        else
             cmdlineP->ggamma = defaultGamma;
     }
     if (bgammaSpec) {
@@ -142,7 +142,7 @@ getGammaFromOpts(struct cmdlineInfo * const cmdlineP,
 
 
 static void
-parseCommandLine(int argc, char ** argv, 
+parseCommandLine(int argc, char ** argv,
                  struct cmdlineInfo * const cmdlineP) {
 
     optEntry *option_def;
@@ -189,7 +189,7 @@ parseCommandLine(int argc, char ** argv,
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
-    opt.allowNegNum = TRUE; 
+    opt.allowNegNum = TRUE;
 
     pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdline_p and others. */
@@ -295,7 +295,7 @@ buildPowGamma(xelval       table[],
               double const gamma) {
 /*----------------------------------------------------------------------------
    Build a gamma table of size maxval+1 for the given gamma value.
-  
+
    This function depends on pow(3m).  If you don't have it, you can
    simulate it with '#define pow(x,y) exp((y)*log(x))' provided that
    you have the exponential function exp(3m) and the natural logarithm
@@ -310,7 +310,7 @@ buildPowGamma(xelval       table[],
             /* Xel sample value normalized to 0..1 */
         double const v = pow(normalized, oneOverGamma);
 
-        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);  
+        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);
             /* denormalize, round and clip */
     }
 }
@@ -337,17 +337,17 @@ buildBt709Gamma(xelval       table[],
        unlike the popular pure exponential gamma transfer function.
     */
     xelval const linearCutoff = (xelval) (maxval * 0.018 + 0.5);
-    double const linearExpansion = 
+    double const linearExpansion =
         (1.099 * pow(0.018, oneOverGamma) - 0.099) / 0.018;
     double const maxvalScaler = (double)newMaxval/maxval;
 
-    for (i = 0; i <= linearCutoff; ++i) 
+    for (i = 0; i <= linearCutoff; ++i)
         table[i] = i * linearExpansion * maxvalScaler + 0.5;
     for (; i <= maxval; ++i) {
         double const normalized = ((double) i) / maxval;
             /* Xel sample value normalized to 0..1 */
         double const v = 1.099 * pow(normalized, oneOverGamma) - 0.099;
-        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);  
+        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);
             /* denormalize, round, and clip */
     }
 }
@@ -375,18 +375,18 @@ buildBt709GammaInverse(xelval       table[],
     */
 
     xelval const linearCutoff = (xelval) (maxval * 0.018 + 0.5);
-    double const linearCompression = 
+    double const linearCompression =
         0.018 / (1.099 * pow(0.018, oneOverGamma) - 0.099);
     double const maxvalScaler = (double)newMaxval/maxval;
 
-    for (i = 0; i <= linearCutoff / linearCompression; ++i) 
+    for (i = 0; i <= linearCutoff / linearCompression; ++i)
         table[i] = i * linearCompression * maxvalScaler + 0.5;
 
     for (; i <= maxval; ++i) {
         double const normalized = ((double) i) / maxval;
             /* Xel sample value normalized to 0..1 */
         double const v = pow((normalized + 0.099) / 1.099, gamma);
-        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);  
+        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);
             /* denormalize, round, and clip */
     }
 }
@@ -413,17 +413,17 @@ buildSrgbGamma(xelval       table[],
        unlike the popular pure exponential gamma transfer function.
     */
     xelval const linearCutoff = (xelval) maxval * 0.0031308 + 0.5;
-    double const linearExpansion = 
+    double const linearExpansion =
         (1.055 * pow(0.0031308, oneOverGamma) - 0.055) / 0.0031308;
     double const maxvalScaler = (double)newMaxval/maxval;
 
-    for (i = 0; i <= linearCutoff; ++i) 
+    for (i = 0; i <= linearCutoff; ++i)
         table[i] = i * linearExpansion * maxvalScaler + 0.5;
     for (; i <= maxval; ++i) {
         double const normalized = ((double) i) / maxval;
             /* Xel sample value normalized to 0..1 */
         double const v = 1.055 * pow(normalized, oneOverGamma) - 0.055;
-        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);  
+        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);
             /* denormalize, round, and clip */
     }
 }
@@ -450,17 +450,17 @@ buildSrgbGammaInverse(xelval       table[],
        unlike the popular pure exponential gamma transfer function.
     */
     xelval const linearCutoff = (xelval) maxval * 0.0031308 + 0.5;
-    double const linearCompression = 
+    double const linearCompression =
         0.0031308 / (1.055 * pow(0.0031308, oneOverGamma) - 0.055);
     double const maxvalScaler = (double)newMaxval/maxval;
 
-    for (i = 0; i <= linearCutoff / linearCompression; ++i) 
+    for (i = 0; i <= linearCutoff / linearCompression; ++i)
         table[i] = i * linearCompression * maxvalScaler + 0.5;
     for (; i <= maxval; ++i) {
         double const normalized = ((double) i) / maxval;
             /* Xel sample value normalized to 0..1 */
         double const v = pow((normalized + 0.055) / 1.055, gamma);
-        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);  
+        table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval);
             /* denormalize, round, and clip */
     }
 }
@@ -491,11 +491,11 @@ buildBt709ToSrgbGamma(xelval       table[],
     */
 
     xelval const linearCutoff709 = (xelval) (maxval * 0.018 + 0.5);
-    double const linearCompression709 = 
+    double const linearCompression709 =
         0.018 / (1.099 * pow(0.018, oneOverGamma709) - 0.099);
 
     double const linearCutoffSrgb = 0.0031308;
-    double const linearExpansionSrgb = 
+    double const linearExpansionSrgb =
         (1.055 * pow(0.0031308, oneOverGammaSrgb) - 0.055) / 0.0031308;
 
     xelval i;
@@ -549,11 +549,11 @@ buildSrgbToBt709Gamma(xelval       table[],
        unlike the popular pure exponential gamma transfer function.
     */
     xelval const linearCutoffSrgb = (xelval) maxval * 0.0031308 + 0.5;
-    double const linearCompressionSrgb = 
+    double const linearCompressionSrgb =
         0.0031308 / (1.055 * pow(0.0031308, oneOverGammaSrgb) - 0.055);
 
     xelval const linearCutoff709 = (xelval) (maxval * 0.018 + 0.5);
-    double const linearExpansion709 = 
+    double const linearExpansion709 =
         (1.099 * pow(0.018, oneOverGamma709) - 0.099) / 0.018;
 
     xelval i;
@@ -588,8 +588,8 @@ static void
 createGammaTables(enum transferFunction const transferFunction,
                   xelval                const maxval,
                   xelval                const newMaxval,
-                  double                const rgamma, 
-                  double                const ggamma, 
+                  double                const rgamma,
+                  double                const ggamma,
                   double                const bgamma,
                   xelval **             const rtableP,
                   xelval **             const gtableP,
@@ -677,7 +677,7 @@ convertRaster(FILE *   const ifP,
     for (row = 0; row < rows; ++row) {
         pnm_readpnmrow(ifP, xelrow, cols, maxval, format);
 
-        pnm_promoteformatrow(xelrow, cols, maxval, format, 
+        pnm_promoteformatrow(xelrow, cols, maxval, format,
                              maxval, outputFormat);
 
         switch (PNM_FORMAT_TYPE(outputFormat)) {
@@ -730,10 +730,10 @@ main(int argc, char *argv[]) {
 
     if (PNM_FORMAT_TYPE(format) == PPM_TYPE)
         outputFormat = PPM_TYPE;
-    else if (cmdline.rgamma != cmdline.ggamma 
-             || cmdline.ggamma != cmdline.bgamma) 
+    else if (cmdline.rgamma != cmdline.ggamma
+             || cmdline.ggamma != cmdline.bgamma)
         outputFormat = PPM_TYPE;
-    else 
+    else
         outputFormat = PGM_TYPE;
 
     if (PNM_FORMAT_TYPE(format) != outputFormat) {
diff --git a/editor/pnminvert.c b/editor/pnminvert.c
index d4aad503..208b8bfa 100644
--- a/editor/pnminvert.c
+++ b/editor/pnminvert.c
@@ -38,18 +38,18 @@ invertPbm(FILE * const ifP,
 -----------------------------------------------------------------------------*/
     int const colChars = pbm_packed_bytes(cols);
 
-    unsigned char * bitrow; 
+    unsigned char * bitrow;
     unsigned int row;
-    
+
     bitrow = pbm_allocrow_packed(cols);
-    
+
     for (row = 0; row < rows; ++row) {
         unsigned int colChar;
-        
+
         pbm_readpbmrow_packed(ifP, bitrow, cols, format);
         for (colChar = 0; colChar < colChars; ++colChar)
             bitrow[colChar] = ~ bitrow[colChar];
-        
+
         /* Clean off remainder of fractional last character and write */
         pbm_cleanrowend_packed(bitrow, cols);
         pbm_writepbmrow_packed(ofP, bitrow, cols, 0);
@@ -69,15 +69,15 @@ invertPnm(FILE * const ifP,
 
     xel * xelrow;
     unsigned int row;
-    
+
     xelrow = pnm_allocrow(cols);
-    
+
     for (row = 0; row < rows; ++row) {
         unsigned int col;
         pnm_readpnmrow(ifP, xelrow, cols, maxval, format);
         for (col = 0; col < cols; ++col)
             pnm_invertxel(&xelrow[col], maxval, format);
-        
+
         pnm_writepnmrow(ofP, xelrow, cols, maxval, format, 0);
     }
     pnm_freerow(xelrow);
@@ -103,7 +103,7 @@ main(int argc, char * argv[]) {
 
     pnm_readpnminit(ifP, &cols, &rows, &maxval, &format);
     pnm_writepnminit(stdout, cols, rows, maxval, format, 0);
-    
+
     if (PNM_FORMAT_TYPE(format) == PBM_TYPE)
         /* Take fast path */
         invertPbm(ifP, stdout, cols, rows, format);
@@ -113,7 +113,7 @@ main(int argc, char * argv[]) {
 
     pm_close(ifP);
     pm_close(stdout);
-    
+
     return 0;
 }
 
diff --git a/editor/pnmmontage.c b/editor/pnmmontage.c
index 7bd00dbe..c6f03ead 100644
--- a/editor/pnmmontage.c
+++ b/editor/pnmmontage.c
@@ -42,7 +42,7 @@ parseCommandLine(int argc, const char ** argv,
                  struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -59,7 +59,7 @@ parseCommandLine(int argc, const char ** argv,
     unsigned int q[10];
 
     MALLOCARRAY_NOFAIL(option_def, 100);
-  
+
     option_def_index = 0;   /* incremented by OPTENTRY */
     OPTENT3( 0,  "data",    OPT_STRING, &cmdlineP->data, &dataSpec, 0);
     OPTENT3( 0,  "header",  OPT_STRING, &cmdlineP->header, &headerSpec, 0);
@@ -93,7 +93,7 @@ parseCommandLine(int argc, const char ** argv,
     if (!qualitySpec)
         cmdlineP->quality = 200;
 
-    
+
     /* cmdlineP->quality2 is the greatest number from the --1, --2, etc.
        options, or 5 if none of those are specified.
     */
@@ -150,7 +150,7 @@ lr(Rectangle const r) {
 
 
 
-static Factorset 
+static Factorset
 factor(unsigned int const arg) {
 /*----------------------------------------------------------------------------
    The prime factors of 'arg'.
@@ -177,7 +177,7 @@ factor(unsigned int const arg) {
 
 
 
-static int 
+static int
 gcf(unsigned int const n,
     unsigned int const m) {
 /*----------------------------------------------------------------------------
@@ -236,12 +236,12 @@ collides(Rectangle         const test,
 
 
 
-static void 
+static void
 recursefindpack(Rectangle *    const current,
                 Coord          const currentsz,
                 Coord *        const best,
                 unsigned int   const minarea,
-                unsigned int * const maxareaP, 
+                unsigned int * const maxareaP,
                 unsigned int   const depth,
                 unsigned int   const n,
                 unsigned int   const xinc,
@@ -295,7 +295,7 @@ recursefindpack(Rectangle *    const current,
 
 
 
-static void 
+static void
 findpack(struct pam * const imgs,
          unsigned int const imgCt,
          Coord **     const coordsP,
@@ -312,7 +312,7 @@ findpack(struct pam * const imgs,
     Coord c;
 
     MALLOCARRAY(coords, imgCt);
-  
+
     if (!coords)
         pm_error("Out of memory allocating %u-element coords array", imgCt);
 
@@ -356,12 +356,12 @@ findpack(struct pam * const imgs,
 
 
 
-static void 
+static void
 adjustDepth(tuple *            const tuplerow,
             const struct pam * const inpamP,
             const struct pam * const outpamP,
             Coord              const coord) {
-    
+
     if (inpamP->depth < outpamP->depth) {
         unsigned int i;
         for (i = coord.x; i < coord.x + inpamP->width; ++i) {
@@ -374,7 +374,7 @@ adjustDepth(tuple *            const tuplerow,
 
 
 
-static void 
+static void
 adjustMaxval(tuple *            const tuplerow,
              const struct pam * const inpamP,
              const struct pam * const outpamP,
@@ -420,14 +420,14 @@ writePam(struct pam *       const outpamP,
 -----------------------------------------------------------------------------*/
     tuple * tuplerow;
     unsigned int row;  /* Row number in the output image */
-  
+
     pnm_writepaminit(outpamP);
 
     tuplerow = pnm_allocpamrow(outpamP);
 
     for (row = 0; row < outpamP->height; ++row) {
         unsigned int imgIdx;
-        
+
         makeRowBlack(outpamP, tuplerow);  /* initial value */
 
         for (imgIdx = 0; imgIdx < imgCt; ++imgIdx) {
@@ -494,13 +494,13 @@ writeHeader(FILE * const headerFileP,
         struct pam const img = imgs[i];
 
         unsigned int j;
-        
+
         *strchr(buffer, '.') = 0;
         for (j = 0; buffer[j]; ++j) {
             if (ISLOWER(buffer[j]))
                 buffer[j] = TOUPPER(buffer[j]);
         }
-        fprintf(headerFileP, "#define %s%sX %u\n", 
+        fprintf(headerFileP, "#define %s%sX %u\n",
                 prefix, buffer, coord.x);
 
         fprintf(headerFileP, "#define %s%sY %u\n",
@@ -538,7 +538,7 @@ sortImagesByArea(unsigned int  const nfiles,
 
                 struct pam p;
                 const char * c;
-                
+
                 p = imgs[i]; imgs[i] = imgs[j]; imgs[j] = p;
                 c = names[i]; names[i] = names[j]; names[j] = c;
             }
@@ -600,7 +600,7 @@ computeOutputDimensions(int *              const widthP,
 
     widthGuess  = 0;  /* initial value */
     heightGuess = 0;  /* initial value */
-    
+
     for (i = 0; i < nfiles; ++i) {
         widthGuess  = MAX(widthGuess,  imgs[i].width  + coords[i].x);
         heightGuess = MAX(heightGuess, imgs[i].height + coords[i].y);
@@ -622,8 +622,8 @@ qfactorFromQuality(unsigned int const quality,
     case 0: case 1:
         qfactor = quality;
         break;
-    case 2: case 3: case 4: case 5: case 6: 
-        qfactor = 100 * (8 - quality2); 
+    case 2: case 3: case 4: case 5: case 6:
+        qfactor = 100 * (8 - quality2);
         break;
     case 7: qfactor = 150; break;
     case 8: qfactor = 125; break;
@@ -709,7 +709,7 @@ closeFiles(const struct pam * const imgPam,
 
 
 
-int 
+int
 main(int argc, const char **argv) {
 
     struct CmdlineInfo cmdline;
@@ -749,7 +749,7 @@ main(int argc, const char **argv) {
     pnm_setminallocationdepth(&outimg, outimg.depth);
     outimg.plainformat = false;
     outimg.file = stdout;
- 
+
     writePam(&outimg, fileCt, coords, imgPam);
 
     if (dataFileP)
diff --git a/editor/pnmnlfilt.c b/editor/pnmnlfilt.c
index bcb3680d..906ce460 100644
--- a/editor/pnmnlfilt.c
+++ b/editor/pnmnlfilt.c
@@ -990,7 +990,7 @@ main(int argc, char *argv[]) {
 
     FILE * ifP;
     struct cmdlineInfo cmdline;
-	int eof;  /* We've hit the end of the input stream */
+        int eof;  /* We've hit the end of the input stream */
     unsigned int imageSeq;  /* Sequence number of image, starting from 0 */
 
     pnm_init(&argc, argv);
diff --git a/editor/pnmrotate.c b/editor/pnmrotate.c
index 44952a59..b034d395 100644
--- a/editor/pnmrotate.c
+++ b/editor/pnmrotate.c
@@ -40,7 +40,7 @@ struct cmdlineInfo {
 enum rotationDirection {CLOCKWISE, COUNTERCLOCKWISE};
 
 struct shearParm {
-    /* These numbers tell how to shear a pixel, but I haven't figured out 
+    /* These numbers tell how to shear a pixel, but I haven't figured out
        yet exactly what each means.
     */
     long fracnew0;
@@ -67,13 +67,13 @@ parseCommandLine(int argc, char ** const argv,
     unsigned int option_def_index;
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0, "background",  OPT_STRING, &cmdlineP->background, 
+    OPTENT3(0, "background",  OPT_STRING, &cmdlineP->background,
             &backgroundSpec,        0);
-    OPTENT3(0, "noantialias", OPT_FLAG,   NULL, 
+    OPTENT3(0, "noantialias", OPT_FLAG,   NULL,
             &cmdlineP->noantialias, 0);
-    OPTENT3(0, "keeptemp",    OPT_FLAG,   NULL, 
+    OPTENT3(0, "keeptemp",    OPT_FLAG,   NULL,
             &cmdlineP->keeptemp,    0);
-    OPTENT3(0, "verbose",     OPT_FLAG,   NULL, 
+    OPTENT3(0, "verbose",     OPT_FLAG,   NULL,
             &cmdlineP->verbose,     0);
 
     opt.opt_table = option_def;
@@ -110,7 +110,7 @@ parseCommandLine(int argc, char ** const argv,
                 cmdlineP->inputFilespec = "-";
             else {
                 cmdlineP->inputFilespec = argv[2];
-                
+
                 if (argc-1 > 2)
                     pm_error("Program takes at most two arguments "
                              "(angle and filename).  You specified %d",
@@ -139,10 +139,10 @@ storeImage(const char * const fileName,
     pm_close(ofP);
 }
 
-  
+
 
 static void
-computeNewFormat(bool     const antialias, 
+computeNewFormat(bool     const antialias,
                  int      const format,
                  xelval   const maxval,
                  int *    const newformatP,
@@ -172,7 +172,7 @@ backgroundColor(const char * const backgroundColorName,
 
     if (backgroundColorName) {
         retval = pnm_parsecolorxel(backgroundColorName, maxval, format);
-    } else 
+    } else
         retval = pnm_backgroundxelrow(topRow, cols, maxval, format);
 
     return retval;
@@ -190,9 +190,9 @@ reportBackground(xel const bgColor) {
 
 
 static void
-shearX(xel * const inRow, 
-       xel * const outRow, 
-       int   const cols, 
+shearX(xel * const inRow,
+       xel * const outRow,
+       int   const cols,
        int   const format,
        xel   const bgxel,
        bool  const antialias,
@@ -210,9 +210,9 @@ shearX(xel * const inRow,
    We shift the row on a background of color 'bgxel'.
 
    The output row has the same format and maxval as the input.
-   
+
    'shiftAmount' may not be negative.
-   
+
    'shiftAmount' can be fractional, so we either just go by the
    nearest integer value or mix pixels to achieve the shift, depending
    on 'antialias'.
@@ -230,7 +230,7 @@ shearX(xel * const inRow,
 
         for (col = 0; col < newcols; ++col)
             outRow[col] = bgxel;
-            
+
         prevxel = bgxel;
         for (col = 0, nxP = &(outRow[shiftWhole]);
              col < cols; ++col, ++nxP) {
@@ -240,21 +240,21 @@ shearX(xel * const inRow,
             switch (PNM_FORMAT_TYPE(format)) {
             case PPM_TYPE:
                 PPM_ASSIGN(*nxP,
-                           (fracShift * PPM_GETR(prevxel) 
-                            + omfracShift * PPM_GETR(p) 
+                           (fracShift * PPM_GETR(prevxel)
+                            + omfracShift * PPM_GETR(p)
                             + HALFSCALE) / SCALE,
-                           (fracShift * PPM_GETG(prevxel) 
-                            + omfracShift * PPM_GETG(p) 
+                           (fracShift * PPM_GETG(prevxel)
+                            + omfracShift * PPM_GETG(p)
                             + HALFSCALE) / SCALE,
-                           (fracShift * PPM_GETB(prevxel) 
-                            + omfracShift * PPM_GETB(p) 
+                           (fracShift * PPM_GETB(prevxel)
+                            + omfracShift * PPM_GETB(p)
                             + HALFSCALE) / SCALE );
                 break;
-                
+
             default:
                 PNM_ASSIGN1(*nxP,
-                            (fracShift * PNM_GET1(prevxel) 
-                             + omfracShift * PNM_GET1(p) 
+                            (fracShift * PNM_GET1(prevxel)
+                             + omfracShift * PNM_GET1(p)
                              + HALFSCALE) / SCALE );
                 break;
             }
@@ -264,21 +264,21 @@ shearX(xel * const inRow,
             switch (PNM_FORMAT_TYPE(format)) {
             case PPM_TYPE:
                 PPM_ASSIGN(*nxP,
-                           (fracShift * PPM_GETR(prevxel) 
-                            + omfracShift * PPM_GETR(bgxel) 
+                           (fracShift * PPM_GETR(prevxel)
+                            + omfracShift * PPM_GETR(bgxel)
                             + HALFSCALE) / SCALE,
-                           (fracShift * PPM_GETG(prevxel) 
-                            + omfracShift * PPM_GETG(bgxel) 
+                           (fracShift * PPM_GETG(prevxel)
+                            + omfracShift * PPM_GETG(bgxel)
                             + HALFSCALE) / SCALE,
-                           (fracShift * PPM_GETB(prevxel) 
-                            + omfracShift * PPM_GETB(bgxel) 
+                           (fracShift * PPM_GETB(prevxel)
+                            + omfracShift * PPM_GETB(bgxel)
                             + HALFSCALE) / SCALE );
                 break;
-                    
+
             default:
                 PNM_ASSIGN1(*nxP,
-                            (fracShift * PNM_GET1(prevxel) 
-                             + omfracShift * PNM_GET1(bgxel) 
+                            (fracShift * PNM_GET1(prevxel)
+                             + omfracShift * PNM_GET1(bgxel)
                              + HALFSCALE) / SCALE );
                 break;
             }
@@ -289,14 +289,14 @@ shearX(xel * const inRow,
         unsigned int outcol;
 
         outcol = 0;  /* initial value */
-        
+
         for (col = 0; col < shiftCols; ++col)
             outRow[outcol++] = bgxel;
         for (col = 0; col < cols; ++col)
             outRow[outcol++] = inRow[col];
         for (col = shiftCols + cols; col < newcols; ++col)
             outRow[outcol++] = bgxel;
-        
+
         assert(outcol == newcols);
     }
 }
@@ -332,7 +332,7 @@ shearXFromInputFile(FILE *                 const ifP,
 -----------------------------------------------------------------------------*/
     unsigned int const maxShear = (rows - 0.5) * xshearfac + 0.5;
     unsigned int const newcols = cols + maxShear;
-    
+
     xel ** shearedXels;
     xel * xelrow;
     xel bgColor;
@@ -348,13 +348,13 @@ shearXFromInputFile(FILE *                 const ifP,
            the right pixel.  We use the distance of the center of this
            pixel from the relevant edge to compute shift amount:
         */
-        float const xDistance = 
+        float const xDistance =
             (direction == COUNTERCLOCKWISE ? row + 0.5 : (rows-0.5 - row));
         float const shiftAmount = xshearfac * xDistance;
 
         pnm_readpnmrow(ifP, xelrow, cols, maxval, format);
 
-        pnm_promoteformatrow(xelrow, cols, maxval, format, 
+        pnm_promoteformatrow(xelrow, cols, maxval, format,
                              newmaxval, newformat);
 
         if (row == 0)
@@ -375,7 +375,7 @@ shearXFromInputFile(FILE *                 const ifP,
 
 
 
-static void 
+static void
 shearYNoAntialias(xel **           const inxels,
                   xel **           const outxels,
                   int              const cols,
@@ -421,7 +421,7 @@ shearYNoAntialias(xel **           const inxels,
 
 
 static void
-shearYColAntialias(xel ** const inxels, 
+shearYColAntialias(xel ** const inxels,
                    xel ** const outxels,
                    int    const col,
                    int    const inrows,
@@ -435,12 +435,12 @@ shearYColAntialias(xel ** const inxels,
     long const fracnew0   = shearParm[col].fracnew0;
     long const omfracnew0 = shearParm[col].omfracnew0;
     int  const shiftWhole = shearParm[col].shiftWhole;
-        
+
     int outrow;
 
     xel prevxel;
     int inrow;
-        
+
     /* Initialize everything to background color */
     for (outrow = 0; outrow < outrows; ++outrow)
         outxels[outrow][col] = bgxel;
@@ -455,21 +455,21 @@ shearYColAntialias(xel ** const inxels,
             switch ( PNM_FORMAT_TYPE(format) ) {
             case PPM_TYPE:
                 PPM_ASSIGN(*nxP,
-                           (fracnew0 * PPM_GETR(prevxel) 
-                            + omfracnew0 * PPM_GETR(x) 
+                           (fracnew0 * PPM_GETR(prevxel)
+                            + omfracnew0 * PPM_GETR(x)
                             + HALFSCALE) / SCALE,
-                           (fracnew0 * PPM_GETG(prevxel) 
-                            + omfracnew0 * PPM_GETG(x) 
+                           (fracnew0 * PPM_GETG(prevxel)
+                            + omfracnew0 * PPM_GETG(x)
                             + HALFSCALE) / SCALE,
-                           (fracnew0 * PPM_GETB(prevxel) 
-                            + omfracnew0 * PPM_GETB(x) 
+                           (fracnew0 * PPM_GETB(prevxel)
+                            + omfracnew0 * PPM_GETB(x)
                             + HALFSCALE) / SCALE );
                 break;
-                        
+
             default:
                 PNM_ASSIGN1(*nxP,
-                            (fracnew0 * PNM_GET1(prevxel) 
-                             + omfracnew0 * PNM_GET1(x) 
+                            (fracnew0 * PNM_GET1(prevxel)
+                             + omfracnew0 * PNM_GET1(x)
                              + HALFSCALE) / SCALE );
                 break;
             }
@@ -481,26 +481,26 @@ shearYColAntialias(xel ** const inxels,
         switch (PNM_FORMAT_TYPE(format)) {
         case PPM_TYPE:
             PPM_ASSIGN(*nxP,
-                       (fracnew0 * PPM_GETR(prevxel) 
-                        + omfracnew0 * PPM_GETR(bgxel) 
+                       (fracnew0 * PPM_GETR(prevxel)
+                        + omfracnew0 * PPM_GETR(bgxel)
                         + HALFSCALE) / SCALE,
-                       (fracnew0 * PPM_GETG(prevxel) 
-                        + omfracnew0 * PPM_GETG(bgxel) 
+                       (fracnew0 * PPM_GETG(prevxel)
+                        + omfracnew0 * PPM_GETG(bgxel)
                         + HALFSCALE) / SCALE,
-                       (fracnew0 * PPM_GETB(prevxel) 
-                        + omfracnew0 * PPM_GETB(bgxel) 
+                       (fracnew0 * PPM_GETB(prevxel)
+                        + omfracnew0 * PPM_GETB(bgxel)
                         + HALFSCALE) / SCALE);
             break;
-                
+
         default:
             PNM_ASSIGN1(*nxP,
-                        (fracnew0 * PNM_GET1(prevxel) 
-                         + omfracnew0 * PNM_GET1(bgxel) 
+                        (fracnew0 * PNM_GET1(prevxel)
+                         + omfracnew0 * PNM_GET1(bgxel)
                          + HALFSCALE) / SCALE);
             break;
         }
     }
-} 
+}
 
 
 
@@ -516,14 +516,14 @@ shearImageY(xel **                 const inxels,
             int                    const yshearjunk,
             xel ***                const outxelsP,
             unsigned int *         const outrowsP) {
-    
+
     unsigned int const maxShear = (cols - 0.5) * yshearfac + 0.5;
     unsigned int const outrows = inrows + maxShear - 2 * yshearjunk;
 
     struct shearParm * shearParm;  /* malloc'ed */
     int col;
     xel ** outxels;
-    
+
     outxels = pnm_allocarray(cols, outrows);
 
     MALLOCARRAY(shearParm, cols);
@@ -536,7 +536,7 @@ shearImageY(xel **                 const inxels,
            the bottom pixel.  We use the distance of the center of this
            pixel from the relevant edge to compute shift amount:
         */
-        float const yDistance = 
+        float const yDistance =
             (direction == CLOCKWISE ? col + 0.5 : (cols-0.5 - col));
         float const shiftAmount = yshearfac * yDistance;
 
@@ -552,12 +552,12 @@ shearImageY(xel **                 const inxels,
         /* TODO: do this row-by-row, same as for noantialias, to save
            real memory.
         */
-        for (col = 0; col < cols; ++col) 
-            shearYColAntialias(inxels, outxels, col, inrows, outrows, format, 
+        for (col = 0; col < cols; ++col)
+            shearYColAntialias(inxels, outxels, col, inrows, outrows, format,
                                bgxel, shearParm);
     }
     free(shearParm);
-    
+
     *outxelsP = outxels;
     *outrowsP = outrows;
 }
@@ -565,9 +565,9 @@ shearImageY(xel **                 const inxels,
 
 
 static void
-shearFinal(xel * const inRow, 
-           xel * const outRow, 
-           int   const incols, 
+shearFinal(xel * const inRow,
+           xel * const outRow,
+           int   const incols,
            int   const outcols,
            int   const format,
            xel   const bgxel,
@@ -585,8 +585,8 @@ shearFinal(xel * const inRow,
     }
 
     if (antialias) {
-        long const fracnew0   = (shiftAmount - (int) shiftAmount) * SCALE; 
-        long const omfracnew0 = SCALE - fracnew0; 
+        long const fracnew0   = (shiftAmount - (int) shiftAmount) * SCALE;
+        long const omfracnew0 = SCALE - fracnew0;
         unsigned int const shiftWhole = (int)shiftAmount - x2shearjunk;
 
         xel prevxel;
@@ -601,21 +601,21 @@ shearFinal(xel * const inRow,
                 switch (PNM_FORMAT_TYPE(format)) {
                 case PPM_TYPE:
                     PPM_ASSIGN(*nxP,
-                               (fracnew0 * PPM_GETR(prevxel) 
-                                + omfracnew0 * PPM_GETR(x) 
+                               (fracnew0 * PPM_GETR(prevxel)
+                                + omfracnew0 * PPM_GETR(x)
                                 + HALFSCALE) / SCALE,
-                               (fracnew0 * PPM_GETG(prevxel) 
-                                + omfracnew0 * PPM_GETG(x) 
+                               (fracnew0 * PPM_GETG(prevxel)
+                                + omfracnew0 * PPM_GETG(x)
                                 + HALFSCALE) / SCALE,
-                               (fracnew0 * PPM_GETB(prevxel) 
-                                + omfracnew0 * PPM_GETB(x) 
+                               (fracnew0 * PPM_GETB(prevxel)
+                                + omfracnew0 * PPM_GETB(x)
                                 + HALFSCALE) / SCALE);
                     break;
-                    
+
                 default:
                     PNM_ASSIGN1(*nxP,
-                                (fracnew0 * PNM_GET1(prevxel) 
-                                 + omfracnew0 * PNM_GET1(x) 
+                                (fracnew0 * PNM_GET1(prevxel)
+                                 + omfracnew0 * PNM_GET1(x)
                                  + HALFSCALE) / SCALE );
                     break;
                 }
@@ -627,21 +627,21 @@ shearFinal(xel * const inRow,
             switch (PNM_FORMAT_TYPE(format)) {
             case PPM_TYPE:
                 PPM_ASSIGN(*nxP,
-                           (fracnew0 * PPM_GETR(prevxel) 
-                            + omfracnew0 * PPM_GETR(bgxel) 
+                           (fracnew0 * PPM_GETR(prevxel)
+                            + omfracnew0 * PPM_GETR(bgxel)
                             + HALFSCALE) / SCALE,
-                           (fracnew0 * PPM_GETG(prevxel) 
-                            + omfracnew0 * PPM_GETG(bgxel) 
+                           (fracnew0 * PPM_GETG(prevxel)
+                            + omfracnew0 * PPM_GETG(bgxel)
                             + HALFSCALE) / SCALE,
-                           (fracnew0 * PPM_GETB(prevxel) 
-                            + omfracnew0 * PPM_GETB(bgxel) 
+                           (fracnew0 * PPM_GETB(prevxel)
+                            + omfracnew0 * PPM_GETB(bgxel)
                             + HALFSCALE) / SCALE);
                 break;
-                
+
             default:
                 PNM_ASSIGN1(*nxP,
-                            (fracnew0 * PNM_GET1(prevxel) 
-                             + omfracnew0 * PNM_GET1(bgxel) 
+                            (fracnew0 * PNM_GET1(prevxel)
+                             + omfracnew0 * PNM_GET1(bgxel)
                              + HALFSCALE) / SCALE );
                 break;
             }
@@ -664,7 +664,7 @@ shearFinal(xel * const inRow,
 static void
 shearXToOutputFile(FILE *                 const ofP,
                    xel **                 const xels,
-                   unsigned int           const cols, 
+                   unsigned int           const cols,
                    unsigned int           const rows,
                    xelval                 const maxval,
                    int                    const format,
@@ -688,7 +688,7 @@ shearXToOutputFile(FILE *                 const ofP,
 
     unsigned int row;
     xel * xelrow;
-    
+
     pnm_writepnminit(ofP, newcols, rows, maxval, format, 0);
 
     xelrow = pnm_allocrow(newcols);
@@ -699,11 +699,11 @@ shearXToOutputFile(FILE *                 const ofP,
            the right pixel.  We use the distance of the center of this
            pixel from the relevant edge to compute shift amount:
         */
-        float const xDistance = 
+        float const xDistance =
             (direction == COUNTERCLOCKWISE ? row + 0.5 : (rows-0.5 - row));
         float const shiftAmount = xshearfac * xDistance;
 
-        shearFinal(xels[row], xelrow, cols, newcols, format, 
+        shearFinal(xels[row], xelrow, cols, newcols, format,
                    bgColor, antialias, shiftAmount, x2shearjunk);
 
         pnm_writepnmrow(ofP, xelrow, newcols, maxval, format, 0);
@@ -714,7 +714,7 @@ shearXToOutputFile(FILE *                 const ofP,
 
 
 int
-main(int argc, char *argv[]) { 
+main(int argc, char *argv[]) {
 
     struct cmdlineInfo cmdline;
     FILE * ifP;
@@ -738,8 +738,8 @@ main(int argc, char *argv[]) {
     ifP = pm_openr(cmdline.inputFilespec);
 
     pnm_readpnminit(ifP, &cols, &rows, &maxval, &format);
-    
-    computeNewFormat(!cmdline.noantialias, format, maxval, 
+
+    computeNewFormat(!cmdline.noantialias, format, maxval,
                      &newformat, &newmaxval);
 
     xshearfac = fabs(tan(cmdline.angle / 2.0));
@@ -755,7 +755,7 @@ main(int argc, char *argv[]) {
                         newmaxval, newformat,
                         !cmdline.noantialias, cmdline.background,
                         &shear1xels, &shear1Cols, &bgColor);
-    
+
     pm_close(ifP);
 
     if (cmdline.verbose)
@@ -777,16 +777,16 @@ main(int argc, char *argv[]) {
     pnm_freearray(shear1xels, rows);
 
     if (cmdline.keeptemp)
-        storeImage("pnmrotate_stage2.pnm", shear2xels, shear1Cols, newrows, 
+        storeImage("pnmrotate_stage2.pnm", shear2xels, shear1Cols, newrows,
                    newmaxval, newformat);
 
     shearXToOutputFile(stdout, shear2xels, shear1Cols, newrows,
                        newmaxval, newformat,
-                       direction, xshearfac, x2shearjunk, 
+                       direction, xshearfac, x2shearjunk,
                        bgColor, !cmdline.noantialias);
 
     pnm_freearray(shear2xels, newrows);
     pm_close(stdout);
-    
+
     return 0;
 }
diff --git a/editor/pnmscalefixed.c b/editor/pnmscalefixed.c
index 884ca315..7d33a9c2 100644
--- a/editor/pnmscalefixed.c
+++ b/editor/pnmscalefixed.c
@@ -15,10 +15,10 @@
 **               - added -reduce N to allow scaling by integer value
 **                 in this case, scale_comp becomes 1/N and x/yscale
 **                 get set as they should
-**    
+**
 **
 */
- 
+
 #include <math.h>
 
 #include "pm_c_util.h"
@@ -27,12 +27,12 @@
 #include "pnm.h"
 
 /* The pnm library allows us to code this program without branching cases
-   for PGM and PPM, but we do the branch anyway to speed up processing of 
+   for PGM and PPM, but we do the branch anyway to speed up processing of
    PGM images.
 */
 
 /* We do all our arithmetic in integers.  In order not to get killed by the
-   rounding, we scale every number up by the factor SCALE, do the 
+   rounding, we scale every number up by the factor SCALE, do the
    arithmetic, then scale it back down.
    */
 #define SCALE 4096
@@ -118,16 +118,16 @@ parse_command_line(int argc, char ** argv,
         pm_error("Cannot specify both -xsize/width and -xscale.");
     if (ysize != -1 && yscale != -1)
         pm_error("Cannot specify both -ysize/height and -yscale.");
-    
-    if (xysize && 
-        (xsize != -1 || xscale != -1 || ysize != -1 || yscale != -1 || 
+
+    if (xysize &&
+        (xsize != -1 || xscale != -1 || ysize != -1 || yscale != -1 ||
          reduce != -1 || pixels != -1) )
         pm_error("Cannot specify -xysize with other dimension options.");
-    if (pixels != -1 && 
+    if (pixels != -1 &&
         (xsize != -1 || xscale != -1 || ysize != -1 || yscale != -1 ||
          reduce != -1) )
         pm_error("Cannot specify -pixels with other dimension options.");
-    if (reduce != -1 && 
+    if (reduce != -1 &&
         (xsize != -1 || xscale != -1 || ysize != -1 || yscale != -1) )
         pm_error("Cannot specify -reduce with other dimension options.");
 
@@ -148,7 +148,7 @@ parse_command_line(int argc, char ** argv,
         else {
             cmdline_p->xbox = atoi(argv[1]);
             cmdline_p->ybox = atoi(argv[2]);
-            
+
             if (argc-1 < 3)
                 cmdline_p->input_filespec = "-";
             else
@@ -157,7 +157,7 @@ parse_command_line(int argc, char ** argv,
     } else {
         cmdline_p->xbox = 0;
         cmdline_p->ybox = 0;
-        
+
         if (xsize == -1 && xscale == -1 && ysize == -1 && yscale == -1
             && pixels == -1 && reduce == -1) {
             /* parameters are scale factor and optional filespec */
@@ -187,7 +187,7 @@ parse_command_line(int argc, char ** argv,
 
             if (reduce != -1) {
                 scale_parm = ((double) 1.0) / ((double) reduce);
-                pm_message("reducing by %d gives scale factor of %f.", 
+                pm_message("reducing by %d gives scale factor of %f.",
                            reduce, scale_parm);
             } else
                 scale_parm = 0.0;
@@ -210,7 +210,7 @@ parse_command_line(int argc, char ** argv,
 
 
 static void
-compute_output_dimensions(const struct cmdline_info cmdline, 
+compute_output_dimensions(const struct cmdline_info cmdline,
                           const int rows, const int cols,
                           int * newrowsP, int * newcolsP) {
 
@@ -226,9 +226,9 @@ compute_output_dimensions(const struct cmdline_info cmdline,
         }
     } else if (cmdline.xbox) {
         const double aspect_ratio = (float) cols / (float) rows;
-        const double box_aspect_ratio = 
+        const double box_aspect_ratio =
             (float) cmdline.xbox / (float) cmdline.ybox;
-        
+
         if (box_aspect_ratio > aspect_ratio) {
             *newrowsP = cmdline.ybox;
             *newcolsP = *newrowsP * aspect_ratio + 0.5;
@@ -254,24 +254,24 @@ compute_output_dimensions(const struct cmdline_info cmdline,
             *newrowsP = rows * ((float) cmdline.xsize/cols) +.5;
         else
             *newrowsP = rows;
-    }    
+    }
 
-    /* If the calculations above yielded (because of rounding) a zero 
+    /* If the calculations above yielded (because of rounding) a zero
        dimension, we fudge it up to 1.  We do this rather than considering
-       it a specification error (and dying) because it's friendlier to 
+       it a specification error (and dying) because it's friendlier to
        automated processes that work on arbitrary input.  It saves them
        having to check their numbers to avoid catastrophe.
     */
 
     if (*newcolsP < 1) *newcolsP = 1;
     if (*newrowsP < 1) *newrowsP = 1;
-}        
+}
 
 
 
 static void
-horizontal_scale(const xel inputxelrow[], xel newxelrow[], 
-                 const int cols, const int newcols, const long sxscale, 
+horizontal_scale(const xel inputxelrow[], xel newxelrow[],
+                 const int cols, const int newcols, const long sxscale,
                  const int format, const xelval maxval,
                  int * stretchP) {
 /*----------------------------------------------------------------------------
@@ -282,14 +282,14 @@ horizontal_scale(const xel inputxelrow[], xel newxelrow[],
    'format' and 'maxval' describe the Netpbm format of the both input and
    output rows.
 
-   *stretchP is the number of columns (could be fractional) on the right 
+   *stretchP is the number of columns (could be fractional) on the right
    that we had to fill by stretching because of rounding problems.
 -----------------------------------------------------------------------------*/
     long r, g, b;
     long fraccoltofill, fraccolleft;
     unsigned int col;
     unsigned int newcol;
-    
+
     newcol = 0;
     fraccoltofill = SCALE;  /* Output column is "empty" now */
     r = g = b = 0;          /* initial value */
@@ -302,7 +302,7 @@ horizontal_scale(const xel inputxelrow[], xel newxelrow[],
         */
         while (fraccolleft >= fraccoltofill) {
             /* Generate one output pixel in 'newxelrow'.  It will consist
-               of anything accumulated from prior input pixels in 'r','g', 
+               of anything accumulated from prior input pixels in 'r','g',
                and 'b', plus a fraction of the current input pixel.
             */
             switch (PNM_FORMAT_TYPE(format)) {
@@ -332,7 +332,7 @@ horizontal_scale(const xel inputxelrow[], xel newxelrow[],
             fraccoltofill = SCALE;
             r = g = b = 0;
         }
-        /* There's not enough left in the current input pixel to fill up 
+        /* There's not enough left in the current input pixel to fill up
            a whole output column, so just accumulate the remainder of the
            pixel into the current output column.
         */
@@ -343,7 +343,7 @@ horizontal_scale(const xel inputxelrow[], xel newxelrow[],
                 g += fraccolleft * PPM_GETG(inputxelrow[col]);
                 b += fraccolleft * PPM_GETB(inputxelrow[col]);
                 break;
-                    
+
             default:
                 g += fraccolleft * PNM_GET1(inputxelrow[col]);
                 break;
@@ -356,7 +356,7 @@ horizontal_scale(const xel inputxelrow[], xel newxelrow[],
     while (newcol < newcols) {
         /* We ran out of input columns before we filled up the output
            columns.  This would be because of rounding down.  For small
-           images, we're probably missing only a tiny fraction of a column, 
+           images, we're probably missing only a tiny fraction of a column,
            but for large images, it could be multiple columns.
 
            So we fake the remaining output columns by copying the rightmost
@@ -382,7 +382,7 @@ horizontal_scale(const xel inputxelrow[], xel newxelrow[],
             if ( b > maxval ) b = maxval;
             PPM_ASSIGN(newxelrow[newcol], r, g, b );
             break;
-                
+
         default:
             g += fraccoltofill * PNM_GET1(inputxelrow[cols-1]);
             g += HALFSCALE;  /* for rounding */
@@ -416,7 +416,7 @@ main(int argc, char **argv ) {
     long* gs;
     long* bs;
     int vertical_stretch;
-        /* The number of rows we had to fill by stretching because of 
+        /* The number of rows we had to fill by stretching because of
            rounding error, which made us run out of input rows before we
            had filled up the output rows.
            */
@@ -434,7 +434,7 @@ main(int argc, char **argv ) {
         newformat = PGM_TYPE;
         newmaxval = PGM_MAXMAXVAL;
         pm_message( "promoting from PBM to PGM" );
-	}  else {
+        }  else {
         newformat = format;
         newmaxval = maxval;
     }
@@ -450,14 +450,14 @@ main(int argc, char **argv ) {
     syscale = SCALE * newrows / rows;
 
     if (cmdline.verbose) {
-        pm_message("Scaling by %ld/%d = %f horizontally to %d columns.", 
+        pm_message("Scaling by %ld/%d = %f horizontally to %d columns.",
                    sxscale, SCALE, (float) sxscale/SCALE, newcols );
-        pm_message("Scaling by %ld/%d = %f vertically to %d rows.", 
+        pm_message("Scaling by %ld/%d = %f vertically to %d rows.",
                    syscale, SCALE, (float) syscale/SCALE, newrows);
     }
 
     xelrow = pnm_allocrow(cols);
-    if (newrows == rows)	/* shortcut Y scaling if possible */
+    if (newrows == rows)        /* shortcut Y scaling if possible */
         tempxelrow = xelrow;
     else
         tempxelrow = pnm_allocrow( cols );
@@ -468,18 +468,18 @@ main(int argc, char **argv ) {
     fracrowleft = syscale;
     needtoreadrow = 1;
     for ( col = 0; col < cols; ++col )
-	rs[col] = gs[col] = bs[col] = HALFSCALE;
+        rs[col] = gs[col] = bs[col] = HALFSCALE;
     fracrowtofill = SCALE;
     vertical_stretch = 0;
-    
+
     pnm_writepnminit( stdout, newcols, newrows, newmaxval, newformat, 0 );
     newxelrow = pnm_allocrow( newcols );
-    
+
     for ( row = 0; row < newrows; ++row ) {
         /* First scale vertically from xelrow into tempxelrow. */
         if ( newrows == rows ) { /* shortcut vertical scaling if possible */
             pnm_readpnmrow( ifp, xelrow, cols, newmaxval, format );
-	    } else {
+            } else {
             while ( fracrowleft < fracrowtofill ) {
                 if ( needtoreadrow )
                     if ( rowsread < rows ) {
@@ -513,8 +513,8 @@ main(int argc, char **argv ) {
                 } else {
                     /* We need another input row to fill up this output row,
                        but there aren't any more.  That's because of rounding
-                       down on our scaling arithmetic.  So we go ahead with 
-                       the data from the last row we read, which amounts to 
+                       down on our scaling arithmetic.  So we go ahead with
+                       the data from the last row we read, which amounts to
                        stretching out the last output row.
                     */
                     vertical_stretch += fracrowtofill;
@@ -544,7 +544,7 @@ main(int argc, char **argv ) {
                 for ( col = 0, xP = xelrow, nxP = tempxelrow;
                       col < cols; ++col, ++xP, ++nxP ) {
                     register long g;
-                    
+
                     g = gs[col] + fracrowtofill * PNM_GET1( *xP );
                     g /= SCALE;
                     if ( g > newmaxval ) g = newmaxval;
@@ -559,37 +559,37 @@ main(int argc, char **argv ) {
                 needtoreadrow = 1;
             }
             fracrowtofill = SCALE;
-	    }
+            }
 
         /* Now scale tempxelrow horizontally into newxelrow & write it out. */
 
-        if (newcols == cols)	/* shortcut X scaling if possible */
-            pnm_writepnmrow(stdout, tempxelrow, newcols, 
+        if (newcols == cols)    /* shortcut X scaling if possible */
+            pnm_writepnmrow(stdout, tempxelrow, newcols,
                             newmaxval, newformat, 0);
         else {
             int stretch;
 
-            horizontal_scale(tempxelrow, newxelrow, cols, newcols, sxscale, 
+            horizontal_scale(tempxelrow, newxelrow, cols, newcols, sxscale,
                              format, newmaxval, &stretch);
-            
+
             if (cmdline.verbose && row == 0 && stretch != 0)
                 pm_message("%d/%d = %f right columns filled by stretching "
-                           "because of arithmetic imprecision", 
+                           "because of arithmetic imprecision",
                            stretch, SCALE, (float) stretch/SCALE);
-            
-            pnm_writepnmrow(stdout, newxelrow, newcols, 
+
+            pnm_writepnmrow(stdout, newxelrow, newcols,
                             newmaxval, newformat, 0 );
         }
-	}
+        }
 
     if (cmdline.verbose && vertical_stretch != 0)
         pm_message("%d/%d = %f bottom rows filled by stretching due to "
-                   "arithmetic imprecision", 
-                   vertical_stretch, SCALE, 
+                   "arithmetic imprecision",
+                   vertical_stretch, SCALE,
                    (float) vertical_stretch/SCALE);
-    
+
     pm_close( ifp );
     pm_close( stdout );
-    
+
     exit( 0 );
 }
diff --git a/editor/pnmsmooth.c b/editor/pnmsmooth.c
index a76bd42b..b4dc1b9a 100644
--- a/editor/pnmsmooth.c
+++ b/editor/pnmsmooth.c
@@ -1,4 +1,4 @@
-/* pnmsmooth.c - smooth out an image by replacing each pixel with the 
+/* pnmsmooth.c - smooth out an image by replacing each pixel with the
 **               average of its width x height neighbors.
 **
 ** Version 2.0   December 5, 1994
@@ -51,7 +51,7 @@ parseCommandLine (int argc, const char ** argv,
                   struct cmdlineInfo *cmdlineP) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -69,9 +69,9 @@ parseCommandLine (int argc, const char ** argv,
     unsigned int widthSpec, heightSpec, sizeSpec;
 
     MALLOCARRAY_NOFAIL(option_def, 100);
-    
+
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0,   "dump",          OPT_FLAG,   
+    OPTENT3(0,   "dump",          OPT_FLAG,
             NULL,                       &cmdlineP->dump, 0);
     OPTENT3(0,   "width",         OPT_UINT,
             &cmdlineP->width,           &widthSpec, 0);
@@ -117,7 +117,7 @@ parseCommandLine (int argc, const char ** argv,
         else {
             cmdlineP->width  = atoi(argv[1]);
             cmdlineP->height = atoi(argv[2]);
-            
+
             if (argc-1 < 3)
                 cmdlineP->inputFilespec = "-";
             else
@@ -179,7 +179,7 @@ makeConvolutionKernel(unsigned int const cols,
     else {
         unsigned int row;
         unsigned int cursor;
-     
+
         for (row = 0, cursor = 0; row < rows; ++row) {
             unsigned int col;
 
diff --git a/editor/pnmstitch.c b/editor/pnmstitch.c
index b27445b0..ab21021c 100644
--- a/editor/pnmstitch.c
+++ b/editor/pnmstitch.c
@@ -152,7 +152,7 @@ typedef struct stitcher {
     bool      (* Match)(struct stitcher *me, Image * Left, Image * Right);
         /* Determine the transformation parameters for the stitching.
            I.e. determine the parameters that affect future invocations
-           of the transformation methods below.  You must execute a 
+           of the transformation methods below.  You must execute a
            'Match' before executing any of the transformation methods.
         */
     /*-----------------------------------------------------------------------
@@ -162,7 +162,7 @@ typedef struct stitcher {
 
       If there is no pixel in the left image that contributes to the output
       pixel in question, the methods return column or row numbers outside
-      the bounds of the left image (possibly negative).  Likewise for the 
+      the bounds of the left image (possibly negative).  Likewise for the
       right image.
     */
     float     (* XLeft)(struct stitcher *me, int x, int y);
@@ -225,7 +225,7 @@ parseCommandLine ( int argc, char ** argv,
 {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -241,25 +241,25 @@ parseCommandLine ( int argc, char ** argv,
     unsigned int option_def_index;
 
     char *outputOpt;
-    unsigned int widthSpec, heightSpec, outputSpec, 
+    unsigned int widthSpec, heightSpec, outputSpec,
         xrightposSpec, yrightposSpec, stitcherSpec, filterSpec;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "width",       OPT_UINT,   &cmdlineP->width, 
+    OPTENT3(0, "width",       OPT_UINT,   &cmdlineP->width,
             &widthSpec,         0);
-    OPTENT3(0, "height",      OPT_UINT,   &cmdlineP->height, 
+    OPTENT3(0, "height",      OPT_UINT,   &cmdlineP->height,
             &heightSpec,        0);
-    OPTENT3(0, "verbose",     OPT_FLAG,   NULL,                  
+    OPTENT3(0, "verbose",     OPT_FLAG,   NULL,
             &cmdlineP->verbose, 0 );
-    OPTENT3(0, "output",      OPT_STRING, &outputOpt, 
+    OPTENT3(0, "output",      OPT_STRING, &outputOpt,
             &outputSpec,        0);
-    OPTENT3(0, "xrightpos",   OPT_UINT,   &cmdlineP->xrightpos, 
+    OPTENT3(0, "xrightpos",   OPT_UINT,   &cmdlineP->xrightpos,
             &xrightposSpec,     0);
-    OPTENT3(0, "yrightpos",   OPT_UINT,   &cmdlineP->yrightpos, 
+    OPTENT3(0, "yrightpos",   OPT_UINT,   &cmdlineP->yrightpos,
             &yrightposSpec,     0);
-    OPTENT3(0, "stitcher",    OPT_STRING, &cmdlineP->stitcher, 
+    OPTENT3(0, "stitcher",    OPT_STRING, &cmdlineP->stitcher,
             &stitcherSpec,      0);
-    OPTENT3(0, "filter",      OPT_STRING, &cmdlineP->filter, 
+    OPTENT3(0, "filter",      OPT_STRING, &cmdlineP->filter,
             &filterSpec,        0);
 
     opt.opt_table = option_def;
@@ -333,14 +333,14 @@ main (int argc, char **argv)
 
     verbose = cmdline.verbose;
 
-    return pnmstitch (cmdline.leftFilespec, 
-                      cmdline.rightFilespec, 
-                      cmdline.outputFilespec, 
-                      cmdline.xrightpos, 
-                      cmdline.yrightpos, 
-                      cmdline.width, 
-                      cmdline.height, 
-                      cmdline.stitcher, 
+    return pnmstitch (cmdline.leftFilespec,
+                      cmdline.rightFilespec,
+                      cmdline.outputFilespec,
+                      cmdline.xrightpos,
+                      cmdline.yrightpos,
+                      cmdline.width,
+                      cmdline.height,
+                      cmdline.stitcher,
                       cmdline.filter);
 } /* main() - end */
 
@@ -353,10 +353,10 @@ static Image *
 allocate_image(void)
 {
     Image * retVal;
-    
+
     MALLOCVAR(retVal);
 
-    if (retVal != NULL) 
+    if (retVal != NULL)
         memset (retVal, 0, (unsigned)sizeof(Image));
 
     return retVal;
@@ -372,11 +372,11 @@ free_image(Image * image)
 {
     if (image->name) {
         pm_strfree(image->name);
-        image->name = NULL;     
+        image->name = NULL;
     }
     if (image->tuple) {
         pnm_freepamarray(image->tuple, &image->pam);
-        image->tuple = NULL; 
+        image->tuple = NULL;
     }
     if (image->pam.file) {
         fclose (image->pam.file);
@@ -393,8 +393,8 @@ openWithPossibleExtension(const char *  const baseName,
                           const char ** const filenameP) {
 
     /* list of possible extensions for input file */
-    const char * const extlist[] = { 
-        "", ".pnm", ".pam", ".pgm", ".pbm", ".ppm" 
+    const char * const extlist[] = {
+        "", ".pnm", ".pam", ".pgm", ".pbm", ".ppm"
     };
 
     FILE * ifP;
@@ -403,23 +403,23 @@ openWithPossibleExtension(const char *  const baseName,
     ifP = NULL;   /* initial value -- no file opened yet */
 
     for (extIndex = 0; extIndex < ARRAY_SIZE(extlist) && !ifP; ++extIndex) {
-        
+
         const char * trialName;
-        
+
         pm_asprintf(&trialName, "%s%s", baseName, extlist[extIndex]);
-        
+
         ifP = fopen(trialName, "rb");
-        
+
         if (ifP)
             *filenameP = trialName;
         else
             pm_strfree(trialName);
     }
-    if (!ifP) 
+    if (!ifP)
         pm_error ("Failed to open input file named '%s' "
-                  "or '%s' with one of various common extensions.", 
+                  "or '%s' with one of various common extensions.",
                   baseName, baseName);
-    
+
     *ifPP = ifP;
 }
 
@@ -435,7 +435,7 @@ readinit(const char * const name)
     Image * const image = allocate_image();
     Image * retVal;
 
-    if (image == NULL) 
+    if (image == NULL)
         retVal = NULL;
     else {
         FILE * ifP;
@@ -446,7 +446,7 @@ readinit(const char * const name)
         } else {
             openWithPossibleExtension(name, &ifP, &image->name);
         }
-        image->tuple = pnm_readpam(ifP, &(image->pam), 
+        image->tuple = pnm_readpam(ifP, &(image->pam),
                                    PAM_STRUCT_SIZE(tuple_type));
         fclose (ifP);
         image->pam.file = NULL;
@@ -507,7 +507,7 @@ regionDifference(Image * left,
 {
     unsigned long total;
     unsigned      row;
-    
+
     total = 0;  /* initial value */
 
     for (row = 0; row < height; ++row) {
@@ -830,7 +830,7 @@ stitchOnePixel(Image *    const Left,
                int        const right_column,
                unsigned * const firstRightP,
                tuple      const outPixel) {
-               
+
     unsigned plane;
 
     for (plane = 0; plane < outpam.depth; ++plane) {
@@ -848,7 +848,7 @@ stitchOnePixel(Image *    const Left,
         rightPixel = 0;
         if (right_column >= 0) {
             rightPixel = Right->tuple[right_row][right_column][plane];
-            if ((rightPixel > 0) && (*firstRightP == 0)) 
+            if ((rightPixel > 0) && (*firstRightP == 0))
                 *firstRightP = column;
         }
         if (leftPixel == 0) {
@@ -869,7 +869,7 @@ stitchOnePixel(Image *    const Left,
             } else {
                 int const v = w * 4;
                 leftPixel = (sample)(
-                    ((leftPixel 
+                    ((leftPixel
                       * (unsigned long)(Left->pam.width - column))
                      + (rightPixel
                         * (unsigned long)(column - Left->pam.width + v)))
@@ -929,22 +929,22 @@ stitchOneRow(Image *    const Left,
                 right_column = -1;
                 right_row    = -1;
             }
-        } else 
+        } else
             right_column = -1;
 
         /* Create the pixel at column 'column' of row 'row' of the
            output 'Out': Row[column].
         */
-        stitchOnePixel(Left, Right, Out->image->pam, row, column, y, 
+        stitchOnePixel(Left, Right, Out->image->pam, row, column, y,
                        right_row, right_column, &firstRight, Row[column]);
     }
 }
 
 
 
-static void 
-stitchit(Image *      const Left, 
-         Image *      const Right, 
+static void
+stitchit(Image *      const Left,
+         Image *      const Right,
          const char * const outfilename,
          const char * const filter,
          Stitcher *   const Stitch,
@@ -954,8 +954,8 @@ stitchit(Image *      const Left,
                                     sizeof(OutputMethods[0]));
     unsigned   row;
     int        xp[8], yp[8], x, y, width, height;
-    
-    if ((Out == (Output *)NULL) || (Out->Name == (char *)NULL)) 
+
+    if ((Out == (Output *)NULL) || (Out->Name == (char *)NULL))
         *retvalP = -2;
     else {
         if (verbose)
@@ -966,13 +966,13 @@ stitchit(Image *      const Left,
         determineMaskCorners(Stitch, Left, Right, xp, yp);
 
         /* Output the combined images */
-                
+
         /* Calculate generic x,y left top corner, and the width and height */
         calculateXyWidthHeight(xp, yp, &x, &y, &width, &height);
-                
-        if (verbose) 
+
+        if (verbose)
             printPlan(xp, yp, Left, Right);
-    
+
         if (!(*(Out->Alloc))(Out, outfilename, width, height, &Left->pam))
             *retvalP = -9;
         else {
@@ -989,7 +989,7 @@ stitchit(Image *      const Left,
             }
             (*(Out->FlushImage))(Out);
             (*(Out->DeAlloc))(Out);
-        
+
             *retvalP = 0;
         }
     }
@@ -1014,10 +1014,10 @@ pnmstitch(const char * const leftfilename,
     Image    * Right;
     int        retval;
 
-    if ((Stitch == (Stitcher *)NULL) || (Stitch->Name == (char *)NULL)) 
+    if ((Stitch == (Stitcher *)NULL) || (Stitch->Name == (char *)NULL))
         retval = -1;
     else {
-        if (verbose) 
+        if (verbose)
             fprintf (stderr, "Selected %s stitcher algorithm\n",
                      Stitch->Name);
 
@@ -1034,7 +1034,7 @@ pnmstitch(const char * const leftfilename,
                 if (Left->pam.depth != Right->pam.depth) {
                     fprintf(stderr, "Images should have matching depth.  "
                             "The left image has depth %d, "
-                            "while the right has depth %d.", 
+                            "while the right has depth %d.",
                             Left->pam.depth, Right->pam.depth);
                     retval = -5;
                 } else if (Left->pam.maxval != Right->pam.maxval) {
@@ -1042,19 +1042,19 @@ pnmstitch(const char * const leftfilename,
                              "Images should have matching maxval.  "
                              "The left image has maxval %u, "
                              "while the right has maxval %u.",
-                             (unsigned)Left->pam.maxval, 
+                             (unsigned)Left->pam.maxval,
                              (unsigned)Right->pam.maxval);
                     retval = -6;
-                } else if ((*(Stitch->Alloc))(Stitch) == FALSE) 
+                } else if ((*(Stitch->Alloc))(Stitch) == FALSE)
                     retval = -7;
                 else {
-                    (*(Stitch->Constrain))(Stitch, reqx, reqy, 
+                    (*(Stitch->Constrain))(Stitch, reqx, reqy,
                                            reqWidth, reqHeight);
 
-                    if ((*(Stitch->Match))(Stitch, Left, Right) == FALSE) 
+                    if ((*(Stitch->Match))(Stitch, Left, Right) == FALSE)
                         retval = -8;
-                    else 
-                        stitchit(Left, Right, outfilename, filter, Stitch, 
+                    else
+                        stitchit(Left, Right, outfilename, filter, Stitch,
                                  &retval);
                 }
                 free_image(Right);
@@ -1356,7 +1356,7 @@ LinearAlloc(Stitcher * me)
     bool retval;
 
     MALLOCARRAY(me->parms, 8);
-    if (me->parms == NULL) 
+    if (me->parms == NULL)
         retval = FALSE;
     else {
         /* Constraints unset */
@@ -1478,7 +1478,7 @@ LinearConstrain(Stitcher * me, int x, int y, int width, int height)
 /* Following global variables are for use by SliverMatch() */
 static unsigned long starPeriod;
     /* The number of events between printing of a "*" progress
-       indicator.  
+       indicator.
     */
 static unsigned long starCount;
     /* The number of events until the next * progress indicator needs to be
@@ -1487,7 +1487,7 @@ static unsigned long starCount;
 
 static void
 starEvent() {
-    
+
     if (--starCount == 0) {
         starCount = starPeriod;
         fprintf (stderr, "*");
@@ -1521,7 +1521,7 @@ findBestMatches(Image *  const Left,
                 unsigned const Xmax,
                 int      const Ymin,
                 int      const Ymax,
-                Best           best[NUM_BEST]) { 
+                Best           best[NUM_BEST]) {
 /*----------------------------------------------------------------------------
   Compare the rectangle 'width' columns by 'height' rows with upper
   left corner at Column 'x', Row y+offY in image 'Right' to a bunch of
@@ -1562,8 +1562,8 @@ allocate_best_array(Best *** const bestP, unsigned const bestSize) {
     MALLOCARRAY(best, bestSize);
     if (best == NULL)
         pm_error("No memory for Best array");
-    
-    for (i = 0; i < bestSize; ++i) 
+
+    for (i = 0; i < bestSize; ++i)
         best[i] = allocate_best();
     *bestP = best;
 }
@@ -1577,7 +1577,7 @@ static void determineXYRange(Stitcher * const me,
                              unsigned * const XmaxP,
                              int *      const YminP,
                              int *      const YmaxP) {
-    
+
     if (me->x == INT_MAX) {
         *XmaxP = Left->pam.width - me->width;
         /* I can't bring myself to go half way */
@@ -1594,7 +1594,7 @@ static void determineXYRange(Stitcher * const me,
         *YminP = me->y;
         *YmaxP = me->y + 1;
     }
-    if (verbose) 
+    if (verbose)
         pm_message("Test %d<x<%d %d<y<%d", *XminP, *XmaxP, *YminP, *YmaxP);
 }
 
@@ -1609,7 +1609,7 @@ SliverMatch(Stitcher * me, Image * Left, Image * Right,
             unsigned image_portion, unsigned skip_sliver)
 {
     /* up/down 3/10, make sure has an odd number of members */
-    unsigned const bestSize = 
+    unsigned const bestSize =
         1 + 2 * ((image_portion * 3) / (10 * skip_sliver));
     Best       ** best; /* malloc'ed array of Best * */
     float         sumydotx, sumx, sumydot, sum;
@@ -1681,8 +1681,8 @@ SliverMatch(Stitcher * me, Image * Left, Image * Right,
             }
             for (X = x; X < (x + me->width); ++X) {
                 for (Y = y + offY; Y < (y + offY + me->height); ++Y) {
-                    for (plane = 0; 
-                         plane < MIN(Right->pam.depth,3); 
+                    for (plane = 0;
+                         plane < MIN(Right->pam.depth,3);
                          ++plane) {
                         sample point = Right->tuple[Y][X][plane];
                         SUM[plane]   += point;
@@ -1693,7 +1693,7 @@ SliverMatch(Stitcher * me, Image * Left, Image * Right,
             /* How many features */
             features[in] = 0.0;
             for (plane = 0; plane < MIN(Right->pam.depth,3); ++plane) {
-                features[in] += SUMSQ[plane] - 
+                features[in] += SUMSQ[plane] -
                     (SUM[plane]*SUM[plane]/(float)(me->width*me->height));
             }
             if ((minf == 0.0) || (features[in] < minf)) {
@@ -1733,12 +1733,12 @@ SliverMatch(Stitcher * me, Image * Left, Image * Right,
             }
             if ((verbose == 1) || (verbose == 2))
                 for (X = Xmin; X < Xmax; ++X) {
-                    for (Y = Ymin; Y < Ymax; ++Y) 
+                    for (Y = Ymin; Y < Ymax; ++Y)
                         starEvent();
                 }
             continue;
         }
-        findBestMatches(Left, Right, x, y, me->width, me->height, 
+        findBestMatches(Left, Right, x, y, me->width, me->height,
                         offY, Xmin, Xmax, Ymin, Ymax,
                         best[in]);
         /* slop (noise in NUM_BEST) */
@@ -1980,7 +1980,7 @@ SliverMatch(Stitcher * me, Image * Left, Image * Right,
 static bool
 LinearMatch(Stitcher * me, Image * Left, Image * Right)
 {
-    if (SliverMatch(me, Left, Right, IMAGE_PORTION, SKIP_SLIVER * 8) 
+    if (SliverMatch(me, Left, Right, IMAGE_PORTION, SKIP_SLIVER * 8)
         == FALSE) {
         return FALSE;
     }
@@ -1989,7 +1989,7 @@ LinearMatch(Stitcher * me, Image * Left, Image * Right)
     me->y = - (me->parms[Sliver_yp] + me->parms[Sliver_ypp]
           + (1 - Left->pam.height)) / 2;
 
-    if (verbose) 
+    if (verbose)
         pm_message("LinearMatch translation parameters are (%d,%d)",
                    me->x, me->y);
 
diff --git a/editor/pnmtile.c b/editor/pnmtile.c
index 5ec53415..ca542c43 100644
--- a/editor/pnmtile.c
+++ b/editor/pnmtile.c
@@ -70,7 +70,7 @@ parseCommandLine(int argc, const char ** argv,
                 pm_error("There are at most three arguments: "
                          "width, height, file name.  You specified %u",
                          argc-1);
-        } else 
+        } else
             cmdlineP->inputFileName = "-";
     }
 }
diff --git a/editor/ppmchange.c b/editor/ppmchange.c
index cfc34769..16f4390e 100644
--- a/editor/ppmchange.c
+++ b/editor/ppmchange.c
@@ -33,8 +33,8 @@ struct CmdlineInfo {
         /* colors user wants replaced */
     const char * newcolorname[TCOLS];
         /* colors with which he wants them replaced */
-    float closeness;    
-    const char * remainder_colorname;  
+    float closeness;
+    const char * remainder_colorname;
       /* Color user specified for -remainder.  Null pointer if he didn't
          specify -remainder.
       */
@@ -87,8 +87,8 @@ parseCommandLine(int argc, const char ** const argv,
     if (cmdlineP->closeness > 100)
         pm_error("-closeness value %f is more than 100%%",
                  cmdlineP->closeness);
-    
-    if ((argc-1) % 2 == 0) 
+
+    if ((argc-1) % 2 == 0)
         cmdlineP->input_filespec = "-";
     else
         cmdlineP->input_filespec = argv[argc-1];
@@ -96,8 +96,8 @@ parseCommandLine(int argc, const char ** const argv,
     {
         int argn;
         cmdlineP->ncolors = 0;  /* initial value */
-        for (argn = 1; 
-             argn+1 < argc && cmdlineP->ncolors < TCOLS; 
+        for (argn = 1;
+             argn+1 < argc && cmdlineP->ncolors < TCOLS;
              argn += 2) {
             cmdlineP->oldcolorname[cmdlineP->ncolors] = argv[argn];
             cmdlineP->newcolorname[cmdlineP->ncolors] = argv[argn+1];
@@ -109,8 +109,8 @@ parseCommandLine(int argc, const char ** const argv,
 
 
 static bool
-colorMatches(pixel        const comparand, 
-             pixel        const comparator, 
+colorMatches(pixel        const comparand,
+             pixel        const comparator,
              unsigned int const allowableDiff) {
 /*----------------------------------------------------------------------------
    The colors 'comparand' and 'comparator' are within 'allowableDiff'
@@ -126,21 +126,21 @@ colorMatches(pixel        const comparand,
 
 
 static void
-changeRow(const pixel * const inrow, 
-          pixel *       const outrow, 
+changeRow(const pixel * const inrow,
+          pixel *       const outrow,
           int           const cols,
-          int           const ncolors, 
-          const pixel         colorfrom[], 
+          int           const ncolors,
+          const pixel         colorfrom[],
           const pixel         colorto[],
-          bool          const remainder_specified, 
-          pixel         const remainder_color, 
+          bool          const remainder_specified,
+          pixel         const remainder_color,
           unsigned int  const allowableDiff) {
 /*----------------------------------------------------------------------------
-   Replace the colors in a single row.  There are 'ncolors' colors to 
+   Replace the colors in a single row.  There are 'ncolors' colors to
    replace.  The to-replace colors are in the array colorfrom[], and the
    replace-with colors are in corresponding elements of colorto[].
    Iff 'remainder_specified' is true, replace all colors not mentioned
-   in colorfrom[] with 'remainder_color'.  
+   in colorfrom[] with 'remainder_color'.
 
    Consider the color in inrow[] to match a color in colorfrom[] if it is
    within 'allowableDiff' color levels of it, in cartesian distance (e.g.
@@ -155,7 +155,7 @@ changeRow(const pixel * const inrow,
     for (col = 0; col < cols; ++col) {
         unsigned int i;
         bool haveMatch; /* logical: It's a color user said to change */
-        pixel newcolor;  
+        pixel newcolor;
         /* Color to which we must change current pixel.  Undefined unless
            'haveMatch' is true.
         */
@@ -205,7 +205,7 @@ main(int argc, const char ** const argv) {
     pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
-    
+
     ifP = pm_openr(cmdline.input_filespec);
 
     ppm_readppminit(ifP, &cols, &rows, &maxval, &format);
@@ -213,7 +213,7 @@ main(int argc, const char ** const argv) {
     if (cmdline.remainder_colorname)
         remainder_color = ppm_parsecolor2(cmdline.remainder_colorname, maxval,
                                           cmdline.closeok);
-    { 
+    {
         int i;
         for (i = 0; i < cmdline.ncolors; ++i) {
             oldcolor[i] = ppm_parsecolor2(cmdline.oldcolorname[i], maxval,
@@ -223,7 +223,7 @@ main(int argc, const char ** const argv) {
         }
     }
     allowableDiff = ROUNDU(sqrt3 * maxval * cmdline.closeness/100);
-    
+
     ppm_writeppminit( stdout, cols, rows, maxval, 0 );
     inrow = ppm_allocrow(cols);
     outrow = ppm_allocrow(cols);
diff --git a/editor/ppmdim.c b/editor/ppmdim.c
index 4e64965a..0bcc8ebb 100644
--- a/editor/ppmdim.c
+++ b/editor/ppmdim.c
@@ -1,4 +1,3 @@
-
 /*********************************************************************/
 /* ppmdim -  dim a picture down to total blackness                   */
 /* Frank Neumann, October 1993                                       */
@@ -29,84 +28,84 @@ int main(argc, argv)
 int argc;
 char *argv[];
 {
-	FILE* ifp;
-	int argn, rows, cols, format, i = 0, j = 0;
-	pixel *srcrow, *destrow;
-	pixel *pP = NULL, *pP2 = NULL;
-	pixval maxval;
-	double dimfactor;
-	long longfactor;
-	const char * const usage = "dimfactor [ppmfile]\n        dimfactor: 0.0 = total blackness, 1.0 = original picture\n";
-
-	/* parse in 'default' parameters */
-	ppm_init(&argc, argv);
-
-	argn = 1;
-
-	/* parse in dim factor */
-	if (argn == argc)
-		pm_usage(usage);
-	if (sscanf(argv[argn], "%lf", &dimfactor) != 1)
-		pm_usage(usage);
-	if (dimfactor < 0.0 || dimfactor > 1.0)
-		pm_error("dim factor must be in the range from 0.0 to 1.0 ");
-	++argn;
-
-	/* parse in filename (if present, stdin otherwise) */
-	if (argn != argc)
-	{
-		ifp = pm_openr(argv[argn]);
-		++argn;
-	}
-	else
-		ifp = stdin;
-
-	if (argn != argc)
-		pm_usage(usage);
-
-	/* read first data from file */
-	ppm_readppminit(ifp, &cols, &rows, &maxval, &format);
-
-	/* no error checking required here, ppmlib does it all for us */
-	srcrow = ppm_allocrow(cols);
-
-	longfactor = (long)(dimfactor * 65536);
-
-	/* allocate a row of pixel data for the new pixels */
-	destrow = ppm_allocrow(cols);
-
-	ppm_writeppminit(stdout, cols, rows, maxval, 0);
-
-	/** now do the dim'ing **/
-	/* the 'float' parameter for dimming is sort of faked - in fact, we */
-	/* convert it to a range from 0 to 65536 for integer math. Shouldn't */
-	/* be something you'll have to worry about, though. */
-
-	for (i = 0; i < rows; i++)
-	{
-		ppm_readppmrow(ifp, srcrow, cols, maxval, format);
-
-		pP = srcrow;
-		pP2 = destrow;
-
-		for (j = 0; j < cols; j++)
-		{
-			PPM_ASSIGN(*pP2, (PPM_GETR(*pP) * longfactor) >> 16,
-							 (PPM_GETG(*pP) * longfactor) >> 16,
-							 (PPM_GETB(*pP) * longfactor) >> 16);
-
-			pP++;
-			pP2++;
-		}
-
-		/* write out one line of graphic data */
-		ppm_writeppmrow(stdout, destrow, cols, maxval, 0);
-	}
-
-	pm_close(ifp);
-	ppm_freerow(srcrow);
-	ppm_freerow(destrow);
-
-	exit(0);
+        FILE* ifp;
+        int argn, rows, cols, format, i = 0, j = 0;
+        pixel *srcrow, *destrow;
+        pixel *pP = NULL, *pP2 = NULL;
+        pixval maxval;
+        double dimfactor;
+        long longfactor;
+        const char * const usage = "dimfactor [ppmfile]\n        dimfactor: 0.0 = total blackness, 1.0 = original picture\n";
+
+        /* parse in 'default' parameters */
+        ppm_init(&argc, argv);
+
+        argn = 1;
+
+        /* parse in dim factor */
+        if (argn == argc)
+                pm_usage(usage);
+        if (sscanf(argv[argn], "%lf", &dimfactor) != 1)
+                pm_usage(usage);
+        if (dimfactor < 0.0 || dimfactor > 1.0)
+                pm_error("dim factor must be in the range from 0.0 to 1.0 ");
+        ++argn;
+
+        /* parse in filename (if present, stdin otherwise) */
+        if (argn != argc)
+        {
+                ifp = pm_openr(argv[argn]);
+                ++argn;
+        }
+        else
+                ifp = stdin;
+
+        if (argn != argc)
+                pm_usage(usage);
+
+        /* read first data from file */
+        ppm_readppminit(ifp, &cols, &rows, &maxval, &format);
+
+        /* no error checking required here, ppmlib does it all for us */
+        srcrow = ppm_allocrow(cols);
+
+        longfactor = (long)(dimfactor * 65536);
+
+        /* allocate a row of pixel data for the new pixels */
+        destrow = ppm_allocrow(cols);
+
+        ppm_writeppminit(stdout, cols, rows, maxval, 0);
+
+        /** now do the dim'ing **/
+        /* the 'float' parameter for dimming is sort of faked - in fact, we */
+        /* convert it to a range from 0 to 65536 for integer math. Shouldn't */
+        /* be something you'll have to worry about, though. */
+
+        for (i = 0; i < rows; i++)
+        {
+                ppm_readppmrow(ifp, srcrow, cols, maxval, format);
+
+                pP = srcrow;
+                pP2 = destrow;
+
+                for (j = 0; j < cols; j++)
+                {
+                        PPM_ASSIGN(*pP2, (PPM_GETR(*pP) * longfactor) >> 16,
+                                                         (PPM_GETG(*pP) * longfactor) >> 16,
+                                                         (PPM_GETB(*pP) * longfactor) >> 16);
+
+                        pP++;
+                        pP2++;
+                }
+
+                /* write out one line of graphic data */
+                ppm_writeppmrow(stdout, destrow, cols, maxval, 0);
+        }
+
+        pm_close(ifp);
+        ppm_freerow(srcrow);
+        ppm_freerow(destrow);
+
+        exit(0);
 }
 
diff --git a/editor/ppmfade b/editor/ppmfade
index 7a346ddd..4e2c8367 100755
--- a/editor/ppmfade
+++ b/editor/ppmfade
@@ -35,7 +35,7 @@ exec perl -w -x -S -- "$0" "$@"
 #
 #  Inspired by the program Pbmfade by Wesley C. Barris of AHPCRC,
 #  Minnesota Supercomputer Center, Inc. January 7, 1994.  Pbmfade does
-#  much the same thing, but handles non-Netpbm formats too, and is 
+#  much the same thing, but handles non-Netpbm formats too, and is
 #  implemented in a more primitive language.
 #
 ##############################################################################
@@ -43,6 +43,14 @@ use strict;
 
 use File::Temp;
 
+#
+#  Define a couple linear ramps.
+#
+# We don't use element 0 of these arrays.
+my @spline10 = (0, 0, 0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 0.77, 0.88, 1.0);
+my @spline20 = (0, 0, 0.05, 0.11, 0.16, 0.21, 0.26, 0.32, 0.37, 0.42, 0.47,
+                0.53, 0.58, 0.63, 0.69, 0.74, 0.79, 0.84, 0.89, 0.95, 1.0);
+
 sub doVersionHack($) {
     my ($argvR) = @_;
 
@@ -58,282 +66,407 @@ my $tmpdir;
 
 $tmpdir = File::Temp::tempdir("ppmfade.XXXXXX", CLEANUP => 1);
 
-my $SPREAD =  1;
-my $SHIFT =   2;
-my $RELIEF =  3;
-my $OIL =     4;
-my $EDGE =    5;
-my $BENTLEY = 6;
-my $BLOCK =   7;
-my $MIX =     8;
-#
-#  Set some defaults.
-#
-my $nframes = 30;			# total number of files created (1 sec)
-my $first_file = "undefined";
-my $last_file = "undefined";
-my $base_name = "fade";		# default base name of output files
-my $image = "ppm";		# default output storage format
-my $mode = $SPREAD;		# default fading mode
+sub commandLineArgs() {
 
-doVersionHack(\@ARGV);
+    my ($firstFileNm, $lastFileNm, $mode, $baseNm);
 
-my $n;  # argument number
+    for (my $i = 0; $i < @ARGV; ++$i) {
+        my $arg = $ARGV[$i];
 
-for ($n = 0; $n < @ARGV; $n++) {
-    if ("$ARGV[$n]" eq "-f") {
-        $n++;
-        $first_file = $ARGV[$n];
-        if (-e $first_file) {
+        if (0) {
+        } elsif ($arg eq "-f") {
+            ++$i;
+            $firstFileNm = $ARGV[$i];
+        } elsif ($arg eq "-l") {
+            ++$i;
+            $lastFileNm = $ARGV[$i];
+        } elsif ($arg eq "-base") {
+            ++$i;
+            $baseNm = $ARGV[$i];
+        } elsif ($arg eq "-spread") {
+            $mode = 'SPREAD';
+        } elsif ($arg eq "-shift") {
+            $mode = 'SHIFT';
+        } elsif ($arg eq "-relief") {
+            $mode = 'RELIEF';
+        } elsif ($arg eq "-oil") {
+            $mode = 'OIL';
+        } elsif ($arg eq "-edge") {
+            $mode = 'EDGE';
+        } elsif ($arg eq "-bentley") {
+            $mode ='BENTLEY';
+        } elsif ($arg eq "-block") {
+            $mode = 'BLOCK';
+        } elsif ($arg eq "-mix") {
+            $mode = 'MIX';
         } else {
-            print "I can't find first file '$first_file'\n";
-            exit 20;
+            if (substr($arg, 0, 1) eq '-') {
+                   print STDERR ("Unknown option '$arg'.  " .
+                                 "We understand -f, -l, -base, " .
+                                 "-spread, -shift, -relief, -oil, -edge, " .
+                                 "-bentley, -block, and -mix\n");
+            } else {
+                print STDERR ("There are no non-option arguments possible.  " .
+                              "You specified '$arg'\n");
+            }
+            exit 100;
         }
-    } elsif ($ARGV[$n] eq "-l") {
-        $n++;
-        $last_file = $ARGV[$n];
-        if (-e $last_file) {
+    }
+
+    if (!defined($firstFileNm) && !defined($lastFileNm)) {
+        print STDERR ("You must specify -f or -l (or both)\n");
+        exit 90;
+    }
+
+    if (!defined($mode)) {
+        $mode = 'SPREAD';
+    }
+
+    if (!defined($baseNm)) {
+        $baseNm = 'fade';
+    }
+
+    return $mode, $firstFileNm, $lastFileNm, $baseNm;
+}
+
+
+
+sub imageDimensions($$) {
+    my ($firstFileNm, $lastFileNm) = @_;
+
+    my ($width, $height);
+
+    if (defined($firstFileNm)) {
+        if ((`pnmfile $firstFileNm` =~ m{\b(\d+)\sby\s(\d+)} )) {
+            $width = $1; $height = $2;
         } else {
-            print "I can't find last file '$last_file'\n";
-            exit 20;
+            print STDERR
+                ("Unrecognized results from pnmfile on $firstFileNm.\n");
+            exit(50);
         }
-    } elsif ($ARGV[$n] eq "-base") {
-        $n++;
-        $base_name = $ARGV[$n];
-    } elsif ($ARGV[$n] eq "-spread") {
-        $mode = $SPREAD;
-    } elsif ($ARGV[$n] eq "-shift") {
-        $mode = $SHIFT;
-    } elsif ($ARGV[$n] eq "-relief") {
-        $mode = $RELIEF;
-    } elsif ($ARGV[$n] eq "-oil") {
-        $mode = $OIL;
-    } elsif ("$ARGV[$n]" eq "-edge") {
-        $mode = $EDGE;
-    } elsif ("$ARGV[$n]" eq "-bentley") {
-        $mode = $BENTLEY;
-    } elsif ("$ARGV[$n]" eq "-block") {
-        $mode = $BLOCK;
-    } elsif ("$ARGV[$n]" eq "-mix") {
-        $mode = $MIX;
     } else {
-        print "Unknown argument: $ARGV[$n]\n";
-        exit 100;
-    } 
+        # $lastFileNm is defined
+        if ((`pnmfile $lastFileNm` =~ m{\b(\d+)\sby\s(\d+)} )) {
+            $width = $1; $height = $2;
+        } else {
+            print STDERR
+                ("Unrecognized results from pnmfile on $firstFileNm.\n");
+            exit(50);
+        }
+    }
+    return $width, $height;
 }
-#
-#  Define a couple linear ramps.
-#
-# We don't use element 0 of these arrays.
-my @spline10 = (0, 0, 0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 0.77, 0.88, 1.0);
-my @spline20 = (0, 0, 0.05, 0.11, 0.16, 0.21, 0.26, 0.32, 0.37, 0.42, 0.47, 
-                0.53, 0.58, 0.63, 0.69, 0.74, 0.79, 0.84, 0.89, 0.95, 1.0);
-#
-#  Just what are we supposed to do?
-#
-my ($height, $width);    # width and height of our frames
-if ($first_file ne "undefined") {
-    if ((`pnmfile $first_file` =~ m{\b(\d+)\sby\s(\d+)} )) { 
-        $width = $1; $height = $2;
+
+
+
+sub spreadOne($) {
+    my ($frameNum) = @_;
+
+    if ($frameNum <= 10) {
+        my $n = $spline20[$frameNum] * 100;
+        system("ppmspread $n $tmpdir/first.ppm >$tmpdir/this.ppm");
+    } elsif ($frameNum <= 20) {
+        my $n;
+        $n = $spline20[$frameNum] * 100;
+        system("ppmspread $n $tmpdir/first.ppm >$tmpdir/junk1a.ppm");
+        $n = (1-$spline20[$frameNum-10]) * 100;
+        system("ppmspread $n $tmpdir/last.ppm >$tmpdir/junk2a.ppm");
+        $n = $spline10[$frameNum-10];
+        system("ppmmix $n $tmpdir/junk1a.ppm $tmpdir/junk2a.ppm " .
+               ">$tmpdir/this.ppm");
     } else {
-        print("Unrecognized results from pnmfile on $first_file.\n");
-        exit(50);
+        my $n = (1-$spline20[$frameNum-10])*100;
+        system("ppmspread $n $tmpdir/last.ppm >$tmpdir/this.ppm");
     }
-} elsif ($last_file ne "undefined") {
-    if ((`pnmfile $last_file` =~ m{\b(\d+)\sby\s(\d+)} )) { 
-        $width = $1; $height = $2;
+}
+
+
+
+sub shiftOne($) {
+    my ($frameNum) = @_;
+
+    if ($frameNum <= 10) {
+        my $n = $spline20[$frameNum] * 100;
+        system("ppmshift $n $tmpdir/first.ppm >$tmpdir/this.ppm");
+    } elsif ($frameNum <= 20) {
+        my $n;
+        $n = $spline20[$frameNum] * 100;
+        system("ppmshift $n $tmpdir/first.ppm >$tmpdir/junk1a.ppm");
+        $n = (1-$spline20[$frameNum-10])*100;
+        system("ppmshift $n $tmpdir/last.ppm >$tmpdir/junk2a.ppm");
+        $n = $spline10[$frameNum-10];
+        system("ppmmix $n $tmpdir/junk1a.ppm $tmpdir/junk2a.ppm " .
+               ">$tmpdir/this.ppm");
     } else {
-        print("Unrecognized results from pnmfile on $first_file.\n");
-        exit(50);
+        my $n = (1-$spline20[$frameNum-10]) * 100;
+        system("ppmshift $n $tmpdir/last.ppm >$tmpdir/this.ppm");
     }
-} else {
-    print("ppmfade:  You must specify -f or -l (or both)\n");
-    exit(90);
 }
 
-print("Frames are " . $width . "W x " . $height . "H\n");
 
-if ($first_file eq "undefined") {
-    print "Fading from black to ";
-    system("ppmmake \\#000 $width $height >$tmpdir/junk1.ppm");
-} else {
-    print "Fading from $first_file to ";
-    system("cp", $first_file, "$tmpdir/junk1.ppm");
+
+sub reliefOne($) {
+    my ($frameNum) = @_;
+
+    if ($frameNum == 1) {
+        system("ppmrelief $tmpdir/first.ppm >$tmpdir/junk1r.ppm");
+    }
+    if ($frameNum <= 10) {
+        my $n = $spline10[$frameNum];
+        system("ppmmix $n $tmpdir/first.ppm $tmpdir/junk1r.ppm " .
+               ">$tmpdir/this.ppm");
+    } elsif ($frameNum <= 20) {
+        my $n = $spline10[$frameNum-10];
+        system("ppmmix $n $tmpdir/junk1r.ppm $tmpdir/junk2r.ppm " .
+               ">$tmpdir/this.ppm");
+    } else {
+        my $n = $spline10[$frameNum-20];
+        system("ppmmix $n $tmpdir/junk2r.ppm $tmpdir/last.ppm " .
+               ">$tmpdir/this.ppm");
+    }
+    if ($frameNum == 10) {
+        system("ppmrelief $tmpdir/last.ppm >$tmpdir/junk2r.ppm");
+    }
 }
 
-if ($last_file eq "undefined") {
-    print "black.\n";
-    system("ppmmake \\#000 $width $height >$tmpdir/junk2.ppm");
-} else {
-    print "$last_file\n";
-    system("cp", $last_file, "$tmpdir/junk2.ppm");
+
+
+sub oilOne($) {
+    my ($frameNum) = @_;
+
+    if ($frameNum == 1) {
+        system("ppmtopgm $tmpdir/first.ppm | pgmoil >$tmpdir/junko.ppm");
+        system("rgb3toppm " .
+               "$tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
+               ">$tmpdir/junk1o.ppm");
+    }
+    if ($frameNum <= 10) {
+        my $n = $spline10[$frameNum];
+        system("ppmmix $n $tmpdir/first.ppm $tmpdir/junk1o.ppm " .
+               ">$tmpdir/this.ppm");
+    } elsif ($frameNum <= 20) {
+        my $n = $spline10[$frameNum-10];
+        system("ppmmix $n $tmpdir/junk1o.ppm $tmpdir/junk2o.ppm " .
+               ">$tmpdir/this.ppm");
+    } else {
+        my $n = $spline10[$frameNum-20];
+        system("ppmmix $n $tmpdir/junk2o.ppm $tmpdir/last.ppm " .
+               ">$tmpdir/this.ppm");
+    }
+    if ($frameNum == 10) {
+        system("ppmtopgm $tmpdir/last.ppm | pgmoil >$tmpdir/junko.ppm");
+        system("rgb3toppm " .
+               "$tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
+               ">$tmpdir/junk2o.ppm");
+    }
+}
+
+
+
+sub edgeOne($) {
+    my ($frameNum) = @_;
+
+    if ($frameNum == 1) {
+        system("ppmtopgm $tmpdir/first.ppm | pgmedge >$tmpdir/junko.ppm");
+        system("rgb3toppm " .
+               "$tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
+               ">$tmpdir/junk1o.ppm");
+    }
+    if ($frameNum <= 10) {
+        my $n = $spline10[$frameNum];
+        system("ppmmix $n $tmpdir/first.ppm $tmpdir/junk1o.ppm " .
+               ">$tmpdir/this.ppm");
+    } elsif ($frameNum <= 20) {
+        my $n = $spline10[$frameNum-10];
+        system("ppmmix $n $tmpdir/junk1o.ppm $tmpdir/junk2o.ppm " .
+               ">$tmpdir/this.ppm");
+    } else {
+        my $n = $spline10[$frameNum-20];
+        system("ppmmix $n $tmpdir/junk2o.ppm $tmpdir/last.ppm " .
+               ">$tmpdir/this.ppm");
+    }
+    if ($frameNum == 10) {
+        system("ppmtopgm $tmpdir/last.ppm | pgmedge >$tmpdir/junko.ppm");
+        system("rgb3toppm " .
+               "$tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
+               ">$tmpdir/junk2o.ppm");
+    }
 }
 
+
+
+sub bentleyOne($) {
+    my ($frameNum) = @_;
+
+    if ($frameNum == 1) {
+        system("ppmtopgm $tmpdir/first.ppm | pgmbentley >$tmpdir/junko.ppm");
+        system("rgb3toppm " .
+               "$tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
+               ">$tmpdir/junk1o.ppm");
+    }
+    if ($frameNum <= 10) {
+        my $n = $spline10[$frameNum];
+        system("ppmmix $n $tmpdir/first.ppm $tmpdir/junk1o.ppm " .
+               ">$tmpdir/this.ppm");
+    } elsif ($frameNum <= 20) {
+        my $n = $spline10[$frameNum-10];
+        system("ppmmix $n $tmpdir/junk1o.ppm $tmpdir/junk2o.ppm " .
+               ">$tmpdir/this.ppm");
+    } else {
+        my $n = $spline10[$frameNum-20];
+        system("ppmmix $n $tmpdir/junk2o.ppm $tmpdir/last.ppm " .
+               ">$tmpdir/this.ppm");
+    }
+    if ($frameNum == 10) {
+        system("ppmtopgm $tmpdir/last.ppm | pgmbentley " .
+               ">$tmpdir/junko.ppm");
+        system("rgb3toppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
+               "$tmpdir/junko.ppm " .
+               ">$tmpdir/junk2o.ppm");
+    }
+}
+
+
+
+sub blockOne($$$) {
+    my ($frameNum, $width, $height) = @_;
+
+    if ($frameNum <= 10) {
+        my $n = 1 - 1.9*$spline20[$frameNum];
+        system("pamscale $n $tmpdir/first.ppm | " .
+               "pamscale -width $width -height $height " .
+               ">$tmpdir/this.ppm");
+        if ($frameNum == 10) {
+            system("cp", "$tmpdir/this.ppm", "$tmpdir/junk1a.ppm");
+            system("pamscale $n $tmpdir/last.ppm | " .
+                   "pamscale -width $width -height $height " .
+                   ">$tmpdir/junk2a.ppm");
+        }
+    } elsif ($frameNum <= 20) {
+        my $n = $spline10[$frameNum-10];
+        system("ppmmix $n $tmpdir/junk1a.ppm $tmpdir/junk2a.ppm " .
+               ">$tmpdir/this.ppm");
+    } else {
+        my $n = 1 - 1.9*$spline20[31-$frameNum];
+        system("pamscale $n $tmpdir/last.ppm | " .
+               "pamscale -width $width -height $height " .
+               ">$tmpdir/this.ppm");
+    }
+}
+
+
+
+sub mixOne($$) {
+    my ($frameNum, $nFrame) = @_;
+
+    my $fadeFactor = sqrt(1/($nFrame - $frameNum + 1));
+
+    system("ppmmix $fadeFactor $tmpdir/first.ppm $tmpdir/last.ppm " .
+           ">$tmpdir/this.ppm");
+}
+
+
+
+sub fade($$$$$) {
+    my ($nFrame, $mode, $width, $height, $baseNm) = @_;
+#-----------------------------------------------------------------------------
+#  Do the fade starting, from image "first.ppm" in the temporary direct
+#  $tmpdir and ending up at "last.ppm", creating $nFrame frames, including
+#  the first and last.
 #
-#  Perform the fade.
+#  Make the outputs $width by $height.
 #
+#  Name the result files $baseNm.NNNN.ppm.
+#-----------------------------------------------------------------------------
 
-# Here's what our temporary files are:
-#   junk1.ppm: The original (fade-from) image
-#   junk2.ppm: The target (fade-from) image
-#   junk3.ppm: The frame of the fade for the current iteration of the 
-#              the for loop.
-#   junk1a.ppm: If the fade involves a ppmmix sequence from one intermediate
-#               image to another, this is the first frame of that 
-#               sequence.
-#   junk2a.ppm: This is the last frame of the above-mentioned ppmmix sequence
-
-my $i;    # Frame number
-for ($i = 1; $i <= $nframes; $i++) {
-    print("Creating $i of $nframes...\n");
-    if ($mode eq $SPREAD) {
-        if ($i <= 10) {
-            my $n = $spline20[$i] * 100;
-            system("ppmspread $n $tmpdir/junk1.ppm >$tmpdir/junk3.ppm");
-        } elsif ($i <= 20) {
-            my $n;
-            $n = $spline20[$i] * 100;
-            system("ppmspread $n $tmpdir/junk1.ppm >$tmpdir/junk1a.ppm");
-            $n = (1-$spline20[$i-10]) * 100;
-            system("ppmspread $n $tmpdir/junk2.ppm >$tmpdir/junk2a.ppm");
-            $n = $spline10[$i-10];
-            system("ppmmix $n $tmpdir/junk1a.ppm $tmpdir/junk2a.ppm " .
-                   ">$tmpdir/junk3.ppm");
-        } else {
-            my $n = (1-$spline20[$i-10])*100;
-            system("ppmspread $n $tmpdir/junk2.ppm >$tmpdir/junk3.ppm");
-        }
-    } elsif ($mode eq $SHIFT) {
-        if ($i <= 10) {
-            my $n = $spline20[$i] * 100;
-            system("ppmshift $n $tmpdir/junk1.ppm >$tmpdir/junk3.ppm");
-        } elsif ($i <= 20) {
-            my $n;
-            $n = $spline20[$i] * 100;
-            system("ppmshift $n $tmpdir/junk1.ppm >$tmpdir/junk1a.ppm");
-            $n = (1-$spline20[$i-10])*100;
-            system("ppmshift $n $tmpdir/junk2.ppm >$tmpdir/junk2a.ppm");
-            $n = $spline10[$i-10];
-            system("ppmmix $n $tmpdir/junk1a.ppm $tmpdir/junk2a.ppm >$tmpdir/junk3.ppm");
-        } else {
-            my $n = (1-$spline20[$i-10]) * 100;
-            system("ppmshift $n $tmpdir/junk2.ppm >$tmpdir/junk3.ppm");
-        }
-    } elsif ($mode eq $RELIEF) {
-        if ($i == 1) {
-            system("ppmrelief $tmpdir/junk1.ppm >$tmpdir/junk1r.ppm");
-        }
-        if ($i <= 10) {
-            my $n = $spline10[$i];
-            system("ppmmix $n $tmpdir/junk1.ppm $tmpdir/junk1r.ppm >$tmpdir/junk3.ppm");
-        } elsif ($i <= 20) {
-            my $n = $spline10[$i-10];
-            system("ppmmix $n $tmpdir/junk1r.ppm $tmpdir/junk2r.ppm >$tmpdir/junk3.ppm");
-        } else {
-            my $n = $spline10[$i-20];
-            system("ppmmix $n $tmpdir/junk2r.ppm $tmpdir/junk2.ppm >$tmpdir/junk3.ppm");
-        }
-        if ($i == 10) {
-            system("ppmrelief $tmpdir/junk2.ppm >$tmpdir/junk2r.ppm");
-        }
-    } elsif ($mode eq $OIL) {
-        if ($i == 1) {
-            system("ppmtopgm $tmpdir/junk1.ppm | pgmoil >$tmpdir/junko.ppm");
-            system("rgb3toppm $tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
-                   ">$tmpdir/junk1o.ppm");
-        }
-        if ($i <= 10) {
-            my $n = $spline10[$i];
-            system("ppmmix $n $tmpdir/junk1.ppm $tmpdir/junk1o.ppm >$tmpdir/junk3.ppm");
-        } elsif ($i <= 20) {
-            my $n = $spline10[$i-10];
-            system("ppmmix $n $tmpdir/junk1o.ppm $tmpdir/junk2o.ppm >$tmpdir/junk3.ppm");
-        } else {
-            my $n = $spline10[$i-20];
-            system("ppmmix $n $tmpdir/junk2o.ppm $tmpdir/junk2.ppm >$tmpdir/junk3.ppm");
-        }
-        if ($i == 10) {
-            system("ppmtopgm $tmpdir/junk2.ppm | pgmoil >$tmpdir/junko.ppm");
-            system("rgb3toppm $tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
-                   ">$tmpdir/junk2o.ppm");
-        }
-    } elsif ($mode eq $EDGE) {
-        if ($i == 1) {
-            system("ppmtopgm $tmpdir/junk1.ppm | pgmedge >$tmpdir/junko.ppm");
-            system("rgb3toppm $tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
-                   ">$tmpdir/junk1o.ppm");
-        }
-        if ($i <= 10) {
-            my $n = $spline10[$i];
-            system("ppmmix $n $tmpdir/junk1.ppm $tmpdir/junk1o.ppm >$tmpdir/junk3.ppm");
-        } elsif ($i <= 20) {
-            my $n = $spline10[$i-10];
-            system("ppmmix $n $tmpdir/junk1o.ppm $tmpdir/junk2o.ppm >$tmpdir/junk3.ppm");
-        } else {
-            my $n = $spline10[$i-20];
-            system("ppmmix $n $tmpdir/junk2o.ppm $tmpdir/junk2.ppm >$tmpdir/junk3.ppm");
-        }
-        if ($i == 10) {
-            system("ppmtopgm $tmpdir/junk2.ppm | pgmedge >$tmpdir/junko.ppm");
-            system("rgb3toppm $tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
-                   ">$tmpdir/junk2o.ppm");
-        } 
-    } elsif ($mode eq $BENTLEY) {
-        if ($i == 1) {
-            system("ppmtopgm $tmpdir/junk1.ppm | pgmbentley >$tmpdir/junko.ppm");
-            system("rgb3toppm $tmpdir/junko.ppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
-                   ">$tmpdir/junk1o.ppm");
-        }
-        if ($i <= 10) {
-            my $n = $spline10[$i];
-            system("ppmmix $n $tmpdir/junk1.ppm $tmpdir/junk1o.ppm >$tmpdir/junk3.ppm");
-        } elsif ($i <= 20) {
-            my $n = $spline10[$i-10];
-            system("ppmmix $n $tmpdir/junk1o.ppm $tmpdir/junk2o.ppm >$tmpdir/junk3.ppm");
-        } else {
-            my $n = $spline10[$i-20];
-            system("ppmmix $n $tmpdir/junk2o.ppm $tmpdir/junk2.ppm " .
-                   ">$tmpdir/junk3.ppm");
-        }
-        if ($i == 10) {
-               system("ppmtopgm $tmpdir/junk2.ppm | pgmbentley " .
-                      ">$tmpdir/junko.ppm");
-            system("rgb3toppm $tmpdir/junko.ppm $tmpdir/junko.ppm " .
-                   "$tmpdir/junko.ppm " .
-                   ">$tmpdir/junk2o.ppm");
-        }
-    } elsif ($mode eq $BLOCK) {
-        if ($i <= 10) {
-            my $n = 1 - 1.9*$spline20[$i];
-            system("pamscale $n $tmpdir/junk1.ppm | " .
-                   "pamscale -width $width -height $height " .
-                   ">$tmpdir/junk3.ppm");
-            if ($i == 10) {
-                   system("cp", "$tmpdir/junk3.ppm", "$tmpdir/junk1a.ppm");
-                   system("pamscale $n $tmpdir/junk2.ppm | " .
-                          "pamscale -width $width -height $height " .
-                          ">$tmpdir/junk2a.ppm");
-               }
-        } elsif ($i <= 20) {
-            my $n = $spline10[$i-10];
-            system("ppmmix $n $tmpdir/junk1a.ppm $tmpdir/junk2a.ppm " .
-                   ">$tmpdir/junk3.ppm");
+    # Here's what our temporary files are:
+    #   first.ppm: The original (fade-from) image
+    #   last.ppm: The target (fade-from) image
+    #   this.ppm: The frame of the fade for the current iteration of the
+    #             the for loop.
+    #   junk1a.ppm: If the fade involves a ppmmix sequence from one
+    #               intermediate image to another, this is the first frame
+    #               of that sequence.
+    #   junk2a.ppm: This is the last frame of the above-mentioned
+    #               ppmmix sequence
+
+    my $frameNum;    # Frame number
+    for ($frameNum = 1; $frameNum <= $nFrame; ++$frameNum) {
+
+        print("Creating Frame $frameNum of $nFrame...\n");
+
+        if ($mode eq 'SPREAD') {
+            spreadOne($frameNum);
+        } elsif ($mode eq 'SHIFT') {
+            shiftOne($frameNum);
+        } elsif ($mode eq 'RELIEF') {
+            reliefOne($frameNum);
+        } elsif ($mode eq 'OIL') {
+            oilOne($frameNum);
+        } elsif ($mode eq 'EDGE') {
+            edgeOne($frameNum);
+        } elsif ($mode eq 'BENTLEY') {
+            bentleyOne($frameNum);
+        } elsif ($mode eq 'BLOCK') {
+            blockOne($frameNum, $width, $height);
+        } elsif ($mode eq 'MIX') {
+            mixOne($frameNum, $nFrame);
         } else {
-            my $n = 1 - 1.9*$spline20[31-$i];
-            system("pamscale $n $tmpdir/junk2.ppm | " .
-                   "pamscale -width $width -height $height " .
-                   ">$tmpdir/junk3.ppm");
+            print("INTERNAL ERROR: impossible mode value '$mode'\n");
         }
-    } elsif ($mode eq $MIX) {
-        my $fade_factor = sqrt(1/($nframes-$i+1));
-        system("ppmmix $fade_factor $tmpdir/junk1.ppm $tmpdir/junk2.ppm " .
-               ">$tmpdir/junk3.ppm");
-    } else {
-        print("Internal error: impossible mode value '$mode'\n");
+
+        my $outFileNm = sprintf("%s.%04d.ppm", $baseNm, $frameNum);
+        system("cp", "$tmpdir/this.ppm", $outFileNm);
     }
+}
+
+
+
+#-----------------------------------------------------------------------------
+#  MAINLINE
+#-----------------------------------------------------------------------------
+
+my $nFrame = 30;
+    # Number of images in created sequence, including the fade-from and
+    # fade-to images.  In standard video, 30 frames is one second.
 
-    my $outfile = sprintf("%s.%04d.ppm", $base_name, $i);
-    system("cp", "$tmpdir/junk3.ppm", $outfile);
+doVersionHack(\@ARGV);
+
+my ($mode, $firstFileNm, $lastFileNm, $baseNm) = commandLineArgs();
+
+if (defined($firstFileNm) && !-e($firstFileNm)) {
+    print STDERR ("First file '$firstFileNm' does not exist\n");
+    exit 20;
+}
+
+if (defined($lastFileNm) && !-e($lastFileNm)) {
+    print STDERR ("Last file '$lastFileNm' does not exist\n");
+    exit 20;
+}
+
+my ($width, $height) = imageDimensions($firstFileNm, $lastFileNm);
+
+    # width and height of our frames in pixels
+
+print("Frames are " . $width . "W x " . $height . "H\n");
+
+my $fromDesc = defined($firstFileNm) ? "'$firstFileNm'" : "black";
+my $toDesc   = defined($lastFileNm)  ? "'$lastFileNm'"  : "black";
+
+if (!defined($firstFileNm)) {
+    system("ppmmake \\#000 $width $height >$tmpdir/first.ppm");
+} else {
+    system("cp", $firstFileNm, "$tmpdir/first.ppm");
 }
 
+if (!defined($lastFileNm)) {
+    system("ppmmake \\#000 $width $height >$tmpdir/last.ppm");
+} else {
+    system("cp", $lastFileNm, "$tmpdir/last.ppm");
+}
+
+print("Fading from $fromDesc to $toDesc\n");
+
+fade($nFrame, $mode, $width, $height, $baseNm);
+
 exit(0);
diff --git a/editor/ppmflash.c b/editor/ppmflash.c
index d1d048df..c8335890 100644
--- a/editor/ppmflash.c
+++ b/editor/ppmflash.c
@@ -1,4 +1,3 @@
-
 /*********************************************************************/
 /* ppmflash -  brighten a picture up to total whiteout               */
 /* Frank Neumann, August 1993                                        */
@@ -89,12 +88,12 @@ int main(argc, argv)
         pP2 = destrow;
 
         for (j = 0; j < cols; j++) {
-            PPM_ASSIGN(*pP2, 
-                       PPM_GETR(*pP) + 
+            PPM_ASSIGN(*pP2,
+                       PPM_GETR(*pP) +
                        (((maxval - PPM_GETR(*pP)) * longfactor) >> 16),
-                       PPM_GETG(*pP) + 
+                       PPM_GETG(*pP) +
                        (((maxval - PPM_GETG(*pP)) * longfactor) >> 16),
-                       PPM_GETB(*pP) + 
+                       PPM_GETB(*pP) +
                        (((maxval - PPM_GETB(*pP)) * longfactor) >> 16));
 
             pP++;
diff --git a/editor/ppmlabel.c b/editor/ppmlabel.c
index 389ab59e..21e7d84c 100644
--- a/editor/ppmlabel.c
+++ b/editor/ppmlabel.c
@@ -26,7 +26,7 @@ static pixel rgbcolor, backcolor;
 /*  DRAWTEXT  --  Draw text at current location and advance to
           start of next line.  */
 
-static void 
+static void
 drawtext(const char * const text) {
 
     if (!transparent && strlen(text) > 0) {
@@ -38,10 +38,10 @@ drawtext(const char * const text) {
         double sina, cosa;
 
         handle = ppmd_fill_create();
-        
+
         ppmd_text_box(size, 0, text, &left, &top, &right, &bottom);
 
-        /* Displacement vector */ 
+        /* Displacement vector */
 
         lx = right;
         ly = -(top - bottom);
diff --git a/editor/specialty/pamdeinterlace.c b/editor/specialty/pamdeinterlace.c
index d6f6aee1..666daa16 100644
--- a/editor/specialty/pamdeinterlace.c
+++ b/editor/specialty/pamdeinterlace.c
@@ -2,7 +2,7 @@
                              pamdeinterlace
 *******************************************************************************
   De-interlace an image, i.e. select every 2nd row.
-   
+
   By Bryan Henderson, San Jose, CA 2001.11.11.
 
   Contributed to the public domain.
@@ -81,7 +81,7 @@ main(int argc, char *argv[]) {
     tuple * tuplerow;   /* Row from input image */
     unsigned int row;
     struct cmdlineInfo cmdline;
-    struct pam inpam;  
+    struct pam inpam;
     struct pam outpam;
 
     pnm_init( &argc, argv );
@@ -89,7 +89,7 @@ main(int argc, char *argv[]) {
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFilespec);
-    
+
     pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
     if (inpam.height < 2 && cmdline.rowsToTake == ODD)
@@ -133,7 +133,7 @@ main(int argc, char *argv[]) {
     pnm_freepamrow(tuplerow);
     pm_close(inpam.file);
     pm_close(outpam.file);
-    
+
     return 0;
 }
 
diff --git a/editor/specialty/pamoil.c b/editor/specialty/pamoil.c
index 6cb8d3ac..2618ac12 100644
--- a/editor/specialty/pamoil.c
+++ b/editor/specialty/pamoil.c
@@ -18,7 +18,7 @@
 #include "pam.h"
 #include "mallocvar.h"
 
-static void 
+static void
 convertRow(struct pam const inpam, tuple ** const tuples,
            tuple * const tuplerow, int const row, int const smearFactor,
            int * const hist) {
@@ -34,7 +34,7 @@ convertRow(struct pam const inpam, tuple ** const tuples,
                    of the pixel being examined
                 */
 
-            /* Compute hist[] - frequencies, in the neighborhood, of each 
+            /* Compute hist[] - frequencies, in the neighborhood, of each
                sample value
             */
             for (i = 0; i <= inpam.maxval; ++i) hist[i] = 0;
@@ -42,8 +42,8 @@ convertRow(struct pam const inpam, tuple ** const tuples,
             for (drow = row - smearFactor; drow <= row + smearFactor; ++drow) {
                 if (drow >= 0 && drow < inpam.height) {
                     int dcol;
-                    for (dcol = col - smearFactor; 
-                         dcol <= col + smearFactor; 
+                    for (dcol = col - smearFactor;
+                         dcol <= col + smearFactor;
                          ++dcol) {
                         if ( dcol >= 0 && dcol < inpam.width )
                             ++hist[tuples[drow][dcol][sample]];
diff --git a/editor/specialty/pampop9.c b/editor/specialty/pampop9.c
index b92c7d6b..7211c5eb 100644
--- a/editor/specialty/pampop9.c
+++ b/editor/specialty/pampop9.c
@@ -1,4 +1,4 @@
-/* 
+/*
  *
  * (c) Robert Tinsley, 2003 (http://www.thepoacher.net/contact)
  *
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
     ydelta = atoi(argv[5]);
 
     if (filename == NULL || *filename == '\0'
-        || xtiles <= 0 || ytiles <= 0 || xdelta < 0 || ydelta < 0) 
+        || xtiles <= 0 || ytiles <= 0 || xdelta < 0 || ydelta < 0)
         pm_error("invalid argument");
 
     /* read src pam */
diff --git a/editor/specialty/pbmlife.c b/editor/specialty/pbmlife.c
index be34cc69..03735d58 100644
--- a/editor/specialty/pbmlife.c
+++ b/editor/specialty/pbmlife.c
@@ -31,12 +31,12 @@ char* argv[];
     pbm_init( &argc, argv );
 
     if ( argc > 2 )
-	pm_usage( "[pbmfile]" );
+        pm_usage( "[pbmfile]" );
 
     if ( argc == 2 )
-	ifp = pm_openr( argv[1] );
+        ifp = pm_openr( argv[1] );
     else
-	ifp = stdin;
+        ifp = stdin;
 
     pbm_readpbminit( ifp, &cols, &rows, &format );
     prevrow = pbm_allocrow( cols );
@@ -49,63 +49,63 @@ char* argv[];
     pbm_readpbmrow( ifp, nextrow, cols, format );
 
     for ( row = 0; row < rows; ++row )
-	{
-	temprow = prevrow;
-	prevrow = thisrow;
-	thisrow = nextrow;
-	nextrow = temprow;
-	if ( row < rows - 1 )
-	    pbm_readpbmrow( ifp, nextrow, cols, format );
+        {
+        temprow = prevrow;
+        prevrow = thisrow;
+        thisrow = nextrow;
+        nextrow = temprow;
+        if ( row < rows - 1 )
+            pbm_readpbmrow( ifp, nextrow, cols, format );
 
         for ( col = 0; col < cols; ++col )
-	    {
-	    /* Check the neighborhood, with an unrolled double loop. */
-	    count = 0;
-	    if ( row > 0 )
-		{
-		/* upper left */
-		if ( col > 0 && prevrow[col - 1] == PBM_WHITE )
-		    ++count;
-		/* upper center */
-		if ( prevrow[col] == PBM_WHITE )
-		    ++count;
-		/* upper right */
-		if ( col < cols - 1 && prevrow[col + 1] == PBM_WHITE )
-		    ++count;
-		}
-	    /* left */
-	    if ( col > 0 && thisrow[col - 1] == PBM_WHITE )
-		++count;
-	    /* right */
-	    if ( col < cols - 1 && thisrow[col + 1] == PBM_WHITE )
-		++count;
-	    if ( row < rows - 1 )
-		{
-		/* lower left */
-		if ( col > 0 && nextrow[col - 1] == PBM_WHITE )
-		    ++count;
-		/* lower center */
-		if ( nextrow[col] == PBM_WHITE )
-		    ++count;
-		/* lower right */
-		if ( col < cols - 1 && nextrow[col + 1] == PBM_WHITE )
-		    ++count;
-		}
+            {
+            /* Check the neighborhood, with an unrolled double loop. */
+            count = 0;
+            if ( row > 0 )
+                {
+                /* upper left */
+                if ( col > 0 && prevrow[col - 1] == PBM_WHITE )
+                    ++count;
+                /* upper center */
+                if ( prevrow[col] == PBM_WHITE )
+                    ++count;
+                /* upper right */
+                if ( col < cols - 1 && prevrow[col + 1] == PBM_WHITE )
+                    ++count;
+                }
+            /* left */
+            if ( col > 0 && thisrow[col - 1] == PBM_WHITE )
+                ++count;
+            /* right */
+            if ( col < cols - 1 && thisrow[col + 1] == PBM_WHITE )
+                ++count;
+            if ( row < rows - 1 )
+                {
+                /* lower left */
+                if ( col > 0 && nextrow[col - 1] == PBM_WHITE )
+                    ++count;
+                /* lower center */
+                if ( nextrow[col] == PBM_WHITE )
+                    ++count;
+                /* lower right */
+                if ( col < cols - 1 && nextrow[col + 1] == PBM_WHITE )
+                    ++count;
+                }
 
-	    /* And compute the new value. */
-	    if ( thisrow[col] == PBM_WHITE )
-		if ( count == 2 || count == 3 )
-		    newrow[col] = PBM_WHITE;
-		else
-		    newrow[col] = PBM_BLACK;
-	    else
-		if ( count == 3 )
-		    newrow[col] = PBM_WHITE;
-		else
-		    newrow[col] = PBM_BLACK;
-	    }
-	pbm_writepbmrow( stdout, newrow, cols, 0 );
-	}
+            /* And compute the new value. */
+            if ( thisrow[col] == PBM_WHITE )
+                if ( count == 2 || count == 3 )
+                    newrow[col] = PBM_WHITE;
+                else
+                    newrow[col] = PBM_BLACK;
+            else
+                if ( count == 3 )
+                    newrow[col] = PBM_WHITE;
+                else
+                    newrow[col] = PBM_BLACK;
+            }
+        pbm_writepbmrow( stdout, newrow, cols, 0 );
+        }
 
     pm_close( ifp );
     pm_close( stdout );
diff --git a/editor/specialty/pgmabel.c b/editor/specialty/pgmabel.c
index 5badfd19..3e05be5e 100644
--- a/editor/specialty/pgmabel.c
+++ b/editor/specialty/pgmabel.c
@@ -117,7 +117,7 @@ abel ( float *y, int N, double *adl)
     for (n=0 ; n<N ; n++)
         {
             if (( n>=1 )&&( n<N-1 ))
-	       (*y++) = ((rho[n-1]*0.5+rho[n]+rho[n+1]*0.5)/2.0);/*1D median filter*/
+               (*y++) = ((rho[n-1]*0.5+rho[n]+rho[n+1]*0.5)/2.0);/*1D median filter*/
             else (*y++) = rho[n];
         }
     free(rho);
diff --git a/editor/specialty/pgmbentley.c b/editor/specialty/pgmbentley.c
index aed92074..87778a62 100644
--- a/editor/specialty/pgmbentley.c
+++ b/editor/specialty/pgmbentley.c
@@ -41,7 +41,7 @@ main(int argc, const char * argv[]) {
             pm_error("There are no options and only one argument.  "
                      "You specified %u", argc-1);
     }
-	ifP = pm_openr(inputFileName);
+        ifP = pm_openr(inputFileName);
 
     gin = pgm_readpgm(ifP, &cols, &rows, &maxval);
 
@@ -62,9 +62,9 @@ main(int argc, const char * argv[]) {
             unsigned int const brow = MIN(rows-1, row + gin[row][col] / N);
 
             gout[brow][col] = gin[row][col];
-	    }
+            }
     }
-     
+
     pgm_writepgm(stdout, gout, cols, rows, maxval, 0);
 
     pm_close(stdout);
diff --git a/editor/specialty/pgmmorphconv.c b/editor/specialty/pgmmorphconv.c
index 2ba2d62d..40ce5d76 100644
--- a/editor/specialty/pgmmorphconv.c
+++ b/editor/specialty/pgmmorphconv.c
@@ -1,9 +1,9 @@
-/* pgmmorphconv.c - morphological convolutions on a graymap: dilation and 
+/* pgmmorphconv.c - morphological convolutions on a graymap: dilation and
 ** erosion
 **
 ** Copyright (C) 2000 by Luuk van Dijk/Mind over Matter
 **
-** Based on 
+** Based on
 ** pnmconvol.c - general MxN convolution on a portable anymap
 **
 ** Copyright (C) 1989, 1991 by Jef Poskanzer.
@@ -95,7 +95,7 @@ parseCommandLine(int argc, const char ** const argv,
             cmdlineP->inputFileName = "-";
         else {
             cmdlineP->inputFileName = argv[2];
-            
+
             if (argc-1 > 2)
                 pm_error("Too many arguments: %u.  "
                          "The only possible arguments "
@@ -146,7 +146,7 @@ setAllPixel(gray **      const image,
     for (col = 0; col < cols; ++col) {
         unsigned int row;
         for (row = 0; row < rows; ++row)
-            image[row][col] = value; 
+            image[row][col] = value;
     }
 }
 
@@ -155,9 +155,9 @@ setAllPixel(gray **      const image,
 static void
 dilate(bit **         const template,
        int            const trowso2,
-       int            const tcolso2, 
+       int            const tcolso2,
        gray **        const inImage,
-       gray **        const outImage, 
+       gray **        const outImage,
        unsigned int   const rows,
        unsigned int   const cols,
        unsigned int * const templateCountP) {
@@ -198,9 +198,9 @@ dilate(bit **         const template,
 static void
 erode(bit **         const template,
       int            const trowso2,
-      int            const tcolso2, 
+      int            const tcolso2,
       gray **        const inImage,
-      gray **        const outImage, 
+      gray **        const outImage,
       unsigned int   const rows,
       unsigned int   const cols,
       unsigned int * const templateCountP) {
@@ -227,10 +227,10 @@ erode(bit **         const template,
                     for (c = ((tc > 0) ? 0 : -tc);
                          c < ((tc > 0) ? (cols-tc) : cols);
                          ++c) {
-                        
+
                         gray const source = inImage[r+tr][c+tc];
                         outImage[r][c] = MIN(source, outImage[r][c]);
-      
+
                     }
                 }
             }
@@ -244,9 +244,9 @@ erode(bit **         const template,
 static void
 openMorph(bit **         const template,
           int            const trowso2,
-          int            const tcolso2, 
+          int            const tcolso2,
           gray **        const inputImage,
-          gray **        const outputImage, 
+          gray **        const outputImage,
           unsigned int   const rows,
           unsigned int   const cols,
           unsigned int * const templateCountP) {
@@ -255,11 +255,11 @@ openMorph(bit **         const template,
     unsigned int erodedTemplateCount;
 
     erodedImage = pgm_allocarray(cols, rows);
-    
-    erode(template, trowso2, tcolso2, 
+
+    erode(template, trowso2, tcolso2,
           inputImage, erodedImage, rows, cols, &erodedTemplateCount);
 
-    dilate(template, trowso2, tcolso2, 
+    dilate(template, trowso2, tcolso2,
            erodedImage, outputImage, rows, cols, templateCountP);
 
     pgm_freearray(erodedImage, rows);
@@ -270,9 +270,9 @@ openMorph(bit **         const template,
 static void
 closeMorph(bit **         const template,
            int            const trowso2,
-           int            const tcolso2, 
+           int            const tcolso2,
            gray **        const inputImage,
-           gray **        const outputImage, 
+           gray **        const outputImage,
            unsigned int   const rows,
            unsigned int   const cols,
            unsigned int * const templateCountP) {
@@ -282,10 +282,10 @@ closeMorph(bit **         const template,
 
     dilatedImage = pgm_allocarray(cols, rows);
 
-    dilate(template, trowso2, tcolso2, 
+    dilate(template, trowso2, tcolso2,
            inputImage, dilatedImage, rows, cols, &dilatedTemplateCount);
 
-    erode(template, trowso2, tcolso2, 
+    erode(template, trowso2, tcolso2,
           dilatedImage, outputImage, rows, cols, templateCountP);
 
     pgm_freearray(dilatedImage, rows);
@@ -296,7 +296,7 @@ closeMorph(bit **         const template,
 static void
 subtract(gray **      const subtrahendImage,
          gray **      const subtractorImage,
-         gray **      const outImage, 
+         gray **      const outImage,
          unsigned int const rows,
          unsigned int const cols ) {
 
@@ -318,9 +318,9 @@ subtract(gray **      const subtrahendImage,
 static void
 gradient(bit **         const template,
          int            const trowso2,
-         int            const tcolso2, 
+         int            const tcolso2,
          gray **        const inputImage,
-         gray **        const outputImage, 
+         gray **        const outputImage,
          unsigned int   const rows,
          unsigned int   const cols,
          unsigned int * const templateCountP) {
@@ -328,14 +328,14 @@ gradient(bit **         const template,
     gray ** dilatedImage;
     gray ** erodedImage;
     unsigned int dilatedTemplateCount;
-    
+
     dilatedImage = pgm_allocarray(cols, rows);
     erodedImage = pgm_allocarray(cols, rows);
 
-    dilate(template, trowso2, tcolso2, 
+    dilate(template, trowso2, tcolso2,
            inputImage, dilatedImage, rows, cols, &dilatedTemplateCount);
 
-    erode(template, trowso2, tcolso2, 
+    erode(template, trowso2, tcolso2,
           inputImage, erodedImage, rows, cols, templateCountP);
 
     subtract(dilatedImage, erodedImage, outputImage, rows, cols);
@@ -369,14 +369,14 @@ main(int argc, const char ** argv) {
                        &template, &templateRows, &templateCols);
 
     /* Template coords run from -templateCols/2 .. 0 .. + templateCols/2 */
-  
+
     inputImage = pgm_readpgm(ifP, &cols, &rows, &maxval);
 
     if (cols < templateCols || rows < templateRows)
         pm_error("the image is smaller than the convolution matrix" );
-  
+
     outputImage = pgm_allocarray(cols, rows);
-  
+
     switch (cmdline.operation) {
     case DILATE:
         dilate(template, templateRows/2, templateCols/2,
diff --git a/editor/specialty/pnmindex.c b/editor/specialty/pnmindex.c
index 2b39e4ec..dcb183ef 100644
--- a/editor/specialty/pnmindex.c
+++ b/editor/specialty/pnmindex.c
@@ -15,12 +15,14 @@
 ============================================================================*/
 
 #define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */
+#define _C99_SOURCE  /* Make sure snprintf() is in stdio.h */
 #define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */
 #define _BSD_SOURCE   /* Make sure strdup is in string.h */
 
 #include <assert.h>
 #include <unistd.h>
 #include <stdarg.h>
+#include <stdio.h>
 #include <errno.h>
 #include <sys/stat.h>
 
@@ -61,7 +63,7 @@ systemf(const char * const fmt,
 
     va_start(varargs, fmt);
 
-    pm_vsnprintf(NULL, 0, fmt, varargs, &dryRunLen);
+    dryRunLen = vsnprintf(NULL, 0, fmt, varargs);
 
     va_end(varargs);
 
@@ -82,7 +84,7 @@ systemf(const char * const fmt,
 
             va_start(varargs, fmt);
 
-            pm_vsnprintf(shellCommand, allocSize, fmt, varargs, &realLen);
+            realLen = vsnprintf(shellCommand, allocSize, fmt, varargs);
 
             assert(realLen == dryRunLen);
             va_end(varargs);
diff --git a/editor/specialty/pnmmercator.c b/editor/specialty/pnmmercator.c
index 81f7f148..0c5c790f 100644
--- a/editor/specialty/pnmmercator.c
+++ b/editor/specialty/pnmmercator.c
@@ -27,16 +27,16 @@
 
 /* The pnm library allows us to code this program without branching cases for
    PGM and PPM, but we do the branch anyway to speed up processing of PGM
-   images. 
+   images.
 */
 
 
 
-struct cmdlineInfo 
+struct cmdlineInfo
 {
     /*
     All the information the user supplied in the command line,
-    in a form easy for the program to use. 
+    in a form easy for the program to use.
     */
 
     const char * input_filespec;  /* Filespecs of input files */
@@ -50,14 +50,14 @@ struct cmdlineInfo
 
 
 static void
-parseCommandLine(int                        argc, 
+parseCommandLine(int                        argc,
                  const char **              argv,
                  struct cmdlineInfo * const cmdlineP ) {
 
     optEntry * option_def;
     optStruct3 opt;
         /* Instructions to pm_optParseOptions3 on how to parse our options. */
-    
+
     unsigned int option_def_index;
 
     MALLOCARRAY_NOFAIL(option_def, 100);
@@ -85,9 +85,9 @@ parseCommandLine(int                        argc,
 
 
 static void
-computeOutputDimensions(const struct cmdlineInfo cmdline, 
+computeOutputDimensions(const struct cmdlineInfo cmdline,
                         const int rows, const int cols,
-                        int * newrowsP, int * newcolsP) 
+                        int * newrowsP, int * newcolsP)
 {
     *newcolsP = cols;
     if (!cmdline.inverse)
@@ -106,7 +106,7 @@ computeOutputDimensions(const struct cmdlineInfo cmdline,
             pm_message("Creating Degrees map, new size is %dx%d",
                        *newcolsP, *newrowsP);
     }
-}        
+}
 
 
 
@@ -117,15 +117,15 @@ transformWithMixing(FILE * const ifP,
                     int const newcols, int const newrows,
                     xelval const newmaxval, int const newformat,
                     bool const inverse,
-                    bool const verbose, bool const vverbose) 
+                    bool const verbose, bool const vverbose)
 {
-    /* 
-    Transform the map image on input file 'ifP' (which is described by 
+    /*
+    Transform the map image on input file 'ifP' (which is described by
     'cols', 'rows', 'format', and 'maxval') to a Mercator projection
-    and write the result to standard output as format 'newformat' and 
+    and write the result to standard output as format 'newformat' and
     with maxval 'newmaxval'.
 
-    We'll blend colors from subsequent rows in the output pixels. 
+    We'll blend colors from subsequent rows in the output pixels.
     */
 
     xel* oddxelrow;  /* an input row */
@@ -142,14 +142,14 @@ transformWithMixing(FILE * const ifP,
     double fLatRad;
     double fLatMerc;
 
-    oddxelrow = pnm_allocrow(cols); 
-    evenxelrow = pnm_allocrow(cols); 
+    oddxelrow = pnm_allocrow(cols);
+    evenxelrow = pnm_allocrow(cols);
     rowInXelrow = 0;
 
     newxelrow = pnm_allocrow(newcols);
 
     for (row = 0; row < newrows; ++row) {
-        
+
         fRow = (double)row + 0.5; /* center on half the pixel */
         if (!inverse) {
             /* the result is mercator, calculate back to degrees */
@@ -207,7 +207,7 @@ transformWithMixing(FILE * const ifP,
             }
         }
 
-        while ((rowInXelrow <= inputRow + 1) && 
+        while ((rowInXelrow <= inputRow + 1) &&
                (rowInXelrow < rows)) {
             /* we need to read one row ahead */
             if (rowInXelrow % 2 == 0) {
@@ -268,16 +268,16 @@ transformNoneMixing(FILE * const ifP,
                    int const newcols, int const newrows,
                    xelval const newmaxval, int const newformat,
                    bool const inverse,
-                   bool const verbose, bool const vverbose) 
+                   bool const verbose, bool const vverbose)
 {
     /*
-    Transform the map image on input file 'ifP' (which is described by 
+    Transform the map image on input file 'ifP' (which is described by
     'cols', 'rows', 'format', and 'maxval') to a Mercator projection and
-    write the result to standard output as format 'newformat' and with 
+    write the result to standard output as format 'newformat' and with
     maxval 'newmaxval'.
 
     Don't mix colors from different input pixels together in the output
-    pixels.  Each output pixel is an exact copy of some corresponding 
+    pixels.  Each output pixel is an exact copy of some corresponding
     input pixel.
     */
 
@@ -293,13 +293,13 @@ transformNoneMixing(FILE * const ifP,
     double fLatRad;
     double fLatMerc;
 
-    xelrow = pnm_allocrow(cols); 
+    xelrow = pnm_allocrow(cols);
     rowInXelrow = 0;
 
     newxelrow = pnm_allocrow(newcols);
 
     for (row = 0; row < newrows; ++row) {
-        
+
         fRow = (double)row + 0.5; /* center on half the pixel */
         if (!inverse) {
             /* the result is mercator, calculate back to degrees */
@@ -377,7 +377,7 @@ transformNoneMixing(FILE * const ifP,
 
 
 int
-main(int argc, const char ** argv ) 
+main(int argc, const char ** argv )
 {
     struct cmdlineInfo cmdline;
     FILE* ifP;
@@ -413,18 +413,18 @@ main(int argc, const char ** argv )
         if (verbose)
             pm_message("Transforming map without mixing/blending colors");
         transformNoneMixing(ifP, cols, rows, maxval, format,
-                            newcols, newrows, newmaxval, newformat, 
+                            newcols, newrows, newmaxval, newformat,
                             cmdline.inverse, verbose, cmdline.vverbose);
     } else {
         if (verbose)
             pm_message("Transforming map while using intermediate colors");
         transformWithMixing(ifP, cols, rows, maxval, format,
-                            newcols, newrows, newmaxval, newformat, 
+                            newcols, newrows, newmaxval, newformat,
                             cmdline.inverse, verbose, cmdline.vverbose);
     }
 
     pm_close(ifP);
     pm_close(stdout);
-    
+
     return 0;
 }
diff --git a/editor/specialty/ppm3d.c b/editor/specialty/ppm3d.c
index a6faa341..bb7cd1af 100644
--- a/editor/specialty/ppm3d.c
+++ b/editor/specialty/ppm3d.c
@@ -33,7 +33,7 @@ parseCommandLine(int argc, char ** argv,
                  struct cmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -64,7 +64,7 @@ parseCommandLine(int argc, char ** argv,
 
     pm_optParseOptions3( &argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
-    
+
     if (argc-1 < 2)
         pm_error("You must specify at least two arguments: left and right "
                  "input file names.  You specified %u", argc-1);
@@ -122,7 +122,7 @@ compute3dRowMono(gray *       const lGrayrow,
                  pixel *      const pixelrow,
                  unsigned int const cols,
                  int          const offset) {
-    
+
     unsigned int col;
     gray *  lgP;
     gray *  rgP;
@@ -133,7 +133,7 @@ compute3dRowMono(gray *       const lGrayrow,
     for (col = 0, pP = pixelrow, lgP = lGrayrow, rgP = rGrayrow;
          col < cols + offset;
          ++col) {
-            
+
         if ((int)col < offset/2)
             ++lgP;
         else if ((int)col < offset) {
@@ -154,7 +154,7 @@ compute3dRowMono(gray *       const lGrayrow,
             ++rgP;
         }
     }
-}    
+}
 
 
 
@@ -164,7 +164,7 @@ compute3dRowColor(pixel *      const lPixelrow,
                   pixel *      const pixelrow,
                   unsigned int const cols,
                   unsigned int const offset) {
-    
+
     unsigned int col;
     pixel * lP;
     pixel * rP;
@@ -175,7 +175,7 @@ compute3dRowColor(pixel *      const lPixelrow,
     for (col = 0, pP = pixelrow, lP = lPixelrow, rP = rPixelrow;
          col < cols + offset;
          ++col) {
-            
+
         if ((int)col < offset/2)
             ++lP;
         else if ((int)col < offset) {
@@ -196,7 +196,7 @@ compute3dRowColor(pixel *      const lPixelrow,
             ++rP;
         }
     }
-}    
+}
 
 
 
@@ -265,11 +265,11 @@ main(int argc, char *argv[]) {
     int lRows, lCols;
     int lFormat;
     pixval lMaxval;
-   
+
     int rRows, rCols;
     int rFormat;
     pixval rMaxval;
-   
+
     ppm_init(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
@@ -279,12 +279,12 @@ main(int argc, char *argv[]) {
 
     ppm_readppminit(lIfP, &lCols, &lRows, &lMaxval, &lFormat);
     ppm_readppminit(rIfP, &rCols, &rRows, &rMaxval, &rFormat);
-    
-    if ((lCols != rCols) || (lRows != rRows) || 
-        (lMaxval != rMaxval) || 
+
+    if ((lCols != rCols) || (lRows != rRows) ||
+        (lMaxval != rMaxval) ||
         (PPM_FORMAT_TYPE(lFormat) != PPM_FORMAT_TYPE(rFormat)))
         pm_error ("Pictures are not of same size and format");
-    
+
     cols   = lCols;
     rows   = lRows;
     maxval = lMaxval;
@@ -293,7 +293,7 @@ main(int argc, char *argv[]) {
         pm_error("Magnitude of -offset (%u columns) is not less than "
                  "width of images "
                  "(%u columns)", abs(cmdline.offset), cols);
-   
+
     ppm_writeppminit(stdout, cols, rows, maxval, 0);
 
     write3dRaster(stdout, lIfP, rIfP, cols, rows, maxval,
diff --git a/editor/specialty/ppmglobe.c b/editor/specialty/ppmglobe.c
index bb043cc6..1ddaabc3 100644
--- a/editor/specialty/ppmglobe.c
+++ b/editor/specialty/ppmglobe.c
@@ -53,7 +53,7 @@ parseCommandLine(int argc, char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "background",     OPT_STRING, &cmdlineP->background, 
+    OPTENT3(0, "background",     OPT_STRING, &cmdlineP->background,
             &backgroundSpec, 0);
     OPTENT3(0, "closeok",        OPT_FLAG, NULL,
             &cmdlineP->closeok, 0);
@@ -68,21 +68,21 @@ parseCommandLine(int argc, char ** argv,
     if (!backgroundSpec)
         cmdlineP->background = NULL;
 
-    if (argc - 1 < 1) 
+    if (argc - 1 < 1)
         pm_error("You must specify at least one argument:  the strip count");
     else {
         int const stripcount = atoi(argv[1]);
         if (stripcount <= 0)
             pm_error("The strip count must be positive.  You specified %d",
                      stripcount);
-            
+
         cmdlineP->stripcount = stripcount;
 
         if (argc-1 < 2)
             cmdlineP->inputFileName = "-";
         else
             cmdlineP->inputFileName = argv[2];
-    
+
         if (argc - 1 > 2)
             pm_error("There are at most two arguments: strip count "
                      "and input file name.  "
@@ -113,9 +113,9 @@ main(int argc, char *argv[]) {
     ppm_init(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
-    
+
     ifP = pm_openr(cmdline.inputFileName);
-    
+
     srcPixels = ppm_readppm(ifP, &srcCols, &srcRows, &srcMaxval);
 
     pm_close(ifP);
@@ -139,7 +139,7 @@ main(int argc, char *argv[]) {
                                  &backgroundColor);
 
     dstPixels = ppm_allocarray(dstCols, dstRows);
-    
+
     for (row = 0; row < dstRows; ++row) {
         double const factor = sin(M_PI * row / dstRows);
             /* Amount by which we squeeze the foreground image of each
diff --git a/editor/specialty/ppmntsc.c b/editor/specialty/ppmntsc.c
index 08fbc835..24edc3bd 100644
--- a/editor/specialty/ppmntsc.c
+++ b/editor/specialty/ppmntsc.c
@@ -6,21 +6,21 @@
    The derivation was done by Bryan Henderson on 2000.04.21 to convert
    it from operating on the RLE format to operating on the PPM format
    and to rewrite it in a cleaner style, taking advantage of modern C
-   compiler technology.  
+   compiler technology.
 */
 
 
 /*
  * This software is copyrighted as noted below.  It may be freely copied,
- * modified, and redistributed, provided that the copyright notice is 
+ * modified, and redistributed, provided that the copyright notice is
  * preserved on all copies.
- * 
+ *
  * There is no warranty or other guarantee of fitness for this software,
  * it is provided solely "as is".  Bug reports or fixes may be sent
  * to the author, who may or may not act on them as he desires.
  *
  * You may not include this software in a program or other software product
- * without supplying the source, or without informing the end-user that the 
+ * without supplying the source, or without informing the end-user that the
  * source is available for no extra charge.
  *
  * If you modify this software, you should include a notice giving the
@@ -28,12 +28,12 @@
  * and the reason for such modification.
  */
 
-/* 
+/*
  * rlelegal.c - Make RGB colors legal in the YIQ or YUV color systems.
- * 
- * Author:	Wes Barris
- * 		Minnesota Supercomputer Center, Inc.
- * Date:	Fri Oct 15, 1993
+ *
+ * Author:      Wes Barris
+ *              Minnesota Supercomputer Center, Inc.
+ * Date:        Fri Oct 15, 1993
  * @Copyright, Research Equipment Inc., d/b/a Minnesota Supercomputer
  * Center, Inc., 1993
 
@@ -104,32 +104,32 @@ parseCommandLine(int argc, const char ** argv,
         cmdlineP->inputFilename = "-";  /* he wants stdin */
     else if (argc - 1 == 1)
         cmdlineP->inputFilename = argv[1];
-    else 
+    else
         pm_error("Too many arguments.  The only arguments accepted "
                  "are the mask color and optional input file specification");
 
     if (legalonly + illegalonly + correctedonly > 1)
         pm_error("--legalonly, --illegalonly, and --correctedonly are "
                  "conflicting options.  Specify at most one of these.");
-        
-    if (legalonly) 
+
+    if (legalonly)
         cmdlineP->output = LEGAL_ONLY;
-    else if (illegalonly) 
+    else if (illegalonly)
         cmdlineP->output = ILLEGAL_ONLY;
-    else if (correctedonly) 
+    else if (correctedonly)
         cmdlineP->output = CORRECTED_ONLY;
-    else 
+    else
         cmdlineP->output = ALL;
 }
 
 
 
-static void 
-rgbtoyiq(const int r, const int g, const int b, 
-         double * const y_p, 
-         double * const i_p, 
+static void
+rgbtoyiq(const int r, const int g, const int b,
+         double * const y_p,
+         double * const i_p,
          double * const q_p) {
-    
+
     *y_p = .299*(r/255.0) + .587*(g/255.0) + .114*(b/255.0);
     *i_p = .596*(r/255.0) - .274*(g/255.0) - .322*(b/255.0);
     *q_p = .211*(r/255.0) - .523*(g/255.0) + .312*(b/255.0);
@@ -137,8 +137,8 @@ rgbtoyiq(const int r, const int g, const int b,
 
 
 
-static void 
-yiqtorgb(const double y, const double i, const double q, 
+static void
+yiqtorgb(const double y, const double i, const double q,
          int * const r_p, int * const g_p, int * const b_p) {
     *r_p = 255.0*(1.00*y + .9562*i + .6214*q);
     *g_p = 255.0*(1.00*y - .2727*i - .6468*q);
@@ -147,10 +147,10 @@ yiqtorgb(const double y, const double i, const double q,
 
 
 
-static void 
-rgbtoyuv(const int r, const int g, const int b, 
-         double * const y_p, 
-         double * const u_p, 
+static void
+rgbtoyuv(const int r, const int g, const int b,
+         double * const y_p,
+         double * const u_p,
          double * const v_p) {
     *y_p =  .299*(r/255.0) + .587*(g/255.0) + .114*(b/255.0);
     *u_p = -.147*(r/255.0) - .289*(g/255.0) + .437*(b/255.0);
@@ -159,10 +159,10 @@ rgbtoyuv(const int r, const int g, const int b,
 
 
 
-static void 
-yuvtorgb(const double y, const double u, const double v, 
+static void
+yuvtorgb(const double y, const double u, const double v,
          int * const r_p, int * const g_p, int * const b_p) {
-    
+
     *r_p = 255.0*(1.00*y + .0000*u +1.1398*v);
     *g_p = 255.0*(1.00*y - .3938*u - .5805*v);
     *b_p = 255.0*(1.00*y +2.0279*u + .0000*v);
@@ -173,12 +173,12 @@ yuvtorgb(const double y, const double u, const double v,
 static void
 makeLegalYiq(double          const y,
              double          const i,
-             double          const q, 
-             double *        const yNewP, 
-             double *        const iNewP, 
+             double          const q,
+             double *        const yNewP,
+             double *        const iNewP,
              double *        const qNewP,
              enum legalize * const actionP) {
-    
+
     double satOld, satNew;
     /*
      * I and Q are legs of a right triangle.  Saturation is the hypotenuse.
@@ -209,13 +209,13 @@ makeLegalYiq(double          const y,
 
 
 static void
-make_legal_yuv(const double y, const double u, const double v, 
-               double * const y_new_p, 
-               double * const u_new_p, 
+make_legal_yuv(const double y, const double u, const double v,
+               double * const y_new_p,
+               double * const u_new_p,
                double * const v_new_p,
                enum legalize * const action_p
     ) {
-    
+
     double sat_old, sat_new;
     /*
      * U and V are legs of a right triangle.  Saturation is the hypotenuse.
@@ -246,13 +246,13 @@ make_legal_yuv(const double y, const double u, const double v,
 
 
 static void
-make_legal_yiq_i(const int r_in, const int g_in, const int b_in, 
-                 int * const r_out_p, 
-                 int * const g_out_p, 
+make_legal_yiq_i(const int r_in, const int g_in, const int b_in,
+                 int * const r_out_p,
+                 int * const g_out_p,
                  int * const b_out_p,
                  enum legalize * const action_p
     ) {
-    
+
     double y, i, q;
     double y_new, i_new, q_new;
     /*
@@ -276,15 +276,15 @@ make_legal_yiq_i(const int r_in, const int g_in, const int b_in,
 
 
 static void
-make_legal_yuv_i(const int r_in, const int g_in, const int b_in, 
-                 int * const r_out_p, 
-                 int * const g_out_p, 
+make_legal_yuv_i(const int r_in, const int g_in, const int b_in,
+                 int * const r_out_p,
+                 int * const g_out_p,
                  int * const b_out_p,
                  enum legalize * const action_p
     ){
-    
+
     double y, u, v;
-    double y_new, u_new, v_new;  
+    double y_new, u_new, v_new;
     /*
      * Convert to YUV and compute the new saturation.
      */
@@ -305,7 +305,7 @@ make_legal_yuv_i(const int r_in, const int g_in, const int b_in,
 
 
 
-static void 
+static void
 make_legal_yiq_b(const pixel input,
                  pixel * const output_p,
                  enum legalize * const action_p) {
@@ -313,7 +313,7 @@ make_legal_yiq_b(const pixel input,
 
     int ir_in, ig_in, ib_in;
     int ir_out, ig_out, ib_out;
-    
+
     ir_in = (int)PPM_GETR(input);
     ig_in = (int)PPM_GETG(input);
     ib_in = (int)PPM_GETB(input);
@@ -327,14 +327,14 @@ make_legal_yiq_b(const pixel input,
 
 
 
-static void 
+static void
 make_legal_yuv_b(const pixel input,
                  pixel * const output_p,
                  enum legalize * const action_p) {
 
     int ir_in, ig_in, ib_in;
     int ir_out, ig_out, ib_out;
-    
+
     ir_in = (int)PPM_GETR(input);
     ig_in = (int)PPM_GETG(input);
     ib_in = (int)PPM_GETB(input);
@@ -347,7 +347,7 @@ make_legal_yuv_b(const pixel input,
 
 
 
-static void 
+static void
 reportMapping(pixel const oldPixel,
               pixel const newPixel) {
 /*----------------------------------------------------------------------------
@@ -358,7 +358,7 @@ reportMapping(pixel const oldPixel,
     static pixel lastChangedPixel;
     static bool firstTime = true;
 
-    if (!PPM_EQUAL(oldPixel, newPixel) && 
+    if (!PPM_EQUAL(oldPixel, newPixel) &&
         (firstTime || PPM_EQUAL(oldPixel, lastChangedPixel))) {
         pm_message("Mapping %u %u %u -> %u %u %u\n",
                    PPM_GETR(oldPixel),
@@ -371,14 +371,14 @@ reportMapping(pixel const oldPixel,
 
         lastChangedPixel = oldPixel;
         firstTime = false;
-    }    
+    }
 }
 
 
 
 static void
 convertOneImage(FILE *             const ifP,
-                struct cmdlineInfo const cmdline, 
+                struct cmdlineInfo const cmdline,
                 unsigned int *     const hiCountP,
                 unsigned int *     const loCountP) {
 
@@ -419,8 +419,8 @@ convertOneImage(FILE *             const ifP,
                         make_legal_yiq_b(inputRow[col],
                                          &corrected,
                                          &action);
-                        
-                    if (action == LOWER_SAT) 
+
+                    if (action == LOWER_SAT)
                         ++*hiCountP;
                     if (action == RAISE_SAT)
                         ++*loCountP;
@@ -456,7 +456,7 @@ convertOneImage(FILE *             const ifP,
 
 int
 main(int argc, const char **argv) {
-    
+
     struct cmdlineInfo cmdline;
     FILE * ifP;
     unsigned int totalHiCount, totalLoCount;
@@ -469,7 +469,7 @@ main(int argc, const char **argv) {
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFilename);
-    
+
     imageCount = 0;    /* initial value */
     totalHiCount = 0;  /* initial value */
     totalLoCount = 0;  /* initial value */
@@ -488,14 +488,14 @@ main(int argc, const char **argv) {
     }
 
 
-	if (cmdline.verbose) {
+        if (cmdline.verbose) {
         pm_message("%u images processed.", imageCount);
-        pm_message("%u pixels were above the saturation limit.", 
+        pm_message("%u pixels were above the saturation limit.",
                    totalHiCount);
-        pm_message("%u pixels were below the saturation limit.", 
+        pm_message("%u pixels were below the saturation limit.",
                    totalLoCount);
     }
-    
+
     pm_close(ifP);
 
     return 0;
diff --git a/editor/specialty/ppmrelief.c b/editor/specialty/ppmrelief.c
index 14a6d0a8..94453bdd 100644
--- a/editor/specialty/ppmrelief.c
+++ b/editor/specialty/ppmrelief.c
@@ -85,7 +85,7 @@ main(int argc, const char * argv[]) {
         for (col = 0; col < cols - 2; ++col) {
             pixel const inputA = inputbuf[rowa][col];
             pixel const inputB = inputbuf[rowb][col + 2];
-            
+
             pixval const r =
                 clip(PPM_GETR(inputA) + (mv2 - PPM_GETR(inputB)), maxval);
             pixval const g =
diff --git a/editor/specialty/ppmshift.c b/editor/specialty/ppmshift.c
index 27cbb78c3..37ed3785 100644
--- a/editor/specialty/ppmshift.c
+++ b/editor/specialty/ppmshift.c
@@ -1,4 +1,3 @@
-
 /*********************************************************************/
 /* ppmshift -  shift lines of a picture left or right by x pixels    */
 /* Frank Neumann, October 1993                                       */
diff --git a/editor/specialty/ppmtv.c b/editor/specialty/ppmtv.c
index da25102a..7e540e34 100644
--- a/editor/specialty/ppmtv.c
+++ b/editor/specialty/ppmtv.c
@@ -1,4 +1,3 @@
-
 /*********************************************************************/
 /* ppmtv -  make a 'look-alike ntsc' picture from a PPM file       */
 /* Frank Neumann, October 1993                                       */
@@ -18,88 +17,88 @@ int main(argc, argv)
 int argc;
 char *argv[];
 {
-	FILE* ifp;
-	int argn, rows, cols, format, i = 0, j = 0;
-	pixel *srcrow, *destrow;
-	pixel *pP = NULL, *pP2 = NULL;
-	pixval maxval;
-	double dimfactor;
-	long longfactor;
-	const char * const usage = "dimfactor [ppmfile]\n        dimfactor: 0.0 = total blackness, 1.0 = original picture\n";
-
-	/* parse in 'default' parameters */
-	ppm_init(&argc, argv);
-
-	argn = 1;
-
-	/* parse in dim factor */
-	if (argn == argc)
-		pm_usage(usage);
-	if (sscanf(argv[argn], "%lf", &dimfactor) != 1)
-		pm_usage(usage);
-	if (dimfactor < 0.0 || dimfactor > 1.0)
-		pm_error("dim factor must be in the range from 0.0 to 1.0 ");
-	++argn;
-
-	/* parse in filename (if present, stdin otherwise) */
-	if (argn != argc)
-	{
-		ifp = pm_openr(argv[argn]);
-		++argn;
-	}
-	else
-		ifp = stdin;
-
-	if (argn != argc)
-		pm_usage(usage);
-
-	/* read first data from file */
-	ppm_readppminit(ifp, &cols, &rows, &maxval, &format);
-
-	/* no error checking required here, ppmlib does it all for us */
-	srcrow = ppm_allocrow(cols);
-
-	longfactor = (long)(dimfactor * 65536);
-
-	/* allocate a row of pixel data for the new pixels */
-	destrow = ppm_allocrow(cols);
-
-	ppm_writeppminit(stdout, cols, rows, maxval, 0);
-
-	/** now do the ntsc'ing (actually very similar to ppmdim) **/
-	for (i = 0; i < rows; i++)
-	{
-		ppm_readppmrow(ifp, srcrow, cols, maxval, format);
-
-		pP = srcrow;
-		pP2 = destrow;
-
-		for (j = 0; j < cols; j++)
-		{
-			/* every alternating row is left in unchanged condition */
-			if (i & 1)
-			{
-				PPM_ASSIGN(*pP2, PPM_GETR(*pP), PPM_GETG(*pP), PPM_GETB(*pP));
-			}
-			/* and the other lines are dimmed to the specified factor */
-			else
-			{
-				PPM_ASSIGN(*pP2, (PPM_GETR(*pP) * longfactor) >> 16,
-								 (PPM_GETG(*pP) * longfactor) >> 16,
-								 (PPM_GETB(*pP) * longfactor) >> 16);
-			}
-			pP++;
-			pP2++;
-		}
-
-		/* write out one line of graphic data */
-		ppm_writeppmrow(stdout, destrow, cols, maxval, 0);
-	}
-
-	pm_close(ifp);
-	ppm_freerow(srcrow);
-	ppm_freerow(destrow);
-
-	exit(0);
+        FILE* ifp;
+        int argn, rows, cols, format, i = 0, j = 0;
+        pixel *srcrow, *destrow;
+        pixel *pP = NULL, *pP2 = NULL;
+        pixval maxval;
+        double dimfactor;
+        long longfactor;
+        const char * const usage = "dimfactor [ppmfile]\n        dimfactor: 0.0 = total blackness, 1.0 = original picture\n";
+
+        /* parse in 'default' parameters */
+        ppm_init(&argc, argv);
+
+        argn = 1;
+
+        /* parse in dim factor */
+        if (argn == argc)
+                pm_usage(usage);
+        if (sscanf(argv[argn], "%lf", &dimfactor) != 1)
+                pm_usage(usage);
+        if (dimfactor < 0.0 || dimfactor > 1.0)
+                pm_error("dim factor must be in the range from 0.0 to 1.0 ");
+        ++argn;
+
+        /* parse in filename (if present, stdin otherwise) */
+        if (argn != argc)
+        {
+                ifp = pm_openr(argv[argn]);
+                ++argn;
+        }
+        else
+                ifp = stdin;
+
+        if (argn != argc)
+                pm_usage(usage);
+
+        /* read first data from file */
+        ppm_readppminit(ifp, &cols, &rows, &maxval, &format);
+
+        /* no error checking required here, ppmlib does it all for us */
+        srcrow = ppm_allocrow(cols);
+
+        longfactor = (long)(dimfactor * 65536);
+
+        /* allocate a row of pixel data for the new pixels */
+        destrow = ppm_allocrow(cols);
+
+        ppm_writeppminit(stdout, cols, rows, maxval, 0);
+
+        /** now do the ntsc'ing (actually very similar to ppmdim) **/
+        for (i = 0; i < rows; i++)
+        {
+                ppm_readppmrow(ifp, srcrow, cols, maxval, format);
+
+                pP = srcrow;
+                pP2 = destrow;
+
+                for (j = 0; j < cols; j++)
+                {
+                        /* every alternating row is left in unchanged condition */
+                        if (i & 1)
+                        {
+                                PPM_ASSIGN(*pP2, PPM_GETR(*pP), PPM_GETG(*pP), PPM_GETB(*pP));
+                        }
+                        /* and the other lines are dimmed to the specified factor */
+                        else
+                        {
+                                PPM_ASSIGN(*pP2, (PPM_GETR(*pP) * longfactor) >> 16,
+                                                                 (PPM_GETG(*pP) * longfactor) >> 16,
+                                                                 (PPM_GETB(*pP) * longfactor) >> 16);
+                        }
+                        pP++;
+                        pP2++;
+                }
+
+                /* write out one line of graphic data */
+                ppm_writeppmrow(stdout, destrow, cols, maxval, 0);
+        }
+
+        pm_close(ifp);
+        ppm_freerow(srcrow);
+        ppm_freerow(destrow);
+
+        exit(0);
 }
 
diff --git a/generator/pamgauss.c b/generator/pamgauss.c
index 9656708b..3697fdc7 100644
--- a/generator/pamgauss.c
+++ b/generator/pamgauss.c
@@ -31,11 +31,11 @@ static void
 parseCommandLine(int argc, const char ** argv,
                  struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
-  Convert program invocation arguments (argc,argv) into a format the 
+  Convert program invocation arguments (argc,argv) into a format the
   program can use easily, struct cmdlineInfo.  Validate arguments along
   the way and exit program with message if invalid.
 
-  Note that some string information we return as *cmdlineP is in the storage 
+  Note that some string information we return as *cmdlineP is in the storage
   argv[] points to.
 -----------------------------------------------------------------------------*/
     optEntry * option_def;
@@ -49,11 +49,11 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0,   "tupletype",  OPT_STRING, &cmdlineP->tupletype, 
+    OPTENT3(0,   "tupletype",  OPT_STRING, &cmdlineP->tupletype,
             &tupletypeSpec,      0);
-    OPTENT3(0,   "maxval",     OPT_UINT,   &cmdlineP->maxval, 
+    OPTENT3(0,   "maxval",     OPT_UINT,   &cmdlineP->maxval,
             &maxvalSpec,         0);
-    OPTENT3(0,   "sigma",      OPT_FLOAT,  &cmdlineP->sigma, 
+    OPTENT3(0,   "sigma",      OPT_FLOAT,  &cmdlineP->sigma,
             &sigmaSpec,          0);
     OPTENT3(0,   "maximize",   OPT_FLAG,   NULL,
             &cmdlineP->maximize, 0);
@@ -75,12 +75,12 @@ parseCommandLine(int argc, const char ** argv,
             pm_error("The tuple type you specified is too long.  "
                      "Maximum %u characters.",
                      (unsigned)sizeof(pam.tuple_type)-1);
-    }        
+    }
 
     if (!sigmaSpec)
         pm_error("You must specify the -sigma option.");
     else if (cmdlineP->sigma <= 0.0)
-        pm_error("-sigma must be positive.  You specified %f", 
+        pm_error("-sigma must be positive.  You specified %f",
                  cmdlineP->sigma);
 
     if (!maxvalSpec)
@@ -91,7 +91,7 @@ parseCommandLine(int argc, const char ** argv,
                      "Maximum is %u", cmdlineP->maxval, PNM_OVERALLMAXVAL);
         if (cmdlineP->maxval < 1)
             pm_error("-maxval must be at least 1");
-    }    
+    }
 
     if (oversampleSpec) {
         if (cmdlineP->oversample < 1)
@@ -164,7 +164,7 @@ pixelValue(unsigned int const width,
   The gaussian function has standard deviation 'sigma' and amplitude 1.
 -----------------------------------------------------------------------------*/
     double const offset = 1.0 / (subpixDivision * 2);
-    double const y0     = (double)row + offset; 
+    double const y0     = (double)row + offset;
     double const x0     = (double)col + offset;
 
     double const subpixSize = 1.0 / subpixDivision;
@@ -236,7 +236,7 @@ maximumKernelValue(double **    const kernel,
        we know the maximum value is at the center.
     */
     return kernel[height/2][width/2];
-}        
+}
 
 
 
@@ -250,13 +250,13 @@ totalKernelValue(double **    const kernel,
 
     for (row = 0, total = 0.0; row < height; ++row) {
         unsigned int col;
-        
+
         for (col = 0; col < width; ++col)
             total += kernel[row][col];
     }
 
     return total;
-}        
+}
 
 
 
@@ -311,7 +311,7 @@ writePam(double **    const kernel,
         unsigned int col;
         for (col = 0; col < pam.width; ++col) {
             tuplerown[col][0] = kernel[row][col] / normalizer;
-        
+
             assert(tuplerown[col][0] <= 1.0);
         }
         pnm_writepamrown(&pam, tuplerown);
@@ -319,7 +319,7 @@ writePam(double **    const kernel,
 
     pnm_freepamrown(tuplerown);
 }
-    
+
 
 
 int
@@ -327,7 +327,7 @@ main(int argc, const char **argv) {
     struct CmdlineInfo cmdline;
     double ** kernel;
     double    normalizer;
-    
+
     pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
@@ -344,6 +344,6 @@ main(int argc, const char **argv) {
              normalizer, stdout);
 
     pm_freearray2((void **)kernel);
-    
+
     return 0;
 }
diff --git a/generator/pamshadedrelief.c b/generator/pamshadedrelief.c
index 35d1e3e0..80b34a0d 100644
--- a/generator/pamshadedrelief.c
+++ b/generator/pamshadedrelief.c
@@ -8,7 +8,7 @@
 
   The input array is a one-channel PAM image.  The sample values are
   elevations of terrain.
-  
+
   This is derived from John Walker's 'pgmcrater' which not only does this
   shading, but first generates a terrain map of fractal craters on which to
   run it.
@@ -95,7 +95,7 @@ parseCommandLine(int argc, const char ** const argv,
     if (cmdlineP->gamma <= 0.0)
         pm_error("gamma correction must be greater than 0");
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFileName = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -201,7 +201,7 @@ writeShadedRelief(struct pam * const terrainPamP,
         }
         {
             /* Wrap around to determine shade of pixel on right edge */
-            int const slope = 
+            int const slope =
                 terrain[row][0][0] - terrain[row][outpam.width-1][0];
             outrow[outpam.width - 1][0] =
                 brightnessOfSlope(slope, slopeGrayMap);
@@ -222,8 +222,8 @@ readTerrain(FILE *       const ifP,
 
     *tuplesP = pnm_readpam(ifP, pamP, PAM_STRUCT_SIZE(tuple_type));
 }
-            
-            
+
+
 
 int
 main(int argc, const char ** argv) {
@@ -243,7 +243,7 @@ main(int argc, const char ** argv) {
     readTerrain(ifP, &terrainPam, &terrain);
 
     writeShadedRelief(&terrainPam, terrain, cmdline.gamma, stdout);
-    
+
     return 0;
 }
 
diff --git a/generator/pamstereogram.test b/generator/pamstereogram.test
deleted file mode 100644
index 80f70ee0..00000000
--- a/generator/pamstereogram.test
+++ /dev/null
@@ -1,70 +0,0 @@
-# Make some input files
-pamdepth -quiet 255 ../testgrid.pbm >/tmp/testgrid.pgm
-
-
-# Random pattern
-
-echo Test 01.  Should print 610673698 293:
-./pamstereogram -randomseed=1 ../testgrid.pbm | cksum 
-echo Test 02.  Should print 610673698 293:
-./pamstereogram -randomseed=1 -blackandwhite ../testgrid.pbm | cksum 
-echo Test 03.  Should print 3439084201 170:
-pamseq -tupletype=GRAYSCALE 1 100 | ./pamstereogram -randomseed=1 | cksum 
-echo Test 04.  Should print 2484923390 1070:
-pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \
-  ./pamstereogram -randomseed=1 -dpi=10 | cksum
-
-# Makemask
-
-echo Test 10.  Should print 1266273778 293:
-./pamstereogram -randomseed=1 -makemask ../testgrid.pbm | cksum 
-
-echo Test 11.  Should print 3034751595 1070:
-pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \
-  ./pamstereogram -randomseed=1 -dpi=10 -makemask | cksum
-
-# Grayscale
-
-echo Test 20.  Should print 2468969328 289:
-./pamstereogram -randomseed=1 -grayscale ../testgrid.pbm | cksum 
-echo Test 21.  Should print 1946982115 4068:
-pamseq 1 100 | pnmtile 200 20 | \
-  ./pamstereogram -randomseed=1 -dpi=10 -grayscale | \
-  cksum
-echo Test 22.  Should print 2078013430 4068:
-pamseq 1 100 | pnmtile 200 20 | \
-  ./pamstereogram -randomseed=1 -dpi=10 -grayscale -maxval 255 | \
-  cksum
-
-# Color
-
-echo Test 30.  Should print 1319392622 731:
-./pamstereogram -randomseed=1 -color ../testgrid.pbm | cksum 
-echo Test 31.  Should print 389886159 12062:
-pamseq 1 100 | pnmtile 200 20 | \
-  ./pamstereogram -randomseed=1 -dpi=10 -color | \
-  cksum
-
-# Pattern file
-
-echo Test 40.  Should print 1834916830 660:
-pamgradient black gray50 white gray50 100 50 | \
-  ./pamstereogram -patfile ../testgrid.pbm -eyesep=.1 -crosseyed | cksum
-
-echo Test 41.  Should print 4016818756 5014:
-pamgradient black gray50 white gray50 100 50 | \
-  ./pamstereogram -patfile /tmp/testgrid.pgm -eyesep=.1 -crosseyed | cksum
-
-# drawguides
-
-echo Test 51.  Should print 2365956562 11071:
-pamgradient black gray50 white gray50 100 50 | \
-  ./pamstereogram -randomseed=1 -dpi 10 -guidesize=20 | cksum
-
-echo Test 51.  Should print 3502025270 1441:
-pamgradient black gray50 white gray50 100 50 | \
-  ./pamstereogram -patfile=../testgrid.pbm -dpi 10 -guidesize=20 | cksum
-
-
-# Clean up files we created
-rm /tmp/testgrid.pgm
diff --git a/generator/pamtris/framebuffer.c b/generator/pamtris/framebuffer.c
index 5665e9a4..4318b1fc 100644
--- a/generator/pamtris/framebuffer.c
+++ b/generator/pamtris/framebuffer.c
@@ -320,7 +320,7 @@ draw_span(uint32_t           const base,
         fbi->z.buffer[j] = (fbi->z.buffer[j] & ~d_mask) | (d & d_mask);
 
         for (l = 0; l < z; l++) {
-	    varying const newval = multiply_varyings(attribs[l], inverse_w);
+            varying const newval = multiply_varyings(attribs[l], inverse_w);
 
             fbi->img.buffer[k + l] =
                 (fbi->img.buffer[k + l] & ~d_mask) |
diff --git a/generator/pamtris/pamtris.c b/generator/pamtris/pamtris.c
index e0becf7a..477b657e 100644
--- a/generator/pamtris/pamtris.c
+++ b/generator/pamtris/pamtris.c
@@ -54,7 +54,7 @@ parse_command_line(int *         const argc_ptr,
     if (!width_spec || !height_spec || (!attribs_spec && !(rgb_spec || grayscale_spec))) {
         pm_errormsg(
             "you must at least specify -width, -height and "
-	    "either -num_attribs, -rgb or -grayscale.");
+            "either -num_attribs, -rgb or -grayscale.");
 
         return 0;
     }
diff --git a/generator/pamtris/triangle.c b/generator/pamtris/triangle.c
index 5143f9ee..264fc221 100644
--- a/generator/pamtris/triangle.c
+++ b/generator/pamtris/triangle.c
@@ -190,8 +190,8 @@ draw_triangle(Xy                 const xy_input,
 
     for (i = 0; i < 3; i++) {
         int32_to_varying_array(attribs_input._[i], attribs[i], n);
-	attribs[i][z] = compute_varying_z(attribs_input._[i][z]);
-	attribs[i][w] = inverse_varying(attribs[i][w]);
+        attribs[i][z] = compute_varying_z(attribs_input._[i][z]);
+        attribs[i][w] = inverse_varying(attribs[i][w]);
         multiply_varying_array_by_varying(attribs[i], attribs[i][w], z);
     }
 
diff --git a/generator/pamtris/utils.c b/generator/pamtris/utils.c
index a6b6e7d4..53f1ea9e 100644
--- a/generator/pamtris/utils.c
+++ b/generator/pamtris/utils.c
@@ -61,7 +61,7 @@ multiply_varying_array_by_varying(varying * const vars,
 
     for (i = 0; i < elements; i++) {
         vars[i].v *= multiplier.v;
-	vars[i].s  = 0.0;
+        vars[i].s  = 0.0;
     }
 }
 
@@ -77,7 +77,7 @@ divide_varying_array_by_varying(varying * const vars,
 
     for (i = 0; i < elements; i++) {
         vars[i].v *= inverse_divisor;
-	vars[i].s  = 0.0;
+        vars[i].s  = 0.0;
     }
 }
 
diff --git a/generator/pbmnoise.c b/generator/pbmnoise.c
index e316dafc..541ce92e 100644
--- a/generator/pbmnoise.c
+++ b/generator/pbmnoise.c
@@ -1,7 +1,7 @@
 /* pbmnoise.c - create a random bitmap of a specified size
                 with a specified ratio of white/black pixels
 
-   Written by Akira F Urushibata and contributed to the public domain 
+   Written by Akira F Urushibata and contributed to the public domain
    December 2021
 */
 
diff --git a/generator/pbmupc.c b/generator/pbmupc.c
index 6ef75654..9d9e6721 100644
--- a/generator/pbmupc.c
+++ b/generator/pbmupc.c
@@ -52,31 +52,31 @@ main( argc, argv )
 
     /* Check for flags. */
     while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
-	{
-	if ( pm_keymatch( argv[argn], "-s1", 3 ) )
-	    style = 1;
-	else if ( pm_keymatch( argv[argn], "-s2", 3 ) )
-	    style = 2;
-	else
-	    pm_usage( usage );
-	argn++;
-	}
+        {
+        if ( pm_keymatch( argv[argn], "-s1", 3 ) )
+            style = 1;
+        else if ( pm_keymatch( argv[argn], "-s2", 3 ) )
+            style = 2;
+        else
+            pm_usage( usage );
+        argn++;
+        }
 
     if ( argn + 3 < argc )
-	pm_usage( usage );
+        pm_usage( usage );
     typecode = argv[argn];
     manufcode = argv[argn + 1];
     prodcode = argv[argn + 2];
     argn += 3;
 
     if ( argn != argc )
-	pm_usage( usage );
+        pm_usage( usage );
 
     if ( strlen( typecode ) != 1 || ( ! alldig( typecode ) ) ||
-	 strlen( manufcode ) != 5 || ( ! alldig ( manufcode ) ) ||
-	 strlen( prodcode ) != 5 || ( ! alldig ( prodcode ) ) )
-	pm_error(
-	    "type code must be one digit, and\n    manufacturer and product codes must be five digits" );
+         strlen( manufcode ) != 5 || ( ! alldig ( manufcode ) ) ||
+         strlen( prodcode ) != 5 || ( ! alldig ( prodcode ) ) )
+        pm_error(
+            "type code must be one digit, and\n    manufacturer and product codes must be five digits" );
     p = typecode[0] - '0';
     lc0 = manufcode[0] - '0';
     lc1 = manufcode[1] - '0';
@@ -95,17 +95,17 @@ main( argc, argv )
     bits = pbm_allocarray( cols, rows );
 
     (void) rect( bits, 0, 0, rows, cols, PBM_WHITE );
-    
+
     row = MARGIN;
     digrow = row + SHORT_HEIGHT;
     col = MARGIN;
     digcolofs = ( LINES_WIDTH - DIGIT_WIDTH ) / 2;
 
     if ( style == 1 )
-	putdigit( p, bits, digrow, col - DIGIT_WIDTH - LINE1_WIDTH );
+        putdigit( p, bits, digrow, col - DIGIT_WIDTH - LINE1_WIDTH );
     else if ( style == 2 )
-	putdigit(
-	    p, bits, row + SHORT_HEIGHT / 2, col - DIGIT_WIDTH - LINE1_WIDTH );
+        putdigit(
+            p, bits, row + SHORT_HEIGHT / 2, col - DIGIT_WIDTH - LINE1_WIDTH );
     col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
     col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE );
     col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
@@ -140,7 +140,7 @@ main( argc, argv )
     col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE );
     col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
     if ( style == 1 )
-	putdigit( sum, bits, digrow, col + LINE1_WIDTH );
+        putdigit( sum, bits, digrow, col + LINE1_WIDTH );
 
     pbm_writepbm( stdout, bits, cols, rows, 0 );
     pm_close( stdout );
@@ -153,8 +153,8 @@ alldig( cp )
     char* cp;
     {
     for ( ; *cp != '\0'; cp++ )
-	if ( *cp < '0' || *cp > '9' )
-	    return 0;
+        if ( *cp < '0' || *cp > '9' )
+            return 0;
     return 1;
     }
 
@@ -399,7 +399,7 @@ putdigit( d, bits, row0, col0 )
             {0,0,0,1,1,1,1,1,1,1,1,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}
-        }, 
+        },
         /* 9 */
         {
             {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -425,92 +425,92 @@ putdigit( d, bits, row0, col0 )
             {0,0,0,0,0,1,1,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,0}
-        } 
+        }
     };
 
     for ( row = 0; row < DIGIT_HEIGHT; row++ )
-	for ( col = 0; col < DIGIT_WIDTH; col++ )
-	    bits[row0 + row][col0 + col] = digits[d][row][col];
+        for ( col = 0; col < DIGIT_WIDTH; col++ )
+            bits[row0 + row][col0 + col] = digits[d][row][col];
     }
 
 static int
 addlines( int d, bit** bits, int row0, int col0, int height, bit color )
     {
     switch ( d )
-	{
-	case 0:
-	col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	break;
-
-	case 1:
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	break;
-
-	case 2:
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	break;
-
-	case 3:
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	break;
-
-	case 4:
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	break;
-
-	case 5:
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	break;
-
-	case 6:
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color );
-	break;
-
-	case 7:
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	break;
-
-	case 8:
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color );
-	break;
-
-	case 9:
-	col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
-	col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
-	col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
-	break;
-
-	default:
-	pm_error( "can't happen" );
-	}
+        {
+        case 0:
+        col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        break;
+
+        case 1:
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        break;
+
+        case 2:
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        break;
+
+        case 3:
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        break;
+
+        case 4:
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        break;
+
+        case 5:
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        break;
+
+        case 6:
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color );
+        break;
+
+        case 7:
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        break;
+
+        case 8:
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color );
+        break;
+
+        case 9:
+        col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
+        col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
+        col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
+        break;
+
+        default:
+        pm_error( "can't happen" );
+        }
 
     return col0;
     }
@@ -521,7 +521,7 @@ rect( bit** bits, int row0, int col0, int height, int width, bit color )
     int row, col;
 
     for ( row = row0; row < row0 + height; row++ )
-	for ( col = col0; col < col0 + width; col++ )
-	    bits[row][col] = color;
+        for ( col = col0; col < col0 + width; col++ )
+            bits[row][col] = color;
     return col0 + width;
     }
diff --git a/generator/pgmkernel.c b/generator/pgmkernel.c
index 37072c38..cbae0882 100644
--- a/generator/pgmkernel.c
+++ b/generator/pgmkernel.c
@@ -39,11 +39,11 @@ static void
 parseCommandLine(int argc, const char ** argv,
                  struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
-  Convert program invocation arguments (argc,argv) into a format the 
+  Convert program invocation arguments (argc,argv) into a format the
   program can use easily, struct cmdlineInfo.  Validate arguments along
   the way and exit program with message if invalid.
 
-  Note that some string information we return as *cmdlineP is in the storage 
+  Note that some string information we return as *cmdlineP is in the storage
   argv[] points to.
 -----------------------------------------------------------------------------*/
     optEntry *option_def;
@@ -57,9 +57,9 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0,   "weight",  OPT_FLOAT, &cmdlineP->weight, 
+    OPTENT3(0,   "weight",  OPT_FLOAT, &cmdlineP->weight,
             &weightSpec,     0);
-    OPTENT3(0,   "maxval",  OPT_UINT, &cmdlineP->maxval, 
+    OPTENT3(0,   "maxval",  OPT_UINT, &cmdlineP->maxval,
             &maxvalSpec,     0);
 
     opt.opt_table = option_def;
diff --git a/generator/pgmmake.c b/generator/pgmmake.c
index ae706639..6fd8d426 100644
--- a/generator/pgmmake.c
+++ b/generator/pgmmake.c
@@ -52,11 +52,11 @@ static void
 parseCommandLine(int argc, const char ** argv,
                  struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
-  Convert program invocation arguments (argc,argv) into a format the 
+  Convert program invocation arguments (argc,argv) into a format the
   program can use easily, struct cmdlineInfo.  Validate arguments along
   the way and exit program with message if invalid.
 
-  Note that some string information we return as *cmdlineP is in the storage 
+  Note that some string information we return as *cmdlineP is in the storage
   argv[] points to.
 -----------------------------------------------------------------------------*/
     optEntry * option_def;
diff --git a/generator/ppmcie.c b/generator/ppmcie.c
index 86325ba6..26289c3c 100644
--- a/generator/ppmcie.c
+++ b/generator/ppmcie.c
@@ -26,8 +26,11 @@
   Introduced option to plot 1976 u' v' chromaticities.
 */
 
+#define _C99_SOURCE  /* Make sure snprintf() is in stdio.h */
+
 #include <assert.h>
 #include <math.h>
+#include <stdio.h>
 
 #include "pm_c_util.h"
 #include "ppm.h"
@@ -1114,15 +1117,15 @@ writeLabel(pixel **                   const pixels,
 
     PPM_ASSIGN(rgbcolor, maxval, maxval, maxval);
 
-    pm_snprintf(sysdesc, sizeof(sysdesc),
-                "System: %s\n"
-                "Primary illuminants (X, Y)\n"
-                "     Red:  %0.4f, %0.4f\n"
-                "     Green: %0.4f, %0.4f\n"
-                "     Blue:  %0.4f, %0.4f\n"
-                "White point (X, Y): %0.4f, %0.4f",
-                cs->name, cs->xRed, cs->yRed, cs->xGreen, cs->yGreen,
-                cs->xBlue, cs->yBlue, cs->xWhite, cs->yWhite);
+    snprintf(sysdesc, sizeof(sysdesc),
+             "System: %s\n"
+             "Primary illuminants (X, Y)\n"
+             "     Red:  %0.4f, %0.4f\n"
+             "     Green: %0.4f, %0.4f\n"
+             "     Blue:  %0.4f, %0.4f\n"
+             "White point (X, Y): %0.4f, %0.4f",
+             cs->name, cs->xRed, cs->yRed, cs->xGreen, cs->yGreen,
+             cs->xBlue, cs->yBlue, cs->xWhite, cs->yWhite);
     sysdesc[sizeof(sysdesc)-1] = '\0';  /* for robustness */
 
     ppmd_text(pixels, pixcols, pixrows, maxval,
diff --git a/generator/ppmcolors.c b/generator/ppmcolors.c
index 701812d1..ecbadf72 100644
--- a/generator/ppmcolors.c
+++ b/generator/ppmcolors.c
@@ -3,7 +3,7 @@
 *******************************************************************************
   Generate a color map containing all the colors representable with a certain
   maxval.
-  
+
   THIS PROGRAM IS OBSOLETE.  USE PAMSEQ INSTEAD.  WE KEEP THIS AROUND
   FOR BACKWARD COMPATIBILITY.
 
@@ -18,7 +18,7 @@ struct cmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    unsigned int maxval;   
+    unsigned int maxval;
 };
 
 
@@ -34,9 +34,9 @@ parseCommandLine(int argc, char ** argv, struct cmdlineInfo *cmdlineP) {
     unsigned int option_def_index;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0,   "maxval",       OPT_UINT,   
+    OPTENT3(0,   "maxval",       OPT_UINT,
             &cmdlineP->maxval,  NULL, 0);
-    
+
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -76,7 +76,7 @@ main(int argc, char *argv[]) {
 
     rc = system(cmd);
 
-    if (rc != 0) 
+    if (rc != 0)
         pm_error("pamseq|pamtopnm pipeline failed.  system() rc = %d", rc);
 
     pm_strfree(cmd);
diff --git a/generator/ppmrough.c b/generator/ppmrough.c
index c43b1fa5..d9f1bb65 100644
--- a/generator/ppmrough.c
+++ b/generator/ppmrough.c
@@ -96,6 +96,7 @@ parseCommandLine(int argc, const char ** argv,
         cmdlineP->fg = NULL;
     if (!varSpec)
         cmdlineP->var = 10;
+
     if (cmdlineP->topSpec && cmdlineP->top > cmdlineP->height)
         pm_error("-top value too large.  Max is %u", cmdlineP->height);
     if (cmdlineP->bottomSpec && cmdlineP->bottom > cmdlineP->height)
@@ -113,6 +114,15 @@ parseCommandLine(int argc, const char ** argv,
 
 
 
+static int
+mean(int const a,
+     int const b) {
+
+    return (a + b) / 2;
+}
+
+
+
 static void
 reportParameters(struct CmdlineInfo const cmdline,
                  pixel              const bgcolor,
@@ -173,13 +183,13 @@ procLeft(pixel **           const pixels,
          struct pm_randSt * const randStP) {
 
     if (r1 + 1 != r2) {
-        int const rm = (r1 + r2) >> 1;
-        int const cm = ((c1 + c2) >> 1) +
+        int const rm = mean(r1, r2);
+        int const cm = mean(c1, c2) +
             (int)floor(((float)pm_drand(randStP) - 0.5) * var + 0.5);
 
         unsigned int c;
 
-        for (c = 0; c < MIN(width, MAX(0, cm)); c++)
+        for (c = 0; c < MIN(width, MAX(0, cm)); ++c)
             pixels[rm][c] = bgcolor;
 
         procLeft(pixels, r1, rm, c1, cm, width, var, bgcolor, randStP);
@@ -201,13 +211,13 @@ procRight(pixel **           const pixels,
           struct pm_randSt * const randStP) {
 
     if (r1 + 1 != r2) {
-        int const rm = (r1 + r2) >> 1;
-        int const cm = ((c1 + c2) >> 1) +
+        int const rm = mean(r1, r2);
+        int const cm = mean(c1, c2) +
             (int)floor(((float)pm_drand(randStP) - 0.5) * var + 0.5);
 
         unsigned int c;
 
-        for (c = MAX(0, cm); c < width; c++)
+        for (c = MAX(0, cm); c < width; ++c)
             pixels[rm][c] = bgcolor;
 
         procRight(pixels, r1, rm, c1, cm, width, var, bgcolor, randStP);
@@ -229,13 +239,13 @@ procTop(pixel **           const pixels,
         struct pm_randSt * const randStP) {
 
     if (c1 + 1 != c2) {
-        int const cm = (c1 + c2) >> 1;
-        int const rm = ((r1 + r2) >> 1) +
+        int const cm = mean(c1, c2);
+        int const rm = mean(r1, r2) +
             (int)floor(((float)pm_drand(randStP) - 0.5) * var + 0.5);
 
         unsigned int r;
 
-        for (r = 0; r < MIN(height, MAX(0, rm)); r++)
+        for (r = 0; r < MIN(height, MAX(0, rm)); ++r)
             pixels[r][cm] = bgcolor;
 
         procTop(pixels, c1, cm, r1, rm, height, var, bgcolor, randStP);
@@ -257,8 +267,8 @@ procBottom(pixel **           const pixels,
            struct pm_randSt * const randStP) {
 
     if (c1 + 1 != c2) {
-        int const cm = (c1 + c2) >> 1;
-        int const rm = ((r1 + r2) >> 1) +
+        int const cm = mean(c1, c2);
+        int const rm = mean(r1, r2) +
             (int)floor(((float)pm_drand(randStP) - 0.5) * var + 0.5);
 
         unsigned int r;
@@ -357,7 +367,8 @@ makeRaggedTopBorder(pixel **           const pixels,
         for (row = 0; row < topR2; ++row)
             pixels[row][topC2] = bgcolor;
 
-        procTop(pixels, topC1, topC2, topR1, topR2, rows, var, bgcolor, randStP);
+        procTop(pixels, topC1, topC2, topR1, topR2, rows,
+                var, bgcolor, randStP);
     }
 }
 
diff --git a/lib/Makefile b/lib/Makefile
index 5040e40f..ffe2a143 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -136,7 +136,7 @@ PERLPROG = print "sgi$(MAJ)." . join(":sgi$(MAJ) . ", (0..$(MIN))) . "\n"
 
 $(SONAME): \
     $(LIBOBJECTS) $(LIBOBJECTS_X) 
-	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
+	$(LD) $(LDSHLIB) $(LDFLAGS) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
           -lc \
 	  -soname libnetpbm.$(NETPBMLIBSUFFIX) \
 	  -set_version $(shell perl -e '$(PERLPROG)') \
@@ -155,7 +155,7 @@ $(SONAME): libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN)
 	rm -f $@
 	$(SYMLINK) $< $@
 libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN): $(LIBOBJECTS) $(LIBOBJECTS_X)
-	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
+	$(LD) $(LDSHLIB) $(LDFLAGS) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
           $(SHLIB_CLIB) -lm $(LADD)
 endif
 
@@ -165,10 +165,10 @@ $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll: $(LIBOBJECTS) $(LIBOBJECTS_X) libnetpbm
 else
 $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll: $(LIBOBJECTS) $(LIBOBJECTS_X)
 endif
-	$(LD) $(LDSHLIB) -Wl,--export-all-symbols \
+	$(LD) $(LDSHLIB) $(LDFLAGS) -Wl,--export-all-symbols \
             -Wl,-soname,$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll \
 	    -Wl,--output-def,$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).def \
-            -Wl,--out-implib,libnetpbm.dll.a -o $@ $(LDFLAGS) \
+            -Wl,--out-implib,libnetpbm.dll.a -o $@ \
             $(LIBOBJECTS) $(LIBOBJECTS_X) $(LDLIBS) $(LADD) 
 endif
 
@@ -182,7 +182,7 @@ libnetpbm.$(MAJ).dylib: libnetpbm.$(MAJ).$(MIN).dylib
 	$(SYMLINK) $< $@
 
 libnetpbm.$(MAJ).$(MIN).dylib: $(LIBOBJECTS) $(LIBOBJECTS_X) 
-	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
+	$(LD) $(LDSHLIB) $(LDFLAGS) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
            -lc $(LADD)
 endif
 
diff --git a/lib/dithers.h b/lib/dithers.h
index 05531a32..d47c39ec 100644
--- a/lib/dithers.h
+++ b/lib/dithers.h
@@ -42,7 +42,7 @@ static int const dither8[16][16] = {
   {  11,227, 51,211,  7,237, 61,221,  8,224, 48,208,  4,238, 62,222},
   { 139, 75,179,115,135, 71,189,125,136, 72,176,112,132, 68,190,126},
   {  43,203, 27,243, 39,199, 23,253, 40,200, 24,240, 36,196, 20,254},
-  { 171,107,155, 91,167,103,151, 87,168,104,152, 88,164,100,148, 84} 
+  { 171,107,155, 91,167,103,151, 87,168,104,152, 88,164,100,148, 84}
 };
 
 /* Order-3 clustered dithering matrix. */
diff --git a/lib/fileio.c b/lib/fileio.c
index 300ae303..d95e5f8c 100644
--- a/lib/fileio.c
+++ b/lib/fileio.c
@@ -25,7 +25,7 @@ pm_getc(FILE * const fileP) {
     if (ich == EOF)
         pm_error("EOF / read error reading a byte");
     ch = (char) ich;
-    
+
     if (ch == '#') {
         do {
             ich = getc(fileP);
@@ -88,7 +88,7 @@ pm_getuint(FILE * const ifP) {
         if (i > INT_MAX/10)
             pm_error("ASCII decimal integer in file is "
                      "too large to be processed.  ");
-        
+
         i *= 10;
 
         if (i > INT_MAX - digitVal)
@@ -106,7 +106,7 @@ pm_getuint(FILE * const ifP) {
 
 
 unsigned int
-pm_getraw(FILE *       const file, 
+pm_getraw(FILE *       const file,
           unsigned int const bytes) {
 
     unsigned int value;  /* our return value */
@@ -129,11 +129,11 @@ pm_getraw(FILE *       const file,
         int n_read;
 
         n_read = fread(inval, bytes, 1, file);
-        if (n_read < 1) 
+        if (n_read < 1)
             pm_error("EOF/error reading %d byte sample from file.", bytes);
         value = 0;  /* initial value */
         cursor = 0;
-        for (shift = (bytes-1)*8; shift >= 0; shift-=8) 
+        for (shift = (bytes-1)*8; shift >= 0; shift-=8)
             value += inval[cursor++] << shift;
     }
     return(value);
@@ -142,8 +142,8 @@ pm_getraw(FILE *       const file,
 
 
 void
-pm_putraw(FILE *       const file, 
-          unsigned int const value, 
+pm_putraw(FILE *       const file,
+          unsigned int const value,
           unsigned int const bytes) {
 
     if (bytes == 1) {
@@ -169,7 +169,7 @@ pm_putraw(FILE *       const file,
             outval[cursor++] = (value >> shift) & 0xFF;
         }
         n_written = fwrite(&outval, bytes, 1, file);
-        if (n_written == 0) 
+        if (n_written == 0)
             pm_error("Error writing %d byte sample to file.", bytes);
     }
 }
diff --git a/lib/libpam.c b/lib/libpam.c
index a01dd596..07241e9e 100644
--- a/lib/libpam.c
+++ b/lib/libpam.c
@@ -127,6 +127,28 @@ validateComputableSize(struct pam * const pamP) {
 
 
 
+static void
+validateComputableMaxval(const struct pam * const pamP) {
+/*----------------------------------------------------------------------------
+  This is similar to validateComputableSize, but for the maxval.
+-----------------------------------------------------------------------------*/
+    /* Code sometimes allocates an array indexed by sample values and
+       represents the size of that array as an INT.  (UNSIGNED INT would be
+       more proper, but there's no need to be that permissive).
+
+       Code also sometimes iterates through sample values and quits when the
+       value is greater than the maxval.
+    */
+
+    if (pamP->maxval == 0)
+        pm_error("Maxval is zero.  Must be at least one.");
+
+    if (pamP->maxval > INT_MAX-1)
+        pm_error("Maxval (%lu) is too large to be processed", pamP->maxval);
+}
+
+
+
 tuple
 pnm_allocpamtuple(const struct pam * const pamP) {
 
@@ -739,7 +761,7 @@ readpaminitrest(struct pam * const pamP) {
     if (pamP->maxval == 0)
         pm_error("MAXVAL value is zero in PAM header");
     if (pamP->maxval > PAM_OVERALL_MAXVAL)
-        pm_error("MAXVAL value (%lu) in PAM header is greater than %u",
+        pm_error("MAXVAL value (%lu) in PAM header is greater than %lu",
                  pamP->maxval, PAM_OVERALL_MAXVAL);
 }
 
@@ -990,6 +1012,8 @@ pnm_readpaminit(FILE *       const file,
     interpretTupleType(pamP);
 
     validateComputableSize(pamP);
+
+    validateComputableMaxval(pamP);
 }
 
 
@@ -1074,7 +1098,7 @@ pnm_writepaminit(struct pam * const pamP) {
 
     if (pamP->maxval > PAM_OVERALL_MAXVAL)
         pm_error("maxval (%lu) passed to pnm_writepaminit() "
-                 "is greater than %u", pamP->maxval, PAM_OVERALL_MAXVAL);
+                 "is greater than %lu", pamP->maxval, PAM_OVERALL_MAXVAL);
 
     if (pamP->len < PAM_STRUCT_SIZE(tuple_type)) {
         tupleType = "";
diff --git a/lib/libpamread.c b/lib/libpamread.c
index 74b1ab83..1ebf4b2f 100644
--- a/lib/libpamread.c
+++ b/lib/libpamread.c
@@ -13,7 +13,7 @@
    offset stuff.
 */
 #define _FILE_OFFSET_BITS 64
-#define _LARGE_FILES  
+#define _LARGE_FILES
 
 #include <string.h>
 #include <limits.h>
@@ -49,11 +49,11 @@ readPbmRow(const struct pam * const pamP,
 
             pbm_readpbmrow_packed(pamP->file, bitrow, pamP->width,
                                   pamP->format);
-    
+
             if (tuplerow) {
                 unsigned int col;
                 for (col = 0; col < pamP->width; ++col) {
-                    tuplerow[col][0] = 
+                    tuplerow[col][0] =
                         ( ((bitrow[col/8] >> (7-col%8)) & 1 ) == PBM_BLACK)
                         ? PAM_PBM_BLACK : PAM_PBM_WHITE
                         ;
@@ -207,7 +207,7 @@ validatePamRow(const struct pam * const pamP,
                tuple *            const tuplerow,
                const char **      const errorP) {
 /*----------------------------------------------------------------------------
-  Check for sample values above maxval in input.  
+  Check for sample values above maxval in input.
 
   Note: a program that wants to deal with invalid sample values itself can
   simply make sure it sets pamP->maxval sufficiently high, so this validation
@@ -251,7 +251,7 @@ static void
 readRawNonPbmRow(const struct pam * const pamP,
                  tuple *            const tuplerow) {
 
-    unsigned int const rowImageSize = 
+    unsigned int const rowImageSize =
         pamP->width * pamP->bytes_per_sample * pamP->depth;
 
     unsigned char * inbuf;
@@ -259,14 +259,14 @@ readRawNonPbmRow(const struct pam * const pamP,
     const char * error;
 
     inbuf = pnm_allocrowimage(pamP);
-    
+
     bytesRead = fread(inbuf, 1, rowImageSize, pamP->file);
 
     if (bytesRead != rowImageSize) {
         if (feof(pamP->file))
             pm_asprintf(&error, "End of file encountered "
                         "when trying to read a row from input file.");
-        else 
+        else
             pm_asprintf(&error, "Error reading a row from input file.  "
                         "fread() fails with errno=%d (%s)",
                         errno, strerror(errno));
@@ -297,23 +297,23 @@ readRawNonPbmRow(const struct pam * const pamP,
 
 
 
-void 
-pnm_readpamrow(const struct pam * const pamP, 
+void
+pnm_readpamrow(const struct pam * const pamP,
                tuple *            const tuplerow) {
 /*----------------------------------------------------------------------------
    Read a row from the Netpbm image file into tuplerow[], at the
    current file position.  If 'tuplerow' is NULL, advance the file
    pointer to the next row, but don't return the contents of the
    current one.
-   
+
    We assume the file is positioned to the beginning of a row of the
    image's raster.
 -----------------------------------------------------------------------------*/
-    /* For speed, we don't check any of the inputs for consistency 
+    /* For speed, we don't check any of the inputs for consistency
        here (unless it's necessary to avoid crashing).  Any consistency
-       checking should have been done by a prior call to 
+       checking should have been done by a prior call to
        pnm_readpaminit().
-    */  
+    */
 
     /* Need a special case for raw PBM because it has multiple tuples (8)
        packed into one byte.
@@ -340,9 +340,9 @@ pnm_readpamrow(const struct pam * const pamP,
 
 
 
-tuple ** 
+tuple **
 pnm_readpam(FILE *       const fileP,
-            struct pam * const pamP, 
+            struct pam * const pamP,
             int          const size) {
 
     jmp_buf jmpbuf;
@@ -350,9 +350,9 @@ pnm_readpam(FILE *       const fileP,
     tuple ** tuplearray;
 
     pnm_readpaminit(fileP, pamP, size);
-    
+
     tuplearray = pnm_allocpamarray(pamP);
-    
+
     if (setjmp(jmpbuf) != 0) {
         pnm_freepamarray(tuplearray, pamP);
         pm_setjmpbuf(origJmpbufP);
@@ -361,8 +361,8 @@ pnm_readpam(FILE *       const fileP,
         unsigned int row;
 
         pm_setjmpbufsave(&jmpbuf, &origJmpbufP);
-            
-        for (row = 0; row < pamP->height; ++row) 
+
+        for (row = 0; row < pamP->height; ++row)
             pnm_readpamrow(pamP, tuplearray[row]);
 
         pm_setjmpbuf(origJmpbufP);
diff --git a/lib/libpbm1.c b/lib/libpbm1.c
index 49ab7fdf..d3403311 100644
--- a/lib/libpbm1.c
+++ b/lib/libpbm1.c
@@ -14,7 +14,7 @@
    offset stuff.
 */
 #define _FILE_OFFSET_BITS 64
-#define _LARGE_FILES  
+#define _LARGE_FILES
 
 #include <stdio.h>
 
@@ -59,7 +59,7 @@ pbm_nextimage(FILE *file, int * const eofP) {
 
 void
 pbm_check(FILE *               const fileP,
-          enum pm_check_type   const checkType, 
+          enum pm_check_type   const checkType,
           int                  const format,
           int                  const cols,
           int                  const rows,
@@ -69,14 +69,14 @@ pbm_check(FILE *               const fileP,
         pm_error("Invalid number of rows passed to pbm_check(): %d", rows);
     if (cols < 0)
         pm_error("Invalid number of columns passed to pbm_check(): %d", cols);
-    
+
     if (checkType != PM_CHECK_BASIC) {
         if (retvalP)
             *retvalP = PM_CHECK_UNKNOWN_TYPE;
     } else if (format != RPBM_FORMAT) {
         if (retvalP)
             *retvalP = PM_CHECK_UNCHECKABLE;
-    } else {        
+    } else {
         pm_filepos const bytesPerRow    = (cols+7)/8;
         pm_filepos const needRasterSize = rows * bytesPerRow;
         pm_check(fileP, checkType, needRasterSize, retvalP);
@@ -179,3 +179,6 @@ pbm_backgroundbitrow(unsigned const char * const packedBits,
     }
     return retval;
 }
+
+
+
diff --git a/lib/libpgm1.c b/lib/libpgm1.c
index 9ef5d2c1..6feb1c8b 100644
--- a/lib/libpgm1.c
+++ b/lib/libpgm1.c
@@ -14,7 +14,7 @@
    offset stuff.
 */
 #define _FILE_OFFSET_BITS 64
-#define _LARGE_FILES  
+#define _LARGE_FILES
 
 #include <string.h>
 #include <stdio.h>
@@ -47,7 +47,7 @@ pgm_allocrow(unsigned int const cols) {
 
 
 
-void 
+void
 pgm_init(int *   const argcP,
          char ** const argv) {
 
@@ -65,13 +65,13 @@ pgm_nextimage(FILE * const file,
 
 
 void
-pgm_readpgminitrest(FILE * const fileP, 
-                    int *  const colsP, 
-                    int *  const rowsP, 
+pgm_readpgminitrest(FILE * const fileP,
+                    int *  const colsP,
+                    int *  const rowsP,
                     gray * const maxvalP) {
 
     gray maxval;
-    
+
     /* Read size. */
     *colsP = (int)pm_getuint(fileP);
     *rowsP = (int)pm_getuint(fileP);
@@ -80,7 +80,7 @@ pgm_readpgminitrest(FILE * const fileP,
     maxval = pm_getuint(fileP);
     if (maxval > PGM_OVERALLMAXVAL)
         pm_error("maxval of input image (%u) is too large.  "
-                 "The maximum allowed by PGM is %u.", 
+                 "The maximum allowed by PGM is %u.",
                  maxval, PGM_OVERALLMAXVAL);
     if (maxval == 0)
         pm_error("maxval of input image is zero.");
@@ -115,9 +115,31 @@ validateComputableSize(unsigned int const cols,
 
 
 
+static void
+validateComputableMaxval(gray const maxval) {
+/*----------------------------------------------------------------------------
+  This is similar to validateComputableSize, but for the maxval.
+-----------------------------------------------------------------------------*/
+    /* Code sometimes allocates an array indexed by sample values and
+       represents the size of that array as an INT.  (UNSIGNED INT would be
+       more proper, but there's no need to be that permissive).
+
+       Code also sometimes iterates through sample values and quits when the
+       value is greater than the maxval.
+    */
+
+    if (maxval == 0)
+        pm_error("Maxval is zero.  Must be at least one.");
+
+    if (maxval > INT_MAX-1)
+        pm_error("Maxval (%u) is too large to be processed", maxval);
+}
+
+
+
 void
 pgm_readpgminit(FILE * const fileP,
-                int *  const colsP, 
+                int *  const colsP,
                 int *  const rowsP,
                 gray * const maxvalP,
                 int *  const formatP) {
@@ -130,7 +152,7 @@ pgm_readpgminit(FILE * const fileP,
     case PBM_TYPE:
         *formatP = realFormat;
         pbm_readpbminitrest(fileP, colsP, rowsP);
-        
+
         /* Mathematically, it makes the most sense for the maxval of a PBM
            file seen as a PGM to be 1.  But we tried this for a while and
            found that it causes unexpected results and frequent need for a
@@ -139,14 +161,14 @@ pgm_readpgminit(FILE * const fileP,
            there's no in-between value to use when maxval is 1.  It's really
            hard even to discover that your lack of Pnmdepth is your problem.
            So we pick 255, which is the most common PGM maxval, and the highest
-           resolution you can get without increasing the size of the PGM 
+           resolution you can get without increasing the size of the PGM
            image.
 
            So this means some programs that are capable of exploiting the
            bi-level nature of a PBM file must be PNM programs instead of PGM
            programs.
         */
-        
+
         *maxvalP = PGM_MAXMAXVAL;
         break;
 
@@ -154,7 +176,7 @@ pgm_readpgminit(FILE * const fileP,
         *formatP = realFormat;
         pgm_readpgminitrest(fileP, colsP, rowsP, maxvalP);
         break;
-        
+
     case PPM_TYPE:
         pm_error("Input file is a PPM, which this program cannot process.  "
                  "You may want to convert it to PGM with 'ppmtopgm'");
@@ -172,17 +194,19 @@ pgm_readpgminit(FILE * const fileP,
                  realFormat);
     }
     validateComputableSize(*colsP, *rowsP);
+
+    validateComputableMaxval(*maxvalP);
 }
 
 
 
 static void
-validateRpgmRow(gray *         const grayrow, 
+validateRpgmRow(gray *         const grayrow,
                 unsigned int   const cols,
                 gray           const maxval,
                 const char **  const errorP) {
 /*----------------------------------------------------------------------------
-  Check for sample values above maxval in input.  
+  Check for sample values above maxval in input.
 
   Note: a program that wants to deal with invalid sample values itself can
   simply make sure it uses a sufficiently high maxval on the read function
@@ -205,23 +229,23 @@ validateRpgmRow(gray *         const grayrow,
         }
         *errorP = NULL;
     }
-}  
+}
 
 
 
 static void
 readRpgmRow(FILE * const fileP,
-            gray * const grayrow, 
+            gray * const grayrow,
             int    const cols,
             gray   const maxval,
             int    const format) {
 
     unsigned int const bytesPerSample = maxval < 256 ? 1 : 2;
     int          const bytesPerRow    = cols * bytesPerSample;
-    
+
     unsigned char * rowBuffer;
     const char * error;
-    
+
     MALLOCARRAY(rowBuffer, bytesPerRow);
     if (rowBuffer == NULL)
         pm_asprintf(&error, "Unable to allocate memory for row buffer "
@@ -243,19 +267,19 @@ readRpgmRow(FILE * const fileP,
             } else {
                 unsigned int bufferCursor;
                 unsigned int col;
-                
+
                 bufferCursor = 0;  /* Start at beginning of rowBuffer[] */
-                
+
                 for (col = 0; col < cols; ++col) {
                     gray g;
-                    
+
                     g = rowBuffer[bufferCursor++] << 8;
                     g |= rowBuffer[bufferCursor++];
-                    
+
                     grayrow[col] = g;
                 }
             }
-            validateRpgmRow(grayrow, cols, maxval, &error); 
+            validateRpgmRow(grayrow, cols, maxval, &error);
         }
         free(rowBuffer);
     }
@@ -264,13 +288,13 @@ readRpgmRow(FILE * const fileP,
         pm_strfree(error);
         pm_longjmp();
     }
-} 
+}
 
 
 
 static void
 readPbmRow(FILE * const fileP,
-           gray * const grayrow, 
+           gray * const grayrow,
            int    const cols,
            gray   const maxval,
            int    const format) {
@@ -278,7 +302,7 @@ readPbmRow(FILE * const fileP,
     jmp_buf jmpbuf;
     jmp_buf * origJmpbufP;
     bit * bitrow;
-    
+
     bitrow = pbm_allocrow_packed(cols);
     if (setjmp(jmpbuf) != 0) {
         pbm_freerow(bitrow);
@@ -306,7 +330,7 @@ readPbmRow(FILE * const fileP,
 
 void
 pgm_readpgmrow(FILE * const fileP,
-               gray * const grayrow, 
+               gray * const grayrow,
                int    const cols,
                gray   const maxval,
                int    const format) {
@@ -322,16 +346,16 @@ pgm_readpgmrow(FILE * const fileP,
         }
     }
     break;
-        
+
     case RPGM_FORMAT:
         readRpgmRow(fileP, grayrow, cols, maxval, format);
         break;
-    
+
     case PBM_FORMAT:
     case RPBM_FORMAT:
         readPbmRow(fileP, grayrow, cols, maxval, format);
         break;
-        
+
     default:
         pm_error("can't happen");
     }
@@ -342,7 +366,7 @@ pgm_readpgmrow(FILE * const fileP,
 gray **
 pgm_readpgm(FILE * const fileP,
             int *  const colsP,
-            int *  const rowsP, 
+            int *  const rowsP,
             gray * const maxvalP) {
 
     gray ** grays;
@@ -353,7 +377,7 @@ pgm_readpgm(FILE * const fileP,
     jmp_buf * origJmpbufP;
 
     pgm_readpgminit(fileP, &cols, &rows, &maxval, &format);
-    
+
     grays = pgm_allocarray(cols, rows);
 
     if (setjmp(jmpbuf) != 0) {
@@ -362,7 +386,7 @@ pgm_readpgm(FILE * const fileP,
         pm_longjmp();
     } else {
         unsigned int row;
-    
+
         pm_setjmpbufsave(&jmpbuf, &origJmpbufP);
 
         for (row = 0; row < rows; ++row)
@@ -379,11 +403,11 @@ pgm_readpgm(FILE * const fileP,
 
 
 void
-pgm_check(FILE *               const file, 
-          enum pm_check_type   const checkType, 
-          int                  const format, 
-          int                  const cols, 
-          int                  const rows, 
+pgm_check(FILE *               const file,
+          enum pm_check_type   const checkType,
+          int                  const format,
+          int                  const cols,
+          int                  const rows,
           gray                 const maxval,
           enum pm_check_code * const retvalP) {
 
@@ -391,7 +415,7 @@ pgm_check(FILE *               const file,
         pm_error("Invalid number of rows passed to pgm_check(): %d", rows);
     if (cols < 0)
         pm_error("Invalid number of columns passed to pgm_check(): %d", cols);
-    
+
     if (checkType != PM_CHECK_BASIC) {
         if (retvalP)
             *retvalP = PM_CHECK_UNKNOWN_TYPE;
@@ -400,10 +424,13 @@ pgm_check(FILE *               const file,
     } else if (format != RPGM_FORMAT) {
         if (retvalP)
             *retvalP = PM_CHECK_UNCHECKABLE;
-    } else {        
+    } else {
         pm_filepos const bytesPerRow    = cols * (maxval > 255 ? 2 : 1);
         pm_filepos const needRasterSize = rows * bytesPerRow;
-        
+
         pm_check(file, checkType, needRasterSize, retvalP);
     }
 }
+
+
+
diff --git a/lib/libpgm2.c b/lib/libpgm2.c
index 80b5cf42..2e3aba90 100644
--- a/lib/libpgm2.c
+++ b/lib/libpgm2.c
@@ -20,29 +20,29 @@
 
 
 void
-pgm_writepgminit(FILE * const fileP, 
-                 int    const cols, 
-                 int    const rows, 
-                 gray   const maxval, 
+pgm_writepgminit(FILE * const fileP,
+                 int    const cols,
+                 int    const rows,
+                 gray   const maxval,
                  int    const forceplain) {
 
     bool const plainFormat = forceplain || pm_plain_output;
 
-    if (maxval > PGM_OVERALLMAXVAL && !plainFormat) 
+    if (maxval > PGM_OVERALLMAXVAL && !plainFormat)
         pm_error("too-large maxval passed to ppm_writepgminit(): %d.\n"
                  "Maximum allowed by the PGM format is %d.",
                  maxval, PGM_OVERALLMAXVAL);
 
-    fprintf(fileP, "%c%c\n%d %d\n%d\n", 
-            PGM_MAGIC1, 
-            plainFormat || maxval >= 1<<16 ? PGM_MAGIC2 : RPGM_MAGIC2, 
+    fprintf(fileP, "%c%c\n%d %d\n%d\n",
+            PGM_MAGIC1,
+            plainFormat || maxval >= 1<<16 ? PGM_MAGIC2 : RPGM_MAGIC2,
             cols, rows, maxval );
 }
 
 
 
 static void
-putus(unsigned short const n, 
+putus(unsigned short const n,
       FILE *         const fileP) {
 
     if (n >= 10)
@@ -85,7 +85,7 @@ format2bpsRow(const gray    * const grayrow,
 
     for (col = 0; col < cols; ++col) {
         gray const val = grayrow[col];
-        
+
         rowBuffer[bufferCursor++] = val >> 8;
         rowBuffer[bufferCursor++] = (unsigned char) val;
     }
@@ -134,8 +134,8 @@ writepgmrowraw(FILE *       const fileP,
 
 static void
 writepgmrowplain(FILE *       const fileP,
-                 const gray * const grayrow, 
-                 unsigned int const cols, 
+                 const gray * const grayrow,
+                 unsigned int const cols,
                  gray         const maxval) {
 
     int col, charcount;
@@ -163,10 +163,10 @@ writepgmrowplain(FILE *       const fileP,
 
 
 void
-pgm_writepgmrow(FILE *       const fileP, 
-                const gray * const grayrow, 
-                int          const cols, 
-                gray         const maxval, 
+pgm_writepgmrow(FILE *       const fileP,
+                const gray * const grayrow,
+                int          const cols,
+                gray         const maxval,
                 int          const forceplain) {
 
     if (forceplain || pm_plain_output || maxval >= 1<<16)
diff --git a/lib/libpm.c b/lib/libpm.c
index 78d941fa..b27b47d5 100644
--- a/lib/libpm.c
+++ b/lib/libpm.c
@@ -442,12 +442,20 @@ pm_maxvaltobits(int const maxval) {
     assert(false);
 }
 
+
+
 int
-pm_bitstomaxval(int const bits) {
-    return ( 1 << bits ) - 1;
+pm_bitstomaxval(int const bitCt) {
+
+    if (bitCt > 16)
+        pm_error("Bits per sample %u too large.  16 is maximum acceptable",
+                 bitCt);
+
+    return (1 << bitCt) - 1;
 }
 
 
+
 unsigned int PURE_FN_ATTR
 pm_lcm(unsigned int const x,
        unsigned int const y,
diff --git a/lib/libpnm1.c b/lib/libpnm1.c
index db21b078..ed5b5e37 100644
--- a/lib/libpnm1.c
+++ b/lib/libpnm1.c
@@ -83,6 +83,28 @@ validateComputableSize(unsigned int const cols,
 
 
 
+static void
+validateComputableMaxval(pixval const maxval) {
+/*----------------------------------------------------------------------------
+  This is similar to validateComputableSize, but for the maxval.
+-----------------------------------------------------------------------------*/
+    /* Code sometimes allocates an array indexed by sample values and
+       represents the size of that array as an INT.  (UNSIGNED INT would be
+       more proper, but there's no need to be that permissive).
+
+       Code also sometimes iterates through sample values and quits when the
+       value is greater than the maxval.
+    */
+
+    if (maxval == 0)
+        pm_error("Maxval is zero.  Must be at least one.");
+
+    if (maxval > INT_MAX-1)
+        pm_error("Maxval (%u) is too large to be processed", maxval);
+}
+
+
+
 void
 pnm_readpnminit(FILE *   const fileP,
                 int *    const colsP,
@@ -130,6 +152,8 @@ pnm_readpnminit(FILE *   const fileP,
                  realFormat);
     }
     validateComputableSize(*colsP, *rowsP);
+
+    validateComputableMaxval(*maxvalP);
 }
 
 
@@ -220,7 +244,7 @@ pnm_readpnmrow(FILE * const fileP,
     case PGM_TYPE:
         readpgmrow(fileP, xelrow, cols, maxval, format);
         break;
-        
+
     case PBM_TYPE:
         readpbmrow(fileP, xelrow, cols, maxval, format);
         break;
@@ -276,7 +300,7 @@ pnm_readpnm(FILE *   const fileP,
 
 void
 pnm_check(FILE *               const fileP,
-          enum pm_check_type   const check_type, 
+          enum pm_check_type   const check_type,
           int                  const format,
           int                  const cols,
           int                  const rows,
@@ -287,7 +311,7 @@ pnm_check(FILE *               const fileP,
     case PBM_TYPE:
         pbm_check(fileP, check_type, format, cols, rows, retvalP);
         break;
-    case PGM_TYPE: 
+    case PGM_TYPE:
         pgm_check(fileP, check_type, format, cols, rows, maxval, retvalP);
         break;
     case PPM_TYPE:
diff --git a/lib/libppm.h b/lib/libppm.h
index ec2a173d..0c561022 100644
--- a/lib/libppm.h
+++ b/lib/libppm.h
@@ -7,9 +7,9 @@
 #include "ppm.h"
 
 void
-ppm_readppminitrest(FILE *   const file, 
-                    int *    const colsP, 
-                    int *    const rowsP, 
+ppm_readppminitrest(FILE *   const file,
+                    int *    const colsP,
+                    int *    const rowsP,
                     pixval * const maxvalP);
 
 #endif
diff --git a/lib/libppm1.c b/lib/libppm1.c
index ccc8adb5..427adf4d 100644
--- a/lib/libppm1.c
+++ b/lib/libppm1.c
@@ -113,6 +113,28 @@ validateComputableSize(unsigned int const cols,
 
 
 
+static void
+validateComputableMaxval(pixval const maxval) {
+/*----------------------------------------------------------------------------
+  This is similar to validateComputableSize, but for the maxval.
+-----------------------------------------------------------------------------*/
+    /* Code sometimes allocates an array indexed by sample values and
+       represents the size of that array as an INT.  (UNSIGNED INT would be
+       more proper, but there's no need to be that permissive).
+
+       Code also sometimes iterates through sample values and quits when the
+       value is greater than the maxval.
+    */
+
+    if (maxval == 0)
+        pm_error("Maxval is zero.  Must be at least one.");
+
+    if (maxval > INT_MAX-1)
+        pm_error("Maxval (%u) is too large to be processed", maxval);
+}
+
+
+
 void
 ppm_readppminit(FILE *   const fileP,
                 int *    const colsP,
@@ -151,6 +173,8 @@ ppm_readppminit(FILE *   const fileP,
                  realFormat);
     }
     validateComputableSize(*colsP, *rowsP);
+
+    validateComputableMaxval(*maxvalP);
 }
 
 
diff --git a/lib/libppm2.c b/lib/libppm2.c
index 694ecdd7..b4690b71 100644
--- a/lib/libppm2.c
+++ b/lib/libppm2.c
@@ -19,22 +19,22 @@
 #include "ppm.h"
 
 void
-ppm_writeppminit(FILE*  const fileP, 
-                 int    const cols, 
-                 int    const rows, 
-                 pixval const maxval, 
+ppm_writeppminit(FILE*  const fileP,
+                 int    const cols,
+                 int    const rows,
+                 pixval const maxval,
                  int    const forceplain) {
 
     bool const plainFormat = forceplain || pm_plain_output;
 
-    if (maxval > PPM_OVERALLMAXVAL && !plainFormat) 
+    if (maxval > PPM_OVERALLMAXVAL && !plainFormat)
         pm_error("too-large maxval passed to ppm_writeppminit(): %d."
                  "Maximum allowed by the PPM format is %d.",
                  maxval, PPM_OVERALLMAXVAL);
 
-    fprintf(fileP, "%c%c\n%d %d\n%d\n", 
-            PPM_MAGIC1, 
-            plainFormat || maxval >= 1<<16 ? PPM_MAGIC2 : RPPM_MAGIC2, 
+    fprintf(fileP, "%c%c\n%d %d\n%d\n",
+            PPM_MAGIC1,
+            plainFormat || maxval >= 1<<16 ? PPM_MAGIC2 : RPPM_MAGIC2,
             cols, rows, maxval );
 }
 
@@ -77,7 +77,7 @@ static void
 format2bpsRow(const pixel *   const pixelrow,
               unsigned int    const cols,
               unsigned char * const rowBuffer) {
-    
+
     /* two byte samples. */
 
     unsigned int col;
@@ -89,7 +89,7 @@ format2bpsRow(const pixel *   const pixelrow,
         pixval const r = PPM_GETR(pixelrow[col]);
         pixval const g = PPM_GETG(pixelrow[col]);
         pixval const b = PPM_GETB(pixelrow[col]);
-        
+
         rowBuffer[bufferCursor++] = r >> 8;
         rowBuffer[bufferCursor++] = (unsigned char)r;
         rowBuffer[bufferCursor++] = g >> 8;
@@ -176,31 +176,31 @@ ppm_writeppmrowplain(FILE *        const fileP,
 
 
 void
-ppm_writeppmrow(FILE *        const fileP, 
-                const pixel * const pixelrow, 
-                int           const cols, 
-                pixval        const maxval, 
+ppm_writeppmrow(FILE *        const fileP,
+                const pixel * const pixelrow,
+                int           const cols,
+                pixval        const maxval,
                 int           const forceplain) {
 
-    if (forceplain || pm_plain_output || maxval >= 1<<16) 
+    if (forceplain || pm_plain_output || maxval >= 1<<16)
         ppm_writeppmrowplain(fileP, pixelrow, cols, maxval);
-    else 
+    else
         ppm_writeppmrowraw(fileP, pixelrow, cols, maxval);
 }
 
 
 
 void
-ppm_writeppm(FILE *  const file, 
-             pixel** const pixels, 
-             int     const cols, 
-             int     const rows, 
-             pixval  const maxval, 
+ppm_writeppm(FILE *  const file,
+             pixel** const pixels,
+             int     const cols,
+             int     const rows,
+             pixval  const maxval,
              int     const forceplain)  {
     int row;
-    
+
     ppm_writeppminit(file, cols, rows, maxval, forceplain);
-    
+
     for (row = 0; row < rows; ++row)
         ppm_writeppmrow(file, pixels[row], cols, maxval, forceplain);
 }
diff --git a/lib/libppmfuzzy.c b/lib/libppmfuzzy.c
index 902d684d..37fa02ca 100644
--- a/lib/libppmfuzzy.c
+++ b/lib/libppmfuzzy.c
@@ -62,7 +62,7 @@ memberTrapez(fzLog const x1,
              fzLog const x) {
 
     fzLog retval;
-    
+
     if (x <= x1 || x > x4)
         retval = 0;
     else if (x > x1 && x <= x2)
@@ -301,7 +301,7 @@ matchBk(pixel     const color,
 
     (*bkMatchP)[BKCOLOR_WHITE]  =
         fzAnd(satVeryLow, valVeryHigh);
-    
+
     (*bkMatchP)[BKCOLOR_RED]    =
         fzAnd(fzAnd(fzOr(hueAround000, hueAround360), fzNot(satVeryLow)),
               fzOr(valMedium, valHigh)
@@ -342,7 +342,7 @@ matchBk(pixel     const color,
              fzAnd(fzOr(hueAround015, hueAround360),
                    fzAnd(fzNot(satVeryLow), fzOr(valLow, valMedium))),
              fzAnd(hueAround015, satLow)
-	    );
+            );
 }
 
 
diff --git a/lib/lum.h b/lib/lum.h
index 3d20032b..b80d602e 100644
--- a/lib/lum.h
+++ b/lib/lum.h
@@ -2,104 +2,104 @@
 
     /* Lookup tables for fast RGB -> luminance calculation. */
     static int times77[256] = {
-	    0,    77,   154,   231,   308,   385,   462,   539,
-	  616,   693,   770,   847,   924,  1001,  1078,  1155,
-	 1232,  1309,  1386,  1463,  1540,  1617,  1694,  1771,
-	 1848,  1925,  2002,  2079,  2156,  2233,  2310,  2387,
-	 2464,  2541,  2618,  2695,  2772,  2849,  2926,  3003,
-	 3080,  3157,  3234,  3311,  3388,  3465,  3542,  3619,
-	 3696,  3773,  3850,  3927,  4004,  4081,  4158,  4235,
-	 4312,  4389,  4466,  4543,  4620,  4697,  4774,  4851,
-	 4928,  5005,  5082,  5159,  5236,  5313,  5390,  5467,
-	 5544,  5621,  5698,  5775,  5852,  5929,  6006,  6083,
-	 6160,  6237,  6314,  6391,  6468,  6545,  6622,  6699,
-	 6776,  6853,  6930,  7007,  7084,  7161,  7238,  7315,
-	 7392,  7469,  7546,  7623,  7700,  7777,  7854,  7931,
-	 8008,  8085,  8162,  8239,  8316,  8393,  8470,  8547,
-	 8624,  8701,  8778,  8855,  8932,  9009,  9086,  9163,
-	 9240,  9317,  9394,  9471,  9548,  9625,  9702,  9779,
-	 9856,  9933, 10010, 10087, 10164, 10241, 10318, 10395,
-	10472, 10549, 10626, 10703, 10780, 10857, 10934, 11011,
-	11088, 11165, 11242, 11319, 11396, 11473, 11550, 11627,
-	11704, 11781, 11858, 11935, 12012, 12089, 12166, 12243,
-	12320, 12397, 12474, 12551, 12628, 12705, 12782, 12859,
-	12936, 13013, 13090, 13167, 13244, 13321, 13398, 13475,
-	13552, 13629, 13706, 13783, 13860, 13937, 14014, 14091,
-	14168, 14245, 14322, 14399, 14476, 14553, 14630, 14707,
-	14784, 14861, 14938, 15015, 15092, 15169, 15246, 15323,
-	15400, 15477, 15554, 15631, 15708, 15785, 15862, 15939,
-	16016, 16093, 16170, 16247, 16324, 16401, 16478, 16555,
-	16632, 16709, 16786, 16863, 16940, 17017, 17094, 17171,
-	17248, 17325, 17402, 17479, 17556, 17633, 17710, 17787,
-	17864, 17941, 18018, 18095, 18172, 18249, 18326, 18403,
-	18480, 18557, 18634, 18711, 18788, 18865, 18942, 19019,
-	19096, 19173, 19250, 19327, 19404, 19481, 19558, 19635 };
+            0,    77,   154,   231,   308,   385,   462,   539,
+          616,   693,   770,   847,   924,  1001,  1078,  1155,
+         1232,  1309,  1386,  1463,  1540,  1617,  1694,  1771,
+         1848,  1925,  2002,  2079,  2156,  2233,  2310,  2387,
+         2464,  2541,  2618,  2695,  2772,  2849,  2926,  3003,
+         3080,  3157,  3234,  3311,  3388,  3465,  3542,  3619,
+         3696,  3773,  3850,  3927,  4004,  4081,  4158,  4235,
+         4312,  4389,  4466,  4543,  4620,  4697,  4774,  4851,
+         4928,  5005,  5082,  5159,  5236,  5313,  5390,  5467,
+         5544,  5621,  5698,  5775,  5852,  5929,  6006,  6083,
+         6160,  6237,  6314,  6391,  6468,  6545,  6622,  6699,
+         6776,  6853,  6930,  7007,  7084,  7161,  7238,  7315,
+         7392,  7469,  7546,  7623,  7700,  7777,  7854,  7931,
+         8008,  8085,  8162,  8239,  8316,  8393,  8470,  8547,
+         8624,  8701,  8778,  8855,  8932,  9009,  9086,  9163,
+         9240,  9317,  9394,  9471,  9548,  9625,  9702,  9779,
+         9856,  9933, 10010, 10087, 10164, 10241, 10318, 10395,
+        10472, 10549, 10626, 10703, 10780, 10857, 10934, 11011,
+        11088, 11165, 11242, 11319, 11396, 11473, 11550, 11627,
+        11704, 11781, 11858, 11935, 12012, 12089, 12166, 12243,
+        12320, 12397, 12474, 12551, 12628, 12705, 12782, 12859,
+        12936, 13013, 13090, 13167, 13244, 13321, 13398, 13475,
+        13552, 13629, 13706, 13783, 13860, 13937, 14014, 14091,
+        14168, 14245, 14322, 14399, 14476, 14553, 14630, 14707,
+        14784, 14861, 14938, 15015, 15092, 15169, 15246, 15323,
+        15400, 15477, 15554, 15631, 15708, 15785, 15862, 15939,
+        16016, 16093, 16170, 16247, 16324, 16401, 16478, 16555,
+        16632, 16709, 16786, 16863, 16940, 17017, 17094, 17171,
+        17248, 17325, 17402, 17479, 17556, 17633, 17710, 17787,
+        17864, 17941, 18018, 18095, 18172, 18249, 18326, 18403,
+        18480, 18557, 18634, 18711, 18788, 18865, 18942, 19019,
+        19096, 19173, 19250, 19327, 19404, 19481, 19558, 19635 };
     static int times150[256] = {
-	    0,   150,   300,   450,   600,   750,   900,  1050,
-	 1200,  1350,  1500,  1650,  1800,  1950,  2100,  2250,
-	 2400,  2550,  2700,  2850,  3000,  3150,  3300,  3450,
-	 3600,  3750,  3900,  4050,  4200,  4350,  4500,  4650,
-	 4800,  4950,  5100,  5250,  5400,  5550,  5700,  5850,
-	 6000,  6150,  6300,  6450,  6600,  6750,  6900,  7050,
-	 7200,  7350,  7500,  7650,  7800,  7950,  8100,  8250,
-	 8400,  8550,  8700,  8850,  9000,  9150,  9300,  9450,
-	 9600,  9750,  9900, 10050, 10200, 10350, 10500, 10650,
-	10800, 10950, 11100, 11250, 11400, 11550, 11700, 11850,
-	12000, 12150, 12300, 12450, 12600, 12750, 12900, 13050,
-	13200, 13350, 13500, 13650, 13800, 13950, 14100, 14250,
-	14400, 14550, 14700, 14850, 15000, 15150, 15300, 15450,
-	15600, 15750, 15900, 16050, 16200, 16350, 16500, 16650,
-	16800, 16950, 17100, 17250, 17400, 17550, 17700, 17850,
-	18000, 18150, 18300, 18450, 18600, 18750, 18900, 19050,
-	19200, 19350, 19500, 19650, 19800, 19950, 20100, 20250,
-	20400, 20550, 20700, 20850, 21000, 21150, 21300, 21450,
-	21600, 21750, 21900, 22050, 22200, 22350, 22500, 22650,
-	22800, 22950, 23100, 23250, 23400, 23550, 23700, 23850,
-	24000, 24150, 24300, 24450, 24600, 24750, 24900, 25050,
-	25200, 25350, 25500, 25650, 25800, 25950, 26100, 26250,
-	26400, 26550, 26700, 26850, 27000, 27150, 27300, 27450,
-	27600, 27750, 27900, 28050, 28200, 28350, 28500, 28650,
-	28800, 28950, 29100, 29250, 29400, 29550, 29700, 29850,
-	30000, 30150, 30300, 30450, 30600, 30750, 30900, 31050,
-	31200, 31350, 31500, 31650, 31800, 31950, 32100, 32250,
-	32400, 32550, 32700, 32850, 33000, 33150, 33300, 33450,
-	33600, 33750, 33900, 34050, 34200, 34350, 34500, 34650,
-	34800, 34950, 35100, 35250, 35400, 35550, 35700, 35850,
-	36000, 36150, 36300, 36450, 36600, 36750, 36900, 37050,
-	37200, 37350, 37500, 37650, 37800, 37950, 38100, 38250 };
+            0,   150,   300,   450,   600,   750,   900,  1050,
+         1200,  1350,  1500,  1650,  1800,  1950,  2100,  2250,
+         2400,  2550,  2700,  2850,  3000,  3150,  3300,  3450,
+         3600,  3750,  3900,  4050,  4200,  4350,  4500,  4650,
+         4800,  4950,  5100,  5250,  5400,  5550,  5700,  5850,
+         6000,  6150,  6300,  6450,  6600,  6750,  6900,  7050,
+         7200,  7350,  7500,  7650,  7800,  7950,  8100,  8250,
+         8400,  8550,  8700,  8850,  9000,  9150,  9300,  9450,
+         9600,  9750,  9900, 10050, 10200, 10350, 10500, 10650,
+        10800, 10950, 11100, 11250, 11400, 11550, 11700, 11850,
+        12000, 12150, 12300, 12450, 12600, 12750, 12900, 13050,
+        13200, 13350, 13500, 13650, 13800, 13950, 14100, 14250,
+        14400, 14550, 14700, 14850, 15000, 15150, 15300, 15450,
+        15600, 15750, 15900, 16050, 16200, 16350, 16500, 16650,
+        16800, 16950, 17100, 17250, 17400, 17550, 17700, 17850,
+        18000, 18150, 18300, 18450, 18600, 18750, 18900, 19050,
+        19200, 19350, 19500, 19650, 19800, 19950, 20100, 20250,
+        20400, 20550, 20700, 20850, 21000, 21150, 21300, 21450,
+        21600, 21750, 21900, 22050, 22200, 22350, 22500, 22650,
+        22800, 22950, 23100, 23250, 23400, 23550, 23700, 23850,
+        24000, 24150, 24300, 24450, 24600, 24750, 24900, 25050,
+        25200, 25350, 25500, 25650, 25800, 25950, 26100, 26250,
+        26400, 26550, 26700, 26850, 27000, 27150, 27300, 27450,
+        27600, 27750, 27900, 28050, 28200, 28350, 28500, 28650,
+        28800, 28950, 29100, 29250, 29400, 29550, 29700, 29850,
+        30000, 30150, 30300, 30450, 30600, 30750, 30900, 31050,
+        31200, 31350, 31500, 31650, 31800, 31950, 32100, 32250,
+        32400, 32550, 32700, 32850, 33000, 33150, 33300, 33450,
+        33600, 33750, 33900, 34050, 34200, 34350, 34500, 34650,
+        34800, 34950, 35100, 35250, 35400, 35550, 35700, 35850,
+        36000, 36150, 36300, 36450, 36600, 36750, 36900, 37050,
+        37200, 37350, 37500, 37650, 37800, 37950, 38100, 38250 };
     static int times29[256] = {
-	    0,    29,    58,    87,   116,   145,   174,   203,
-	  232,   261,   290,   319,   348,   377,   406,   435,
-	  464,   493,   522,   551,   580,   609,   638,   667,
-	  696,   725,   754,   783,   812,   841,   870,   899,
-	  928,   957,   986,  1015,  1044,  1073,  1102,  1131,
-	 1160,  1189,  1218,  1247,  1276,  1305,  1334,  1363,
-	 1392,  1421,  1450,  1479,  1508,  1537,  1566,  1595,
-	 1624,  1653,  1682,  1711,  1740,  1769,  1798,  1827,
-	 1856,  1885,  1914,  1943,  1972,  2001,  2030,  2059,
-	 2088,  2117,  2146,  2175,  2204,  2233,  2262,  2291,
-	 2320,  2349,  2378,  2407,  2436,  2465,  2494,  2523,
-	 2552,  2581,  2610,  2639,  2668,  2697,  2726,  2755,
-	 2784,  2813,  2842,  2871,  2900,  2929,  2958,  2987,
-	 3016,  3045,  3074,  3103,  3132,  3161,  3190,  3219,
-	 3248,  3277,  3306,  3335,  3364,  3393,  3422,  3451,
-	 3480,  3509,  3538,  3567,  3596,  3625,  3654,  3683,
-	 3712,  3741,  3770,  3799,  3828,  3857,  3886,  3915,
-	 3944,  3973,  4002,  4031,  4060,  4089,  4118,  4147,
-	 4176,  4205,  4234,  4263,  4292,  4321,  4350,  4379,
-	 4408,  4437,  4466,  4495,  4524,  4553,  4582,  4611,
-	 4640,  4669,  4698,  4727,  4756,  4785,  4814,  4843,
-	 4872,  4901,  4930,  4959,  4988,  5017,  5046,  5075,
-	 5104,  5133,  5162,  5191,  5220,  5249,  5278,  5307,
-	 5336,  5365,  5394,  5423,  5452,  5481,  5510,  5539,
-	 5568,  5597,  5626,  5655,  5684,  5713,  5742,  5771,
-	 5800,  5829,  5858,  5887,  5916,  5945,  5974,  6003,
-	 6032,  6061,  6090,  6119,  6148,  6177,  6206,  6235,
-	 6264,  6293,  6322,  6351,  6380,  6409,  6438,  6467,
-	 6496,  6525,  6554,  6583,  6612,  6641,  6670,  6699,
-	 6728,  6757,  6786,  6815,  6844,  6873,  6902,  6931,
-	 6960,  6989,  7018,  7047,  7076,  7105,  7134,  7163,
-	 7192,  7221,  7250,  7279,  7308,  7337,  7366,  7395 };
+            0,    29,    58,    87,   116,   145,   174,   203,
+          232,   261,   290,   319,   348,   377,   406,   435,
+          464,   493,   522,   551,   580,   609,   638,   667,
+          696,   725,   754,   783,   812,   841,   870,   899,
+          928,   957,   986,  1015,  1044,  1073,  1102,  1131,
+         1160,  1189,  1218,  1247,  1276,  1305,  1334,  1363,
+         1392,  1421,  1450,  1479,  1508,  1537,  1566,  1595,
+         1624,  1653,  1682,  1711,  1740,  1769,  1798,  1827,
+         1856,  1885,  1914,  1943,  1972,  2001,  2030,  2059,
+         2088,  2117,  2146,  2175,  2204,  2233,  2262,  2291,
+         2320,  2349,  2378,  2407,  2436,  2465,  2494,  2523,
+         2552,  2581,  2610,  2639,  2668,  2697,  2726,  2755,
+         2784,  2813,  2842,  2871,  2900,  2929,  2958,  2987,
+         3016,  3045,  3074,  3103,  3132,  3161,  3190,  3219,
+         3248,  3277,  3306,  3335,  3364,  3393,  3422,  3451,
+         3480,  3509,  3538,  3567,  3596,  3625,  3654,  3683,
+         3712,  3741,  3770,  3799,  3828,  3857,  3886,  3915,
+         3944,  3973,  4002,  4031,  4060,  4089,  4118,  4147,
+         4176,  4205,  4234,  4263,  4292,  4321,  4350,  4379,
+         4408,  4437,  4466,  4495,  4524,  4553,  4582,  4611,
+         4640,  4669,  4698,  4727,  4756,  4785,  4814,  4843,
+         4872,  4901,  4930,  4959,  4988,  5017,  5046,  5075,
+         5104,  5133,  5162,  5191,  5220,  5249,  5278,  5307,
+         5336,  5365,  5394,  5423,  5452,  5481,  5510,  5539,
+         5568,  5597,  5626,  5655,  5684,  5713,  5742,  5771,
+         5800,  5829,  5858,  5887,  5916,  5945,  5974,  6003,
+         6032,  6061,  6090,  6119,  6148,  6177,  6206,  6235,
+         6264,  6293,  6322,  6351,  6380,  6409,  6438,  6467,
+         6496,  6525,  6554,  6583,  6612,  6641,  6670,  6699,
+         6728,  6757,  6786,  6815,  6844,  6873,  6902,  6931,
+         6960,  6989,  7018,  7047,  7076,  7105,  7134,  7163,
+         7192,  7221,  7250,  7279,  7308,  7337,  7366,  7395 };
 
 /* The ppm_fastlumin() macro is a way to compute luminosity without
    floating point arithmetic.  On modern computers, floating point often isn't
diff --git a/lib/pam.h b/lib/pam.h
index 94c85b4e..99498ed1 100644
--- a/lib/pam.h
+++ b/lib/pam.h
@@ -210,7 +210,7 @@ typedef sample *tuple;
        of the image (see pam.depth above).
     */
 
-#define PAM_OVERALL_MAXVAL 65535
+#define PAM_OVERALL_MAXVAL 65535lu
 
 /* Note: xv uses the same "P7" signature for its thumbnail images (it
    started using it years before PAM and unbeknownst to the designer
diff --git a/lib/pamdraw.h b/lib/pamdraw.h
index aaa6f20e..03bffbbf 100644
--- a/lib/pamdraw.h
+++ b/lib/pamdraw.h
@@ -65,7 +65,7 @@ typedef struct {
 -----------------------------------------------------------------------------*/
     unsigned int version;
         /* Must be zero.  For future expansion. */
-    pamd_point   begPoint;  
+    pamd_point   begPoint;
     unsigned int legCount;
         /* Number of legs in the path; i.e. size of 'legs' array */
     size_t       legSize;
@@ -111,7 +111,7 @@ pamd_drawproc pamd_point_drawproc;
 
 /* Outline drawing routines.  Lines, splines, circles, etc. */
 
-int 
+int
 pamd_setlinetype(int const type);
 
 #define PAMD_LINETYPE_NORMAL 0
@@ -132,11 +132,11 @@ pamd_setlineclip(int const clip);
 */
 
 void
-pamd_line(tuple **      const tuples, 
-          int           const cols, 
-          int           const rows, 
-          int           const depth, 
-          sample        const maxval, 
+pamd_line(tuple **      const tuples,
+          int           const cols,
+          int           const rows,
+          int           const depth,
+          sample        const maxval,
           pamd_point    const p0,
           pamd_point    const p1,
           pamd_drawproc       drawProc,
@@ -145,11 +145,11 @@ pamd_line(tuple **      const tuples,
     /* Draws a line from p0 to p1.  */
 
 void
-pamd_spline3(tuple **      const tuples, 
-             int           const cols, 
-             int           const rows, 
-             int           const depth, 
-             sample        const maxval, 
+pamd_spline3(tuple **      const tuples,
+             int           const cols,
+             int           const rows,
+             int           const depth,
+             sample        const maxval,
              pamd_point    const p0,
              pamd_point    const p1,
              pamd_point    const p2,
@@ -158,15 +158,15 @@ pamd_spline3(tuple **      const tuples,
 
     /* Draws a three-point spline from p0 to p2, with p1
        as the control point.  All drawing is done via pamd_line(),
-       so the routines that control it control pamd_spline3p() as well. 
+       so the routines that control it control pamd_spline3p() as well.
     */
 
 void
-pamd_polyspline(tuple **      const tuples, 
-                unsigned int  const cols, 
-                unsigned int  const rows, 
-                unsigned int  const depth, 
-                sample        const maxval, 
+pamd_polyspline(tuple **      const tuples,
+                unsigned int  const cols,
+                unsigned int  const rows,
+                unsigned int  const depth,
+                sample        const maxval,
                 pamd_point    const p0,
                 unsigned int  const nc,
                 pamd_point *  const c,
@@ -180,11 +180,11 @@ pamd_polyspline(tuple **      const tuples,
     */
 
 void
-pamd_spline4(tuple **      const tuples, 
-             unsigned int  const cols, 
-             unsigned int  const rows, 
-             unsigned int  const depth, 
-             sample        const maxval, 
+pamd_spline4(tuple **      const tuples,
+             unsigned int  const cols,
+             unsigned int  const rows,
+             unsigned int  const depth,
+             sample        const maxval,
              pamd_point    const endPt0,
              pamd_point    const endPt1,
              pamd_point    const ctlPt0,
@@ -193,13 +193,13 @@ pamd_spline4(tuple **      const tuples,
              const void *  const clientdata);
 
 void
-pamd_circle(tuple **      const tuples, 
-            unsigned int  const cols, 
-            unsigned int  const rows, 
-            unsigned int  const depth, 
-            sample        const maxval, 
+pamd_circle(tuple **      const tuples,
+            unsigned int  const cols,
+            unsigned int  const rows,
+            unsigned int  const depth,
+            sample        const maxval,
             pamd_point    const center,
-            unsigned int  const radius, 
+            unsigned int  const radius,
             pamd_drawproc       drawProc,
             const void *  const clientData);
     /* Draws a circle centered at 'center' with radius 'radius' */
@@ -207,25 +207,25 @@ pamd_circle(tuple **      const tuples,
 /* Simple filling routines.  */
 
 void
-pamd_filledrectangle(tuple **      const tuples, 
-                     int           const cols, 
-                     int           const rows, 
-                     int           const depth, 
-                     sample        const maxval, 
-                     int           const left, 
-                     int           const top, 
-                     int           const width, 
-                     int           const height, 
+pamd_filledrectangle(tuple **      const tuples,
+                     int           const cols,
+                     int           const rows,
+                     int           const depth,
+                     sample        const maxval,
+                     int           const left,
+                     int           const top,
+                     int           const width,
+                     int           const height,
                      pamd_drawproc       drawProc,
                      const void *  const clientdata);
     /* Fills in the rectangle [left, top, width, height]. */
 
 
 void
-pamd_fill_path(tuple **      const tuples, 
-               int           const cols, 
-               int           const rows, 
-               int           const depth, 
+pamd_fill_path(tuple **      const tuples,
+               int           const cols,
+               int           const rows,
+               int           const depth,
                sample        const maxval,
                pamd_path *   const pathP,
                tuple         const color);
@@ -248,11 +248,11 @@ void
 pamd_fill_destroy(struct fillobj * fillObjP);
 
 void
-pamd_fill_drawproc(tuple **     const tuples, 
-                   unsigned int const cols, 
-                   unsigned int const rows, 
-                   unsigned int const depth, 
-                   sample       const maxval, 
+pamd_fill_drawproc(tuple **     const tuples,
+                   unsigned int const cols,
+                   unsigned int const rows,
+                   unsigned int const depth,
+                   sample       const maxval,
                    pamd_point   const p,
                    const void * const clientdata);
     /* Use this drawproc to trace the outline you want filled.  Use
@@ -260,11 +260,11 @@ pamd_fill_drawproc(tuple **     const tuples,
     */
 
 void
-pamd_fill(tuple **         const tuples, 
-          int              const cols, 
-          int              const rows, 
-          int              const depth, 
-          sample           const maxval, 
+pamd_fill(tuple **         const tuples,
+          int              const cols,
+          int              const rows,
+          int              const depth,
+          sample           const maxval,
           struct fillobj * const fillObjP,
           pamd_drawproc          drawProc,
           const void *     const clientdata);
@@ -277,15 +277,15 @@ pamd_fill(tuple **         const tuples,
 /* Text drawing routines. */
 
 void
-pamd_text(tuple**       const tuples, 
-          int           const cols, 
-          int           const rows, 
-          int           const depth, 
-          sample        const maxval, 
+pamd_text(tuple**       const tuples,
+          int           const cols,
+          int           const rows,
+          int           const depth,
+          sample        const maxval,
           pamd_point    const pos,
-          int           const height, 
-          int           const angle, 
-          const char *  const sArg, 
+          int           const height,
+          int           const angle,
+          const char *  const sArg,
           pamd_drawproc       drawProc,
           const void *  const clientdata);
 
@@ -297,12 +297,12 @@ pamd_text(tuple**       const tuples,
     */
 
 void
-pamd_text_box(int          const height, 
-              int          const angle, 
-              const char * const s, 
-              int *        const leftP, 
-              int *        const topP, 
-              int *        const rightP, 
+pamd_text_box(int          const height,
+              int          const angle,
+              const char * const s,
+              int *        const leftP,
+              int *        const topP,
+              int *        const rightP,
               int *        const bottomP);
     /* Calculates the extents box for text drawn by pamd_text with the given
        string, size, and orientation.  Most extent box calculations should use
diff --git a/lib/path.c b/lib/path.c
index 8d53eb9e..3323cf6b 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -33,7 +33,7 @@
    visited that row, and then remove that entry from the stack.  Note
    that because we go one point at a time, the entry on the stack for
    the row we're at now will always be on the top of stack.
-   
+
    Note that the points on the stack always have consecutive row
    numbers, monotonically increasing or decreasing, whichever is the
    direction we started out in.
@@ -131,7 +131,7 @@ ppmd_pathbuilder_setLegArray(ppmd_pathbuilder * const pathBuilderP,
         pm_error("Leg array pointer is null");
 
     pathBuilderP->legsAreAutoAllocated = false;
-    
+
     pathBuilderP->legsAllocSize = legCount;
 
     pathBuilderP->path.legs = legs;
@@ -164,7 +164,7 @@ ppmd_pathbuilder_setBegPoint(ppmd_pathbuilder * const pathBuilderP,
                              ppmd_point         const begPoint) {
 
     pathBuilderP->path.begPoint = begPoint;
-    
+
     pathBuilderP->begIsSet = true;
 }
 
@@ -183,11 +183,11 @@ ppmd_pathbuilder_addLineLeg(ppmd_pathbuilder * const pathBuilderP,
             pathBuilderP->legsAllocSize =
                 MAX(16, pathBuilderP->legsAllocSize * 2);
 
-            REALLOCARRAY(pathBuilderP->path.legs, 
+            REALLOCARRAY(pathBuilderP->path.legs,
                          pathBuilderP->legsAllocSize);
 
             if (pathBuilderP->path.legs == NULL)
-                pm_error("Unable to allocate memory for %u legs", 
+                pm_error("Unable to allocate memory for %u legs",
                          pathBuilderP->legsAllocSize);
         } else
             pm_error("Out of space in user-supplied legs array "
@@ -252,7 +252,7 @@ isOnLineSeg(ppmd_point const here,
         here.y <= MAX(begPoint.y, endPoint.y) &&
         here.x >= MIN(begPoint.x, endPoint.x) &&
         here.x <= MAX(begPoint.x, endPoint.x);
-}    
+}
 
 
 
@@ -496,13 +496,13 @@ fillPoint(fillStack * const stackP,
     } else {
         if (againstStackDirection(stackP, point))
             popStack(stackP);
-        
+
         if (stackIsEmpty(stackP)) {
             reverseStackDirection(stackP);
             pushStack(stackP, point);
         } else {
             assert(isLateralFromTopOfStack(stackP, point));
-            
+
             drawFillLine(topOfStack(stackP), point, pixels, color);
             replaceTopOfStack(stackP, point);
         }
@@ -539,7 +539,7 @@ fillLeg(ppmd_point  const begPoint,
         ppmd_point here;
 
         here = begPoint;
-    
+
         while (here.y != endPoint.y) {
             here.y += step;
             here.x = ROUNDU(begPoint.x + vertDisp(begPoint, here) * invSlope);
@@ -554,9 +554,9 @@ fillLeg(ppmd_point  const begPoint,
 
 
 void
-ppmd_fill_path(pixel **          const pixels, 
-               int               const cols, 
-               int               const rows, 
+ppmd_fill_path(pixel **          const pixels,
+               int               const cols,
+               int               const rows,
                pixval            const maxval,
                const ppmd_path * const pathP,
                pixel             const color) {
diff --git a/lib/ppm.h b/lib/ppm.h
index 9fc90bb3..acc70c85 100644
--- a/lib/ppm.h
+++ b/lib/ppm.h
@@ -185,9 +185,9 @@ ppm_freecolornames(const char ** const colornames);
 
 #define PPM_DEPTH(newp,p,oldmaxval,newmaxval) \
     PPM_ASSIGN( (newp), \
-	( (int) PPM_GETR(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \
-	( (int) PPM_GETG(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \
-	( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) )
+        ( (int) PPM_GETR(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \
+        ( (int) PPM_GETG(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \
+        ( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) )
 
 #define PPM_SQR(x) (x)*(x)
 
diff --git a/lib/ppmdfont.c b/lib/ppmdfont.c
index f64cd10f..d2be215d 100644
--- a/lib/ppmdfont.c
+++ b/lib/ppmdfont.c
@@ -63,7 +63,7 @@ readCharacter(FILE *              const ifP,
 static void
 readFontHeader(FILE *                   const ifP,
                struct ppmd_fontHeader * const fontHeaderP) {
-    
+
     size_t rc;
 
     rc = fread(&fontHeaderP->signature, 1, sizeof(fontHeaderP->signature),
@@ -135,7 +135,7 @@ ppmd_free_font(const struct ppmd_font * const fontP) {
     for (relativeCodePoint = 0;
          relativeCodePoint < fontP->header.characterCount;
          ++relativeCodePoint) {
-        
+
         free((void*)fontP->glyphTable[relativeCodePoint].commandList);
     }
     free((void*)fontP->glyphTable);
diff --git a/lib/ppmdfont.h b/lib/ppmdfont.h
index 329386ff..aa220dc0 100644
--- a/lib/ppmdfont.h
+++ b/lib/ppmdfont.h
@@ -10,10 +10,10 @@
         struct ppmd_glyphHeader glyphHeader;
         struct ppmd_glyphCommand glyphCommand[N];
     } glyph[M]
-    
+
     Where:
         M is fontHeader.characterCount
-        N is glyphHeader.commandCount   
+        N is glyphHeader.commandCount
 
     glyph[i] is the glyph for code point Q,
       where i = Q - fontHeader.firstCodePoint
diff --git a/lib/ppmdraw.h b/lib/ppmdraw.h
index 5fd4148c..b2c4b5d5 100644
--- a/lib/ppmdraw.h
+++ b/lib/ppmdraw.h
@@ -69,7 +69,7 @@ typedef struct {
 -----------------------------------------------------------------------------*/
     unsigned int version;
         /* Must be zero.  For future expansion. */
-    ppmd_point   begPoint;  
+    ppmd_point   begPoint;
     unsigned int legCount;
         /* Number of legs in the path; i.e. size of 'legs' array */
     size_t       legSize;
@@ -94,7 +94,7 @@ typedef struct {
         /* User has set path.begPoint.  If this is false, path.begPoint is
            meaningless.
         */
-    
+
     unsigned int legsAllocSize;
         /* How many legs of space is allocated in the leg array path.legs */
 
@@ -103,7 +103,7 @@ typedef struct {
            ppmd_path_addlineline(), as opposed to being supplied by the
            user as part of initializing this structure, never to be altered.
         */
-    
+
 } ppmd_pathbuilder;
 
 ppmd_pathbuilder *
@@ -166,7 +166,7 @@ ppmd_drawproc ppmd_point_drawproc;
 
 /* Outline drawing routines.  Lines, splines, circles, etc. */
 
-int 
+int
 ppmd_setlinetype(int const type);
 
 #define PPMD_LINETYPE_NORMAL 0
@@ -187,10 +187,10 @@ ppmd_setlineclip(int const clip);
 */
 
 void
-ppmd_linep(pixel **       const pixels, 
-           int            const cols, 
-           int            const rows, 
-           pixval         const maxval, 
+ppmd_linep(pixel **       const pixels,
+           int            const cols,
+           int            const rows,
+           pixval         const maxval,
            ppmd_point     const p0,
            ppmd_point     const p1,
            ppmd_drawprocp       drawProc,
@@ -199,23 +199,23 @@ ppmd_linep(pixel **       const pixels,
     /* Draws a line from p0 to p1.  */
 
 void
-ppmd_line(pixel**       const pixels, 
-          int           const cols, 
-          int           const rows, 
-          pixval        const maxval, 
-          int           const x0, 
-          int           const y0, 
-          int           const x1, 
-          int           const y1, 
+ppmd_line(pixel**       const pixels,
+          int           const cols,
+          int           const rows,
+          pixval        const maxval,
+          int           const x0,
+          int           const y0,
+          int           const x1,
+          int           const y1,
           ppmd_drawproc       drawproc,
           const void *  const clientdata);
     /* Draws a line from (x0, y0) to (x1, y1). */
 
 void
-ppmd_spline3p(pixel **       const pixels, 
-              int            const cols, 
-              int            const rows, 
-              pixval         const maxval, 
+ppmd_spline3p(pixel **       const pixels,
+              int            const cols,
+              int            const rows,
+              pixval         const maxval,
               ppmd_point     const p0,
               ppmd_point     const p1,
               ppmd_point     const p2,
@@ -224,28 +224,28 @@ ppmd_spline3p(pixel **       const pixels,
 
     /* Draws a three-point spline from p0 to p2, with p1
        as the control point.  All drawing is done via ppmd_linep(),
-       so the routines that control it control ppmd_spline3p() as well. 
+       so the routines that control it control ppmd_spline3p() as well.
     */
 
 void
-ppmd_spline3(pixel **      const pixels, 
-             int           const cols, 
-             int           const rows, 
-             pixval        const maxval, 
-             int           const x0, 
-             int           const y0, 
-             int           const x1, 
-             int           const y1, 
-             int           const x2, 
-             int           const y2, 
+ppmd_spline3(pixel **      const pixels,
+             int           const cols,
+             int           const rows,
+             pixval        const maxval,
+             int           const x0,
+             int           const y0,
+             int           const x1,
+             int           const y1,
+             int           const x2,
+             int           const y2,
              ppmd_drawproc       drawproc,
              const void *  const clientdata);
 
 void
-ppmd_polysplinep(pixel **       const pixels, 
-                 unsigned int   const cols, 
-                 unsigned int   const rows, 
-                 pixval         const maxval, 
+ppmd_polysplinep(pixel **       const pixels,
+                 unsigned int   const cols,
+                 unsigned int   const rows,
+                 pixval         const maxval,
                  ppmd_point     const p0,
                  unsigned int   const nc,
                  ppmd_point *   const c,
@@ -259,25 +259,25 @@ ppmd_polysplinep(pixel **       const pixels,
     */
 
 void
-ppmd_polyspline(pixel **     const pixels, 
-                int          const cols, 
-                int          const rows, 
-                pixval       const maxval, 
-                int          const x0, 
-                int          const y0, 
-                int          const nc, 
-                int *        const xc, 
-                int *        const yc, 
-                int          const x1, 
-                int          const y1, 
+ppmd_polyspline(pixel **     const pixels,
+                int          const cols,
+                int          const rows,
+                pixval       const maxval,
+                int          const x0,
+                int          const y0,
+                int          const nc,
+                int *        const xc,
+                int *        const yc,
+                int          const x1,
+                int          const y1,
                 ppmd_drawproc      drawProc,
                 const void * const clientdata);
 
 void
-ppmd_spline4p(pixel **       const pixels, 
-              unsigned int   const cols, 
-              unsigned int   const rows, 
-              pixval         const maxval, 
+ppmd_spline4p(pixel **       const pixels,
+              unsigned int   const cols,
+              unsigned int   const rows,
+              pixval         const maxval,
               ppmd_point     const endPt0,
               ppmd_point     const endPt1,
               ppmd_point     const ctlPt0,
@@ -286,24 +286,24 @@ ppmd_spline4p(pixel **       const pixels,
               const void *   const clientdata);
 
 void
-ppmd_circlep(pixel **       const pixels, 
-             unsigned int   const cols, 
-             unsigned int   const rows, 
-             pixval         const maxval, 
+ppmd_circlep(pixel **       const pixels,
+             unsigned int   const cols,
+             unsigned int   const rows,
+             pixval         const maxval,
              ppmd_point     const center,
-             unsigned int   const radius, 
+             unsigned int   const radius,
              ppmd_drawprocp       drawProc,
              const void *   const clientData);
     /* Draws a circle centered at 'center' with radius 'radius' */
 
 void
-ppmd_circle(pixel **     const pixels, 
-            int          const cols, 
-            int          const rows, 
-            pixval       const maxval, 
-            int          const cx, 
-            int          const cy, 
-            int          const radius, 
+ppmd_circle(pixel **     const pixels,
+            int          const cols,
+            int          const rows,
+            pixval       const maxval,
+            int          const cx,
+            int          const cy,
+            int          const radius,
             ppmd_drawproc      drawProc,
             const void * const clientdata);
 
@@ -311,23 +311,23 @@ ppmd_circle(pixel **     const pixels,
 /* Simple filling routines.  */
 
 void
-ppmd_filledrectangle(pixel **      const pixels, 
-                     int           const cols, 
-                     int           const rows, 
-                     pixval        const maxval, 
-                     int           const x, 
-                     int           const y, 
-                     int           const width, 
-                     int           const height, 
+ppmd_filledrectangle(pixel **      const pixels,
+                     int           const cols,
+                     int           const rows,
+                     pixval        const maxval,
+                     int           const x,
+                     int           const y,
+                     int           const width,
+                     int           const height,
                      ppmd_drawproc       drawproc,
                      const void *  const clientdata );
     /* Fills in the rectangle [x, y, width, height]. */
 
 
 void
-ppmd_fill_path(pixel **          const pixels, 
-               int               const cols, 
-               int               const rows, 
+ppmd_fill_path(pixel **          const pixels,
+               int               const cols,
+               int               const rows,
                pixval            const maxval,
                const ppmd_path * const pathP,
                pixel             const color);
@@ -354,10 +354,10 @@ char *
 ppmd_fill_init(void);
 
 void
-ppmd_fill_drawprocp(pixel **     const pixels, 
-                    unsigned int const cols, 
-                    unsigned int const rows, 
-                    pixval       const maxval, 
+ppmd_fill_drawprocp(pixel **     const pixels,
+                    unsigned int const cols,
+                    unsigned int const rows,
+                    pixval       const maxval,
                     ppmd_point   const p,
                     const void * const clientdata);
     /* Use this drawproc to trace the outline you want filled.  Use
@@ -365,19 +365,19 @@ ppmd_fill_drawprocp(pixel **     const pixels,
     */
 
 void
-ppmd_fill_drawproc(pixel **     const pixels, 
-                   int          const cols, 
-                   int          const rows, 
-                   pixval       const maxval, 
-                   int          const x, 
-                   int          const y, 
+ppmd_fill_drawproc(pixel **     const pixels,
+                   int          const cols,
+                   int          const rows,
+                   pixval       const maxval,
+                   int          const x,
+                   int          const y,
                    const void * const clientdata);
 
 void
-ppmd_fill(pixel **         const pixels, 
-          int              const cols, 
-          int              const rows, 
-          pixval           const maxval, 
+ppmd_fill(pixel **         const pixels,
+          int              const cols,
+          int              const rows,
+          pixval           const maxval,
           struct fillobj * const fh,
           ppmd_drawproc          drawProc,
           const void *     const clientdata);
@@ -390,27 +390,27 @@ ppmd_fill(pixel **         const pixels,
 /* Text drawing routines. */
 
 void
-ppmd_textp(pixel**        const pixels, 
-           int            const cols, 
-           int            const rows, 
-           pixval         const maxval, 
+ppmd_textp(pixel**        const pixels,
+           int            const cols,
+           int            const rows,
+           pixval         const maxval,
            ppmd_point     const pos,
-           int            const height, 
-           int            const angle, 
-           const char *   const sArg, 
+           int            const height,
+           int            const angle,
+           const char *   const sArg,
            ppmd_drawprocp       drawProc,
            const void *   const clientdata);
 
 void
-ppmd_text(pixel**       const pixels, 
-          int           const cols, 
-          int           const rows, 
-          pixval        const maxval, 
-          int           const xpos, 
-          int           const ypos, 
-          int           const height, 
-          int           const angle, 
-          const char *  const sArg, 
+ppmd_text(pixel**       const pixels,
+          int           const cols,
+          int           const rows,
+          pixval        const maxval,
+          int           const xpos,
+          int           const ypos,
+          int           const height,
+          int           const angle,
+          const char *  const sArg,
           ppmd_drawproc       drawProc,
           const void *  const clientdata);
 /* Draws the null-terminated string 's' left justified at the point
@@ -421,12 +421,12 @@ ppmd_text(pixel**       const pixels,
 */
 
 void
-ppmd_text_box(int          const height, 
-              int          const angle, 
-              const char * const s, 
-              int *        const leftP, 
-              int *        const topP, 
-              int *        const rightP, 
+ppmd_text_box(int          const height,
+              int          const angle,
+              const char * const s,
+              int *        const leftP,
+              int *        const topP,
+              int *        const rightP,
               int *        const bottomP);
 /* Calculates the extents box for text drawn by ppm_text with the given
    string, size, and orientation.  Most extent box calculations should use
diff --git a/lib/util/LICENSE.txt b/lib/util/LICENSE.txt
index 4baac593..98d7e10e 100644
--- a/lib/util/LICENSE.txt
+++ b/lib/util/LICENSE.txt
@@ -1,7 +1,7 @@
 The Frontier Artistic License Version 1.0
 Derived from the Artistic License at OpenSource.org.
 Submitted to OpenSource.org for Open Source Initiative certification.
-   
+
 Preamble
 
 The intent of this document is to state the conditions under which a
@@ -10,7 +10,7 @@ semblance of artistic control over the development of the package,
 while giving the users of the package the right to use and distribute
 the Package in a more-or-less customary fashion, plus the right to
 make reasonable modifications.
-   
+
 Definitions
 
   "Package" refers to the script, suite, file, or collection of
@@ -37,7 +37,7 @@ Definitions
   itself, though there may be fees involved in handling the item.
   It also means that recipients of the item may redistribute it under
   the same conditions they received it.
-       
+
 
 Terms
 
@@ -45,50 +45,50 @@ Terms
 the Standard Version of this Package without restriction, provided
 that you duplicate all of the original copyright notices and
 associated disclaimers.
-   
+
 2. You may apply bug fixes, portability fixes, and other modifications
 derived from the Public Domain or from the Copyright Holder. A Package
 modified in such a way shall still be considered the Standard Version.
-   
+
 3. You may otherwise modify your copy of this Package in any way,
 provided that you insert a prominent notice in each changed script,
 suite, or file stating how and when you changed that script, suite,
 or file, and provided that you do at least ONE of the following:
-   
+
   a) Use the modified Package only within your corporation or
   organization, or retain the modified Package solely for personal use.
-     
+
   b) Place your modifications in the Public Domain or otherwise make
   them Freely Available, such as by posting said modifications to Usenet
   or an equivalent medium, or placing the modifications on a major archive
   site such as ftp.uu.net, or by allowing the Copyright Holder to include
   your modifications in the Standard Version of the Package.
-     
+
   c) Rename any non-standard executables so the names do not conflict
   with standard executables, which must also be provided, and provide
   a separate manual page (or equivalent) for each non-standard executable
   that clearly documents how it differs from the Standard Version.
-     
+
   d) Make other distribution arrangements with the Copyright Holder.
-     
+
 4. You may distribute the programs of this Package in object code or
 executable form, provided that you do at least ONE of the following:
-   
+
   a) Distribute a Standard Version of the executables and library
   files, together with instructions (in the manual page or
   equivalent) on where to get the Standard Version.
-     
+
   b) Accompany the distribution with the machine-readable source of
   the Package with your modifications.
-     
+
   c) Accompany any non-standard executables with their corresponding
   Standard Version executables, give the non-standard executables
   non-standard names, and clearly document the differences in manual
   pages (or equivalent), together with instructions on where to get
   the Standard Version.
-     
+
   d) Make other distribution arrangements with the Copyright Holder.
-     
+
 5. You may charge a reasonable copying fee for any distribution of
 this Package. You may charge any fee you choose for support of this
 Package. You may not charge a fee for this Package itself. However,
@@ -96,25 +96,25 @@ you may distribute this Package in aggregate with other (possibly
 commercial) programs as part of a larger (possibly commercial)
 software distribution provided that you do not advertise this Package
 as a product of your own.
-   
+
 6. The scripts and library files supplied as input to or produced as
 output from the programs of this Package do not automatically fall
 under the copyright of this Package, but belong to whomever generated
 them, and may be sold commercially, and may be aggregated with this
 Package.
-   
+
 7. Scripts, suites, or programs supplied by you that depend on or
 otherwise make use of this Package shall not be considered part of
 this Package.
-   
+
 8. The name of the Copyright Holder may not be used to endorse or
 promote products derived from this software without specific prior
 written permission.
-   
+
 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-   
+
                         The End
 
 
diff --git a/lib/util/bitio.c b/lib/util/bitio.c
index ca1b55f9..9d96892c 100644
--- a/lib/util/bitio.c
+++ b/lib/util/bitio.c
@@ -6,7 +6,7 @@
  * Works for (sizeof(unsigned long)-1)*8 bits.
  *
  * Copyright (C) 1992 by David W. Sanderson.
- * 
+ *
  * 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
@@ -89,7 +89,7 @@ pm_bitinit(FILE * const f, const char * const mode) {
  * pm_bitfini() - deallocate the given struct bitstream *.
  *
  * You must call this after you are done with the struct bitstream *.
- * 
+ *
  * It may flush some bits left in the buffer.
  *
  * Returns the number of bytes written, -1 on error.
@@ -137,13 +137,13 @@ pm_bitfini(b)
 
 /*
  * pm_bitread() - read the next nbits into *val from the given file.
- * 
+ *
  * The last pm_bitread() must be followed by a call to pm_bitfini().
- * 
+ *
  * Returns the number of bytes read, -1 on error.
  */
 
-int 
+int
 pm_bitread(b, nbits, val)
     struct bitstream *b;
     unsigned long   nbits;
@@ -172,9 +172,9 @@ pm_bitread(b, nbits, val)
 
 /*
  * pm_bitwrite() - write the low nbits of val to the given file.
- * 
+ *
  * The last pm_bitwrite() must be followed by a call to pm_bitfini().
- * 
+ *
  * Returns the number of bytes written, -1 on error.
  */
 
diff --git a/lib/util/bitio.h b/lib/util/bitio.h
index dfc5a153..d1fbbff2 100644
--- a/lib/util/bitio.h
+++ b/lib/util/bitio.h
@@ -6,7 +6,7 @@
  * Works for (sizeof(unsigned long)-1)*8 bits.
  *
  * Copyright (C) 1992 by David W. Sanderson.
- * 
+ *
  * 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
@@ -41,7 +41,7 @@ extern "C" {
 } /* to fake out automatic code indenters */
 #endif
 
-typedef struct bitstream	*BITSTREAM;
+typedef struct bitstream        *BITSTREAM;
 
 struct bitstream *
 pm_bitinit(FILE * const f, const char * const mode);
@@ -50,7 +50,7 @@ pm_bitinit(FILE * const f, const char * const mode);
  * pm_bitfini() - deallocate the given BITSTREAM.
  *
  * You must call this after you are done with the BITSTREAM.
- * 
+ *
  * It may flush some bits left in the buffer.
  *
  * Returns the number of bytes written, -1 on error.
@@ -61,7 +61,7 @@ pm_bitfini(BITSTREAM b);
 
 /*
  * pm_bitread() - read the next nbits into *val from the given file.
- * 
+ *
  * Returns the number of bytes read, -1 on error.
  */
 
@@ -72,9 +72,9 @@ pm_bitread(BITSTREAM       b,
 
 /*
  * pm_bitwrite() - write the low nbits of val to the given file.
- * 
+ *
  * The last pm_bitwrite() must be followed by a call to pm_bitflush().
- * 
+ *
  * Returns the number of bytes written, -1 on error.
  */
 
diff --git a/lib/util/bitreverse.h b/lib/util/bitreverse.h
index b3f0ea13..9acdc5fe 100644
--- a/lib/util/bitreverse.h
+++ b/lib/util/bitreverse.h
@@ -13,7 +13,7 @@
 **
 **     c = ((c >>  1) & 0x55) | ((c <<  1) & 0xaa);
 **     c = ((c >>  2) & 0x33) | ((c <<  2) & 0xcc);
-**     c = ((c >> 4) & 0x0f) | ((c << 4) & 0xf0); 
+**     c = ((c >> 4) & 0x0f) | ((c << 4) & 0xf0);
 */
 
 #ifndef _BITR_H_
diff --git a/lib/util/floatcode.h b/lib/util/floatcode.h
index dc31d038..07012dad 100644
--- a/lib/util/floatcode.h
+++ b/lib/util/floatcode.h
@@ -33,9 +33,9 @@ pm_floatFromBigendFloat(pm_bigendFloat const arg) {
             pm_bigendFloat bigend;
             float native;
         } converter;
-        
+
         converter.bigend = arg;
-        
+
         retval = converter.native;
     }; break;
     case LITTLE_ENDIAN: {
@@ -68,7 +68,7 @@ pm_bigendFloatFromFloat(float const arg) {
             pm_bigendFloat bigend;
             float native;
         } converter;
-        
+
         converter.native = arg;
 
         retval = converter.bigend;
@@ -117,9 +117,9 @@ pm_doubleFromBigendDouble(pm_bigendDouble const arg) {
             pm_bigendDouble bigend;
             double native;
         } converter;
-        
+
         converter.bigend = arg;
-        
+
         retval = converter.native;
     }; break;
     case LITTLE_ENDIAN: {
@@ -156,7 +156,7 @@ pm_bigendDoubleFromDouble(double const arg) {
             pm_bigendDouble bigend;
             double native;
         } converter;
-        
+
         converter.native = arg;
 
         retval = converter.bigend;
diff --git a/lib/util/intcode.h b/lib/util/intcode.h
index 1066ee9b..6f40a740 100644
--- a/lib/util/intcode.h
+++ b/lib/util/intcode.h
@@ -108,7 +108,7 @@ pm_uintFromBigend32(bigend32 const arg) {
 
 #if HAVE_GCC_BSWAP
     case LITTLE_ENDIAN: {
-        /* Use GCC built-in */  
+        /* Use GCC built-in */
         union {
             bigend32 bigend;
             uint32_t native;
@@ -117,7 +117,7 @@ pm_uintFromBigend32(bigend32 const arg) {
         retval = __builtin_bswap32(converter.native);
     } break;
 #endif
-    
+
     default:
         retval =
             (arg.bytes[0] << 24) |
@@ -146,9 +146,9 @@ pm_bigendFromUint32(uint32_t const arg) {
         retval = converter.bigend;
     } break;
 
-#if HAVE_GCC_BSWAP    
+#if HAVE_GCC_BSWAP
     case LITTLE_ENDIAN: {
-        /* Use GCC built-in */  
+        /* Use GCC built-in */
         union {
             bigend32 bigend;
             uint32_t native;
@@ -156,7 +156,7 @@ pm_bigendFromUint32(uint32_t const arg) {
         converter.native = __builtin_bswap32(arg);
         retval = converter.bigend;
     } break;
-#endif    
+#endif
 
     default: {
         uint32_t shift;
@@ -208,9 +208,9 @@ pm_uintFromBigend64(bigend64 const arg) {
         retval = converter.native;
     } break;
 
-#if HAVE_GCC_BSWAP    
+#if HAVE_GCC_BSWAP
     case LITTLE_ENDIAN: {
-        /* Use GCC built-in */  
+        /* Use GCC built-in */
         union {
             bigend64 bigend;
             uint64_t native;
@@ -249,7 +249,7 @@ pm_bigendFromUint64(uint64_t const arg) {
 #if HAVE_GCC_BSWAP
     case LITTLE_ENDIAN: {
 
-        /* Use GCC built-in */  
+        /* Use GCC built-in */
         union {
             bigend64 bigend;
             uint64_t native;
@@ -258,7 +258,7 @@ pm_bigendFromUint64(uint64_t const arg) {
         retval = converter.bigend;
     } break;
 #endif
-    
+
     default: {
         uint64_t shift;
         shift = arg;
diff --git a/lib/util/io.c b/lib/util/io.c
index 54ecb6a8..ad17f680 100644
--- a/lib/util/io.c
+++ b/lib/util/io.c
@@ -32,7 +32,7 @@ pm_freadline(FILE *        const fileP,
 
     bufferSize = 1024;  /* initial value */
     *errorP = NULL; /* initial value */
-    
+
     MALLOCARRAY(buffer, bufferSize);
 
     for (cursor = 0, gotLine = false, eof = false;
@@ -53,7 +53,7 @@ pm_freadline(FILE *        const fileP,
                         (unsigned int)bufferSize);
         else {
             int const rc = getc(fileP);
-        
+
             if (rc < 0) {
                 if (feof(fileP))
                     eof = true;
diff --git a/lib/util/matrix.c b/lib/util/matrix.c
index e9456e93..1849bf49 100644
--- a/lib/util/matrix.c
+++ b/lib/util/matrix.c
@@ -201,7 +201,7 @@ pm_solvelineareq(double **     const aArg,
             /* Work from the bottom up to solve for the unknowns x[], from
                the a and c rows in question and all the x[] below it
             */
-            
+
             unsigned int k;
             for (k = 0; k < n; ++k) {
                 unsigned int const m = n - k - 1;
@@ -210,7 +210,7 @@ pm_solvelineareq(double **     const aArg,
 
                 for (j = m+1, xwork = c[m]; j < n; ++j)
                     xwork -= a[m][j] * x[j];
-                    
+
                 x[m] = xwork / a[m][m];
             }
         }
diff --git a/lib/util/nstring.c b/lib/util/nstring.c
index 6663ebf0..623fd7b7 100644
--- a/lib/util/nstring.c
+++ b/lib/util/nstring.c
@@ -1,26 +1,6 @@
 /*=============================================================================
                                nstring.c
 ===============================================================================
-
-  pm_snprintf (and pm_vsnprintf) in this file used to be derived from
-  'portable_snprintf' from
-  http://www.ijs.si/software/snprintf/snprintf-2.2.tar.gz, because not all
-  system C libraries had snprintf.  But in 2013, we extended that snprintf to
-  implement %f by calling 'snprintf' in the system C library, just to see if
-  it caused any build failures.  As of August 2022, there had been no
-  complaints of problems caused by this reliance on the system providing
-  snprintf, so we just made pm_snprintf a wrapper of snprintf for everything.
-
-  Eventually we will remove pm_snprintf and pm_vsnprintf altogether and their
-  callers will call 'snprintf' and 'vsnprintf' instead
-
-  Note that snprintf is required by the C99 standard.
-
-  The code from which pm_snprintf was formerly derived was protected by
-  copyright and licensed to the public under GPL.  A user in August 2022 noted
-  that GPL was insufficient for his use of it, making him unable to use
-  libnetpbm.
-
   Code in this file is contributed to the public domain by its authors.
 =============================================================================*/
 #define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */
@@ -59,46 +39,6 @@ pm_strnlen(const char * const s,
 
 
 
-void
-pm_vsnprintf(char *       const str,
-             size_t       const maxSize,
-             const char * const fmt,
-             va_list            ap,
-             size_t *     const sizeP) {
-
-    int rc;
-
-    rc = vsnprintf(str, maxSize, fmt, ap);
-
-    assert((size_t)rc == rc);
-
-    *sizeP = (size_t)rc;
-}
-
-
-
-int
-pm_snprintf(char *       const dest,
-            size_t       const maxSize,
-            const char * const fmt,
-            ...) {
-
-    size_t size;
-    va_list ap;
-
-    va_start(ap, fmt);
-
-    pm_vsnprintf(dest, maxSize, fmt, ap, &size);
-
-    va_end(ap);
-
-    assert(size <= INT_MAX);
-
-    return size;
-}
-
-
-
 /* When a function that is supposed to return a malloc'ed string cannot
    get the memory for it, it should return 'pm_strsol'.  That has a much
    better effect on the caller, if the caller doesn't explicitly allow for
@@ -144,7 +84,7 @@ pm_asprintf(const char ** const resultP,
 
     va_start(varargs, fmt);
 
-    pm_vsnprintf(NULL, 0, fmt, varargs, &dryRunLen);
+    vsnprintf(NULL, 0, fmt, varargs, &dryRunLen);
 
     va_end(varargs);
 
@@ -161,7 +101,7 @@ pm_asprintf(const char ** const resultP,
 
             va_start(varargs, fmt);
 
-            pm_vsnprintf(buffer, allocSize, fmt, varargs, &realLen);
+            vsnprintf(buffer, allocSize, fmt, varargs, &realLen);
 
             assert(realLen == dryRunLen);
             va_end(varargs);
diff --git a/lib/util/nstring.h b/lib/util/nstring.h
index 1f03e4f2..1aa486c6 100644
--- a/lib/util/nstring.h
+++ b/lib/util/nstring.h
@@ -22,13 +22,13 @@ extern "C" {
    array.
 */
 #define STRSCPY(A,B) \
-	(strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
+        (strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
 #define STRSCMP(A,B) \
-	(strncmp((A), (B), sizeof(A)))
+        (strncmp((A), (B), sizeof(A)))
 #define STRSCAT(A,B) \
     (strncpy(A+strlen(A), B, sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
 #define STRSEQ(A, B) \
-	(strneq((A), (B), sizeof(A)))
+        (strneq((A), (B), sizeof(A)))
 
 #define MEMSEQ(a,b) (memeq(a, b, sizeof(*(a))))
 
@@ -128,8 +128,7 @@ strncaseeq(const char * const comparand,
    subroutines whose names are similar.  They're here because not all standard
    C libraries have them.
 
-   The GNU C library has all of them.  All but the oldest standard C libraries
-   have snprintf().
+   The GNU C library has all of them.
 
    There are slight differences between the asprintf() family and that
    found in other libraries:
@@ -155,19 +154,6 @@ size_t
 pm_strnlen(const char * const s,
            size_t       const maxlen);
 
-int
-pm_snprintf(char *       const dest,
-            size_t       const maxSize,
-            const char * const fmt,
-            ...) PM_GNU_PRINTF_ATTR(3,4);
-
-void
-pm_vsnprintf(char *       const str,
-             size_t       const maxSize,
-             const char * const fmt,
-             va_list            ap,
-             size_t *     const sizeP);
-
 const char *
 pm_strdup(const char * const arg);
 
diff --git a/lib/util/pm_c_util.h b/lib/util/pm_c_util.h
index a093adb6..110d7536 100644
--- a/lib/util/pm_c_util.h
+++ b/lib/util/pm_c_util.h
@@ -13,7 +13,7 @@
 #undef ABS
 #define ABS(a) ((a) >= 0 ? (a) : -(a))
 #undef SGN
-#define SGN(a)		(((a)<0) ? -1 : 1)
+#define SGN(a)          (((a)<0) ? -1 : 1)
 #undef ODD
 #define ODD(n) ((n) & 1)
 #undef ROUND
@@ -65,7 +65,7 @@
   */
   #if ( defined(__GNUC__) && (__GNUC__ >= 2) ) || \
       ( defined(__STDC__) && (__STDC__ == 1) && \
-        defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ) 
+        defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) )
     #include <stdbool.h>
   #else
     /* We used to assume that if TRUE was defined, then bool was too.
@@ -76,7 +76,7 @@
        also another library that defines bool, he can either make the
        other library define/respect HAVE_BOOL or just define HAVE_BOOL in
        the file that includes pm_config.h or with a compiler option.  Note
-       that C++ always has bool.  
+       that C++ always has bool.
     */
     #ifndef HAVE_BOOL
       #define HAVE_BOOL 1
diff --git a/lib/util/runlength.h b/lib/util/runlength.h
index de921650..f984267b 100644
--- a/lib/util/runlength.h
+++ b/lib/util/runlength.h
@@ -14,12 +14,12 @@ extern "C" {
 
 
 enum pm_RleMode { PM_RLE_PACKBITS,          /* most common mode */
-                  PM_RLE_GRAPHON,           /* reserved */ 
+                  PM_RLE_GRAPHON,           /* reserved */
                   PM_RLE_PPA,               /* reserved */
                   PM_RLE_SGI8,              /* reserved */
                   PM_RLE_SGI16,
                   PM_RLE_PALM16,
-                  PM_RLE_PALMPDB  
+                  PM_RLE_PALMPDB
                 };
 
 size_t
diff --git a/lib/util/shhopt.c b/lib/util/shhopt.c
index 00f9c341..32d0916d 100644
--- a/lib/util/shhopt.c
+++ b/lib/util/shhopt.c
@@ -252,10 +252,10 @@ static int
 optNeedsArgument(const optEntry opt)
 {
     return opt.type == OPT_STRING
-	|| opt.type == OPT_INT
-	|| opt.type == OPT_UINT
-	|| opt.type == OPT_LONG
-	|| opt.type == OPT_ULONG
+        || opt.type == OPT_INT
+        || opt.type == OPT_UINT
+        || opt.type == OPT_LONG
+        || opt.type == OPT_ULONG
     || opt.type == OPT_FLOAT
     || opt.type == OPT_NAMELIST
     || opt.type == OPT_STRINGLIST
@@ -717,28 +717,28 @@ parse_short_option_token(char *argv[], const int argc, const int ai,
     while (*o && !processed_arg) {
         bool found;
         int mi;   /* index into option table */
-		/* find matching option */
-		optMatch(opt_table, o, SL_SHORT, &found, &mi);
-		if (!found)
-		    optFatal("unrecognized option `-%c'", *o);
-
-		/* does this option take an argument? */
-		if (optNeedsArgument(opt_table[mi])) {
-		    /* option needs an argument. find it. */
-		    arg = o + 1;
-		    if (!*arg) {
+                /* find matching option */
+                optMatch(opt_table, o, SL_SHORT, &found, &mi);
+                if (!found)
+                    optFatal("unrecognized option `-%c'", *o);
+
+                /* does this option take an argument? */
+                if (optNeedsArgument(opt_table[mi])) {
+                    /* option needs an argument. find it. */
+                    arg = o + 1;
+                    if (!*arg) {
                 if (ai + 1 >= argc)
-			    optFatal("option `%s' requires an argument",
-				     optString(opt_table[mi], 0));
-			arg = argv[ai+1];
+                            optFatal("option `%s' requires an argument",
+                                     optString(opt_table[mi], 0));
+                        arg = argv[ai+1];
             (*tokens_consumed_p)++;
-		    }
-		    processed_arg = 1;
-		} else
+                    }
+                    processed_arg = 1;
+                } else
             arg = NULL;
-		/* perform the action of this option. */
-		optExecute(opt_table[mi], arg, 0);
-		++o;
+                /* perform the action of this option. */
+                optExecute(opt_table[mi], arg, 0);
+                ++o;
     }
 }
 
diff --git a/lib/util/testnstring.c b/lib/util/testnstring.c
index 87e6139e..0952f04c 100644
--- a/lib/util/testnstring.c
+++ b/lib/util/testnstring.c
@@ -12,7 +12,7 @@ int
 main(int argc, char **argv) {
 
     char snprintfNResult[80];
-    const char * asprintfNResult; 
+    const char * asprintfNResult;
 
     printf("Hello world.\n");
 
@@ -20,7 +20,7 @@ main(int argc, char **argv) {
 
     printf("snprintfN result='%s'\n", snprintfNResult);
 
-    asprintfN(&asprintfNResult, "asprintf'ed string %d %u %s", 
+    asprintfN(&asprintfNResult, "asprintf'ed string %d %u %s",
               5, 89, "substring");
 
     printf("asprintfN result='%s'\n", asprintfNResult);
diff --git a/lib/util/token.c b/lib/util/token.c
index a68a4821..c81432f7 100644
--- a/lib/util/token.c
+++ b/lib/util/token.c
@@ -65,7 +65,7 @@ pm_gettoken(const char *  const tokenStart,
                 token[charCount++] = *cursor++;
             }
             token[charCount] = '\0';
-            
+
             *tokenP = token;
             *nextP = cursor;
         }
diff --git a/lib/util/vasprintf.c b/lib/util/vasprintf.c
index a947f763..fbca457a 100644
--- a/lib/util/vasprintf.c
+++ b/lib/util/vasprintf.c
@@ -1,9 +1,11 @@
+#define _C99_SOURCE  /* Make sure snprintf() is in stdio.h */
 #define _GNU_SOURCE
    /* Because of conditional compilation, this is GNU source only if the C
       library is GNU.
    */
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 
 #include "pm_config.h"
 #include "pm_c_util.h"
@@ -36,7 +38,7 @@ pm_vasprintf(const char ** const resultP,
        simply make two copies of the va_list variable in normal C
        fashion, but on others you need va_copy, which is a relatively
        recent invention.  In particular, the simple va_list copy
-       failed on an AMD64 Gcc Linux system in March 2006.  
+       failed on an AMD64 Gcc Linux system in March 2006.
 
        So instead, we just allocate 4K and truncate or waste as
        necessary.
@@ -49,14 +51,14 @@ pm_vasprintf(const char ** const resultP,
     */
     size_t const allocSize = 4096;
     result = malloc(allocSize);
-    
+
     if (result == NULL)
         *resultP = pm_strsol;
     else {
         size_t realLen;
 
-        pm_vsnprintf(result, allocSize, format, varargs, &realLen);
-        
+        realLen = vsnprintf(result, allocSize, format, varargs);
+
         if (realLen >= allocSize)
             strcpy(result + allocSize - 15, "<<<TRUNCATED");
 
@@ -75,3 +77,6 @@ pm_vasprintf_knows_float(void) {
     return false;
 #endif
 }
+
+
+
diff --git a/other/pamchannel.c b/other/pamchannel.c
index e89a979b..0b9c3947 100644
--- a/other/pamchannel.c
+++ b/other/pamchannel.c
@@ -54,9 +54,9 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "infile",     OPT_STRING, &cmdlineP->inputFileName, 
+    OPTENT3(0, "infile",     OPT_STRING, &cmdlineP->inputFileName,
             &infileSpec, 0);
-    OPTENT3(0, "tupletype",  OPT_STRING, &cmdlineP->tupletype, 
+    OPTENT3(0, "tupletype",  OPT_STRING, &cmdlineP->tupletype,
             &tupletypeSpec, 0);
 
     opt.opt_table = option_def;
@@ -78,16 +78,16 @@ parseCommandLine(int argc, const char ** argv,
                      (unsigned)sizeof(pam.tuple_type));
 
     cmdlineP->n_channel = 0;  /* initial value */
-    { 
+    {
         int argn;
         for (argn = 1; argn < argc; argn++) {
             int n;
             char *endptr;
 
-            if (cmdlineP->n_channel >= MAX_CHANNELS) 
+            if (cmdlineP->n_channel >= MAX_CHANNELS)
                 pm_error("You may not specify more than %d channels.",
                          MAX_CHANNELS);
-            
+
             n = strtol(argv[argn], &endptr, 10);
             if (n < 0)
                 pm_error("Channel numbers cannot be negative.  "
@@ -95,7 +95,7 @@ parseCommandLine(int argc, const char ** argv,
             if (endptr == NULL)
                 pm_error("non-numeric channel number argument: '%s'",
                          argv[argn]);
-            
+
             cmdlineP->channel_to_extract[cmdlineP->n_channel++] = n;
         }
     }
@@ -106,13 +106,13 @@ parseCommandLine(int argc, const char ** argv,
 
 
 static void
-validateChannels(int          const n_channel, 
-                 unsigned int const channels[], 
+validateChannels(int          const n_channel,
+                 unsigned int const channels[],
                  int          const depth) {
 
     int i;
 
-    for (i = 0; i < n_channel; i++) 
+    for (i = 0; i < n_channel; i++)
         if (channels[i] > depth-1)
             pm_error("You specified channel number %d.  The highest numbered\n"
                      "channel in the input image is %d.",
@@ -140,18 +140,18 @@ doOneImage(FILE *       const ifP,
     outpam.depth  = nChannel;
     outpam.format = PAM_FORMAT;
     strcpy(outpam.tuple_type, tupletype);
-    
+
     pnm_writepaminit(&outpam);
 
     {
         tuple * inrow;
         tuple * outrow;
-        
-        inrow  = pnm_allocpamrow(&inpam);      
+
+        inrow  = pnm_allocpamrow(&inpam);
         outrow = pnm_allocpamrow(&outpam);
-        { 
+        {
             unsigned int row;
-            
+
             for (row = 0; row < inpam.height; ++row) {
                 unsigned int col;
 
@@ -159,15 +159,15 @@ doOneImage(FILE *       const ifP,
 
                 for (col = 0; col < inpam.width; ++col) {
                     unsigned int plane;
-                    for (plane = 0; plane < nChannel; ++plane) 
-                        outrow[col][plane] = 
+                    for (plane = 0; plane < nChannel; ++plane)
+                        outrow[col][plane] =
                             inrow[col][channelToExtract[plane]];
                 }
                 pnm_writepamrow(&outpam, outrow);
             }
         }
         pnm_freepamrow(outrow);
-        pnm_freepamrow(inrow);        
+        pnm_freepamrow(inrow);
     }
 }
 
@@ -183,7 +183,7 @@ main(int argc, const char *argv[]) {
     pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
-    
+
     ifP = pm_openr(cmdline.inputFileName);
 
     eof = FALSE;
diff --git a/other/pamdepth.c b/other/pamdepth.c
index 46601864..4349f5ea 100644
--- a/other/pamdepth.c
+++ b/other/pamdepth.c
@@ -124,7 +124,7 @@ transformRaster(struct pam * const inpamP,
                 tuplerow[col][plane] = sampleMap[tuplerow[col][plane]];
         }
         pnm_writepamrow(outpamP, tuplerow);
-	}
+        }
 
     pnm_freepamrow(tuplerow);
 
diff --git a/other/pamlookup.c b/other/pamlookup.c
index d57546d9..23a113c3 100644
--- a/other/pamlookup.c
+++ b/other/pamlookup.c
@@ -4,7 +4,7 @@
 
   Look up integers or ordered pairs from an index image in a lookup table and
   produce a corresponding image containing the results of the lookups.
-  
+
   The index image and lookup table are PAM images.  The output image is
   a PAM image with the width and height of the index image and tuples of
   the kind in the lookup table.
@@ -26,7 +26,7 @@ struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char * indexFilespec;  
+    const char * indexFilespec;
     char *       lookupFilespec;
     char *       missingcolor;  /* null if not specified */
     unsigned int fit;
@@ -48,19 +48,19 @@ parseCommandLine(int argc, const char ** const argv,
     optStruct3 opt;
 
     unsigned int option_def_index;
-    
+
     unsigned int lookupfileSpec, missingcolorSpec;
 
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0, "lookupfile",     OPT_STRING, &cmdlineP->lookupFilespec,  
+    OPTENT3(0, "lookupfile",     OPT_STRING, &cmdlineP->lookupFilespec,
             &lookupfileSpec, 0);
-    OPTENT3(0,   "missingcolor", OPT_STRING, 
+    OPTENT3(0,   "missingcolor", OPT_STRING,
             &cmdlineP->missingcolor,   &missingcolorSpec, 0);
-    OPTENT3(0,   "fit", OPT_FLAG, 
+    OPTENT3(0,   "fit", OPT_FLAG,
             NULL,   &cmdlineP->fit, 0);
-    OPTENT3(0,   "byplane", OPT_FLAG, 
+    OPTENT3(0,   "byplane", OPT_FLAG,
             NULL,   &cmdlineP->byplane, 0);
 
     opt.opt_table = option_def;
@@ -85,12 +85,12 @@ parseCommandLine(int argc, const char ** const argv,
         cmdlineP->indexFilespec = argv[1];
 
     free(option_def);
-}        
+}
 
 
 
 static void
-fitLookup(tuple **     const inputLookup, 
+fitLookup(tuple **     const inputLookup,
           struct pam   const inputLookuppam,
           tuple ***    const fitLookupP,
           struct pam * const fitLookuppamP,
@@ -115,7 +115,7 @@ fitLookup(tuple **     const inputLookup,
     inPamtuples.tuplesP = (tuple ***) &inputLookup;
     outPamtuples.pamP = fitLookuppamP;
     outPamtuples.tuplesP = fitLookupP;
-    
+
     pm_system_lp("pamscale",
                  &pm_feed_from_pamtuples, &inPamtuples,
                  &pm_accept_to_pamtuples, &outPamtuples,
@@ -128,7 +128,7 @@ fitLookup(tuple **     const inputLookup,
 
 
 static void
-getLookup(const char * const lookupFileName, 
+getLookup(const char * const lookupFileName,
           unsigned int const indexDegree,
           unsigned int const indexMaxval,
           tuple ***    const lookupP,
@@ -136,7 +136,7 @@ getLookup(const char * const lookupFileName,
           bool         const fit) {
 /*----------------------------------------------------------------------------
    Get the lookup image (the one that maps integers to tuples, e.g. a
-   color index / color map / palette) from the file named 
+   color index / color map / palette) from the file named
    'lookupFileName'.
 
    Interpret the lookup image for use with indices that are ntuples of size
@@ -154,25 +154,25 @@ getLookup(const char * const lookupFileName,
     tuple ** inputLookup;
 
     lookupfileP = pm_openr(lookupFileName);
-    inputLookup = pnm_readpam(lookupfileP, 
+    inputLookup = pnm_readpam(lookupfileP,
                               &inputLookuppam, PAM_STRUCT_SIZE(tuple_type));
 
     pm_close(lookupfileP);
-    
+
     if (fit) {
         fitLookup(inputLookup, inputLookuppam, lookupP, lookuppamP,
-                  indexMaxval + 1, 
+                  indexMaxval + 1,
                   indexDegree > 1 ? indexMaxval + 1 : 1);
         pnm_freepamarray(inputLookup, &inputLookuppam);
     } else {
         *lookupP = inputLookup;
         *lookuppamP = inputLookuppam;
     }
-        
+
     if (indexDegree == 1 && lookuppamP->height != 1)
         pm_error("Your index image has integer indices, "
                  "so the lookup table image must be one row.  "
-                 "Yours is %d rows.", 
+                 "Yours is %d rows.",
                  lookuppamP->height);
 
     if (lookuppamP->width - 1 > indexMaxval)
@@ -190,9 +190,9 @@ getLookup(const char * const lookupFileName,
 
 
 static void
-computeDefaultTuple(struct CmdlineInfo const cmdline, 
+computeDefaultTuple(struct CmdlineInfo const cmdline,
                     tuple **           const lookup,
-                    struct pam *       const lookuppamP, 
+                    struct pam *       const lookuppamP,
                     tuple *            const defaultTupleP) {
 
     tuple retval;
@@ -204,10 +204,10 @@ computeDefaultTuple(struct CmdlineInfo const cmdline,
        lookup table.  We should probably check here for a lookup file
        that has a visual image tuple type, but we don't out of
        laziness.  The program probably ought to have a generic
-       "missing tuple type" option too.  
+       "missing tuple type" option too.
     */
     if (cmdline.missingcolor) {
-        pixel const color = 
+        pixel const color =
             ppm_parsecolor(cmdline.missingcolor, lookuppamP->maxval);
 
         if (lookuppamP->depth >= 3) {
@@ -224,7 +224,7 @@ computeDefaultTuple(struct CmdlineInfo const cmdline,
             else
                 retval[0] = PPM_GETR(color);
         }
-    } else 
+    } else
         pnm_assigntuple(lookuppamP, retval, lookup[0][0]);
 
     *defaultTupleP = retval;
@@ -261,7 +261,7 @@ doLookupByPlane(struct pam const indexpam,
     outpam = indexpam;  /* initial value */
     outpam.maxval = lookuppam.maxval;
     outpam.file = ofP;
-    
+
     tuplerowIndex = pnm_allocpamrow(&indexpam);
     tuplerowOut = pnm_allocpamrow(&outpam);
 
@@ -273,7 +273,7 @@ doLookupByPlane(struct pam const indexpam,
     for (row = 0; row < indexpam.height; ++row) {
         unsigned int col;
         pnm_readpamrow(&indexpam, tuplerowIndex);
-        
+
         for (col = 0; col < indexpam.width; ++col) {
             unsigned int plane;
 
@@ -320,7 +320,7 @@ doLookupWholeTuple(struct pam const indexpam,
     outpam.height = indexpam.height;
     outpam.width = indexpam.width;
     outpam.file = ofP;
-    
+
     tuplerowIndex = pnm_allocpamrow(&indexpam);
     tuplerowOut = pnm_allocpamrow(&outpam);
 
@@ -329,11 +329,11 @@ doLookupWholeTuple(struct pam const indexpam,
     for (row = 0; row < outpam.height; ++row) {
         unsigned int col;
         pnm_readpamrow(&indexpam, tuplerowIndex);
-        
+
         for (col = 0; col < outpam.width; ++col) {
             unsigned int indexRow, indexCol;
             tuple v;
-            
+
             if (indexpam.depth < 2) {
                 indexRow = 0;
                 indexCol = tuplerowIndex[col][0];
@@ -368,7 +368,7 @@ main(int argc, const char ** const argv) {
     tuple ** lookup;
 
     tuple defaultTuple;
-    
+
     pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
@@ -385,7 +385,7 @@ main(int argc, const char ** const argv) {
 
     indexDegree = cmdline.byplane ? 1 : indexpam.depth;
 
-    getLookup(cmdline.lookupFilespec, indexDegree, indexpam.maxval, 
+    getLookup(cmdline.lookupFilespec, indexDegree, indexpam.maxval,
               &lookup, &lookuppam, cmdline.fit || cmdline.byplane);
 
     computeDefaultTuple(cmdline, lookup, &lookuppam, &defaultTuple);
@@ -399,7 +399,7 @@ main(int argc, const char ** const argv) {
 
     pnm_freepamtuple(defaultTuple);
     pnm_freepamarray(lookup, &lookuppam);
-    
+
     return 0;
 }
 
diff --git a/other/pamsplit.c b/other/pamsplit.c
index 93c1726a..8c7aff11 100644
--- a/other/pamsplit.c
+++ b/other/pamsplit.c
@@ -66,7 +66,7 @@ parseCommandLine(int argc, const char ** argv,
     if (!padnameSpec)
         cmdlineP->padname = 0;
 
-    if (argc - 1 < 1) 
+    if (argc - 1 < 1)
         cmdlineP->inputFileName = "-";
     else
         cmdlineP->inputFileName = argv[1];
@@ -91,7 +91,7 @@ extractOneImage(FILE * const infileP,
     struct pam inpam;
     struct pam outpam;
     enum pm_check_code checkRetval;
-    
+
     unsigned int row;
     tuple * tuplerow;
 
@@ -115,7 +115,7 @@ extractOneImage(FILE * const infileP,
 
 
 static void
-computeOutputName(char          const outputFilePattern[], 
+computeOutputName(char          const outputFilePattern[],
                   unsigned int  const padCount,
                   unsigned int  const imageSeq,
                   const char ** const outputNameP) {
@@ -157,13 +157,13 @@ main(int argc, const char *argv[]) {
 
     FILE * ifP;
     int eof;  /* No more images in input */
-    unsigned int imageSeq;  
+    unsigned int imageSeq;
         /* Sequence of current image in input file.  First = 0 */
 
     pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
-    
+
     ifP = pm_openr(cmdline.inputFileName);
 
     eof = FALSE;
@@ -171,7 +171,7 @@ main(int argc, const char *argv[]) {
         FILE * ofP;
         const char * outputFileName;  /* malloc'ed */
 
-        computeOutputName(cmdline.outputFilePattern, cmdline.padname, 
+        computeOutputName(cmdline.outputFilePattern, cmdline.padname,
                           imageSeq,
                           &outputFileName);
         pm_message("WRITING %s", outputFileName);
@@ -185,7 +185,7 @@ main(int argc, const char *argv[]) {
         pnm_nextimage(ifP, &eof);
     }
     pm_close(ifP);
-    
+
     return 0;
 }
 
diff --git a/other/pamsummcol.c b/other/pamsummcol.c
index c84f38ad..673eaf57 100644
--- a/other/pamsummcol.c
+++ b/other/pamsummcol.c
@@ -68,18 +68,18 @@ parseCommandLine(int argc, char ** const argv,
         cmdlineP->function = FN_MIN;
     } else if (maxSpec) {
         cmdlineP->function = FN_MAX;
-    } else 
+    } else
         pm_error("You must specify one of -sum, -min, or -max");
-        
+
     if (argc-1 > 1)
         pm_error("Too many arguments (%d).  File spec is the only argument.",
                  argc-1);
 
     if (argc-1 < 1)
         cmdlineP->inputFilespec = "-";
-    else 
+    else
         cmdlineP->inputFilespec = argv[1];
-    
+
 }
 
 
@@ -98,7 +98,7 @@ createAccumulator(enum function    const function,
                   unsigned int     const cols,
                   unsigned int     const planes,
                   struct accum *** const accumulatorP) {
-    
+
     struct accum ** accumulator;
     unsigned int col;
 
@@ -115,7 +115,7 @@ createAccumulator(enum function    const function,
             case FN_MEAN: accumulator[col][plane].u.sum = 0;        break;
             case FN_MIN:  accumulator[col][plane].u.min = UINT_MAX; break;
             case FN_MAX:  accumulator[col][plane].u.max = 0;        break;
-            } 
+            }
         }
     }
     *accumulatorP = accumulator;
@@ -148,14 +148,14 @@ aggregate(struct pam *    const inpamP,
         unsigned int plane;
         for (plane = 0; plane < inpamP->depth; ++plane) {
             switch(function) {
-            case FN_ADD:  
-            case FN_MEAN: 
-                if (accumulator[col][plane].u.sum > 
+            case FN_ADD:
+            case FN_MEAN:
+                if (accumulator[col][plane].u.sum >
                     UINT_MAX - tupleRow[col][plane])
                     pm_error("Numerical overflow in Column %u", col);
                 accumulator[col][plane].u.sum += tupleRow[col][plane];
             break;
-            case FN_MIN:  
+            case FN_MIN:
                 if (tupleRow[col][plane] < accumulator[col][plane].u.min)
                     accumulator[col][plane].u.min = tupleRow[col][plane];
                 break;
@@ -163,7 +163,7 @@ aggregate(struct pam *    const inpamP,
                 if (tupleRow[col][plane] > accumulator[col][plane].u.min)
                     accumulator[col][plane].u.min = tupleRow[col][plane];
                 break;
-            } 
+            }
         }
     }
 }
@@ -176,31 +176,31 @@ makeSummaryRow(struct accum ** const accumulator,
                struct pam *  const   pamP,
                enum function const   function,
                tuple *       const   tupleRow) {
-    
+
     unsigned int col;
 
     for (col = 0; col < pamP->width; ++col) {
         unsigned int plane;
         for (plane = 0; plane < pamP->depth; ++plane) {
             switch(function) {
-            case FN_ADD:  
-                tupleRow[col][plane] = 
+            case FN_ADD:
+                tupleRow[col][plane] =
                     MIN(accumulator[col][plane].u.sum, pamP->maxval);
                 break;
-            case FN_MEAN: 
-                tupleRow[col][plane] = 
+            case FN_MEAN:
+                tupleRow[col][plane] =
                     ROUNDU((double)accumulator[col][plane].u.sum / count);
                 break;
-            case FN_MIN:  
-                tupleRow[col][plane] = 
+            case FN_MIN:
+                tupleRow[col][plane] =
                     accumulator[col][plane].u.min;
                 break;
             case FN_MAX:
-                tupleRow[col][plane] = 
+                tupleRow[col][plane] =
                     accumulator[col][plane].u.max;
                 break;
             }
-        } 
+        }
     }
 }
 
@@ -226,7 +226,7 @@ main(int argc, char *argv[]) {
 
     pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
-    createAccumulator(cmdline.function, inpam.width, inpam.depth, 
+    createAccumulator(cmdline.function, inpam.width, inpam.depth,
                       &accumulator);
 
     inputRow = pnm_allocpamrow(&inpam);
@@ -244,7 +244,7 @@ main(int argc, char *argv[]) {
 
         aggregate(&inpam, inputRow, cmdline.function, accumulator);
     }
-    makeSummaryRow(accumulator, inpam.height, &outpam, cmdline.function, 
+    makeSummaryRow(accumulator, inpam.height, &outpam, cmdline.function,
                    outputRow);
     pnm_writepamrow(&outpam, outputRow);
 
@@ -253,6 +253,6 @@ main(int argc, char *argv[]) {
     destroyAccumulator(accumulator, inpam.width);
     pm_close(inpam.file);
     pm_close(outpam.file);
-    
+
     return 0;
 }
diff --git a/other/pamvalidate.c b/other/pamvalidate.c
index a7b08b8e..613df736 100644
--- a/other/pamvalidate.c
+++ b/other/pamvalidate.c
@@ -74,7 +74,7 @@ main(int argc, const char * argv[]) {
 
         if (ferror(tmpfile))
             pm_error("Error reading from temporary file.  "
-                     "Incomplete output.  "    
+                     "Incomplete output.  "
                      "Errno = %s (%d)", strerror(errno), errno);
         else
             fwrite(buffer, 1, bytesReadCt, stdout);
diff --git a/other/pamx/fill.c b/other/pamx/fill.c
index 13a2b21e..dc61ce33 100644
--- a/other/pamx/fill.c
+++ b/other/pamx/fill.c
@@ -1,8 +1,8 @@
-/* 
+/*
    fill an image area with a particular pixel value
- 
+
    By Jim Frost 1989.10.02, Bryan Henderson 2006.03.25.
- 
+
    See COPYRIGHT file for copyright information.
 */
 
@@ -52,7 +52,7 @@ fill(Image * const imageP,
             }
         }
     } break;
-        
+
   case IRGB:
     case ITRUE: {
         unsigned int const linelen= imageP->width * imageP->pixlen;
diff --git a/other/pamx/image.c b/other/pamx/image.c
index 0e719438..fc256ae1 100644
--- a/other/pamx/image.c
+++ b/other/pamx/image.c
@@ -1,8 +1,8 @@
 /*
    Functions to allocate and deallocate structures and structure data
- 
+
    By Jim Frost 1989.09.29, Bryan Henderson 2006.03.25.
- 
+
    See COPYRIGHT file for copyright information.
 */
 
@@ -156,7 +156,7 @@ Image *
 newRGBImage(unsigned int const width,
             unsigned int const height,
             unsigned int const depth) {
-    
+
     unsigned int const pixlen = depth > 0 ? (depth + 7) / 8 : 1;
         /* Special case for "zero" depth image, which is sometimes
            interpreted as "one color"
@@ -164,7 +164,7 @@ newRGBImage(unsigned int const width,
     unsigned int const numcolors = depthToColors(depth);
 
     Image * imageP;
-    
+
     MALLOCVAR_NOFAIL(imageP);
     imageP->type   = IRGB;
     newRGBMapData(&imageP->rgb, numcolors);
@@ -191,7 +191,7 @@ newTrueImage(unsigned int const width,
              unsigned int const height) {
 
     unsigned int const pixlen = 3;
-    
+
     Image * imageP;
 
     MALLOCVAR_NOFAIL(imageP);
diff --git a/other/pamx/pamx.c b/other/pamx/pamx.c
index 35900f82..cc2a70ae 100644
--- a/other/pamx/pamx.c
+++ b/other/pamx/pamx.c
@@ -1,4 +1,4 @@
-/* By Bryan Henderson 2006.03.25 
+/* By Bryan Henderson 2006.03.25
 
    Copyright information is in the file COPYRIGHT
 */
@@ -52,13 +52,13 @@ struct cmdlineInfo {
 
 
 
-static void 
-parseCommandLine(int argc, 
-                 char ** argv, 
+static void
+parseCommandLine(int argc,
+                 char ** argv,
                  struct cmdlineInfo  * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -69,7 +69,7 @@ parseCommandLine(int argc,
     optEntry *option_def;
         /* Instructions to pm_optParseOptions3 on how to parse our options. */
     optStruct3 opt;
-  
+
     unsigned int option_def_index;
 
     unsigned int displaySpec, titleSpec, foregroundSpec, backgroundSpec,
@@ -111,7 +111,7 @@ parseCommandLine(int argc,
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;   /* We have no parms that are negative numbers */
-    
+
     pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
@@ -194,7 +194,7 @@ fillRow(struct pam *     const pamP,
    for its contents, according to 'depth'.
 -----------------------------------------------------------------------------*/
     unsigned int col;
-    
+
     for (col = 0; col < pamP->width; ++col) {
         /* Truecolor image data has 3 bytes per pixel, one each for
            red, green, and blue.
@@ -238,7 +238,7 @@ loadPamImage(FILE *   const ifP,
 
     for (row = 0; row < pam.height; ++row) {
         pnm_readpamrow(&pam, tuplerow);
-        
+
         /* This semantically wasteful code allows a dumb compiler
            optimizer to recognize that the depth is constant and
            therefore not generate code that checks the depth every
@@ -288,7 +288,7 @@ processImage(Image *            const imageP,
             imageP->rgb.grn[FOREGROUND_IDX] = color.green;
             imageP->rgb.blu[FOREGROUND_IDX] = color.blue;
         }
-    }    
+    }
 }
 
 
@@ -296,9 +296,9 @@ processImage(Image *            const imageP,
 static void
 determineTitle(struct cmdlineInfo const cmdline,
                const char **      const titleP) {
-    
+
     const char * title;
-    
+
     if (cmdline.title)
         title = strdup(cmdline.title);
     else {
@@ -332,7 +332,7 @@ main(int     argc,
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFileName);
-    
+
     dispP = XOpenDisplay(cmdline.display);
     if (!dispP)
         pm_error("Cannot open display '%s'", XDisplayName(cmdline.display));
diff --git a/other/pamx/send.c b/other/pamx/send.c
index 3c3852e2..c33c5c06 100644
--- a/other/pamx/send.c
+++ b/other/pamx/send.c
@@ -1,10 +1,10 @@
 /*
- 
+
   Send an Image to an X pixmap
 
 
   By Jim Frost 1989.10.02, Bryan Henderson 2006.03.25.
- 
+
   Copyright 1989, 1990, 1991 Jim Frost.
   See COPYRIGHT file for copyright information.
 */
@@ -59,7 +59,7 @@ ximageToPixmap(Display *    const disp,
 
     XErrorHandler old_handler;
     Pixmap        pixmap;
-  
+
     GotError = FALSE;
     old_handler = XSetErrorHandler(pixmapErrorTrap);
     XSync(disp, False);
@@ -114,7 +114,7 @@ bitsPerPixelAtDepth(Display *    const disp,
   fprintf(stderr, "bitsPerPixelAtDepth: Can't find pixmap depth info!\n");
   exit(1);
 }
-     
+
 
 
 static void
@@ -130,7 +130,7 @@ findColors(const Image *   const imageP,
 
     for (color = 0; color < 32768; ++color)
         pixelCt[color] = 0;  /* initial value */
-  
+
     for (y = 0, pixel = imageP->data; y < imageP->height; ++y) {
         unsigned int x;
         for (x = 0; x < imageP->width; ++x) {
@@ -184,7 +184,7 @@ pseudoColorImageFromItrue(Image *      const imageP,
 
             /* Put the color in the color map */
             newImageP->rgb.red[colorCt] = red<<11;
-            newImageP->rgb.grn[colorCt] = grn<<11; 
+            newImageP->rgb.grn[colorCt] = grn<<11;
             newImageP->rgb.blu[colorCt] = blu<<11;
 
             /* Reverse-index it */
@@ -192,9 +192,9 @@ pseudoColorImageFromItrue(Image *      const imageP,
 
             ++colorCt;
         }
-    }    
+    }
     newImageP->rgb.used = colorCt;
-    
+
     for (y = 0, pixel  = imageP->data, dpixel = newImageP->data;
          y < imageP->height;
          ++y) {
@@ -241,7 +241,7 @@ makeUsableVisual(Image *      const origImageP,
                      visualP->class);
         }
         break;
-        
+
     case IRGB:
         switch(visualP->class) {
         case TrueColor:
@@ -253,13 +253,13 @@ makeUsableVisual(Image *      const origImageP,
             pm_error("INTERNAL ERROR: impossible visual class %u",
                      visualP->class);
         }
-        
+
     case IBITMAP:
         /* no processing ever needs to be done for bitmaps */
         *newImagePP = origImageP;
         break;
     }
-}    
+}
 
 
 
@@ -271,7 +271,7 @@ makeColorMap1(Display *  const disp,
               Pixel **   const redvalueP,
               Pixel **   const grnvalueP,
               Pixel **   const bluvalueP) {
-    
+
     Pixel * redvalue;
     Pixel * grnvalue;
     Pixel * bluvalue;
@@ -281,22 +281,22 @@ makeColorMap1(Display *  const disp,
     unsigned int redbottom, grnbottom, blubottom;
     unsigned int redtop, grntop, blutop;
     unsigned int a;
-            
+
     MALLOCARRAY_NOFAIL(redvalue, 256);
     MALLOCARRAY_NOFAIL(grnvalue, 256);
     MALLOCARRAY_NOFAIL(bluvalue, 256);
-            
+
     if (visualP == DefaultVisual(disp, scrn))
         *cmapP = DefaultColormap(disp, scrn);
     else
         *cmapP = XCreateColormap(disp, RootWindow(disp, scrn),
                                  visualP, AllocNone);
-            
+
  retry_direct: /* tag we hit if a DirectColor allocation fails on
                 * default colormap */
-            
+
     /* calculate number of distinct colors in each band */
-            
+
     redcolors = grncolors = blucolors = 1;
     for (pixval = 1; pixval; pixval <<= 1) {
         if (pixval & visualP->red_mask)
@@ -306,16 +306,16 @@ makeColorMap1(Display *  const disp,
         if (pixval & visualP->blue_mask)
             blucolors <<= 1;
     }
-            
+
     /* sanity check */
-            
+
     if ((redcolors > visualP->map_entries) ||
         (grncolors > visualP->map_entries) ||
         (blucolors > visualP->map_entries)) {
         pm_message("Warning: inconsistency in color information "
                    "(this may be ugly)");
     }
-            
+
     redstep= 256 / redcolors;
     grnstep= 256 / grncolors;
     blustep= 256 / blucolors;
@@ -329,7 +329,7 @@ makeColorMap1(Display *  const disp,
             grntop = grnbottom + grnstep;
         if (blubottom < 256)
             blutop = blubottom + blustep;
-                
+
         xcolor.flags = DoRed | DoGreen | DoBlue;
         xcolor.red   = (redtop - 1) << 8;
         xcolor.green = (grntop - 1) << 8;
@@ -347,15 +347,15 @@ makeColorMap1(Display *  const disp,
                                          visualP, AllocNone);
                 goto retry_direct;
             }
-                    
+
             /* something completely unexpected happened */
-                    
+
             pm_error("INTERNAL ERROR: XAllocColor failed on a "
                      "TrueColor/Directcolor visual");
         }
-                
+
         /* fill in pixel values for each band at this intensity */
-                
+
         while ((redbottom < 256) && (redbottom < redtop))
             redvalue[redbottom++] = xcolor.pixel & visualP->red_mask;
         while ((grnbottom < 256) && (grnbottom < grntop))
@@ -369,7 +369,7 @@ makeColorMap1(Display *  const disp,
 }
 
 
- 
+
 static void
 allocColorCells(Display *      const disp,
                 Colormap       const cmap,
@@ -379,7 +379,7 @@ allocColorCells(Display *      const disp,
 
     bool outOfCells;
     unsigned int cellCount;
-    
+
     outOfCells = false;  /* initial value */
     cellCount = 0;       /* initial value */
     while (cellCount < colorCount && !outOfCells) {
@@ -392,7 +392,7 @@ allocColorCells(Display *      const disp,
     *cellCountP = cellCount;
 }
 
-    
+
 
 
 static void
@@ -412,9 +412,9 @@ makeColorMap2(Display *  const disp,
     Pixel * colorIndex;
 
     MALLOCARRAY_NOFAIL(colorIndex, rgb.used);
-        
+
     /* 'privateCmap' is invalid if not a dynamic visual */
-        
+
     switch (visualP->class) {
     case StaticColor:
     case StaticGray:
@@ -422,9 +422,9 @@ makeColorMap2(Display *  const disp,
     default:
         privateCmap = userWantsPrivateCmap;
     }
-        
+
     /* get the colormap to use. */
-        
+
     if (privateCmap) { /* user asked us to use a private cmap */
         newmap = TRUE;
         fit = FALSE;
@@ -433,7 +433,7 @@ makeColorMap2(Display *  const disp,
                (visualP->class == StaticColor) ||
                (visualP->class == TrueColor) ||
                (visualP->class == DirectColor)) {
-            
+
         unsigned int a;
 
         fit = userWantsFit;
@@ -442,16 +442,16 @@ makeColorMap2(Display *  const disp,
            shareable.  otherwise we're using a static visual and
            should treat it accordingly.
         */
-            
+
         if (visualP == DefaultVisual(disp, scrn))
             *cmapP = DefaultColormap(disp, scrn);
         else
             *cmapP = XCreateColormap(disp, RootWindow(disp, scrn),
                                      visualP, AllocNone);
         newmap = FALSE;
-            
+
         /* allocate colors shareable (if we can) */
-            
+
         for (a = 0; a < rgb.used; ++a) {
             Status rc;
             XColor  xcolor;
@@ -484,7 +484,7 @@ makeColorMap2(Display *  const disp,
         newmap = TRUE;
         fit    = FALSE;
     }
-        
+
     if (newmap) {
         /* Either create a new colormap or fit the image into the
            one we have.  To create a new one, we create a private
@@ -497,10 +497,10 @@ makeColorMap2(Display *  const disp,
            4. reduce the depth of the image to fit.
            5. allocate the colors again shareable.
            6. ungrab the server and continue on our way.
-               
+
            Someone should shoot the people who designed X color allocation.
         */
-            
+
         unsigned int a;
 
         if (fit) {
@@ -510,13 +510,13 @@ makeColorMap2(Display *  const disp,
         } else {
             if (verbose)
                 pm_message("Using private colormap");
-                
+
             /* create new colormap */
-                
+
             *cmapP = XCreateColormap(disp, RootWindow(disp, scrn),
                                      visualP, AllocNone);
         }
-            
+
         allocColorCells(disp, *cmapP, colorIndex, rgb.used, &a);
 
         if (fit) {
@@ -525,10 +525,10 @@ makeColorMap2(Display *  const disp,
             if (a <= 2)
                 pm_error("Cannot fit into default colormap");
         }
-            
+
         if (a == 0)
             pm_error("Color allocation failed!");
-            
+
         if (fit) {
             unsigned int a;
             for (a = 0; a < rgb.used; ++a) {
@@ -537,7 +537,7 @@ makeColorMap2(Display *  const disp,
                 xcolor.red   = rgb.red[a];
                 xcolor.green = rgb.grn[a];
                 xcolor.blue  = rgb.blu[a];
-                
+
                 if (!XAllocColor(disp, *cmapP, &xcolor))
                     pm_error("XAllocColor failed while fitting colormap!");
                 colorIndex[a] = xcolor.pixel;
@@ -574,7 +574,7 @@ doColorAllocation(XImageInfo * const ximageinfoP,
                   Pixel **     const redvalP,
                   Pixel **     const grnvalP,
                   Pixel **     const bluvalP) {
-    
+
     if ((visualP->class == TrueColor || visualP->class == DirectColor) &&
         !BITMAPP(imageP)) {
         makeColorMap1(disp, scrn, visualP, &ximageinfoP->cmap,
@@ -584,11 +584,11 @@ doColorAllocation(XImageInfo * const ximageinfoP,
         makeColorMap2(disp, scrn, visualP, imageP->rgb,
                       userWantsPrivateCmap, userWantsFit, verbose,
                       &ximageinfoP->cmap, colorIndexP);
-        
+
         *redvalP = *grnvalP = *bluvalP = NULL;
     }
 }
-    
+
 
 
 
@@ -637,19 +637,19 @@ makeXImage(XImageInfo * const ximageinfoP,
     case IRGB:
     case ITRUE: {
         /* Modify image data to match visual and colormap */
-        
+
         unsigned int const dbits = bitsPerPixelAtDepth(disp, scrn, ddepth);
         unsigned int const dpixlen = (dbits + 7) / 8;
 
         ximageinfoP->depth = ddepth;
-        
+
         switch (visualP->class) {
         case DirectColor:
         case TrueColor: {
             unsigned char * data;
             unsigned char * destptr;
             unsigned char * srcptr;
-        
+
             ximageinfoP->ximageP =
                 XCreateImage(disp, visualP, ddepth, ZPixmap, 0,
                              NULL, imageP->width, imageP->height, 8, 0);
@@ -702,7 +702,7 @@ makeXImage(XImageInfo * const ximageinfoP,
         } break;
 
         default: {
-            
+
             /* only IRGB images make it this far. */
 
             /* If our XImage doesn't have modulus 8 bits per pixel,
@@ -734,7 +734,7 @@ makeXImage(XImageInfo * const ximageinfoP,
                 ximageinfoP->ximageP->byte_order = MSBFirst;
                 for (a= 0; a < dbits; ++a) {
                     Pixel const pixmask = 1 << a;
-                    unsigned char * const destdata = 
+                    unsigned char * const destdata =
                         data + ((ddepth - a - 1) * imageP->height * linelen);
 
                     unsigned int y;
@@ -792,7 +792,7 @@ makeXImage(XImageInfo * const ximageinfoP,
                 }
             }
         } break;
-        }   
+        }
     } break;
     }
     if (verbose)
@@ -819,7 +819,7 @@ imageToXImage(Display *    const disp,
     Pixel * bluvalue;
 
     assertGoodImage(origImageP);
-  
+
     MALLOCVAR_NOFAIL(ximageinfoP);
     ximageinfoP->disp = disp;
     ximageinfoP->scrn = scrn;
@@ -828,7 +828,7 @@ imageToXImage(Display *    const disp,
     ximageinfoP->foreground = ximageinfoP->background = 0;
     ximageinfoP->gc = NULL;
     ximageinfoP->ximageP = NULL;
-  
+
     makeUsableVisual(origImageP, visualP, ddepth, &imageP);
 
     assertGoodImage(imageP);
@@ -849,7 +849,7 @@ imageToXImage(Display *    const disp,
     }
     if (imageP != origImageP)
         freeImage(imageP);
-    
+
     return ximageinfoP;
 }
 
@@ -870,7 +870,7 @@ sendXImage(XImageInfo * const ximageinfoP,
     XGCValues gcv;
 
     /* build and cache the GC */
-    
+
     if (!ximageinfoP->gc) {
         gcv.function = GXcopy;
         if (ximageinfoP->ximageP->depth == 1) {
@@ -885,7 +885,7 @@ sendXImage(XImageInfo * const ximageinfoP,
                 XCreateGC(ximageinfoP->disp, ximageinfoP->drawable,
                           GCFunction, &gcv);
     }
-    
+
     XPutImage(ximageinfoP->disp, ximageinfoP->drawable, ximageinfoP->gc,
               ximageinfoP->ximageP, src_x, src_y, dst_x, dst_y, w, h);
 }
diff --git a/other/ppmdcfont.c b/other/ppmdcfont.c
index 130b6383..a8bcbcd8 100644
--- a/other/ppmdcfont.c
+++ b/other/ppmdcfont.c
@@ -30,10 +30,10 @@ generateGlyphCommand(struct ppmd_glyphCommand const glyphCommand) {
     case CMD_DRAWLINE: verb = "CMD_DRAWLINE"; break;
     case CMD_MOVEPEN:  verb = "CMD_MOVEPEN";  break;
     }
-    
+
     fprintf(stdout, "  {/* glyphCommand */ %s, %u, %u }\n",
             verb, glyphCommand.x, glyphCommand.y);
-    
+
 }
 
 
@@ -76,7 +76,7 @@ generateCommandTables(const struct ppmd_font * const fontP,
             pm_asprintf(&commandTableVariableName, "%s_cmd_%u",
                         glyphTableVariableName,
                         fontP->header.firstCodePoint + relativeCodePoint);
-            
+
             generateCommandTable(fontP->glyphTable[relativeCodePoint],
                                  commandTableVariableName);
 
@@ -133,7 +133,7 @@ generateGlyphTable(const struct ppmd_font * const fontP,
         pm_asprintf(&commandTableVariableName, "%s_cmd_%u",
                     variableName,
                     fontP->header.firstCodePoint + relativeCodePoint);
-        
+
         generateGlyph(fontP->glyphTable[relativeCodePoint],
                       commandTableVariableName);
 
@@ -154,7 +154,7 @@ generateFont(const struct ppmd_font * const fontP,
              const char *             const glyphTableVariableName) {
 
     fprintf(stdout, "struct ppmd_font const %s = {\n", fontVariableName);
-    
+
     generateHeader(fontP->header);
 
     fprintf(stdout, "  ,\n");
@@ -189,12 +189,12 @@ main(int argc, char **argv) {
     generateGlyphTable(fontP, glyphTableVariableName);
 
     fprintf(stdout, "\n");
-        
+
     generateFont(fontP, fontVariableName, glyphTableVariableName);
 
     pm_strfree(glyphTableVariableName);
 
     ppmd_free_font(fontP);
-    
+
     return 0;
 }
diff --git a/other/ppmddumpfont.c b/other/ppmddumpfont.c
index 3ab477ab..1c3474e8 100644
--- a/other/ppmddumpfont.c
+++ b/other/ppmddumpfont.c
@@ -19,7 +19,7 @@ untwos(unsigned char const arg) {
 
 static void
 dumpHeader(struct ppmd_fontHeader const fontHeader) {
-    
+
     pm_message("Font has %u characters", fontHeader.characterCount);
     pm_message("Font has code points %u through %u",
                fontHeader.firstCodePoint,
@@ -34,7 +34,7 @@ dumpGlyph(struct ppmd_glyph const glyph) {
     unsigned int commandNum;
 
     pm_message("  skip before: %u pixels; skip after: %u pixels; "
-               "%u commands:", 
+               "%u commands:",
                glyph.header.skipBefore,
                glyph.header.skipAfter,
                glyph.header.commandCount);
@@ -42,10 +42,10 @@ dumpGlyph(struct ppmd_glyph const glyph) {
     for (commandNum = 0;
          commandNum < glyph.header.commandCount;
          ++commandNum) {
-         
+
         struct ppmd_glyphCommand const glyphCommand =
             glyph.commandList[commandNum];
-        
+
         const char * verbDisp;
 
         switch (glyphCommand.verb) {
@@ -84,6 +84,6 @@ main(int argc, char **argv) {
     }
 
     ppmd_free_font(fontP);
-    
+
     return 0;
 }
diff --git a/other/ppmdmkfont.c b/other/ppmdmkfont.c
index 7cf1256f..f340e4f4 100644
--- a/other/ppmdmkfont.c
+++ b/other/ppmdmkfont.c
@@ -63,7 +63,7 @@ static unsigned char char37[] =
   250, 244, 252, 244, 254, 245, 1, 246, 4, 246, 7, 245, 9, 244,
   192, 0, 5, 2, 3, 3, 2, 5, 2, 7, 4, 9, 6, 9, 8, 8, 9, 6, 9, 4, 7,
   2, 5, 2 };
-  
+
 static unsigned char char38[] =
 { 34, 243, 13,
   10, 253, 10, 252, 9, 251, 8, 251, 7, 252, 6, 254, 4,
@@ -155,7 +155,7 @@ static unsigned char char54[] =
 static unsigned char char55[] =
 { 5, 246, 10,
   7, 244, 253, 9, 192, 0, 249, 244, 7, 244 };
-    
+
 static unsigned char char56[] =
 { 29, 246, 10,
   254, 244, 251, 245, 250, 247, 250, 249, 251, 251,
@@ -169,12 +169,12 @@ static unsigned char char57[] =
   254, 249, 251, 249, 250, 250, 247, 252, 245, 255, 244, 0, 244, 3,
   245, 5, 247, 6, 251, 6, 0, 5, 5, 3, 8, 0, 9, 254, 9, 251, 8, 250,
   6 };
-      
+
 static unsigned char char58[] =
 { 11, 251, 5,
   0, 251, 255, 252, 0, 253, 1, 252, 0, 251, 192, 0, 0,
   7, 255, 8, 0, 9, 1, 8, 0, 7 };
-                                
+
 static unsigned char char59[] =
 { 14, 251, 5,
   0, 251, 255, 252, 0, 253, 1, 252, 0, 251, 192, 0, 1,
@@ -208,7 +208,7 @@ static unsigned char char64[] =
   248, 247, 250, 246, 253, 246, 0, 247, 3, 248, 5, 250, 7, 252, 8,
   255, 9, 2, 9, 5, 8, 7, 7, 8, 6, 192, 0, 6, 249, 5, 1, 5, 3, 6, 4
 };
-  
+
 static unsigned char char65[] =
 { 8, 247, 9,
   0, 244, 248, 9, 192, 0, 0, 244, 8, 9, 192, 0, 251, 2,
@@ -266,7 +266,7 @@ static unsigned char char75[] =
   249, 244, 249, 9, 192, 0, 7, 244, 249, 2, 192, 0,
   254, 253, 7, 9 };
 
-static unsigned char char76[] = 
+static unsigned char char76[] =
 { 3, 246, 7,
   250, 244, 250, 9, 6, 9 };
 
@@ -274,12 +274,12 @@ static unsigned char char77[] =
 { 11, 244, 12,
   248, 244, 248, 9, 192, 0, 248, 244, 0, 9, 192, 0, 8,
   244, 0, 9, 192, 0, 8, 244, 8, 9 };
-                                               
+
 static unsigned char char78[] =
 { 8, 245, 11,
   249, 244, 249, 9, 192, 0, 249, 244, 7, 9, 192, 0, 7,
   244, 7, 9 };
-                         
+
 static unsigned char char79[] =
 { 21, 245, 11,
   254, 244, 252, 245, 250, 247, 249, 249, 248, 252,
@@ -297,7 +297,7 @@ static unsigned char char81[] =
   248, 1, 249, 4, 250, 6, 252, 8, 254, 9, 2, 9, 4, 8, 6, 6, 7, 4,
   8, 1, 8, 252, 7, 249, 6, 247, 4, 245, 2, 244, 254, 244, 192, 0,
   1, 5, 7, 11 };
-                           
+
 static unsigned char char82[] =
 { 16, 245, 10,
   249, 244, 249, 9, 192, 0, 249, 244, 2, 244, 5, 245,
@@ -372,13 +372,13 @@ static unsigned char char97[] =
   6, 251, 6, 9, 192, 0, 6, 254, 4, 252, 2, 251, 255,
   251, 253, 252, 251, 254, 250, 1, 250, 3, 251, 6, 253, 8, 255, 9,
   2, 9, 4, 8, 6, 6 };
-                                
+
 static unsigned char char98[] =
 { 17, 246, 9,
   250, 244, 250, 9, 192, 0, 250, 254, 252, 252, 254,
   251, 1, 251, 3, 252, 5, 254, 6, 1, 6, 3, 5, 6, 3, 8, 1, 9, 254,
   9, 252, 8, 250, 6 };
-                                 
+
 static unsigned char char99[] =
 { 14, 247, 9,
   6, 254, 4, 252, 2, 251, 255, 251, 253, 252, 251, 254,
@@ -389,7 +389,7 @@ static unsigned char char100[] =
   6, 244, 6, 9, 192, 0, 6, 254, 4, 252, 2, 251, 255,
   251, 253, 252, 251, 254, 250, 1, 250, 3, 251, 6, 253, 8, 255, 9,
   2, 9, 4, 8, 6, 6 };
-                                 
+
 static unsigned char char101[] =
 { 17, 247, 9,
   250, 1, 6, 1, 6, 255, 5, 253, 4, 252, 2, 251, 255,
@@ -429,7 +429,7 @@ static unsigned char char107[] =
 static unsigned char char108[] =
 { 2, 252, 4,
   0, 244, 0, 9 };
-                                        
+
 static unsigned char char109[] =
 { 18, 241, 15,
   245, 251, 245, 9, 192, 0, 245, 255, 248, 252, 250,
@@ -458,12 +458,12 @@ static unsigned char char113[] =
   6, 251, 6, 16, 192, 0, 6, 254, 4, 252, 2, 251, 255,
   251, 253, 252, 251, 254, 250, 1, 250, 3, 251, 6, 253, 8, 255, 9,
   2, 9, 4, 8, 6, 6 };
-                                 
+
 static unsigned char char114[] =
 { 8, 249, 6,
   253, 251, 253, 9, 192, 0, 253, 1, 254, 254, 0, 252,
   2, 251, 5, 251 };
-                               
+
 static unsigned char char115[] =
 { 17, 248, 9,
   6, 254, 5, 252, 2, 251, 255, 251, 252, 252, 251,
@@ -482,7 +482,7 @@ static unsigned char char117[] =
 static unsigned char char118[] =
 { 5, 248, 8,
   250, 251, 0, 9, 192, 0, 6, 251, 0, 9 };
-                                                                
+
 static unsigned char char119[] =
 { 11, 245, 11,
   248, 251, 252, 9, 192, 0, 0, 251, 252, 9, 192, 0,
@@ -496,7 +496,7 @@ static unsigned char char121[] =
 { 9, 248, 8,
   250, 251, 0, 9, 192, 0, 6, 251, 0, 9, 254, 13, 252,
   15, 250, 16, 249, 16 };
-                                     
+
 static unsigned char char122[] =
 { 8, 248, 9,
   6, 251, 251, 9, 192, 0, 251, 251, 6, 251, 192, 0,
@@ -554,7 +554,7 @@ writeGlyphCommand(FILE *                   const ofP,
     fputc(glyphCommand.verb, ofP);
     fputc(glyphCommand.x, ofP);
     fputc(glyphCommand.y, ofP);
-}    
+}
 
 
 
@@ -563,11 +563,11 @@ writeMovePen(FILE *                const ofP,
              const unsigned char * const glyphData) {
 
     struct ppmd_glyphCommand glyphCommand;
-            
+
     glyphCommand.verb = CMD_MOVEPEN;
     glyphCommand.x = glyphData[0];
     glyphCommand.y = glyphData[1];
-    
+
     writeGlyphCommand(ofP, glyphCommand);
 }
 
@@ -578,13 +578,13 @@ writeMovePenNoop(FILE *                const ofP,
                  const unsigned char * const glyphData) {
 
     struct ppmd_glyphCommand glyphCommand;
-            
+
     glyphCommand.verb = CMD_MOVEPEN;
     glyphCommand.x = glyphData[0];
     glyphCommand.y = glyphData[1];
-    
+
     writeGlyphCommand(ofP, glyphCommand);
-                
+
     glyphCommand.verb = CMD_NOOP;
     glyphCommand.x = 0;
     glyphCommand.y = 0;
@@ -603,10 +603,10 @@ writeDrawLine(FILE *                const ofP,
     glyphCommand.verb = CMD_DRAWLINE;
     glyphCommand.x = glyphData[0];
     glyphCommand.y = glyphData[1];
-    
+
     writeGlyphCommand(ofP, glyphCommand);
 }
-            
+
 
 
 static void
@@ -616,7 +616,7 @@ writeGlyphHeader(FILE *                  const ofP,
     fputc(glyphHeader.commandCount, ofP);
     fputc(glyphHeader.skipBefore, ofP);
     fputc(glyphHeader.skipAfter, ofP);
-}    
+}
 
 
 
@@ -638,7 +638,7 @@ writeBuiltinCharacter(FILE *       const ofP,
     commandNum = 0;
 
     while (commandNum < glyphHeader.commandCount) {
-            
+
         if (commandNum == 0) {
             writeMovePen(ofP, &glyphData[3 + commandNum * 2]);
             commandNum += 1;
@@ -700,6 +700,6 @@ main(int argc, char **argv) {
     ppm_init(&argc, argv);
 
     writeBuiltinFont(stdout);
-    
+
     return 0;
 }
diff --git a/other/ppmsvgalib.c b/other/ppmsvgalib.c
index c5700992..97cef286 100644
--- a/other/ppmsvgalib.c
+++ b/other/ppmsvgalib.c
@@ -6,7 +6,7 @@
    By Bryan Henderson, San Jose CA 2002.01.06.
 
    Contributed to the public domain.
-   
+
 ******************************************************************************/
 
 #define _XOPEN_SOURCE    /* Make sure modern signal stuff is in signal.h */
@@ -37,7 +37,7 @@ parseCommandLine (int argc, char ** argv,
                   struct cmdlineInfo *cmdlineP) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -83,10 +83,10 @@ parseCommandLine (int argc, char ** argv,
 
 
 static void
-displayImage(FILE * const ifP, 
-             int    const cols, 
+displayImage(FILE * const ifP,
+             int    const cols,
              int    const rows,
-             pixval const maxval, 
+             pixval const maxval,
              int    const format,
              int    const originCol,
              int    const originRow) {
@@ -107,7 +107,7 @@ displayImage(FILE * const ifP,
 
     pixelrow = ppm_allocrow(cols);
 
-    /* Implementation note:  It might be faster to use 
+    /* Implementation note:  It might be faster to use
        vga_drawscansegment() instead of vga_drawpixel()
     */
 
@@ -143,13 +143,13 @@ sigintHandler(int const signal) {
 
 
 
-static void 
+static void
 waitforSigint(void) {
 
     struct sigaction oldsigaction;
     struct sigaction newsigaction;
     int rc;
-    
+
     newsigaction.sa_handler = &sigintHandler;
     sigemptyset(&newsigaction.sa_mask);
     newsigaction.sa_flags = 0;
@@ -166,19 +166,19 @@ waitforSigint(void) {
 
 
 static void
-display(FILE * const ifP, 
-        int    const cols, 
-        int    const rows, 
-        pixval const maxval, 
-        int    const format, 
-        int    const videoMode, 
+display(FILE * const ifP,
+        int    const cols,
+        int    const rows,
+        pixval const maxval,
+        int    const format,
+        int    const videoMode,
         bool   const verbose) {
 
     int xmax, ymax;
     vga_modeinfo *modeinfo;
 
     modeinfo = vga_getmodeinfo(videoMode);
-    
+
     if (verbose) {
         pm_message("Screen Width: %d  Height: %d  Colors: %d",
                    modeinfo->width,
@@ -193,18 +193,18 @@ display(FILE * const ifP,
     if (modeinfo->colors <= 256)
         pm_error("This video mode has %d or fewer colors, which means "
                  "it is colormapped (aka paletted, aka pseudocolor).  "
-                 "This program cannot drive colormapped modes.", 
+                 "This program cannot drive colormapped modes.",
                  modeinfo->colors);
 
     if (cols > modeinfo->width)
         pm_error("Image is too wide (%d columns) for screen (%d columns).  "
-                 "Use Pamcut to select part to display.", 
+                 "Use Pamcut to select part to display.",
                  cols, modeinfo->width);
     if (rows > modeinfo->height)
         pm_error("Image is too tall (%d rows) for screen (%d rows).  "
                  "Use Pamcut to select part to display.",
                  rows, modeinfo->height);
-    
+
     /* The program must not terminate after we set the video mode and before
        we reset it to text mode.  Note that vga_setmode() sets up handlers
        for signals such as SIGINT that attempt to restore modes and then exit
@@ -241,7 +241,7 @@ display(FILE * const ifP,
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
 
     FILE * ifP;
@@ -261,7 +261,7 @@ main(int argc, char *argv[]) {
 
     {
         enum pm_check_code checkResult;
-        ppm_check(ifP, PM_CHECK_BASIC, format, cols, rows, maxval, 
+        ppm_check(ifP, PM_CHECK_BASIC, format, cols, rows, maxval,
                   &checkResult);
     }
 
@@ -274,7 +274,7 @@ main(int argc, char *argv[]) {
         pm_error("Svgalib unable to allocate a virtual console.");
 
     if (vga_hasmode(cmdline.mode))
-        display(ifP, cols, rows, maxval, format, 
+        display(ifP, cols, rows, maxval, format,
                 cmdline.mode, cmdline.verbose);
     else {
         pm_error("Svgalib video mode #%d not available.  Either the "
diff --git a/test/Test-Order b/test/Test-Order
index 16eeaf8e..05742ac0 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -27,6 +27,8 @@ pamcrater.test
 ppmpat.test
 ppmforge-parameters.test
 
+pamstereogram.test
+
 # Generators with random components
 
 pbmnoise1.test
@@ -37,6 +39,7 @@ pgmnoise-parameters.test
 ppmpat-random.test
 ppmforge.test
 ppmrough.test
+ppmrough-parameters.test
 
 # Analyzer tests
 
@@ -134,6 +137,10 @@ pnmcrop-blank.test
 ppmmix.test
 pammixmulti-identity.test
 
+pamaddnoise-parameters.test
+
+pamstack.test
+
 # Symmetry test
 
 symmetry.test
@@ -158,14 +165,18 @@ pbm-misc-converters.test
 # Format converter tests
 
 pamtopdbimg.test
+pamtosvg.test
 pbmtog3.test
 ppmtoapplevol.test
+ppmtomitsu.test
 411toppm.test
 eyuvtoppm.test
 rawtoppm.test
 
 gif-transparent1.test
 
+pnmtojpeg-scans.test
+
 # Miscellaneous utility tests
 
 ppmdfont.test
@@ -255,6 +266,7 @@ xbm-roundtrip.test
 xpm-roundtrip.test
 xv-roundtrip.test
 xwd-roundtrip.test
+ybm-roundtrip.test
 
 # Round-trip tests : lossy converters
 
diff --git a/test/cis-roundtrip.ok b/test/cis-roundtrip.ok
index 1bb50cb7..8cac8da6 100644
--- a/test/cis-roundtrip.ok
+++ b/test/cis-roundtrip.ok
@@ -1,5 +1,8 @@
 Test 1. Should print 2631579683 1546 twice
 2631579683 1546
 2631579683 1546
-Test 2. Should print 281226646 481, cksum of maze.pbm
+Test 2. Should print 281226646 481, cksum of maze.pbm four times
+281226646 481
+281226646 481
+281226646 481
 281226646 481
diff --git a/test/cis-roundtrip.test b/test/cis-roundtrip.test
index ad34173e..3316868c 100755
--- a/test/cis-roundtrip.test
+++ b/test/cis-roundtrip.test
@@ -1,6 +1,6 @@
 #! /bin/sh
 # This script tests: pbmtocis cistopbm
-# Also requires: pbmmake pamcut pamfile
+# Also requires: pbmmake pamcut pamfile pnmcrop
 
 tmpdir=${tmpdir:-/tmp}
 test_pbm=${tmpdir}/test.pbm
@@ -13,8 +13,11 @@ echo "Test 1. Should print 2631579683 1546 twice"
 pbmmake -g 128 96 | tee ${test_pbm} | cksum
 pbmtocis ${test_pbm} | cistopbm | cksum
 
-echo "Test 2. Should print 281226646 481, cksum of maze.pbm"
-size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}')
-pbmtocis maze.pbm | cistopbm | pamcut -left=0 -top=0 ${size} | cksum
+rm ${test_pbm}
 
-rm ${test_pbm}
\ No newline at end of file
+echo "Test 2. Should print 281226646 481, cksum of maze.pbm four times"
+size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}')
+pbmtocis    maze.pbm | cistopbm    | pamcut -left=0 -top=0 ${size} | cksum
+pbmtocis -i maze.pbm | cistopbm -i | pamcut -left=0 -top=0 ${size} | cksum
+pbmtocis    maze.pbm | cistopbm    | pnmcrop -black -right -bottom | cksum
+pbmtocis -w maze.pbm | cistopbm    | pnmcrop -white -right -bottom | cksum
diff --git a/test/pamaddnoise-parameters.ok b/test/pamaddnoise-parameters.ok
new file mode 100644
index 00000000..e86632cf
--- /dev/null
+++ b/test/pamaddnoise-parameters.ok
@@ -0,0 +1,62 @@
+Test Invalid
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
+Expected failure 15 (no output)
+Expected failure 16 (no output)
+Expected failure 17 (no output)
+Expected failure 18 (no output)
+Expected failure 19 (no output)
+Expected failure 20 (no output)
+Expected failure 21 (no output)
+Expected failure 22 (no output)
+Expected failure 23 (no output)
+Expected failure 24 (no output)
+Expected failure 25 (no output)
+Expected failure 26 (no output)
+Expected failure 27 (no output)
+Expected failure 28 (no output)
+Expected failure 29 (no output)
+Expected failure 30 (no output)
+Expected failure 31 (no output)
+Expected failure 32 (no output)
+Expected failure 33 (no output)
+Expected failure 34 (no output)
+Expected failure 35 (no output)
+Expected failure 36 (no output)
+Expected failure 37 (no output)
+Expected failure 38 (no output)
+Expected failure 39 (no output)
+Expected failure 40 (no output)
+Expected failure 41 (no output)
+Expected failure 42 (no output)
+Expected failure 43 (no output)
+Expected failure 44 (no output)
+Expected failure 45 (no output)
+Expected failure 46 (no output)
+Expected failure 47 (no output)
+Expected failure 48 (no output)
+Expected failure 49 (no output)
+Expected failure 50 (no output)
+Expected failure 51 (no output)
+Expected failure 52 (no output)
+Expected failure 53 (no output)
+Expected failure 54 (no output)
+Expected failure 55 (no output)
+Expected failure 56 (no output)
+Expected failure 57 (no output)
+Expected failure 58 (no output)
+Expected failure 59 (no output)
+Expected failure 60 (no output)
+Expected failure 61 (no output)
diff --git a/test/pamaddnoise-parameters.test b/test/pamaddnoise-parameters.test
new file mode 100755
index 00000000..098d4946
--- /dev/null
+++ b/test/pamaddnoise-parameters.test
@@ -0,0 +1,337 @@
+#! /bin/sh
+# This script tests: pamaddnoise
+# Also requires:
+
+tmpdir=${tmpdir:-/tmp}
+test_out=/${tmpdir}/test.out
+
+# Test Invalid
+echo "Test Invalid"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+# type gaussian implied
+
+pamaddnoise -sigma1=-4.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -sigma2=-20.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -mgsigma=0.5 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -lsigma=10.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -tolerance=0.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -salt=0.50 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -lambda=12.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+# type gaussian explicitly stated
+
+pamaddnoise -type gaussian -sigma1=-0.01 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -sigma2=-0.01 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -mgsigma=0.5 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -lsigma=10.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -tolerance=0.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -salt=0.50 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -lambda=12.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+# type multiplicative gaussian
+
+pamaddnoise -type multiplicative_gaussian -sigma1=4.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 15 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+  
+pamaddnoise -type multiplicative_gaussian -sigma2=20.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 16 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type multiplicative_gaussian -mgsigma=-0.5 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 17 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type multiplicative_gaussian -lsigma=10.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 18 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type multiplicative_gaussian -tolerance=0.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 19 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type multiplicative_gaussian -salt=0.50 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 20 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type multiplicative_gaussian -lambda=12.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 21 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+# type laplacian
+
+pamaddnoise -type laplacian -sigma1=4.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 22 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type laplacian -sigma2=20.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 23 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type laplacian -mgsigma=0.5 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 24 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type laplacian -lsigma=-10.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 25 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type laplacian -tolerance=0.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 26 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type laplacian -salt=0.50 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 27 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type laplacian -lambda=12.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 28 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+ 
+
+# type impulse
+
+pamaddnoise -type impulse -sigma1=4.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 29 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -sigma2=20.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 30 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -mgsigma=0.5 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 31 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -lsigma=10.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 32 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -tolerance=-0.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 33 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -tolerance=1.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 34 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -salt=-0.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 35 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -salt=+1.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 36 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impulse -lambda=12.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 37 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+# type poisson
+
+pamaddnoise -type poisson -sigma1=4.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 38 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type poisson -sigma2=20.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 39 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type poisson -mgsigma=0.5 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 40 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type poisson -lsigma=10.0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 41 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type poisson -tolerance=0.10 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 42 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type poisson -salt=0.50 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 43 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type poisson -lambda=0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 44 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+# Missing or invalid numerical parameters
+
+pamaddnoise -sigma1 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 45 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -sigma1 Z testgrid.pbm > ${test_out} || \
+  printf "Expected failure 46 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -sigma2 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 47 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type gaussian -sigma2 sigma testgrid.pbm > ${test_out} || \
+  printf "Expected failure 48 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type mult -mgsigma testgrid.pbm > ${test_out} || \
+  printf "Expected failure 49 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type mult -mgsigma 10,0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 50 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type lapl -lsigma 1..0 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 51 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type lapl -lsigma lsigma testgrid.pbm > ${test_out} || \
+  printf "Expected failure 52 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impul -tolerance testgrid.pbm > ${test_out} || \
+  printf "Expected failure 53 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impul -tolerance t testgrid.pbm > ${test_out} || \
+  printf "Expected failure 54 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impul -salt testgrid.pbm > ${test_out} || \
+  printf "Expected failure 55 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type impul -salt pepper testgrid.pbm > ${test_out} || \
+  printf "Expected failure 56 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type pois -lambda testgrid.pbm > ${test_out} || \
+  printf "Expected failure 57 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -type pois -lambda L testgrid.pbm > ${test_out} || \
+  printf "Expected failure 58 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -seed -1 testgrid.pbm > ${test_out} || \
+  printf "Expected failure 59 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamaddnoise -seed random testgrid.pbm > ${test_out} || \
+  printf "Expected failure 60 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+  
+# no type specified
+
+pamaddnoise -type testgrid.pbm > ${test_out} || \
+  printf "Expected failure 61 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
diff --git a/test/pamarith.ok b/test/pamarith.ok
index c2d34dea..a0942fb8 100644
--- a/test/pamarith.ok
+++ b/test/pamarith.ok
@@ -233,45 +233,45 @@ Prints 2247801875 481 three times, then 320101399 59 three times
 -xor
 320101399 59
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
-Expected failure 13 1
-Expected failure 14 1
-Expected failure 15 1
-Expected failure 16 1
-Expected failure 17 1
-Expected failure 18 1
-Expected failure 19 1
-Expected failure 20 1
-Expected failure 21 1
-Expected failure 22 1
-Expected failure 23 1
-Expected failure 24 1
-Expected failure 25 1
-Expected failure 26 1
-Expected failure 27 1
-Expected failure 28 1
-Expected failure 29 1
-Expected failure 30 1
-Expected failure 31 1
-Expected failure 32 1
-Expected failure 33 1
-Expected failure 34 1
-Expected failure 35 1
-Expected failure 36 1
-Expected failure 37 1
-Expected failure 38 1
-Expected failure 39 1
-Expected failure 40 1
-Expected failure 41 1
-Expected failure 42 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
+Expected failure 15 (no output)
+Expected failure 16 (no output)
+Expected failure 17 (no output)
+Expected failure 18 (no output)
+Expected failure 19 (no output)
+Expected failure 20 (no output)
+Expected failure 21 (no output)
+Expected failure 22 (no output)
+Expected failure 23 (no output)
+Expected failure 24 (no output)
+Expected failure 25 (no output)
+Expected failure 26 (no output)
+Expected failure 27 (no output)
+Expected failure 28 (no output)
+Expected failure 29 (no output)
+Expected failure 30 (no output)
+Expected failure 31 (no output)
+Expected failure 32 (no output)
+Expected failure 33 (no output)
+Expected failure 34 (no output)
+Expected failure 35 (no output)
+Expected failure 36 (no output)
+Expected failure 37 (no output)
+Expected failure 38 (no output)
+Expected failure 39 (no output)
+Expected failure 40 (no output)
+Expected failure 41 (no output)
+Expected failure 42 (no output)
diff --git a/test/pamarith.test b/test/pamarith.test
index 061f9488..03ce7317 100755
--- a/test/pamarith.test
+++ b/test/pamarith.test
@@ -127,130 +127,130 @@ test_out=${tmpdir}/test_out
 # multiple functions
 
 pamarith -add -subtract testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -multiply -divide testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -difference -minimum testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -maximum -mean testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -compare -and testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -compare -equal testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -or -nand testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -nor -xor testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # -add does not take a value
 
 pamarith -add=1 testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 10"
- test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # No function
 
 pamarith -plain testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Just one input image file
 
 pamarith -add testimg.ppm > ${test_out} || \
-  printf "Expected failure 13"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # No input image file
 
 pamarith -add > ${test_out} || \
-  printf "Expected failure 14"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Input images with different depth (number of planes)
 
 pamchannel -infile testimg.ppm 0 1 | \
   pamarith -add testimg.ppm - > ${test_out} || \
-  printf "Expected failure 15"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 15 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Input images with different x/y dimensions
 
 pamarith -add testimg.ppm testgrid.pbm > ${test_out} || \
-  printf "Expected failure 16"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 16 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamenlarge -xscale=2 testgrid.pbm | \
   pamarith -add testgrid.pbm - > ${test_out} || \
-  printf "Expected failure 17"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 17 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamenlarge -yscale=3 testgrid.pbm | \
   pamarith -add testgrid.pbm - > ${test_out} || \
-  printf "Expected failure 18"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 18 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Invalid usage of -closeness
 
 pamarith -equal -closeness=100.1 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 19"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 19 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -equal -closeness=-10 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 20"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 20 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -closeness -equal testgrid.pbm > ${test_out} || \
-  printf "Expected failure 21"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 21 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -compare -closeness=10 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 22"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 22 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Bit string functions
@@ -267,65 +267,65 @@ pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm}
 # Bit string functions - Maxval must match
 
 pamarith -and ${input3_pgm} ${input5_pgm} > ${test_out} || \
-  printf "Expected failure 23"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 23 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -or ${input3_pgm} ${input5_pgm} > ${test_out} || \
-  printf "Expected failure 24"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 24 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -nand ${input3_pgm} ${input5_pgm} > ${test_out} || \
-  printf "Expected failure 25"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 25 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -nor ${input3_pgm} ${input5_pgm} > ${test_out} || \
-  printf "Expected failure 26"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 26 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -xor ${input3_pgm} ${input5_pgm} > ${test_out} || \
-  printf "Expected failure 27"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 27 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Bit string functions - Maxval must be 2^n -1
 
 pamarith -and ${input4_pgm} ${input4_pgm} > ${test_out} || \
-  printf "Expected failure 28"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 28 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -or ${input4_pgm} ${input4_pgm} > ${test_out} || \
-  printf "Expected failure 29"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 29 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -nand ${input4_pgm} ${input4_pgm} > ${test_out} || \
-  printf "Expected failure 30"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 30 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -nor ${input4_pgm} ${input4_pgm} > ${test_out} || \
-  printf "Expected failure 31"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 31 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -xor ${input4_pgm} ${input4_pgm} > ${test_out} || \
-  printf "Expected failure 32"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 32 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${test_out} || \
-  printf "Expected failure 33"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 33 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${test_out} || \
-  printf "Expected failure 34"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 34 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
@@ -335,44 +335,44 @@ rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
 # three or more inputs.
 
 pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 35"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 35 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 36"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 36 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 37"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 37 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 38"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 38 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 39"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 39 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
-  printf "Expected failure 40"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 40 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Currently -equal and -mean do not allow more than two input images.
 # These two cases should be removed once improvements are made.
 
 pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \
-  printf "Expected failure 41"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 41 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamarith -mean testgrid.pbm  testgrid.pbm testgrid.pbm > ${test_out} || \
-  printf "Expected failure 42"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 42 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamcat1.ok b/test/pamcat1.ok
index 4e23666f..630b635f 100644
--- a/test/pamcat1.ok
+++ b/test/pamcat1.ok
@@ -134,17 +134,17 @@ Test 12.  Should print 2773166369 245, 0 nine times, 1 once
 0
 1
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
-Expected failure 13 1
-Expected failure 14 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
diff --git a/test/pamcat1.test b/test/pamcat1.test
index 67d941cc..902ef6d7 100755
--- a/test/pamcat1.test
+++ b/test/pamcat1.test
@@ -196,76 +196,76 @@ echo "-----------------------------------------------------------" 1>&2
 
 # direction not specified
 pamcat testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # both directions specified
 pamcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # both pad colors specified
 pamcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # justification parameters overspecified
 pamcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # justification parameter in the wrong direction
 pamcat -lr -jleft    testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -lr -jright   testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -tb -jtop     testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcat -tb -jbottom  testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 13"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # more than one input image from standard input
 cat testgrid.pbm | pamcat -lr - - testimg.ppm > ${test_out} || \
-  printf "Expected failure 14"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamcat3.ok b/test/pamcat3.ok
index 5dbb2cbc..768f6f1e 100644
--- a/test/pamcat3.ok
+++ b/test/pamcat3.ok
@@ -8,12 +8,12 @@ Test 2.   Should print 1331083756 152559 three times
 1331083756 152559
 1331083756 152559
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
diff --git a/test/pamcat3.test b/test/pamcat3.test
index 3aed0131..fb89c3f6 100755
--- a/test/pamcat3.test
+++ b/test/pamcat3.test
@@ -36,59 +36,59 @@ echo "-----------------------------------------------------------" 1>&2
 
 # listfile not specified
 pamcat -lr -listfile > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # listfile does not exist
 pamcat -lr -listfile=`mktemp -u` > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # listfile empty
 pamcat -lr -listfile=/dev/null > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # listfile from stdin, empty
 cat /dev/null | pamcat -lr -listfile=- > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Files provided from command line in addition to listfile
 pamcat -lr -listfile=${list} testgrid.pbm testgrid.pbm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # "-" (stdin) provided from command line in addition to listfile
 pamcat -lr -listfile=${list} - > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # listfile has nothing but blank lines
 sed 's/^.*$//' ${list3} > ${liste1}  
 pamcat -lr -listfile=${liste1} > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out} ${liste1}
 
 # Non-existing file in listfile
 ( cat ${list} ; mktemp -u ) > ${liste2}
 pamcat -lr -listfile=${liste2} > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out} ${liste2}
 
 # Multiple instances of "-" in listfile
 ( echo "-"; cat ${list}; echo "-"; echo "-" ) > ${liste3}
 pamcat -lr -listfile=${liste3} > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out} ${liste3}
 
 
diff --git a/test/pamchannel.ok b/test/pamchannel.ok
index 91629202..72b84354 100644
--- a/test/pamchannel.ok
+++ b/test/pamchannel.ok
@@ -7,6 +7,6 @@ Test 3:blue-channel  Should produce 3164158573 33838
 Test 4:single-channel  Should produce 281226646 481
 281226646 481
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pamchannel.test b/test/pamchannel.test
index f2662706..2f772bf9 100755
--- a/test/pamchannel.test
+++ b/test/pamchannel.test
@@ -42,17 +42,16 @@ test_out=${tmpdir}/test_out
 echo "Test Invalid"
 
 pamchannel  -infile testgrid.pbm 1 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamchannel  -infile testimg.ppm 3 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamtopam testimg.ppm | pamchannel -infile=- 4 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
-
diff --git a/test/pamcrater.ok b/test/pamcrater.ok
index a5571f35..53faebf2 100644
--- a/test/pamcrater.ok
+++ b/test/pamcrater.ok
@@ -7,7 +7,7 @@ Test 2.
 2
 2
 Test Invalid.
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pamcrater.test b/test/pamcrater.test
index e0c98afb..1b4ffd54 100755
--- a/test/pamcrater.test
+++ b/test/pamcrater.test
@@ -64,21 +64,21 @@ echo "Error messages should appear below the line." 1>&2
 echo "------------------------------" 1>&2
 
 pamcrater -width 0 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcrater -height 0 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcrater -number 0 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcrater -test -radius=10 | pamshadedrelief -gamma 0 > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamcut.ok b/test/pamcut.ok
index fc4dc3de..60919865 100644
--- a/test/pamcut.ok
+++ b/test/pamcut.ok
@@ -19,18 +19,18 @@ Test 5. Should print 281226646 481 five times
 Test 6.  Should print 3412257956 129
 3412257956 129
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 6 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
-Expected failure 13 1
-Expected failure 14 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 6 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
diff --git a/test/pamcut.test b/test/pamcut.test
index a489635a..7cda5bce 100755
--- a/test/pamcut.test
+++ b/test/pamcut.test
@@ -56,79 +56,79 @@ echo "-----------------------------------------------------------" 1>&2
 
 # overspecification
 pamcut -left=1 -right=1 -width=14 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -top=1 -bottom=1 -height=16 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -right=1 -cropright=1 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -top=1 -croptop=1 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -bottom=1 -cropbottom=1 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -left=1 -cropleft=1 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # excessive cropping
 pamcut -cropleft=7 -cropright=8 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -left=7 -right=6 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -croptop=8 -cropbottom=8 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -top=10 -bottom=9 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # pad absent
 pamcut -cropleft=1 -width=14 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut -croptop=1  -height=16 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # legacy style: insufficient number of positional parameters
 pamcut 5 testimg.ppm > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut 5 4 testimg.ppm > ${test_out} || \
-  printf "Expected failure 13"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamcut 5 5 30 testimg.ppm > ${test_out} || \
-  printf "Expected failure 14"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamdepth.ok b/test/pamdepth.ok
index 1bd897ac..fefcc14f 100644
--- a/test/pamdepth.ok
+++ b/test/pamdepth.ok
@@ -10,5 +10,5 @@ stdin: PAM RAW 14 16 1 1 GRAYSCALE
 Test 2
 0 0 : 0
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
diff --git a/test/pamdepth.test b/test/pamdepth.test
index 7ff73f41..d97992a1 100755
--- a/test/pamdepth.test
+++ b/test/pamdepth.test
@@ -30,11 +30,11 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pamdepth 0 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamdepth 65536 testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamditherbw-random.ok b/test/pamditherbw-random.ok
index d21e3613..d21e3613 100755..100644
--- a/test/pamditherbw-random.ok
+++ b/test/pamditherbw-random.ok
diff --git a/test/pamditherbw.ok b/test/pamditherbw.ok
index 02200d0f..da3f6e8b 100644
--- a/test/pamditherbw.ok
+++ b/test/pamditherbw.ok
@@ -14,15 +14,15 @@ Test: Cluster-4
 Test: Cluster-8
 3493215477 33894
 Test: Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
diff --git a/test/pamditherbw.test b/test/pamditherbw.test
index be560089..ea3e803f 100755
--- a/test/pamditherbw.test
+++ b/test/pamditherbw.test
@@ -47,63 +47,63 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pamditherbw -fs -atkinson       ${test_red} > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -floyd -atkinson    ${test_red} > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -dither8  -cluster3 ${test_red} > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -cluster3 -cluster4 ${test_red} > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -cluster3 -cluster8 ${test_red} > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -cluster4 -cluster8 ${test_red} > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -hilbert -threshold ${test_red} > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -clump=8            ${test_red} > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -fs -clump=8        ${test_red} > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -hilbert -clump=1   ${test_red} > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -th -value=-1       ${test_red} > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamditherbw -th -value=1.1      ${test_red} > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${test_red}
diff --git a/test/pamfile.ok b/test/pamfile.ok
index e222592c..91beec60 100644
--- a/test/pamfile.ok
+++ b/test/pamfile.ok
@@ -14,6 +14,6 @@ Test 3
 testimg.ppm: PPM RAW 227 149 3 255 RGB
 stdin: PBM RAW 14 16 1 1 BLACKANDWHITE
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pamfile.test b/test/pamfile.test
index 260d0b27..7be061ef 100755
--- a/test/pamfile.test
+++ b/test/pamfile.test
@@ -31,16 +31,16 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pamfile -size -machine  testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfile -count -machine testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 head -n1 testimg.ppm | pamfile > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamfind.ok b/test/pamfind.ok
index de53166e..7776ba37 100644
--- a/test/pamfind.ok
+++ b/test/pamfind.ok
@@ -258,7 +258,7 @@ Test 3
 okay
 okay
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pamfind.test b/test/pamfind.test
index 9165fbdf..e7c9707f 100755
--- a/test/pamfind.test
+++ b/test/pamfind.test
@@ -44,21 +44,21 @@ echo "-----------------------------------------------------------" 1>&2
 echo "Test Invalid"
 
 pamfind -color=black -target=1,1,1 testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfind -target=0,0 testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfind -target=0,0,0,0 testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfind testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamfix.ok b/test/pamfix.ok
index 7302f91e..ba1c678a 100644
--- a/test/pamfix.ok
+++ b/test/pamfix.ok
@@ -62,7 +62,7 @@ P2
 0 1 2 
 3 4 7 
 0 0 0 
-Test invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Test Invalid
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pamfix.test b/test/pamfix.test
index a18cae10..c274de86 100755
--- a/test/pamfix.test
+++ b/test/pamfix.test
@@ -44,7 +44,7 @@ printf "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0\n" |\
 
 # Test Invalid
 
-echo "Test invalid"
+echo "Test Invalid"
 
 test_out=${tmpdir}/test_out
 
@@ -54,16 +54,16 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 printf "P2\n3 2\n7\n0 1 2\n6 7 8\n" | pamfix -change -clip > ${test_out} || \
-  printf "Expected failure 1";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 printf "P1\n5 5\n" | pamfix -truncate -plain > ${test_out} || \
-  printf "Expected failure 2";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 printf "P2\n3 3\255\n" | pamfix -truncate -plain > ${test_out} || \
-  printf "Expected failure 3";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamfunc.ok b/test/pamfunc.ok
index d358355b..0010476e 100644
--- a/test/pamfunc.ok
+++ b/test/pamfunc.ok
@@ -44,27 +44,27 @@ Test 5: Should print 281226646 481 six times
 281226646 481
 281226646 481
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
-Expected failure 13 1
-Expected failure 14 1
-Expected failure 15 1
-Expected failure 16 1
-Expected failure 17 1
-Expected failure 18 1
-Expected failure 19 1
-Expected failure 20 1
-Expected failure 21 1
-Expected failure 22 1
-Expected failure 23 1
-Expected failure 24 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
+Expected failure 15 (no output)
+Expected failure 16 (no output)
+Expected failure 17 (no output)
+Expected failure 18 (no output)
+Expected failure 19 (no output)
+Expected failure 20 (no output)
+Expected failure 21 (no output)
+Expected failure 22 (no output)
+Expected failure 23 (no output)
+Expected failure 24 (no output)
diff --git a/test/pamfunc.test b/test/pamfunc.test
index fe142be7..21f69247 100755
--- a/test/pamfunc.test
+++ b/test/pamfunc.test
@@ -93,121 +93,121 @@ echo "Test Invalid"
 test_out=${tmpdir}/test_out
 
 pamfunc -multiplier testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -multiplier=-1 testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -divisor testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -divisor=-20 testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -adder testimg.ppm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -adder 0.5 testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -subtractor testimg.ppm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -subtractor 0.1 testimg.ppm > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -multiplier=1 -divisor=2 testimg.ppm > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -adder=2 -subtractor=3 testimg.ppm > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -min testimg.ppm > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -max testimg.ppm > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -andmask testimg.ppm > ${test_out} || \
-  printf "Expected failure 13"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -ormask testimg.ppm > ${test_out} || \
-  printf "Expected failure 14"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -xormask testimg.ppm > ${test_out} || \
-  printf "Expected failure 15"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 15 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -not 1 testimg.ppm > ${test_out} || \
-  printf "Expected failure 16"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 16 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -min=1 -max=2 testimg.ppm > ${test_out} || \
-  printf "Expected failure 17"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 17 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -andmask=1 -ormask=0 testimg.ppm > ${test_out} || \
-  printf "Expected failure 18"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 18 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -andmask=0xffff testimg.ppm > ${test_out} || \
-  printf "Expected failure 19"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 19 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -shiftleft testimg.ppm > ${test_out} || \
-  printf "Expected failure 20"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 20 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -shiftright testimg.ppm > ${test_out} || \
-  printf "Expected failure 21"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 21 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -changemaxval testimg.ppm > ${test_out} || \
-  printf "Expected failure 22"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 22 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -shiftleft=1 -shiftright=1 testimg.ppm > ${test_out} || \
-  printf "Expected failure 23"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 23 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamfunc -multiplier=0.5 -changemaxval=65535 testimg.ppm > ${test_out} || \
-  printf "Expected failure 24"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 24 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamgauss.ok b/test/pamgauss.ok
index e31a2ee8..cc4d1465 100644
--- a/test/pamgauss.ok
+++ b/test/pamgauss.ok
@@ -84,8 +84,8 @@ Test 2
 stdin:	PAM, 3 by 3 by 1 maxval 255
     Tuple type: GRAYSCALE
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
diff --git a/test/pamgauss.test b/test/pamgauss.test
index 9400e928..b15ccbf0 100755
--- a/test/pamgauss.test
+++ b/test/pamgauss.test
@@ -28,26 +28,26 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pamgauss 3 3               > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamgauss 3 3   -sigma=0    > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamgauss 3 3   -sigma=-1.5 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamgauss 3     -sigma=0.5  > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamgauss 3 3 3 -sigma=0.5  > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamhue.ok b/test/pamhue.ok
index 5935cc5e..4bc4c385 100644
--- a/test/pamhue.ok
+++ b/test/pamhue.ok
@@ -33,4 +33,4 @@ Test 4
 0 0 : 0
 0 0 : 0
 Test Invalid
-Expected failure 1 1
+Expected failure 1 (no output)
diff --git a/test/pamhue.test b/test/pamhue.test
index 5979e414..ca7a7d82 100755
--- a/test/pamhue.test
+++ b/test/pamhue.test
@@ -43,6 +43,6 @@ echo "An error message should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pamhue testimg.ppm  > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamrecolor.ok b/test/pamrecolor.ok
index 0a6b5413..f1bd74fb 100755..100644
--- a/test/pamrecolor.ok
+++ b/test/pamrecolor.ok
@@ -3,9 +3,9 @@ Test 1. Should produce 3500040755 101532
 Test 2. Should produce 3500040755 101532 twice
 3500040755 101532
 3500040755 101532
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
diff --git a/test/pamrecolor.test b/test/pamrecolor.test
index a5fecc1f..4d75f2cc 100755
--- a/test/pamrecolor.test
+++ b/test/pamrecolor.test
@@ -28,35 +28,35 @@ echo "-----------------------------------------------------------" 1>&2
 
 pamrecolor --targetcolor=rgb:00/11/22 \
            --colorfile=${base1_pgm} testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrecolor --rmult=0.3  --gmult=0.3  --bmult=0.3 \
            --colorfile=${base1_pgm} testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrecolor --colorspace=void \
            --targetcolor=rgb:80/80/80 testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrecolor --targetcolor=vague testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrecolor --colorfile=${truncated_file} testimg.ppm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrecolor --rmult=0.2989 --gmult=0.5866 testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${base_pgm} ${truncated_file}
diff --git a/test/pamrestack.ok b/test/pamrestack.ok
index 07552913..63f809e8 100644
--- a/test/pamrestack.ok
+++ b/test/pamrestack.ok
@@ -61,8 +61,8 @@ Test 4. Should produce 1768948962 101484 twice
 1768948962 101484
 1768948962 101484
 Test Invalid.
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
diff --git a/test/pamrestack.test b/test/pamrestack.test
index 2ebee49f..776fe91b 100755
--- a/test/pamrestack.test
+++ b/test/pamrestack.test
@@ -64,28 +64,28 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pamrestack testgrid.pbm maze.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrestack -abort \
   -width=$((pixels * 2 + 1 )) maze.pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrestack -crop \
   -width=$((pixels * 2 + 1)) maze.pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrestack -width=0 maze.pbm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamrestack -width maze.pbm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamscale-reportonly.ok b/test/pamscale-reportonly.ok
index bf5cde99..a3ece300 100644
--- a/test/pamscale-reportonly.ok
+++ b/test/pamscale-reportonly.ok
@@ -12,9 +12,9 @@ Test 1
 227 149 1.400881 2.684564 318 400
 227 149 1.000000 1.000000 227 149
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
diff --git a/test/pamscale-reportonly.test b/test/pamscale-reportonly.test
index 924fb7c2..2bf1030a 100755
--- a/test/pamscale-reportonly.test
+++ b/test/pamscale-reportonly.test
@@ -31,36 +31,36 @@ echo "-----------------------------------------------------------" 1>&2
 
 pamscale -reportonly -xsize=640 -ysize=400 -xscale=2 testimg.ppm > \
   ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamscale -reportonly -xsize=640 -xscale=2 -yscale=3 testimg.ppm > \
   ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamscale -reportonly -xsize=640 -ysize=400 -pixels=200000 testimg.ppm \
   > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamscale -reportonly -xsize=640 -ysize=400 -xysize 640 400 testimg.ppm \
   > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamscale -reportonly -xsize=640 -ysize=400 -xyfit  640 400 testimg.ppm \
   > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamscale -reportonly -xsize=640 -ysize=400 -xyfill 640 400 testimg.ppm \
   > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamseq.ok b/test/pamseq.ok
index 654596fb..a632de66 100644
--- a/test/pamseq.ok
+++ b/test/pamseq.ok
@@ -1,7 +1,7 @@
 Test 1
 3929266994 304
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pamseq.test b/test/pamseq.test
index ce3d4995..61fbfac7 100755
--- a/test/pamseq.test
+++ b/test/pamseq.test
@@ -17,18 +17,18 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pamseq 1 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamseq 0 255 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamseq 3 0   > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 c64="0123456789012345678901234567890123456789012345678901234567890123"
@@ -37,6 +37,6 @@ c256=${c64}${c64}${c64}${c64}
 # Tupletype string length=256
 
 pamseq -tupletype="${c256}" 3 15 > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamshuffle.ok b/test/pamshuffle.ok
index 4f829744..ec8c1a9c 100755..100644
--- a/test/pamshuffle.ok
+++ b/test/pamshuffle.ok
@@ -14,6 +14,6 @@ nomatch
 nomatch
 nomatch
 Test Invalid.
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pamshuffle.test b/test/pamshuffle.test
index 2941a9bc..700631cb 100755
--- a/test/pamshuffle.test
+++ b/test/pamshuffle.test
@@ -52,16 +52,16 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pamshuffle testimg.ppm testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamshuffle -randomseed -column testgrid.pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamshuffle -randomseed=null testgrid.pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamstack.ok b/test/pamstack.ok
new file mode 100644
index 00000000..881cb6c5
--- /dev/null
+++ b/test/pamstack.ok
@@ -0,0 +1,38 @@
+test 0: Should print 1652911383 4046
+1652911383 4046
+test 1: Should print 1398841785 13544 three times
+1398841785 13544
+1398841785 13544
+1398841785 13544
+test 2: Should print 210239904 3186 five times
+210239904 3186
+210239904 3186
+210239904 3186
+210239904 3186
+210239904 3186
+test 3: maxval should be 65535
+stdin:	PAM, 14 by 16 by 6 maxval 65535
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 6 maxval 65535
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 5 maxval 65535
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 2 maxval 65535
+    Tuple type: 
+test 4: maxval should be 255 then 767
+stdin:	PAM, 14 by 16 by 2 maxval 255
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 2 maxval 767
+    Tuple type: 
+test 5: Should print 2741208386 719 twice
+2741208386 719
+2741208386 719
+test 6: Should print true four times
+true
+true
+true
+true
+Test Invalid
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pamstack.test b/test/pamstack.test
new file mode 100755
index 00000000..7c375b12
--- /dev/null
+++ b/test/pamstack.test
@@ -0,0 +1,125 @@
+#! /bin/sh
+# This script tests: pamstack
+# Also requires: pamdepth pgmmake pamfile
+
+tmpdir=${tmpdir:-/tmp}
+i1_pgm=${tmpdir}/testimg_1.pnm
+i2_pgm=${tmpdir}/testimg_2.pgm
+i7_pgm=${tmpdir}/testimg_7.pgm
+i31_pgm=${tmpdir}/testimg_31.pgm
+std_pgm=${tmpdir}/testimg_255.pgm
+max_pgm=${tmpdir}/testimg_max.pgm
+
+maze2_pbm=${tmpdir}/testimg_maze2.pgm
+maze3_pbm=${tmpdir}/testimg_maze3.pgm
+
+pamdepth 1 testgrid.pbm > ${i1_pgm}
+pgmmake -maxval=2 0 14 16 > ${i2_pgm}
+pgmmake -maxval=7 0.5 14 16 > ${i7_pgm}
+pgmmake -maxval=31 0.5 14 16 > ${i31_pgm}
+pgmmake -maxval=255 0.5 14 16 > ${std_pgm}
+pgmmake -maxval=65535 0.5 14 16 > ${max_pgm}
+cat maze.pbm maze.pbm > ${maze2_pbm}
+cat maze.pbm maze.pbm maze.pbm > ${maze3_pbm}
+
+# test 0
+echo test 0: Should print 1652911383 4046
+
+# Test the integrity of the input files
+cat ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm} \
+    ${maze2_pbm} ${maze3_pbm}| cksum
+
+# test 1
+echo test 1: Should print 1398841785 13544 three times
+pamstack ${maze2_pbm} ${maze2_pbm} | cksum
+pamstack ${maze3_pbm} ${maze2_pbm} | cksum
+pamstack ${maze2_pbm} ${maze3_pbm} | cksum
+
+rm ${maze2_pbm} ${maze3_pbm}
+
+# test 2
+echo test 2: Should print 210239904 3186 five times
+pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+                      ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum
+pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+	              ${i7_pgm} ${i2_pgm} ${i1_pgm} testgrid.pbm | cksum
+
+pamstack -lcmmaxval   ${max_pgm} ${std_pgm} ${i31_pgm} \
+	              ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum
+pamstack ${i1_pgm} ${i1_pgm} |\
+  pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i2_pgm} - | cksum
+pamstack -firstmaxval ${i2_pgm} testgrid.pbm ${i1_pgm} |\
+  pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} - | cksum
+
+
+# test 3
+echo test 3: maxval should be 65535
+pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+	              ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile
+
+pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+	            ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile
+
+pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i1_pgm} | pamfile
+
+pamstack -firstmaxval ${max_pgm} ${i2_pgm} | pamfile
+
+
+# test 4
+echo test 4: maxval should be 255 then 767
+pamstack -firstmaxval ${std_pgm} ${i2_pgm} | pamfile
+pamstack -lcmmaxval ${std_pgm} ${i2_pgm} | pamfile
+
+# test 5
+echo test 5: Should print 2741208386 719 twice
+
+pamstack -lcmmaxval   ${i31_pgm} ${i1_pgm} ${i7_pgm} | cksum
+pamstack -firstmaxval ${i31_pgm} ${i1_pgm} ${i7_pgm}  | cksum
+
+# test 6
+echo test 6: Should print true four times
+
+s0=$(pamstack ${i1_pgm} | pamfile)
+s1=$(pamstack -lcmmaxval ${i1_pgm} | pamfile)
+s2=$(pamstack -firstmaxval ${i1_pgm} | pamfile)
+
+test "$s0" = "$s1" && echo "true" || echo "false"
+test "$s0" = "$s2" && echo "true" || echo "false"
+
+
+s0=$(pamstack ${std_pgm} | pamfile)
+s1=$(pamstack -lcmmaxval ${std_pgm} | pamfile)
+s2=$(pamstack -firstmaxval ${std_pgm} | pamfile)
+
+test "$s0" = "$s1" && echo "true" || echo "false"
+test "$s0" = "$s2" && echo "true" || echo "false"
+  
+
+# Test Invalid
+echo "Test Invalid"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+test_out=${tmpdir}/test_out
+
+pamstack testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamstack ${i1_pgm} ${std_pgm} > ${test_out} || \
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamstack -lcmmaxval -firstmaxval testgrid.pbm testgrid.pbm > ${test_out} || \
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+  
+rm ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm}
+
diff --git a/test/pamstereogram.ok b/test/pamstereogram.ok
new file mode 100644
index 00000000..265a4fc5
--- /dev/null
+++ b/test/pamstereogram.ok
@@ -0,0 +1,32 @@
+Test 00. Should print 729348909 237
+729348909 237
+Test 01. Should print 3308667841 293
+3308667841 293
+Test 02. Should print 3308667841 293
+3308667841 293
+Test 03. Should print 748200469 170
+748200469 170
+Test 04. Should print 1538641408 1070
+1538641408 1070
+Test 10. Should print 1266273778 293
+1266273778 293
+Test 11. Should print 55276708 1070
+55276708 1070
+Test 20. Should print 1920539795 289
+1920539795 289
+Test 21. Should print 4069109690 4068
+4069109690 4068
+Test 22. Should print 1163376052 4068
+1163376052 4068
+Test 30. Should print 2127252909 731
+2127252909 731
+Test 31. Should print 858421050 12062
+858421050 12062
+Test 40. Should print 1236679620 660
+1236679620 660
+Test 41. Should print 1022068930 5014
+1022068930 5014
+Test 51. Should print 3784833098 11071
+3784833098 11071
+Test 52. Should print 1419662425 1441
+1419662425 1441
diff --git a/test/pamstereogram.test b/test/pamstereogram.test
new file mode 100755
index 00000000..02da9724
--- /dev/null
+++ b/test/pamstereogram.test
@@ -0,0 +1,80 @@
+#! /bin/sh
+# This script tests: pamstereogram
+# Also requires: pamdepth
+
+tmpdir=${tmpdir:-/tmp}
+testgrid_pgm=${tmpdir}/testgrid.pgm
+
+# Make input file
+
+echo "Test 00. Should print 729348909 237"
+pamdepth -quiet 255 testgrid.pbm | tee ${testgrid_pgm} | cksum
+
+
+# Random pattern
+
+echo "Test 01. Should print 3308667841 293"
+pamstereogram -randomseed=1 testgrid.pbm | cksum 
+echo "Test 02. Should print 3308667841 293"
+pamstereogram -randomseed=1 -blackandwhite testgrid.pbm | cksum 
+echo "Test 03. Should print 748200469 170"
+pamseq -tupletype=GRAYSCALE 1 100 | pamstereogram -randomseed=1 | cksum 
+echo "Test 04. Should print 1538641408 1070"
+pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \
+  pamstereogram -randomseed=1 -dpi=10 | cksum
+
+# Makemask
+
+echo "Test 10. Should print 1266273778 293"
+pamstereogram -randomseed=1 -makemask testgrid.pbm | cksum 
+
+echo "Test 11. Should print 55276708 1070"
+pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \
+  pamstereogram -randomseed=1 -dpi=10 -makemask | cksum
+
+# Grayscale
+
+echo "Test 20. Should print 1920539795 289"
+pamstereogram -randomseed=1 -grayscale testgrid.pbm | cksum 
+echo "Test 21. Should print 4069109690 4068"
+pamseq 1 100 | pnmtile 200 20 | \
+  pamstereogram -randomseed=1 -dpi=10 -grayscale | \
+  cksum
+echo "Test 22. Should print 1163376052 4068"
+pamseq 1 100 | pnmtile 200 20 | \
+  pamstereogram -randomseed=1 -dpi=10 -grayscale -maxval 255 | \
+  cksum
+
+# Color
+
+echo "Test 30. Should print 2127252909 731"
+pamstereogram -randomseed=1 -color testgrid.pbm | cksum 
+echo "Test 31. Should print 858421050 12062"
+pamseq 1 100 | pnmtile 200 20 | \
+  pamstereogram -randomseed=1 -dpi=10 -color | \
+  cksum
+
+# Pattern file
+
+echo "Test 40. Should print 1236679620 660"
+pamgradient black gray50 white gray50 100 50 | \
+  pamstereogram -patfile testgrid.pbm -eyesep=.1 -crosseyed | cksum
+
+echo "Test 41. Should print 1022068930 5014"
+pamgradient black gray50 white gray50 100 50 | \
+  pamstereogram -patfile  ${testgrid_pgm} -eyesep=.1 -crosseyed | cksum
+
+# drawguides
+
+echo "Test 51. Should print 3784833098 11071"
+pamgradient black gray50 white gray50 100 50 | \
+  pamstereogram -randomseed=1 -dpi 10 -guidesize=20 -guidetop | cksum
+
+echo "Test 52. Should print 1419662425 1441"
+pamgradient black gray50 white gray50 100 50 | \
+  pamstereogram -patfile=testgrid.pbm -dpi 10 -guidesize=20 -guidetop | cksum
+
+
+# Clean up files we created
+rm  ${testgrid_pgm}
+
diff --git a/test/pamsumm.ok b/test/pamsumm.ok
index b9ce0269..5524e7b5 100644
--- a/test/pamsumm.ok
+++ b/test/pamsumm.ok
@@ -14,7 +14,7 @@ Test 3.  Should print in order: 10772432, 15, 255, 106.164760
 255
 106.164760
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pamsumm.test b/test/pamsumm.test
index f482911a..6fef5972 100755
--- a/test/pamsumm.test
+++ b/test/pamsumm.test
@@ -35,21 +35,21 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pamsumm -sum -min  testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamsumm -sum -max  testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamsumm -mean -max testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pamsumm            testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamtable.ok b/test/pamtable.ok
index d63c7720..5d69ffb7 100644
--- a/test/pamtable.ok
+++ b/test/pamtable.ok
@@ -122,5 +122,5 @@ Test 8
 65535     0     0|    0     0 65535|    0     0 65535|    0 65535     0
 
 Test Invalid
-Should print: Expected failure 1
-Expected failure 1
+Should print: Expected failure (no output)
+Expected failure (no output)
diff --git a/test/pamtable.test b/test/pamtable.test
index e948ad0c..740b2199 100755
--- a/test/pamtable.test
+++ b/test/pamtable.test
@@ -53,10 +53,10 @@ echo "Invalid command-line argument combinations." 1>&2
 echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
-echo "Should print: Expected failure 1"
+echo "Should print: Expected failure (no output)"
 
 pamseq -tupletype="void" 1 1 | pamtable -tuple -hex > \
   ${test_out} || \
-  printf "Expected failure"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pamtosvg.ok b/test/pamtosvg.ok
new file mode 100644
index 00000000..918555e0
--- /dev/null
+++ b/test/pamtosvg.ok
@@ -0,0 +1,4 @@
+Test 1.  Should print match
+match
+Test 2.  Should print match
+match
diff --git a/test/pamtosvg.test b/test/pamtosvg.test
new file mode 100755
index 00000000..332040ea
--- /dev/null
+++ b/test/pamtosvg.test
@@ -0,0 +1,45 @@
+#! /bin/sh
+# This script tests: pamtosvg
+# Also requires: ppmmake ppmdraw
+
+tmpdir=${tmpdir:-/tmp}
+testline_svg=${tmpdir}/testline.svg
+testgrid_svg=${tmpdir}/testgrid.svg
+
+cat > ${testline_svg} << EOF
+<?xml version="1.0" standalone="yes"?>
+<svg width="20" height="20">
+<path style="fill:#000000; stroke:none;" d="M0 0L0 20L20 20L20 0L0 0z"/>
+<path style="fill:#ffffff; stroke:none;" d="M5 2L15 18L16 18L5 2z"/>
+</svg>
+EOF
+
+echo "Test 1.  Should print match"
+
+ppmmake black 20 20 | ppmdraw -script="line 5 2 15 17" | pamtosvg |\
+    cmp -s ${testline_svg} - && echo "match" || echo "no match"
+rm ${testline_svg}
+
+cat > ${testgrid_svg} << EOF
+<?xml version="1.0" standalone="yes"?>
+<svg width="14" height="16">
+<path style="fill:#000000; stroke:none;" d="M0 0L0 16L14 16L14 1L13 0L0 0z"/>
+<path style="fill:#ffffff; stroke:none;" d="M1 0L2 1L1 0M3 0L4 1L3 0M5 0L6 \
+1L5 0M7 0L8 1L7 0M9 0L10 1L9 0M11 0L12 1L11 0M13 0L14 1L13 0M1 2L2 3L1 2M3 \
+2L4 3L3 2M5 2L6 3L5 2M7 2L8 3L7 2M9 2L10 3L9 2M11 2L12 3L11 2M13 2L14 3L13 \
+2M1 4L2 5L1 4M3 4L4 5L3 4M5 4L6 5L5 4M7 4L8 5L7 4M9 4L10 5L9 4M11 4L12 5L11 \
+4M13 4L14 5L13 4M1 6L2 7L1 6M3 6L4 7L3 6M5 6L6 7L5 6M7 6L8 7L7 6M9 6L10 7L9 \
+6M11 6L12 7L11 6M13 6L14 7L13 6M1 8L2 9L1 8M3 8L4 9L3 8M5 8L6 9L5 8M7 8L8 9L7 \
+8M9 8L10 9L9 8M11 8L12 9L11 8M13 8L14 9L13 8M1 10L2 11L1 10M3 10L4 11L3 10M5 \
+10L6 11L5 10M7 10L8 11L7 10M9 10L10 11L9 10M11 10L12 11L11 10M13 10L14 11L13 \
+10M1 12L2 13L1 12M3 12L4 13L3 12M5 12L6 13L5 12M7 12L8 13L7 12M9 12L10 13L9 \
+12M11 12L12 13L11 12M13 12L14 13L13 12M1 14L2 15L1 14M3 14L4 15L3 14M5 14L6 \
+15L5 14M7 14L8 15L7 14M9 14L10 15L9 14M11 14L12 15L11 14M13 14L14 15L13 14z"/>
+</svg>
+EOF
+
+echo "Test 2.  Should print match"
+
+pamtosvg testgrid.pbm | tee /tmp/a2 |\
+    cmp -s ${testgrid_svg} - && echo "match" || echo "no match"
+rm ${testgrid_svg}
diff --git a/test/pamundice.ok b/test/pamundice.ok
index 1234431d..9c869609 100644
--- a/test/pamundice.ok
+++ b/test/pamundice.ok
@@ -13,15 +13,15 @@ Test 4.  Should print 2434390296 4436 four times
 2434390296 4436
 2434390296 4436
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
diff --git a/test/pamundice.test b/test/pamundice.test
index ba532c30..1190fbdc 100755
--- a/test/pamundice.test
+++ b/test/pamundice.test
@@ -123,64 +123,64 @@ echo "-----------------------------------------------------------" 1>&2
 
 # No input file pattern specified
 pamundice -down=5 -across=2 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # -down=0
 pamundice -down=0 -across=2 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # -across=0
 pamundice -down=5 -across=0 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # -down too large
 pamundice -down=6 -across=2 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # -across too large
 pamundice -down=5 -across=3 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # precision does not match
 pamundice -down=5 -across=2 ${fname_stem}_"%2d"_"%2a".pbm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # precision set to zero
 pamundice -down=5 -across=2 ${fname_stem}_"%0d"_"%0a".pbm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # no precision
 pamundice -down=5 -across=2 ${fname_stem}_"%d"_"%a".pbm > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # -hoverlap too large
 pamundice -down=5 -across=2 -hoverlap=$((${mw}+1)) \
   ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # -voverlap too large
 pamundice -down=5 -across=2 -voverlap=$((${mh}+1)) \
   ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # corrupt listfile : file names do not exist
@@ -188,15 +188,15 @@ for i in 0 1 2 3 4 5 6 7 8 9
   do
   mktemp -u XXXXXXXXXX.${i} || echo ":::::::::::"${i}":::::::::::"
   done | pamundice -down=5 -across=2 -listfile=- > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # listfile with insufficient lines (insufficient file entries)
 ls ${fname_stem}_*_*.pbm | head -n 9 | \
   pamundice -down=5 -across=2 -listfile=- > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${fname_stem}*.pbm
diff --git a/test/pbmclean.ok b/test/pbmclean.ok
index 17ee0338..5fc9a2d5 100644
--- a/test/pbmclean.ok
+++ b/test/pbmclean.ok
@@ -85,4 +85,4 @@ Test 3
 436062787 5051
 4188415575 5051
 Test Invalid
-Expected failure 1 1
+Expected failure 1 (no output)
diff --git a/test/pbmclean.test b/test/pbmclean.test
index 5eba68e0..9d59a5a6 100755
--- a/test/pbmclean.test
+++ b/test/pbmclean.test
@@ -46,8 +46,8 @@ echo "-----------------------------------------------------------" 1>&2
 
 # overspecification
 pbmclean -black -white -min=1 -extended testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # note that without -extended the above is valid.
diff --git a/test/pbmlife.ok b/test/pbmlife.ok
index bd214dfb..bd214dfb 100755..100644
--- a/test/pbmlife.ok
+++ b/test/pbmlife.ok
diff --git a/test/pbmmake.ok b/test/pbmmake.ok
index e39f4cf8..4b13cf54 100644
--- a/test/pbmmake.ok
+++ b/test/pbmmake.ok
@@ -44,11 +44,11 @@ Test 2
 3651864954 3375
 3302595397 3849
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
diff --git a/test/pbmmake.test b/test/pbmmake.test
index 1d1c682b..52765747 100755
--- a/test/pbmmake.test
+++ b/test/pbmmake.test
@@ -33,41 +33,41 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pbmmake -b -w -plain 1 1 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmmake -b -g -plain 1 1 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmmake -white -gray -plain 1 1 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmmake -white -plain   > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmmake -white -plain 1 > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmmake -white -plain 1 0 > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmmake -white -plain 0 1 > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmmake -white -plain 1 1 1 > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pbmnoise-parameters.ok b/test/pbmnoise-parameters.ok
index c2a61c37..d430f0f1 100644
--- a/test/pbmnoise-parameters.ok
+++ b/test/pbmnoise-parameters.ok
@@ -1,26 +1,26 @@
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
-Expected failure 13 1
-Expected failure 14 1
-Expected failure 15 1
-Expected failure 16 1
-Expected failure 17 1
-Expected failure 17 1
-Expected failure 18 1
-Expected failure 19 1
-Expected failure 20 1
-Expected failure 21 1
-Expected failure 22 1
-Expected failure 23 1
-Expected failure 24 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
+Expected failure 15 (no output)
+Expected failure 16 (no output)
+Expected failure 17 (no output)
+Expected failure 17 (no output)
+Expected failure 18 (no output)
+Expected failure 19 (no output)
+Expected failure 20 (no output)
+Expected failure 21 (no output)
+Expected failure 22 (no output)
+Expected failure 23 (no output)
+Expected failure 24 (no output)
diff --git a/test/pbmnoise-parameters.test b/test/pbmnoise-parameters.test
index 17d2c76b..0d9319cc 100755
--- a/test/pbmnoise-parameters.test
+++ b/test/pbmnoise-parameters.test
@@ -13,131 +13,131 @@ test_out=${tmpdir}/test_out
 # Invalid -ratio arguments
 
 pbmnoise -ratio       100 100 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio 0     1  100 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=1.1   100 100 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
   
 pbmnoise -ratio=-1    100 100 > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=half  100 100 > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=0/1/1 100 100 > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=-1/2  100 100 > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=1/0   100 100 > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=/2    100 100 > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=4/2   100 100 > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=6/    100 100 > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=1.0/2.0 100 100 > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # denominator must be power of 2  
 pbmnoise -ratio=3/9   100 100 > ${test_out} || \
-  printf "Expected failure 13"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=a/2   100 100 > ${test_out} || \
-  printf "Expected failure 14"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 
 pbmnoise -ratio=2/a  100 100 > ${test_out} || \
-        printf "Expected failure 15"
-  test -s ${test_out}; echo " "$?
+        printf "Expected failure 15 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=1/-2  100 100 > ${test_out} || \
-        printf "Expected failure 16"
-  test -s ${test_out}; echo " "$?
+        printf "Expected failure 16 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Denominator must be 65536 or less
 pbmnoise -ratio=1/65537 100 100 > ${test_out} || \
-  printf "Expected failure 17"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 17 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -ratio=1/131072 100 100 > ${test_out} || \
-  printf "Expected failure 17"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 17 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -endian=large 100 100 > ${test_out} || \
-  printf "Expected failure 18"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 18 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -randomseed 100 100 > ${test_out} || \
-  printf "Expected failure 19"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 19 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -randomseed=-1 100 100 > ${test_out} || \
-  printf "Expected failure 20"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 20 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise -randomseed=0.1 100 100 > ${test_out} || \
-  printf "Expected failure 21"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 21 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise > ${test_out} || \
-  printf "Expected failure 22"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 22 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise 100 > ${test_out} || \
-  printf "Expected failure 23"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 23 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmnoise 100 200 300 > ${test_out} || \
-  printf "Expected failure 24"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 24 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
   
diff --git a/test/pbmpage.ok b/test/pbmpage.ok
index 8013f2f2..21731b08 100644
--- a/test/pbmpage.ok
+++ b/test/pbmpage.ok
@@ -4,6 +4,6 @@ Test 1
 2347597649 4210813
 3453559794 4349933
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pbmpage.test b/test/pbmpage.test
index 4f15452d..ee3dc25c 100755
--- a/test/pbmpage.test
+++ b/test/pbmpage.test
@@ -20,16 +20,16 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pbmpage -a3 1 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmpage 0 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmpage 4 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pbmpscale.ok b/test/pbmpscale.ok
index 9ea594d8..25552343 100644
--- a/test/pbmpscale.ok
+++ b/test/pbmpscale.ok
@@ -173,6 +173,6 @@ Test 9.  Should print 146160766 820
 Test 10. Should print 3327221668 2111
 3327221668 2111
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pbmpscale.test b/test/pbmpscale.test
index efa5bfb5..65ab6467 100755
--- a/test/pbmpscale.test
+++ b/test/pbmpscale.test
@@ -36,16 +36,16 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pbmpscale testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmpscale 0 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmpscale 2 3 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pbmtext-iso88591.test b/test/pbmtext-iso88591.test
index 6df296dd..e8dec8d2 100755
--- a/test/pbmtext-iso88591.test
+++ b/test/pbmtext-iso88591.test
@@ -3,7 +3,7 @@
 # Also requires:
 
 # This test requires an iso-8859-1 locale
-# Skip this test if it is not available
+# Skip this test if none are available
 
 LANG=C
 LC_ALL=C
@@ -12,26 +12,29 @@ export LANG LC_ALL
 tmpdir=${tmpdir:-/tmp}
 iso88591_locale_list=${tmpdir}/iso88591_locale_list
 
-
-locale_to_test="en_US.iso88591"  # Initial value
+locale_to_test="en_US.iso88591"  # Initial value; this
+# does not have to be present in
 # Edit the above value if necessary
-  
+
 # Make a list of available locales which end in "iso88591"
-locale -a | grep "\.iso88591$" > ${iso88591_locale_list}
+# If none are found, abort test
 
-# Hunt for a valid iso-8859-1 locale  
+locale -a | grep "\.iso88591$" > ${iso88591_locale_list} ||\
+    locale_to_test=""
+
+# Hunt for a valid iso-8859-1 locale
 # Submit each candidate to a trial pbmtext run until one that works is
 # encountered
 
-i=0
 until [ -z ${locale_to_test} ] || \
   echo "A" | LC_ALL=${locale_to_test} pbmtext -wchar > /dev/null
   do
-    let i=$(($i+1));
-    locale_to_test=`sed "$i"p -n  ${iso88591_locale_list}`;
+      # Read first line of file
+      locale_to_test=`head -n 1 ${iso88591_locale_list}`;
+      # then erase the line
+      sed -i 1d ${iso88591_locale_list};
   done;
 
-rm ${iso88591_locale_list};
 if [ -z  ${locale_to_test} ]
   then echo "No iso-8859-1 locale available." 1>&2
        echo "Skipping." 1>&2
@@ -42,7 +45,6 @@ fi;
 
 locale_for_test=${locale_to_test};
 
-
 # Two rows
 # Should print 2066913605 5110 twice
 echo "Test 1"
diff --git a/test/pbmtext-utf8.ok b/test/pbmtext-utf8.ok
index 84743a09..0d40adde 100644
--- a/test/pbmtext-utf8.ok
+++ b/test/pbmtext-utf8.ok
@@ -13,12 +13,12 @@ Test 5 Invalid
 9998
 989454365 52512
 9999
-Expected failure 1 1
-Expected failure 2 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
 Test 6 Invalid
-6-1: 0 1 : 1 1
-6-2: 0 1 : 1 1
-6-3: 0 1 : 1 1
-6-4: 0 1 : 1 1
-6-5: 0 1 : 1 1
-6-6: 0 1 : 1 1
+6-1: 0 1 : 1 (no output)
+6-2: 0 1 : 1 (no output)
+6-3: 0 1 : 1 (no output)
+6-4: 0 1 : 1 (no output)
+6-5: 0 1 : 1 (no output)
+6-6: 0 1 : 1 (no output)
diff --git a/test/pbmtext-utf8.test b/test/pbmtext-utf8.test
index 9203607f..a10b3d33 100755
--- a/test/pbmtext-utf8.test
+++ b/test/pbmtext-utf8.test
@@ -6,9 +6,8 @@ LANG=C
 LC_ALL=C
 export LANG LC_ALL
 
-
 # This test requires a working UTF-8 locale
-# Skip this test if it is are not available
+# Skip this test if none are available
 
 iconv /dev/null
 if [ $? -ne 0  ]
@@ -20,25 +19,29 @@ fi
 tmpdir=${tmpdir:-/tmp}
 utf_locale_list=${tmpdir}/utf_locale_list
 
-locale_to_test="en_US.utf8"  # Initial value
+locale_to_test="en_US.utf8"  # Initial value; this
+# does not have to be present in  following list
 # Edit the above value if necessary
 
 # Make a list of available locales which end in "utf8"
-locale -a | grep "\.utf8$" > ${utf_locale_list}
+# If none are found, abort test
+
+locale -a | grep "\.utf8$" > ${utf_locale_list} ||\
+    locale_to_test=""
 
 # Hunt for a valid utf8 locale
 # Submit each candidate to a trial pbmtext run until one that works is
 # encountered
 
-i=0
 until [ -z ${locale_to_test} ] || \
   echo "A" | LC_ALL=${locale_to_test} pbmtext -wchar > /dev/null
     do
-      let i=$(($i+1));
-      locale_to_test=`sed "$i"p -n  ${utf_locale_list}`;
+      # Read first line of file
+      locale_to_test=`head -n 1 ${utf_locale_list}`;
+      # then erase the line
+      sed -i 1d ${utf_locale_list};
     done;
 
-rm ${utf_locale_list};
 if [ -z  ${locale_to_test} ]
   then echo "No utf-8 locale available." 1>&2
        echo "Skipping." 1>&2
@@ -115,10 +118,10 @@ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print "" } '
 awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""}' | \
         LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar -text-dump
 
+
 # Test 5.
 # Long input text
 
-
 echo "Test 5 Invalid"
 
 long_txt=${tmpdir}/long.txt
@@ -141,15 +144,15 @@ cat ${long_txt} | wc -c | tr -d ' '
 cat ${long_txt} | \
   LC_ALL=${locale_for_test} \
   pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \
-  printf "Expected failure 1";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 cat ${long_txt} | \
   LC_ALL=${locale_for_test} \
   pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \
-  printf "Expected failure 2";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${long_txt}
@@ -169,41 +172,41 @@ echo "Test 6 Invalid"
 awk 'BEGIN { printf("%c%c",128,129);  print ""}' | \
         LC_ALL=${locale_for_test} \
         pbmtext -builtin bdf -wchar -text-dump > ${test_out}
-  printf "6-1: ${PIPESTATUS[*]} : $?"
-  test -s ${test_out}; echo " "$?
+  printf "6-1: ${PIPESTATUS[*]} : $? "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 awk 'BEGIN { printf("ABC%c%c",192, 193);  print ""}' | \
         LC_ALL=${locale_for_test} \
         pbmtext -builtin bdf -wchar -text-dump > ${test_out}
-  printf "6-2: ${PIPESTATUS[*]} : $?"
-  test -s ${test_out}; echo " "$?
+  printf "6-2: ${PIPESTATUS[*]} : $? "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 awk 'BEGIN { printf("abcde%c%c", 254, 253);  print ""}' | \
         LC_ALL=${locale_for_test} \
         pbmtext -builtin bdf -wchar -text-dump > ${test_out}
-  printf "6-3: ${PIPESTATUS[*]} : $?"
-  test -s ${test_out}; echo " "$?
+  printf "6-3: ${PIPESTATUS[*]} : $? "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 awk 'BEGIN { printf("abcdefg%c%c", 195, 15);  print ""}' | \
         LC_ALL=${locale_for_test} \
         pbmtext -builtin bdf -wchar -text-dump > ${test_out}
-  printf "6-4: ${PIPESTATUS[*]} : $?"
-  test -s ${test_out}; echo " "$?
+  printf "6-4: ${PIPESTATUS[*]} : $? "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 awk 'BEGIN { printf("123456789%c%c%c", 224, 143 ,0);  print ""}' | \
         LC_ALL=${locale_for_test} \
         pbmtext -builtin bdf -wchar -text-dump > ${test_out}
-  printf "6-5: ${PIPESTATUS[*]} : $?"
-  test -s ${test_out}; echo " "$?
+  printf "6-5: ${PIPESTATUS[*]} : $? "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 awk 'BEGIN { printf("abcdefg123ABCDEFG%c%c%c%c",247, 135, 135, 7);  print ""}' | \
         LC_ALL=${locale_for_test} \
         pbmtext -builtin bdf -wchar -text-dump > ${test_out}
-  printf "6-6: ${PIPESTATUS[*]} : $?"
-  test -s ${test_out}; echo " "$?
+  printf "6-6: ${PIPESTATUS[*]} : $? "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pbmtext.ok b/test/pbmtext.ok
index 68ed40d8..975911f2 100644
--- a/test/pbmtext.ok
+++ b/test/pbmtext.ok
@@ -20,20 +20,20 @@ Test 5
 2547645687 4564
 1174281741 5741
 Test 6 Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
 Test 7
 text length: 4999
 1854691667 52512
 1854691667 52512
 Test 8 Invalid
 text length: 5000
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pbmtext.test b/test/pbmtext.test
index 247f76c5..d4ab027e 100755
--- a/test/pbmtext.test
+++ b/test/pbmtext.test
@@ -112,43 +112,43 @@ echo "Test 6 Invalid"
 test_out=${tmpdir}/test_out
 
 pbmtext -font=testgrid.pbm foo > ${test_out} || \
-  printf "Expected failure 1";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtext -font=testimg.ppm  foo > ${test_out} || \
-  printf "Expected failure 2";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtext -builtin=void      foo > ${test_out} || \
-  printf "Expected failure 3";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtext -font=${font_pbm} -builtin=fixed foo > ${test_out}  || \
-  printf "Expected failure 4";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtext -dry-run    -text-dump  foo > ${test_out} || \
-  printf "Expected failure 5";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtext -dump-sheet -text-dump  foo > ${test_out} || \
-  printf "Expected failure 6";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtext -dry-run    -dump-sheet foo > ${test_out} || \
-  printf "Expected failure 7";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtext -wchar foo > ${test_out} || \
-  printf "Expected failure 8";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${font_pbm}
@@ -177,19 +177,19 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pbmtext -nomargins -builtin fixed `cat ${long_txt}` > ${test_out}  || \
-  printf "Expected failure 1";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 cat ${long_txt} | pbmtext -nomargins -builtin fixed > ${test_out}  || \
-  printf "Expected failure 2";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 cat ${long_txt} | \
   LC_ALL=C pbmtext -nomargins -builtin fixed -wchar > ${test_out}  || \
-  printf "Expected failure 3";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${long_txt}
diff --git a/test/pbmtextps-dump.ok b/test/pbmtextps-dump.ok
index 11a4c5fd..71b2d2a2 100644
--- a/test/pbmtextps-dump.ok
+++ b/test/pbmtextps-dump.ok
@@ -51,38 +51,38 @@ Test 2
 <303132 20 414243 2d 78797a 2e>
 1
 Test Invalid
-Expected failure 1 (-fontsize) 1
-Expected failure 2 (-fontsize 0) 1
-Expected failure 3 (-resolution) 1
-Expected failure 4 (-resolution=0) 1
-Expected failure 5 (-leftmargin) 1
-Expected failure 6 (-leftmargin -1) 1
-Expected failure 7 (-rightmargin) 1
-Expected failure 8 (-rightmargin -1) 1
-Expected failure 9 (-topmargin) 1
-Expected failure 10 (-topmargin -1) 1
-Expected failure 11 (-bottommargin) 1
-Expected failure 12 (-bottommargin -1) 1
-Expected failure 13 (-ascent) 1
-Expected failure 14 (-ascent -1) 1
-Expected failure 15 (-descent) 1
-Expected failure 16 (-descent -1) 1
-Expected failure 17 (-stroke=A) 1
-Expected failure 18 (-pad -crop) 1
-Expected failure 19 (-asciihex <a>) 1
-Expected failure 20 (-asciihex ) 1
-Expected failure 21 (-asciihex <53756c667572) 1
-Expected failure 22 (-asciihex 53756c667572>) 1
-Expected failure 23 (-asciihex <5375<6c667572>) 1
-Expected failure 24 (-asciihex <53756c>667572>) 1
-Expected failure 25 (-ascii85 <~@<6O!FD5W(~) 1
-Expected failure 26 (-ascii85 ~@<6O!FD5W(~>) 1
-Expected failure 27 (-ascii85 <~@<6O<~!FD5W(~>) 1
-Expected failure 28 (-ascii85 <~@<6O~>!FD5W(~>) 1
-Expected failure 29 (-ascii85 <~@<6O!FD5W(~~>) 1
-Expected failure 30 (-ascii85 v) 1
-Expected failure 31 (-ascii85 y) 1
-Expected failure 32 (-ascii85 1z) 1
-Expected failure 33 (-ascii85 z1z) 1
-Expected failure 34 (-ascii85 <~0123z~>) 1
-Expected failure 35 (-font="") 1
+Expected failure 1 (-fontsize) (no output)
+Expected failure 2 (-fontsize 0) (no output)
+Expected failure 3 (-resolution) (no output)
+Expected failure 4 (-resolution=0) (no output)
+Expected failure 5 (-leftmargin) (no output)
+Expected failure 6 (-leftmargin -1) (no output)
+Expected failure 7 (-rightmargin) (no output)
+Expected failure 8 (-rightmargin -1) (no output)
+Expected failure 9 (-topmargin) (no output)
+Expected failure 10 (-topmargin -1) (no output)
+Expected failure 11 (-bottommargin) (no output)
+Expected failure 12 (-bottommargin -1) (no output)
+Expected failure 13 (-ascent) (no output)
+Expected failure 14 (-ascent -1) (no output)
+Expected failure 15 (-descent) (no output)
+Expected failure 16 (-descent -1) (no output)
+Expected failure 17 (-stroke=A) (no output)
+Expected failure 18 (-pad -crop) (no output)
+Expected failure 19 (-asciihex <a>) (no output)
+Expected failure 20 (-asciihex ) (no output)
+Expected failure 21 (-asciihex <53756c667572) (no output)
+Expected failure 22 (-asciihex 53756c667572>) (no output)
+Expected failure 23 (-asciihex <5375<6c667572>) (no output)
+Expected failure 24 (-asciihex <53756c>667572>) (no output)
+Expected failure 25 (-ascii85 <~@<6O!FD5W(~) (no output)
+Expected failure 26 (-ascii85 ~@<6O!FD5W(~>) (no output)
+Expected failure 27 (-ascii85 <~@<6O<~!FD5W(~>) (no output)
+Expected failure 28 (-ascii85 <~@<6O~>!FD5W(~>) (no output)
+Expected failure 29 (-ascii85 <~@<6O!FD5W(~~>) (no output)
+Expected failure 30 (-ascii85 v) (no output)
+Expected failure 31 (-ascii85 y) (no output)
+Expected failure 32 (-ascii85 1z) (no output)
+Expected failure 33 (-ascii85 z1z) (no output)
+Expected failure 34 (-ascii85 <~0123z~>) (no output)
+Expected failure 35 (-font="") (no output)
diff --git a/test/pbmtextps-dump.test b/test/pbmtextps-dump.test
index 82856f7e..fd68667d 100755
--- a/test/pbmtextps-dump.test
+++ b/test/pbmtextps-dump.test
@@ -90,8 +90,8 @@ for error_flag in \
   "-pad -crop"
   do
     pbmtextps ${error_flag} -dump-ps ${text} >${test_out} || \
-    printf "Expected failure $n (${error_flag})";
-    test -s ${test_out}; echo " "$?
+    printf "Expected failure $n (${error_flag}) "
+    test -s ${test_out} && echo "unexpected output" || echo "(no output)"
     rm -f ${test_out}
     n=$((n + 1))
   done
@@ -105,8 +105,8 @@ for asciihex_string in \
   "<53756c>667572>"
   do
     pbmtextps -dump-ps -asciihex ${asciihex_string} >${test_out} || \
-    printf "Expected failure $n (-asciihex ${asciihex_string})";
-    test -s ${test_out}; echo " "$?
+    printf "Expected failure $n (-asciihex ${asciihex_string}) "
+    test -s ${test_out} && echo "unexpected output" || echo "(no output)"
     rm -f ${test_out}
     n=$((n + 1))
   done
@@ -124,13 +124,13 @@ for ascii85_string in \
   "<~0123z~>"
   do
     pbmtextps -dump-ps -ascii85 ${ascii85_string} >${test_out} || \
-    printf "Expected failure $n (-ascii85 ${ascii85_string})";
-    test -s ${test_out}; echo " "$?
+	printf "Expected failure $n (-ascii85 ${ascii85_string}) "
+    test -s ${test_out} && echo "unexpected output" || echo "(no output)"
     rm -f ${test_out}
     n=$((n + 1))
   done
 
   pbmtextps -font="" -dump-ps ${text} >${test_out} || \
-  printf "Expected failure $n (-font=\"\")";
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure $n (-font=\"\") "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pbmtopgm.ok b/test/pbmtopgm.ok
index 6ccf9c64..11242259 100644
--- a/test/pbmtopgm.ok
+++ b/test/pbmtopgm.ok
@@ -19,7 +19,7 @@ P2
 0 1 0 1 0 1 0 1 0 1 0 1 0 1
 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pbmtopgm.test b/test/pbmtopgm.test
index 02f2bb21..f2c5cf1f 100755
--- a/test/pbmtopgm.test
+++ b/test/pbmtopgm.test
@@ -18,21 +18,21 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pbmtopgm 5 0 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtopgm 0 9 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtopgm 15 5 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmtopgm 5 17 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pbmupc.ok b/test/pbmupc.ok
index f1b91e99..4f2fd0ae 100644
--- a/test/pbmupc.ok
+++ b/test/pbmupc.ok
@@ -1,12 +1,12 @@
 Test 1
 2619309127 10172
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
diff --git a/test/pbmupc.test b/test/pbmupc.test
index f8343dd7..74bd54d9 100755
--- a/test/pbmupc.test
+++ b/test/pbmupc.test
@@ -20,46 +20,46 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pbmupc -s3 0 72890 00011     > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1   72890 00011     > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1 0 72890           > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1 10 72890 00011    > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1 0 172890 00011    > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1 0   2890 00011    > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1 0 72890 100011    > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1 0 72890   0011    > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pbmupc -s1 0 72890 100011 1  > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pgmhist.ok b/test/pgmhist.ok
index 3be73ff9..f9184828 100644
--- a/test/pgmhist.ok
+++ b/test/pgmhist.ok
@@ -30,7 +30,7 @@ Test 2
 230
 255
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pgmhist.test b/test/pgmhist.test
index c141627d..a47ab71e 100755
--- a/test/pgmhist.test
+++ b/test/pgmhist.test
@@ -35,21 +35,21 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pgmhist -median   -quartile testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmhist -median   -decile   testgrid.pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmhist -quartile -decile   testgrid.pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmhist testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pgmmake.ok b/test/pgmmake.ok
index 8b242822..ac9b968c 100644
--- a/test/pgmmake.ok
+++ b/test/pgmmake.ok
@@ -2,11 +2,11 @@ Test 1
 3662611538 2513
 3109612402 5012
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
diff --git a/test/pgmmake.test b/test/pgmmake.test
index 3c96d99e..80997d07 100755
--- a/test/pgmmake.test
+++ b/test/pgmmake.test
@@ -19,41 +19,41 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pgmmake 100  5 5 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmmake 1.01 5 5 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmmake .5   5   > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmmake .5       > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmmake -maxval=5        5 5 > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmmake -maxval=0     .5 5 5 > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmmake -maxval=-1    .5 5 5 > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmmake -maxval=65536 .5 5 5 > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pgmnoise-parameters.ok b/test/pgmnoise-parameters.ok
index 1bb1cd59..10a05cfa 100644
--- a/test/pgmnoise-parameters.ok
+++ b/test/pgmnoise-parameters.ok
@@ -1,5 +1,5 @@
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
diff --git a/test/pgmnoise-parameters.test b/test/pgmnoise-parameters.test
index c5e6ada5..79c068d8 100755
--- a/test/pgmnoise-parameters.test
+++ b/test/pgmnoise-parameters.test
@@ -11,26 +11,26 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pgmnoise -maxval=255  -randomseed=1 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 100 -randomseed=1 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 100 0 -randomseed=1 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 0 100 -randomseed=1 > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 100 100 100 -randomseed=1 > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pgmnoise.ok b/test/pgmnoise.ok
index d98ee053..2a2db565 100644
--- a/test/pgmnoise.ok
+++ b/test/pgmnoise.ok
@@ -90,13 +90,13 @@ First column should be 2^n - 1.  Last column should be 'pool'.
 1023 pgmnoise: method: pool
 65535 pgmnoise: method: pool
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
diff --git a/test/pgmnoise.test b/test/pgmnoise.test
index 6141121a..ed41622f 100755
--- a/test/pgmnoise.test
+++ b/test/pgmnoise.test
@@ -78,51 +78,51 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pgmnoise 0 0  > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 0 1  > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 1 0  > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise      > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 1    > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise 100 -1 > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise -randomseed=-1 100 100  > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise -maxval=-1 100 100  > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise -maxval=0 100 100  > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmnoise -maxval=$((256 * 256 * 256 * 256)) 10 10 > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pgmramp.ok b/test/pgmramp.ok
index de0d9206..69e3a6e5 100644
--- a/test/pgmramp.ok
+++ b/test/pgmramp.ok
@@ -42,8 +42,8 @@ Test 2
 Test 3
 886972785 131087
 Test Invalid
-Expected failure: -lr -tb 1
-Expected failure: -lr -rectangle 1
-Expected failure: -rectangle -ellipse 1
-Expected failure: insufficient parameters 1
-Expected failure: excessive parameters 1
+Expected failure: -lr -tb (no output)
+Expected failure: -lr -rectangle (no output)
+Expected failure: -rectangle -ellipse (no output)
+Expected failure: insufficient parameters (no output)
+Expected failure: excessive parameters (no output)
diff --git a/test/pgmramp.test b/test/pgmramp.test
index b4dbb3cd..d2e34885 100755
--- a/test/pgmramp.test
+++ b/test/pgmramp.test
@@ -31,17 +31,17 @@ test_out=${tmpdir}/test_out
 
 for combination in "-lr -tb" "-lr -rectangle" "-rectangle -ellipse"
 do pgmramp $combination 10 10 > ${test_out} || \
-  printf "Expected failure: $combination"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure: $combination "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 done
 
 pgmramp -lr     1 > ${test_out} || \
-  printf "Expected failure: insufficient parameters"; \
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure: insufficient parameters "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmramp -tb 1 1 1 > ${test_out} || \
-  printf "Expected failure: excessive parameters"; \
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure: excessive parameters "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pgmtoppm.ok b/test/pgmtoppm.ok
index 2484c487..4a2114ab 100644
--- a/test/pgmtoppm.ok
+++ b/test/pgmtoppm.ok
@@ -26,14 +26,14 @@ Test 6. Should print 3083028153 685 three times
 3083028153 685
 3083028153 685
 Test 7 Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
diff --git a/test/pgmtoppm.test b/test/pgmtoppm.test
index 36f63de7..6054fc03 100755
--- a/test/pgmtoppm.test
+++ b/test/pgmtoppm.test
@@ -66,74 +66,74 @@ echo "-----------------------------------------------------------" 1>&2
 
 pgmtoppm white testimg.ppm > \
   ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm -map=/dev/null testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm black white testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm hwite testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm off-color testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm rgb-255:7/7/7 testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm -black=black -white=white white testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm -black=rgb:0/0/0 -map=${palette_ppm} testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm -white=rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pgmtoppm rgb:00/00/00-rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \
   ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 #pgmtoppm rgb-255:7/7/7 testgrid.pbm > \
 #  ${test_out} || \
-#  printf "Expected failure 12"
-#  test -s ${test_out}; echo " "$?
+#  printf "Expected failure 12 "
+#  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
 #  rm -f ${test_out}
 
 rm -f ${palette_ppm}
diff --git a/test/pnmcat.ok b/test/pnmcat.ok
index 96e2b884..9958ad62 100644
--- a/test/pnmcat.ok
+++ b/test/pnmcat.ok
@@ -82,17 +82,17 @@ Test 15.  Should print 3948141157 107742
 Test 16.  Should print 3910239002 107742
 3910239002 107742
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
-Expected failure 13 1
-Expected failure 14 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
diff --git a/test/pnmcat.test b/test/pnmcat.test
index bf40ada2..02fefd38 100755
--- a/test/pnmcat.test
+++ b/test/pnmcat.test
@@ -109,76 +109,76 @@ echo "-----------------------------------------------------------" 1>&2
 
 # direction not specified
 pnmcat testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # both directions specified
 pnmcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # both pad colors specified
 pnmcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # justification parameters overspecified
 pnmcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # justification parameter in the wrong direction
 pnmcat -lr -jleft    testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -lr -jright   testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -tb -jtop     testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcat -tb -jbottom  testgrid.pbm testimg.ppm > ${test_out} || \
-  printf "Expected failure 13"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # more than one input image from standard input
 cat testgrid.pbm | pnmcat -lr - - testimg.ppm > ${test_out} || \
-  printf "Expected failure 14"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pnmcolormap.ok b/test/pnmcolormap.ok
index 0c6f0d71..8918cf25 100644
--- a/test/pnmcolormap.ok
+++ b/test/pnmcolormap.ok
@@ -31,10 +31,10 @@ ok
 ok
 
 Test Invalid.
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
diff --git a/test/pnmcolormap.test b/test/pnmcolormap.test
index 11d47385..b34a0360 100755
--- a/test/pnmcolormap.test
+++ b/test/pnmcolormap.test
@@ -44,37 +44,37 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pnmcolormap 0 testimg.ppm   > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcolormap -1 testimg.ppm  > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcolormap 0.1 testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcolormap -center -meancolor 16 testimg.ppm    > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcolormap -center -meanpixel 16 testimg.ppm    > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcolormap -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmcolormap -spreadbrightness -spreadluminosity 16 \
   testimg.ppm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pnmcrop1.ok b/test/pnmcrop1.ok
index d979d2db..35852c8c 100644
--- a/test/pnmcrop1.ok
+++ b/test/pnmcrop1.ok
@@ -69,14 +69,14 @@ file: rose.ppm option: -white
 file: rose.ppm option: -top
 0
 Test Invalid
-Expected failure:  -reportfull -reportsize 1
-Expected failure:  -reportfull -borderfile=testgrid.pbm 1
-Expected failure:  -reportsize -borderfile=testgrid.pbm 1
-Expected failure:  -black -white 1
-Expected failure:  -black -sides 1
-Expected failure:  -white -bg-color=red 1
-Expected failure:  -white -bg-corner=topleft 1
-Expected failure:  -white -bg-corner=top 1
-Expected failure:  -blank-image=pasturize 1
-Expected failure:  -bg-color=black -closeness=-1 1
-Expected failure:  -bg-color=black -closeness=101 1
+Expected failure:  -reportfull -reportsize (no output)
+Expected failure:  -reportfull -borderfile=testgrid.pbm (no output)
+Expected failure:  -reportsize -borderfile=testgrid.pbm (no output)
+Expected failure:  -black -white (no output)
+Expected failure:  -black -sides (no output)
+Expected failure:  -white -bg-color=red (no output)
+Expected failure:  -white -bg-corner=topleft (no output)
+Expected failure:  -white -bg-corner=top (no output)
+Expected failure:  -blank-image=pasturize (no output)
+Expected failure:  -bg-color=black -closeness=-1 (no output)
+Expected failure:  -bg-color=black -closeness=101 (no output)
diff --git a/test/pnmcrop1.test b/test/pnmcrop1.test
index 3c86efd7..811b36d8 100755
--- a/test/pnmcrop1.test
+++ b/test/pnmcrop1.test
@@ -1,4 +1,4 @@
- #! /bin/sh
+#! /bin/sh
 # This script tests: pnmcrop
 # Also requires: pnmpad pnmmargin pamcut
 
@@ -78,7 +78,7 @@ for option in "-reportfull -reportsize" \
               "-bg-color=black -closeness=101"
     do
     pnmcrop -reportfull ${option} testgrid.pbm > ${test_out} || \
-        printf "Expected failure:  %s" "${option}"
-        test -s ${test_out}; echo " "$?
+        printf "Expected failure:  %s" "${option} "
+        test -s ${test_out} && echo "unexpected output" || echo "(no output)"	
         rm ${test_out}
     done
diff --git a/test/pnmcrop3.ok b/test/pnmcrop3.ok
index 5a86139c..4b096940 100644
--- a/test/pnmcrop3.ok
+++ b/test/pnmcrop3.ok
@@ -86,5 +86,5 @@ P1
 1111111111111
 -3 -1 -1 -1 9 13
 544280424 101484
-Expected failure 1 1
-Expected failure 2 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
diff --git a/test/pnmcrop3.test b/test/pnmcrop3.test
index 1e8da345..3d32ca21 100755
--- a/test/pnmcrop3.test
+++ b/test/pnmcrop3.test
@@ -68,13 +68,13 @@ echo "Error messages should appear below the line." 1>&2
 echo "--------------------------------------------" 1>&2
 
 pnmcrop -borderfile=${border_ppm} ${test_pbm} > ${test_out} || \
-        printf "Expected failure 1";
-        test -s ${test_out}; echo " "$?
-        rm ${test_out}
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm ${test_out}
 
 pnmcrop -borderfile=${border_pbm} ${test_ppm} > ${test_out} || \
-        printf "Expected failure 2";
-        test -s ${test_out}; echo " "$?
-        rm ${test_out}
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm ${test_out}
 
 rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm}
diff --git a/test/pnmpsnr.ok b/test/pnmpsnr.ok
index 7042f86c..38bed0f3 100644
--- a/test/pnmpsnr.ok
+++ b/test/pnmpsnr.ok
@@ -8,7 +8,7 @@ Test 2
 match
 match
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pnmpsnr.test b/test/pnmpsnr.test
index ae6ba3cc..efabe9aa 100755
--- a/test/pnmpsnr.test
+++ b/test/pnmpsnr.test
@@ -36,23 +36,23 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pnmpsnr ${b_pbm} ${w_pbm} ${b_pbm}     > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmpsnr ${b_pbm}                       > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmpsnr ${b_pbm} ${w_pbm} -target1=100 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmpsnr                   -machine     > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 rm ${b_pbm} ${w_pbm}
diff --git a/test/pnmquant.ok b/test/pnmquant.ok
index 407d42a3..f4229601 100644
--- a/test/pnmquant.ok
+++ b/test/pnmquant.ok
@@ -8,11 +8,11 @@ Test 1
 1 1
 1 1
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
diff --git a/test/pnmquant.test b/test/pnmquant.test
index cbe69f5c..4baff9a8 100755
--- a/test/pnmquant.test
+++ b/test/pnmquant.test
@@ -42,41 +42,41 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pnmquant 0 testimg.ppm   > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmquant testimg.ppm  > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmquant 10.5 testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmquant -center -meancolor 16 testimg.ppm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmquant -center -meanpixel 16 testimg.ppm    > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmquant -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmquant -spreadbrightness -spreadluminosity 16 testimg.ppm > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmquant -randomseed 1 -norandom 10 testimg.ppm > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pnmremap1.ok b/test/pnmremap1.ok
index 23a9dddd..0f511754 100644
--- a/test/pnmremap1.ok
+++ b/test/pnmremap1.ok
@@ -1,7 +1,7 @@
 3602410851 101482
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
diff --git a/test/pnmremap1.test b/test/pnmremap1.test
index 8626c50f..9c60460b 100755
--- a/test/pnmremap1.test
+++ b/test/pnmremap1.test
@@ -33,32 +33,32 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pnmremap -mapfile=/dev/null testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmremap -mapfile=/dev/zero testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmremap testimg.ppm                    > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmremap -fs -nofs testimg.ppm          > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmremap -mapfile=testgrid.pbm -missingcolor=rgb:00/ff/00 testimg.ppm \
  > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmremap -mapfile=testgrid.pbm -firstisdefault testimg.ppm > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pnmtile.ok b/test/pnmtile.ok
index d28fafa3..572893df 100644
--- a/test/pnmtile.ok
+++ b/test/pnmtile.ok
@@ -1,6 +1,6 @@
 4228632379 259
 0 0 0 : 0
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
diff --git a/test/pnmtile.test b/test/pnmtile.test
index b72ef946..74bae013 100755
--- a/test/pnmtile.test
+++ b/test/pnmtile.test
@@ -29,21 +29,21 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 pnmtile 100 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmtile 100 0 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmtile 0 100 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 pnmtile 100 100 100 testgrid.pbm > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/pnmtojpeg-scans.ok b/test/pnmtojpeg-scans.ok
new file mode 100644
index 00000000..089dfebf
--- /dev/null
+++ b/test/pnmtojpeg-scans.ok
@@ -0,0 +1,20 @@
+success
+pnmtojpeg: Input file has format P6.
+It has 149 rows of 227 columns of pixels with max sample value of 255.
+pnmtojpeg: A scan script with 7 entries is being used:
+pnmtojpeg:     Scan  0: Ss= 0 Se= 0 Ah= 0 Al= 0  3 components
+pnmtojpeg:         Color component 0 index: 0
+pnmtojpeg:         Color component 1 index: 1
+pnmtojpeg:         Color component 2 index: 2
+pnmtojpeg:     Scan  1: Ss= 1 Se= 2 Ah= 0 Al= 0  1 components
+pnmtojpeg:         Color component 0 index: 0
+pnmtojpeg:     Scan  2: Ss= 3 Se= 5 Ah= 0 Al= 0  1 components
+pnmtojpeg:         Color component 0 index: 0
+pnmtojpeg:     Scan  3: Ss= 1 Se=63 Ah= 0 Al= 0  1 components
+pnmtojpeg:         Color component 0 index: 1
+pnmtojpeg:     Scan  4: Ss= 1 Se=63 Ah= 0 Al= 0  1 components
+pnmtojpeg:         Color component 0 index: 2
+pnmtojpeg:     Scan  5: Ss= 6 Se= 9 Ah= 0 Al= 0  1 components
+pnmtojpeg:         Color component 0 index: 0
+pnmtojpeg:     Scan  6: Ss=10 Se=63 Ah= 0 Al= 0  1 components
+pnmtojpeg:         Color component 0 index: 0
diff --git a/test/pnmtojpeg-scans.test b/test/pnmtojpeg-scans.test
new file mode 100755
index 00000000..ea17c8c0
--- /dev/null
+++ b/test/pnmtojpeg-scans.test
@@ -0,0 +1,32 @@
+#! /bin/bash
+# This script tests: pnmtojpeg
+# Also requires:
+
+tmpdir=${tmpdir:-/tmp}
+test_jpegscan=${tmpdir}/test.jpegscan
+err_out=${tmpdir}/err.out
+
+cat > ${test_jpegscan} << EOF
+# This is a example of a scan script to be used by 'pnmtojpeg' with -scan .
+# It should work with any color image.
+
+#Interleaved DC scan for Y, Cb, Cr:
+0, 1, 2: 0-0, 0, 0 ;
+
+# AC scans:
+0:  1- 2, 0, 0 ;
+0:  3- 5, 0, 0 ;
+1:  1-63, 0, 0 ;
+2:  1-63, 0, 0 ;
+0:  6- 9, 0, 0 ;
+0: 10-63, 0, 0 ;
+EOF
+
+pnmtojpeg testimg.ppm -scans=${test_jpegscan} -verbose \
+ > /dev/null 2> ${err_out} && echo "success" || echo "failure"
+
+cat ${err_out}
+
+rm ${err_out} ${test_jpegscan}
+
+# TODO test invalid scan script
diff --git a/test/ppmforge-parameters.ok b/test/ppmforge-parameters.ok
index c8edc5dd..afb3e855 100644
--- a/test/ppmforge-parameters.ok
+++ b/test/ppmforge-parameters.ok
@@ -5,10 +5,10 @@ Test 2: Should print 40 30
 Test 3: Should print 90 90
 90 90
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
diff --git a/test/ppmforge-parameters.test b/test/ppmforge-parameters.test
index e5822673..ba436bf0 100755
--- a/test/ppmforge-parameters.test
+++ b/test/ppmforge-parameters.test
@@ -30,36 +30,36 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 ppmforge -night  -dimension=0  > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmforge  -dimension=10  > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmforge  -dimension=-1  > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmforge -clouds -mesh=1.99    > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmforge -clouds -power=0      > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmforge         -ice=-1       > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmforge         -glaciers=-1  > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/ppmhist.ok b/test/ppmhist.ok
index 468bd317..a78540f1 100644
--- a/test/ppmhist.ok
+++ b/test/ppmhist.ok
@@ -20,6 +20,6 @@ Test 2
  Summary: 6 colors: 1 black, 0 white, 0 gray, 5 color
  Summary: 6 colors: 1 black, 1 white, 1 gray, 3 color
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/ppmhist.test b/test/ppmhist.test
index 8c2eedbc..27ae9cea 100755
--- a/test/ppmhist.test
+++ b/test/ppmhist.test
@@ -36,16 +36,16 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 ppmhist -hexcolor -float testimg.ppm > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmhist -hexcolor -map   testimg.ppm > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmhist -float    -map   testimg.ppm > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/ppmmake.ok b/test/ppmmake.ok
index 6d559c8d..0231874f 100644
--- a/test/ppmmake.ok
+++ b/test/ppmmake.ok
@@ -3,13 +3,13 @@ Test 1
 4294967295 0
 2378991101 7513
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
diff --git a/test/ppmmake.test b/test/ppmmake.test
index 30eb596a..fb7bf74a 100755
--- a/test/ppmmake.test
+++ b/test/ppmmake.test
@@ -19,51 +19,51 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 ppmmake rgb:gg/00/00  2 2  > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake rgb:ff/ff/00  2    > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake rgbi:1.1/0/0  2 2  > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake rgbi:1.0/.5   2 2  > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake rainbow       2 2  > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake               2 2  > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake blue -maxval=0 2 2  > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake blue -maxval=-1 2 2  > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmmake blue -maxval=65536 2 2  > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 RGBDEF=/dev/null ppmmake red 2 2 > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/ppmpat-random.ok b/test/ppmpat-random.ok
index 71f631e5..71f631e5 100755..100644
--- a/test/ppmpat-random.ok
+++ b/test/ppmpat-random.ok
diff --git a/test/ppmpat.ok b/test/ppmpat.ok
index f2b355a9..dc7922ed 100644
--- a/test/ppmpat.ok
+++ b/test/ppmpat.ok
@@ -19,29 +19,29 @@ Test 9. Should print: 3057513592 661
 Test 10. Should print: 1861389287 661
 1861389287 661
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
-Expected failure 9 1
-Expected failure 10 1
-Expected failure 11 1
-Expected failure 12 1
-Expected failure 13 1
-Expected failure 14 1
-Expected failure 15 1
-Expected failure 16 1
-Expected failure 17 1
-Expected failure 18 1
-Expected failure 19 1
-Expected failure 20 1
-Expected failure 21 1
-Expected failure 22 1
-Expected failure 23 1
-Expected failure 24 1
-Expected failure 25 1
-Expected failure 26 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
+Expected failure 15 (no output)
+Expected failure 16 (no output)
+Expected failure 17 (no output)
+Expected failure 18 (no output)
+Expected failure 19 (no output)
+Expected failure 20 (no output)
+Expected failure 21 (no output)
+Expected failure 22 (no output)
+Expected failure 23 (no output)
+Expected failure 24 (no output)
+Expected failure 25 (no output)
+Expected failure 26 (no output)
diff --git a/test/ppmpat.test b/test/ppmpat.test
index ced2e64a..48c2460f 100755
--- a/test/ppmpat.test
+++ b/test/ppmpat.test
@@ -50,48 +50,48 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 ppmpat -g2 -g3 10 10 > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -madras -tartan 10 10 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -poles -squig 10 10 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -camo -anticamo 10 10 > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -argyle1 -argyle2 10 10 > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat 10 10 > ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -g2 10 > ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -g2 10 10 10 > ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -g2 10 > ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 clist1="-color=rgb:00/00/00"
@@ -101,89 +101,89 @@ clist4="-color=rgb:00/00/00,rgb:00/00/ff,rgb:00/ff/ff,rgb:ff/ff/ff"
 
 # These patterns require exactly 2 colors
 ppmpat -gingham2 ${clist1} 10 10 > ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -argyle1  ${clist1} 10 10 > ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -gingham2 ${clist3} 10 10 > ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -argyle1  ${clist3} 10 10 > ${test_out} || \
-  printf "Expected failure 13"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # These require exactly 3 colors
 ppmpat -gingham3 ${clist2} 10 10 > ${test_out} || \
-  printf "Expected failure 14"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -argyle2  ${clist2} 10 10 > ${test_out} || \
-  printf "Expected failure 15"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 15 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -madras   ${clist2} 10 10 > ${test_out} || \
-  printf "Expected failure 16"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 16 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -tartan   ${clist2} 10 10 > ${test_out} || \
-  printf "Expected failure 17"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 17 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -gingham3 ${clist4} 10 10 > ${test_out} || \
-  printf "Expected failure 18"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 18 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -argyle2  ${clist4} 10 10 > ${test_out} || \
-  printf "Expected failure 19"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 19 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -madras   ${clist4} 10 10 > ${test_out} || \
-  printf "Expected failure 20"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 20 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -tartan   ${clist4} 10 10 > ${test_out} || \
-  printf "Expected failure 21"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 21 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # These require at least 3 colors
 ppmpat -squig    ${clist2} 10 10 > ${test_out} || \
-  printf "Expected failure 22"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 22 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -camo     ${clist2} 10 10 > ${test_out} || \
-  printf "Expected failure 23"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 23 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -anticamo ${clist2} 10 10 > ${test_out} || \
-  printf "Expected failure 24"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 24 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # The squig pattern has an aspect ratio restriction
 ppmpat -squig ${clist3} 10 250  > ${test_out} || \
-  printf "Expected failure 25"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 25 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmpat -squig ${clist3} 500 20  > ${test_out} || \
-  printf "Expected failure 26"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 26 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/ppmrough-parameters.ok b/test/ppmrough-parameters.ok
new file mode 100644
index 00000000..473ace05
--- /dev/null
+++ b/test/ppmrough-parameters.ok
@@ -0,0 +1,25 @@
+Test Invalid
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
+Expected failure 13 (no output)
+Expected failure 14 (no output)
+Expected failure 15 (no output)
+Expected failure 16 (no output)
+Expected failure 17 (no output)
+Expected failure 20 (no output)
+Expected failure 18 (no output)
+Expected failure 19 (no output)
+Expected failure 20 (no output)
+Expected failure 21 (no output)
+Expected failure 22 (no output)
+Expected failure 23 (no output)
diff --git a/test/ppmrough-parameters.test b/test/ppmrough-parameters.test
new file mode 100755
index 00000000..fb67424e
--- /dev/null
+++ b/test/ppmrough-parameters.test
@@ -0,0 +1,145 @@
+#! /bin/sh
+# This script tests: ppmrough
+# Also requires:
+
+tmpdir=${tmpdir:-/tmp}
+test_out=${tmpdir}/test_out
+
+
+# Test Invalid
+echo "Test Invalid"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+ppmrough -h 10 -w 10 -top -1 > ${test_out} || \
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -h 10 -w 100 -top 11 > ${test_out} || \
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+ppmrough -h 10 -w 10 -bottom -1 > ${test_out} || \
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -h 10 -w 1000 -bottom 11 > ${test_out} || \
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -h 10 -w 10 -left -1 > ${test_out} || \
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -h 10 -w 100 -left 101 > ${test_out} || \
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+ppmrough -h 10 -w 10 -right -1 > ${test_out} || \
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -h 10 -w 1000 -right 1001 > ${test_out} || \
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+ppmrough -width 0.1 > ${test_out} || \
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -width -1 > ${test_out} || \
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -width > ${test_out} || \
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+ppmrough -height 0.1 > ${test_out} || \
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -height -1 > ${test_out} || \
+  printf "Expected failure 13 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -height > ${test_out} || \
+  printf "Expected failure 14 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+ppmrough -randomseed 0.1 > ${test_out} || \
+  printf "Expected failure 15 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -randomseed -1 > ${test_out} || \
+  printf "Expected failure 16 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -randomseed > ${test_out} || \
+  printf "Expected failure 17 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+
+ppmrough -var A > ${test_out} || \
+  printf "Expected failure 20 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -var -1 > ${test_out} || \
+  printf "Expected failure 18 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -var > ${test_out} || \
+  printf "Expected failure 19 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+ppmrough -bg redmint > ${test_out} || \
+  printf "Expected failure 20 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -bg > ${test_out} || \
+  printf "Expected failure 21 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+
+ppmrough -fg redmint > ${test_out} || \
+  printf "Expected failure 22 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+ppmrough -fg > ${test_out} || \
+  printf "Expected failure 23 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
diff --git a/test/ppmrough.ok b/test/ppmrough.ok
index 83643849..4beff006 100755..100644
--- a/test/ppmrough.ok
+++ b/test/ppmrough.ok
@@ -1 +1,24 @@
+Test 1. Should print 378403602 30015
 378403602 30015
+Test 2. Should print 378403602 30015
+378403602 30015
+Test 3. Should print 535171440 30015
+535171440 30015
+Test 4. Should print 937167683 30015
+937167683 30015
+Test 5. Should print 1927474861 30015
+1927474861 30015
+Test 6. Should print 3596045345 30015
+3596045345 30015
+Test 7. Should print 198510149 30015
+198510149 30015
+Test 8. Should print 1128371780 30015
+1128371780 30015
+Test 9. Should print 2909877411 30015
+2909877411 30015
+Test 10. Should print 2820370592 30015
+2820370592 30015
+Test 11. Should print 2028409204 30015
+2028409204 30015
+Test 12. Should print 4234304830 30015
+4234304830 30015
diff --git a/test/ppmrough.test b/test/ppmrough.test
index b10ba941..e1d720d5 100755
--- a/test/ppmrough.test
+++ b/test/ppmrough.test
@@ -2,5 +2,47 @@
 # This script tests: ppmrough
 # Also requires:
 
-# Should print: 378403602 30015 (Glibc and MAC OS)
-ppmrough  -randomseed 1 | cksum
+defaultopts="-randomseed 1 -bg rgb:00/ff/ff -fg rgb:ff/ff/00 -w 100 -h 100"
+
+# No border
+
+echo "Test 1. Should print 378403602 30015"
+ppmrough -randomseed 1 | cksum
+
+echo "Test 2. Should print 378403602 30015"
+ppmrough -randomseed 1 -var 0 | cksum
+
+# Vertical border
+
+echo "Test 3. Should print 535171440 30015"
+ppmrough ${defaultopts} -left 20 | cksum
+
+echo "Test 4. Should print 937167683 30015"
+ppmrough ${defaultopts} -right 20 | cksum
+
+echo "Test 5. Should print 1927474861 30015"
+ppmrough ${defaultopts} -left 50 | cksum
+
+echo "Test 6. Should print 3596045345 30015"
+ppmrough ${defaultopts} -right 50 | cksum
+
+echo "Test 7. Should print 198510149 30015"
+ppmrough ${defaultopts} -right 20 -var 0 | cksum
+
+# Horizontal border
+
+echo "Test 8. Should print 1128371780 30015"
+ppmrough ${defaultopts} -top 30 | cksum
+
+echo "Test 9. Should print 2909877411 30015"
+ppmrough ${defaultopts} -bottom 25 | cksum
+
+echo "Test 10. Should print 2820370592 30015"
+ppmrough ${defaultopts} -top 50 | cksum
+
+echo "Test 11. Should print 2028409204 30015"
+ppmrough ${defaultopts} -bottom 50 | cksum
+
+echo "Test 12. Should print 4234304830 30015"
+ppmrough ${defaultopts} -bottom 10 -var 0 | cksum
+
diff --git a/test/ppmshift.ok b/test/ppmshift.ok
index 735ac445..735ac445 100755..100644
--- a/test/ppmshift.ok
+++ b/test/ppmshift.ok
diff --git a/test/ppmspread.ok b/test/ppmspread.ok
index 40f44465..40f44465 100755..100644
--- a/test/ppmspread.ok
+++ b/test/ppmspread.ok
diff --git a/test/ppmtoapplevol.ok b/test/ppmtoapplevol.ok
index 46acda60..daed172c 100644
--- a/test/ppmtoapplevol.ok
+++ b/test/ppmtoapplevol.ok
@@ -1,6 +1,6 @@
 Test: should print 1518149010 3065
 1518149010 3065
 Test Invalid
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/ppmtoapplevol.test b/test/ppmtoapplevol.test
index 4964ede8..a11e6aa6 100755
--- a/test/ppmtoapplevol.test
+++ b/test/ppmtoapplevol.test
@@ -15,16 +15,16 @@ tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
 pbmmake 10 11 | ppmtoapplevol > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
  
 pbmmake 10 13 | ppmtoapplevol > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
  
 pbmmake 256 12 | ppmtoapplevol > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/ppmtomitsu.ok b/test/ppmtomitsu.ok
new file mode 100644
index 00000000..951189d4
--- /dev/null
+++ b/test/ppmtomitsu.ok
@@ -0,0 +1,14 @@
+Test 0. Should print 458455366 101484
+458455366 101484
+Test 1. Should print 3110813682 101562
+3110813682 101562
+Test 2. Should print 4168174994 34399
+4168174994 34399
+Test 3. Should print 3201293405 310
+3201293405 310
+Test 4. Should print 3354679572 752
+3354679572 752
+Test 5. Should print 3999654426 101549
+3999654426 101549
+Test 6. Should print 4201246884 101549
+4201246884 101549
diff --git a/test/ppmtomitsu.test b/test/ppmtomitsu.test
new file mode 100755
index 00000000..ce4bbf56
--- /dev/null
+++ b/test/ppmtomitsu.test
@@ -0,0 +1,31 @@
+#! /bin/sh
+# This script tests: ppmtomitsu
+# Also requires: pnmcolormap pnmremap
+
+tmpdir=${tmpdir:-/tmp}
+testimg100_ppm=${tmpdir}/testimg100.ppm
+
+echo "Test 0. Should print 458455366 101484"
+# equivalent to: Pnmquant 100 testimg.ppm
+pnmcolormap 100 testimg.ppm | pnmremap -nofloyd -mapfile=- testimg.ppm |\
+ tee ${testimg100_ppm} | cksum
+
+echo "Test 1. Should print 3110813682 101562"
+ppmtomitsu testimg.ppm | cksum 
+
+echo "Test 2. Should print 4168174994 34399"
+ppmtomitsu ${testimg100_ppm} | cksum 
+
+echo "Test 3. Should print 3201293405 310"
+ppmtomitsu testgrid.pbm | cksum 
+
+echo "Test 4. Should print 3354679572 752"
+ppmtomitsu -tiny testgrid.pbm | cksum 
+
+echo "Test 5. Should print 3999654426 101549"
+ppmtomitsu -tiny testimg.ppm | cksum 
+
+echo "Test 6. Should print 4201246884 101549"
+ppmtomitsu -tiny ${testimg100_ppm} | cksum 
+
+rm ${testimg100_ppm}
diff --git a/test/ppmwheel.ok b/test/ppmwheel.ok
index 790a19cb..525bee2c 100644
--- a/test/ppmwheel.ok
+++ b/test/ppmwheel.ok
@@ -2,8 +2,8 @@ Test 1.
 1537578995 59
 875938089 86
 Test Invalid.
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
diff --git a/test/ppmwheel.test b/test/ppmwheel.test
index c6583f97..ca439bea 100755
--- a/test/ppmwheel.test
+++ b/test/ppmwheel.test
@@ -122,26 +122,26 @@ echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 ppmwheel 10 -huevalue -huesaturation > ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmwheel 0 > ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmwheel 3 > ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmwheel > ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ppmwheel 10 10 > ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
diff --git a/test/qoi-roundtrip.ok b/test/qoi-roundtrip.ok
index faa7601f..66e25bd8 100644
--- a/test/qoi-roundtrip.ok
+++ b/test/qoi-roundtrip.ok
@@ -17,18 +17,18 @@ Test 3.  Should print 3.N 0 0
 3.3 0 0
 3.4 0 0
 Test Invalid
-Should print: Expected failure N 1
-Expected failure 1 1
-Expected failure 2 1
-Expected failure 3 1
-Expected failure 4 1
-Expected failure 5 1
-Expected failure 6 1
-Expected failure 7 1
-Expected failure 8 1
+Should print: Expected failure N (no output)
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
 ------------------------------
-Should print: Expected failure N 0
-Expected failure 9 0
-Expected failure 10 0
-Expected failure 11 0
-Expected failure 12 0
+Should print: Expected failure N (output produced)
+Expected failure 9 (output produced)
+Expected failure 10 (output produced)
+Expected failure 11 (output produced)
+Expected failure 12 (output produced)
diff --git a/test/qoi-roundtrip.test b/test/qoi-roundtrip.test
index f758abcc..52396e39 100755
--- a/test/qoi-roundtrip.test
+++ b/test/qoi-roundtrip.test
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 # This script tests: qoitopam pamtoqoi
 # Also requires: pamdepth pamfile pamseq pamstack pamtopnm pbmmake
 # Also requires: pgmnoise ppmpat ppmtopgm
@@ -155,19 +155,19 @@ echo "Invalid command-line argument combinations." 1>&2
 echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
-echo "Should print: Expected failure N 1"
+echo "Should print: Expected failure N (no output)"
 
 pamseq -tupletype="void" 1 1 | pamtoqoi > \
   ${test_out} || \
-  printf "Expected failure 1"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ( echo "P1"; echo "400000001 1" ;
   head -c 400000001 /dev/zero ) | pamtoqoi > \
   ${test_out} || \
-  printf "Expected failure 2"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Replace fields in the qoi file header with invalid values
@@ -175,24 +175,24 @@ pamseq -tupletype="void" 1 1 | pamtoqoi > \
 ( printf "qojf"
   tail -c +5 ${maze_qoi} ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 3"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ( head -c 4 ${maze_qoi}
   head -c 4 /dev/zero
   tail -c +9 ${maze_qoi} ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 4"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 4 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ( head -c 8 ${maze_qoi}
   head -c 4 /dev/zero
   tail -c +13 ${maze_qoi} ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 5"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 5 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 # Following sed construct means: "replace first 8 bytes of input
@@ -204,51 +204,51 @@ pamseq -tupletype="void" 1 1 | pamtoqoi > \
   tail -c +5 ${maze_qoi} | \
   sed '1s/^......../\x00\x00\x4F\xFF\x00\x00\x4F\xFF/' ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 6"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 6 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ( head -c 12 ${maze_qoi}
   tail -c +13 ${maze_qoi} | sed '1s/^./\x01/' ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 7"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 7 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 ( head -c 13 ${maze_qoi}
   tail -c +14 ${maze_qoi} | sed '1s/^./\x02/' ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 8"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 8 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
   rm -f ${test_out}
 
 echo "------------------------------"
-echo "Should print: Expected failure N 0"
+echo "Should print: Expected failure N (output produced)"
 
 ( head -c $(( ${maze_qoi_size} - 9 )) ${maze_qoi}
   tail -c 9 ${maze_qoi} |   sed '1s/^./\xfd/' ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 9"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 9 "
+  test -s ${test_out} && echo "(output produced)"|| echo "no output"
   rm -f ${test_out}
 
 head -c $(( ${maze_qoi_size} - 1 )) ${maze_qoi} | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 10"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 10 "
+  test -s ${test_out} && echo "(output produced)"|| echo "no output"
   rm -f ${test_out}
 
 ( head -c $(( ${maze_qoi_size} - 1 )) ${maze_qoi}
   printf '1' ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 11"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 11 "
+  test -s ${test_out} && echo "(output produced)"|| echo "no output"
   rm -f ${test_out}
 
 ( cat ${maze_qoi}; printf '1' ) | qoitopam > \
   ${test_out} || \
-  printf "Expected failure 12"
-  test -s ${test_out}; echo " "$?
+  printf "Expected failure 12 "
+  test -s ${test_out} && echo "(output produced)"|| echo "no output"
   rm -f ${test_out}
 
 rm ${maze_qoi}
diff --git a/test/stdin-pam1.test b/test/stdin-pam1.test
index 7cb15dfc..2ab7b11c 100755
--- a/test/stdin-pam1.test
+++ b/test/stdin-pam1.test
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 # This script tests: pamaddnoise pamaltsat pambackground pambayer
 # This script tests: pambrighten pamcat pamcut pamdeinterlace pamdepth pamditherbw
 # This script tests: pamedge pamexec pamfile pamfind pamfix pamflip
diff --git a/test/stdin-pam2.test b/test/stdin-pam2.test
index f47df604..10713c77 100755
--- a/test/stdin-pam2.test
+++ b/test/stdin-pam2.test
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 # This script tests: pammasksharpen pammixmulti pamdice
 # This script tests: pamlookup pamunlookup
 # Also requires: pbmmake
diff --git a/test/stdin-ppm3.test b/test/stdin-ppm3.test
index 064e3e22..1313ac40 100755
--- a/test/stdin-ppm3.test
+++ b/test/stdin-ppm3.test
@@ -1,4 +1,4 @@
-o#! /bin/sh
+#! /bin/sh
 # This script tests: ppmtobmp bmptopnm
 # This script tests: ppmtoilbm ilbmtoppm
 # This script tests: ppmtoleaf leaftoppm
diff --git a/test/xpm-roundtrip.ok b/test/xpm-roundtrip.ok
index 5168378d..2083dc10 100644
--- a/test/xpm-roundtrip.ok
+++ b/test/xpm-roundtrip.ok
@@ -1 +1,4 @@
+Test 1. Should print 1926073387 101484
+1926073387 101484
+Test 2. Should print 281226646 481
 281226646 481
diff --git a/test/xpm-roundtrip.test b/test/xpm-roundtrip.test
index 6e3e415b..c016c8c3 100755
--- a/test/xpm-roundtrip.test
+++ b/test/xpm-roundtrip.test
@@ -2,8 +2,10 @@
 # This script tests: ppmtoxpm xpmtoppm
 # Also requires: pgmtopbm ppmtopgm
 
+echo "Test 1. Should print 1926073387 101484"
+ppmtoxpm -hexonly testimg.ppm | \
+  xpmtoppm  | cksum
 
-#ppmtoxpm -hexonly testimg.ppm | \
-# xpmtoppm  | cksum
+echo "Test 2. Should print 281226646 481"
 ppmtoxpm maze.pbm | xpmtoppm | \
   ppmtopgm | pgmtopbm -th -value=0.5 | cksum
diff --git a/test/xwd-roundtrip.ok b/test/xwd-roundtrip.ok
index 864d737a..31dcba3e 100644
--- a/test/xwd-roundtrip.ok
+++ b/test/xwd-roundtrip.ok
@@ -1,6 +1,9 @@
-Test 1.  Should produce 1571496937 33838, cksum of testimg.red
+Test 1.  Should produce 1571496937 33838, cksum of testimg.red twice
+1571496937 33838
 1571496937 33838
 Test 2.  Should produce 1926073387 101484
 1926073387 101484
-Test 3.  Should produce 281226646 481
+Test 3.  Should produce 281226646 481 three times
+281226646 481
+281226646 481
 281226646 481
diff --git a/test/xwd-roundtrip.test b/test/xwd-roundtrip.test
index 2d00971d..1583cd68 100755
--- a/test/xwd-roundtrip.test
+++ b/test/xwd-roundtrip.test
@@ -1,15 +1,22 @@
 #! /bin/sh
 # This script tests: pnmtoxwd xwdtopnm
-# Also requires: pamchannel pamtopnm pamdepth
+# Also requires: pamchannel pamtopnm pamdepth ppmtopgm
 
-echo "Test 1.  Should produce 1571496937 33838, cksum of testimg.red"
+echo "Test 1.  Should produce 1571496937 33838, cksum of testimg.red twice"
 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
   pnmtoxwd | xwdtopnm | pamdepth 255 | cksum
 
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  pnmtoxwd -direct | xwdtopnm -quiet | pamdepth 255 | ppmtopgm | cksum
+
 echo "Test 2.  Should produce 1926073387 101484"
 pnmtoxwd --quiet testimg.ppm | \
   xwdtopnm --quiet | pamdepth 255 | cksum
 
-echo "Test 3.  Should produce 281226646 481"
-pnmtoxwd --quiet maze.pbm | \
-  xwdtopnm | cksum
+echo "Test 3.  Should produce 281226646 481 three times"
+pnmtoxwd --quiet maze.pbm | xwdtopnm | cksum
+
+pnmtoxwd --quiet -pseudodepth 1 maze.pbm | xwdtopnm | cksum
+
+pnmtoxwd --quiet -pseudodepth 16 maze.pbm | xwdtopnm | cksum
+
diff --git a/test/ybm-roundtrip.ok b/test/ybm-roundtrip.ok
new file mode 100644
index 00000000..3873d097
--- /dev/null
+++ b/test/ybm-roundtrip.ok
@@ -0,0 +1,2 @@
+Test.  Should print 281226646 481
+281226646 481
diff --git a/test/ybm-roundtrip.test b/test/ybm-roundtrip.test
new file mode 100755
index 00000000..b53d2ba0
--- /dev/null
+++ b/test/ybm-roundtrip.test
@@ -0,0 +1,7 @@
+#! /bin/sh
+# This script tests: pbmtoybm xbmtopbm
+# Also requires:
+
+echo "Test.  Should print 281226646 481"
+
+pbmtoybm maze.pbm | ybmtopbm | cksum
diff --git a/version.mk b/version.mk
index 54ae6917..fca21779 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 11
-NETPBM_MINOR_RELEASE = 3
-NETPBM_POINT_RELEASE = 6
+NETPBM_MINOR_RELEASE = 4
+NETPBM_POINT_RELEASE = 0