diff options
186 files changed, 6318 insertions, 4675 deletions
diff --git a/analyzer/pgmtexture.c b/analyzer/pgmtexture.c index 07317336..84c6bf4a 100644 --- a/analyzer/pgmtexture.c +++ b/analyzer/pgmtexture.c @@ -518,11 +518,12 @@ f3_corr(float ** const p, the image. -----------------------------------------------------------------------------*/ unsigned int i; - float sumSqrx, sumSqry, tmp; + float sumSqrx; + float tmp; float * px; float meanx, meany, stddevx, stddevy; - sumSqrx = 0.0; sumSqry = 0.0; + sumSqrx = 0.0; meanx = 0.0; meany = 0.0; px = vector(0, ng); @@ -545,7 +546,6 @@ f3_corr(float ** const p, } meany = meanx; - sumSqry = sumSqrx; stddevx = sqrt(sumSqrx - (SQR(meanx))); stddevy = stddevx; diff --git a/analyzer/pnmpsnr.c b/analyzer/pnmpsnr.c index 19f013a4..1ddefac2 100644 --- a/analyzer/pnmpsnr.c +++ b/analyzer/pnmpsnr.c @@ -2,7 +2,7 @@ * pnmpsnr.c: Compute error (RMSE, PSNR) between images * * - * Derived from pnmpnsmr by Ulrich Hafner, part of his fiasco package, + * Derived from pnmpnsmr by Ullrich Hafner, part of his fiasco package, * On 2001.03.04. * Copyright (C) 1994-2000 Ullrich Hafner <hafner@bigfoot.de> @@ -402,6 +402,21 @@ psnrFromSumSqDiff(struct SqDiff const sumSqDiff, +static bool +psnrIsFinite(double const psnr) { + + /* We would just use C standard isfinite(), but that is not standard + before C99. Neither is INFINITY. + + A finite PSNR, in this program, cannot be anywhere near 1,000,000, + because of limits of the program, so we just compare to that. + */ + + return psnr < 1000000.0; +} + + + static void reportPsnrHuman(struct Psnr const psnr, ColorSpace const colorSpace, @@ -417,7 +432,7 @@ reportPsnrHuman(struct Psnr const psnr, pm_asprintf(&label, "%s:", colorSpace.componentName[i]); - if (isfinite(psnr.psnr[i])) + if (psnrIsFinite(psnr.psnr[i])) pm_message(" %-6.6s %.2f dB", label, psnr.psnr[i]); else pm_message(" %-6.6s no difference", label); diff --git a/buildtools/Makefile b/buildtools/Makefile index 8671c066..0490865b 100644 --- a/buildtools/Makefile +++ b/buildtools/Makefile @@ -33,10 +33,20 @@ libopt.o: libopt.c typegen.o endiangen.o:%.o:%.c $(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) $< +# genfontc is strange because it isn't really a build tool; it's a development +# tool. And it uses Netpbm. So we don't even build it by default and the +# developer who builds it explicitly may have to be careful. +genfontc.o:%.o:%.c importinc + $(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) \ + $(NETPBM_INCLUDES) \ + $< +genfontc:%:%.o $(NETPBMLIB) + $(LD_FOR_BUILD) -o $@ $(LDFLAGS_FOR_BUILD) $< $(NETPBMLIB) + $(BUILDPROGS):%:%.o $(LD_FOR_BUILD) -o $@ $(LDFLAGS_FOR_BUILD) $< distclean clean: cleanlocal .PHONY: cleanlocal cleanlocal: - rm -f $(BUILDPROGS) + rm -f $(BUILDPROGS) genfontc diff --git a/buildtools/configure.pl b/buildtools/configure.pl index 9cafd019..5a7d8a33 100755 --- a/buildtools/configure.pl +++ b/buildtools/configure.pl @@ -1456,14 +1456,52 @@ sub gnuOptimizeOpt($) { +sub wnostrictoverflowWorks($) { + my ($gccCommandName) = @_; + + my ($cFile, $cFileName) = tempFile(".c"); + + print $cFile "int x;"; + + my $compileCommand = + "$gccCommandName -c -o /dev/null -Wno-strict-overflow $cFileName"; + print ("Doing test compile to see if -Wno-strict-overflow works: " + . "$compileCommand\n"); + my $rc = system($compileCommand); + + unlink($cFileName); + close($cFile); + + return ($rc == 0); +} + + + sub gnuCflags($) { my ($gccCommandName) = @_; - return("CFLAGS = " . gnuOptimizeOpt($gccCommandName) . " -ffast-math " . - " -pedantic -fno-common " . - "-Wall -Wno-uninitialized -Wmissing-declarations -Wimplicit " . - "-Wwrite-strings -Wmissing-prototypes -Wundef " . - "-Wno-unknown-pragmas\n"); + my $flags; + + $flags = gnuOptimizeOpt($gccCommandName) . " -ffast-math " . + " -pedantic -fno-common " . + "-Wall -Wno-uninitialized -Wmissing-declarations -Wimplicit " . + "-Wwrite-strings -Wmissing-prototypes -Wundef " . + "-Wno-unknown-pragmas "; + + if (wnostrictoverflowWorks($gccCommandName)) { + # The compiler generates some optimizations based on the assumption + # that you wouldn't code something that can arithmetically overflow, + # so adding a positive value to something can only make it bigger. + # E.g. if (x + y > x), where y is unsigned, is a no-op. The compiler + # optionally warns when it makes that assumption. Sometimes, the + # compiler is able to do that optimization because of inlining, so the + # code per se is not ridiculous, it just becomes superfluous in + # context. That means you can't code around the warning. Ergo, we + # must disable the warning. + + $flags .= '-Wno-strict-overflow'; + } + return("CFLAGS = $flags\n"); } diff --git a/buildtools/genfontc.c b/buildtools/genfontc.c new file mode 100644 index 00000000..ce6b8c9c --- /dev/null +++ b/buildtools/genfontc.c @@ -0,0 +1,199 @@ +#include "pm_c_util.h" +#include "mallocvar.h" +#include "shhopt.h" +#include "pm.h" +#include "pbmfont.h" + + + +struct CmdlineInfo { + /* All the information the user supplied in the command line, + in a form easy for the program to use. + */ + const char * font; + const char * builtin; + const char * header; + const char * varname; + unsigned int verbose; +}; + + + +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 us as the argv array. +-----------------------------------------------------------------------------*/ + optEntry * option_def; + /* Instructions to OptParseOptions3 on how to parse our options. + */ + optStruct3 opt; + + unsigned int fontSpec, builtinSpec, headerSpec, varnameSpec; + + unsigned int option_def_index; + + MALLOCARRAY_NOFAIL(option_def, 100); + + option_def_index = 0; /* incremented by OPTENTRY */ + OPTENT3(0, "font", OPT_STRING, &cmdlineP->font, &fontSpec, 0); + OPTENT3(0, "builtin", OPT_STRING, &cmdlineP->builtin, &builtinSpec, 0); + OPTENT3(0, "header", OPT_STRING, &cmdlineP->header, &headerSpec, 0); + OPTENT3(0, "varname", OPT_STRING, &cmdlineP->varname, &varnameSpec, 0); + 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, (char **)argv, opt, sizeof(opt), 0); + /* Uses and sets argc, argv, and some of *cmdlineP and others. */ + + if (!fontSpec) + cmdlineP->font = NULL; + + if (!builtinSpec) + cmdlineP->builtin = NULL; + + if (!headerSpec) + cmdlineP->header = NULL; + + if (!varnameSpec) + cmdlineP->varname = NULL; +} + + + +static void +reportFont(struct font * const fontP) { + + unsigned int n; + unsigned int c; + + pm_message("FONT:"); + pm_message(" character dimensions: %uw x %uh", + fontP->maxwidth, fontP->maxheight); + pm_message(" Additional vert white space: %d pixels", fontP->y); + + for (c = 0, n = 0; c < ARRAY_SIZE(fontP->glyph); ++c) { + if (fontP->glyph[c]) + ++n; + } + + pm_message(" # characters: %u", n); +} + + + +static void +computeFont(const char * const fontName, + const char * const builtinName, + struct font ** const fontPP) { + + struct font * fontP; + + if (fontName) + fontP = pbm_loadfont(fontName); + else { + if (builtinName) + fontP = pbm_defaultfont(builtinName); + else + fontP = pbm_defaultfont("bdf"); + } + + *fontPP = fontP; +} + + + + +static void +dumpfont(struct font * const fontP, + const char * const header, + const char * const varname, + FILE * const ofP) { +/*---------------------------------------------------------------------------- + Dump out font as C source code. +-----------------------------------------------------------------------------*/ + unsigned int i; + unsigned int ng; + + for (i = 0, ng = 0; i < 256; ++i) { + if (fontP->glyph[i]) + ++ng; + } + + if (header != NULL) + printf("#include \"%s\"\n\n", header); + + printf("static struct glyph _g[%d] = {\n", ng); + + for (i = 0; i < 256; ++i) { + struct glyph * const glyphP = fontP->glyph[i]; + + if (glyphP) { + unsigned int j; + + printf(" { %d, %d, %d, %d, %d, \"", + glyphP->width, glyphP->height, + glyphP->x, glyphP->y, glyphP->xadd); + + for (j = 0; j < glyphP->width * glyphP->height; ++j) { + if (glyphP->bmap[j]) + printf("\\1"); + else + printf("\\0"); + } + --ng; + printf("\" }%s\n", ng ? "," : ""); + } + } + printf("};\n"); + + printf("struct font %s = { %d, %d, %d, %d, {\n", + (varname == NULL) ? "XXX_font" : varname, + fontP->maxwidth, fontP->maxheight, fontP->x, fontP->y); + + { + unsigned int i; + + for (i = 0; i < 256; ++i) { + if (fontP->glyph[i]) + printf(" _g + %d", ng++); + else + printf(" NULL"); + + if (i != 255) + printf(","); + + printf("\n"); + } + } + + printf(" }\n};\n"); +} + + + +int +main(int argc, const char *argv[]) { + + struct CmdlineInfo cmdline; + struct font * fontP; + + pm_proginit(&argc, argv); + + parseCommandLine(argc, argv, &cmdline); + + computeFont(cmdline.font, cmdline.builtin, &fontP); + + if (cmdline.verbose) + reportFont(fontP); + + dumpfont(fontP, cmdline.header, cmdline.varname, stdout); +} + + + diff --git a/buildtools/libopt.c b/buildtools/libopt.c index a0bf1cda..274e7c66 100644 --- a/buildtools/libopt.c +++ b/buildtools/libopt.c @@ -497,21 +497,20 @@ main(int argc, char **argv) { bool error; bool runtime; /* -runtime option has been seen */ - bool quiet; /* -quiet option has been seen */ int retval; unsigned int arg; /* Index into argv[] of argument we're processing */ char outputLine[1024]; strcpy(outputLine, ""); /* initial value */ runtime = FALSE; /* initial value */ - quiet = FALSE; /* initial value */ error = FALSE; /* no error yet */ + for (arg = 1; arg < argc && !error; arg++) { if (strcmp(argv[arg], "-runtime") == 0) runtime = TRUE; - else if (strcmp(argv[arg], "-quiet") == 0) - quiet = TRUE; - else { + else if (strcmp(argv[arg], "-quiet") == 0) { + /* Doesn't do anything today */ + } else { const char * options; processOneLibrary(argv[arg], runtime, explicit, &options, &error); diff --git a/converter/bmp.h b/converter/bmp.h index 524bbf7e..78c469d1 100644 --- a/converter/bmp.h +++ b/converter/bmp.h @@ -83,7 +83,37 @@ #include "pm.h" /* For pm_error() */ -enum bmpClass {C_WIN=1, C_OS2=2}; +enum bmpClass { + BMP_C_OS2_1x, + BMP_C_OS2_2x, + BMP_C_WIN_V1, + BMP_C_WIN_V2, + BMP_C_WIN_V3, + BMP_C_WIN_V4, + BMP_C_WIN_V5 +}; + + + +static __inline__ const char * +BMPClassName(enum bmpClass const class) { + + const char * name; + + switch (class) { + case BMP_C_OS2_1x: name = "OS/2 (v1)"; break; + case BMP_C_OS2_2x: name = "OS/2 (v2)"; break; + case BMP_C_WIN_V1: name = "Windows (v1)"; break; + case BMP_C_WIN_V2: name = "Windows (v2)"; break; + case BMP_C_WIN_V3: name = "Windows (v3)"; break; + case BMP_C_WIN_V4: name = "Windows (v4)"; break; + case BMP_C_WIN_V5: name = "Windows (v5)"; break; + } + + return name; +} + + static char const er_internal[] = "%s: internal error!"; @@ -114,29 +144,100 @@ BMPCompTypeName(BMPCompType const compression) { static __inline__ unsigned int -BMPlenfileheader(enum bmpClass const class) { +BMPlenfileheader(void) { + + return 14; +} + + + +enum BMPinfoHeaderLen { +/*---------------------------------------------------------------------------- + BMPs come in various kinds, distinguished by the length of their + info header, which is the first field in that header. + + These are those lengths. +-----------------------------------------------------------------------------*/ + BMP_HDRLEN_OS2_1x = 12, + /* BITMAPCOREHEADER; since Windows 2.0, OS/2 1.x */ + BMP_HDRLEN_OS2_2x = 64, + /* not documented by Microsoft; since OS/2 2.x */ + BMP_HDRLEN_WIN_V1 = 40, + /* BITMAPINFOHEADER; since Windows NT 3, Windows 3.x */ + BMP_HDRLEN_WIN_V2 = 52, + /* not documented by Microsoft */ + BMP_HDRLEN_WIN_V3 = 56, + /* not documented by Microsoft */ + BMP_HDRLEN_WIN_V4 = 108, + /* BITMAPV4HEADER; since Windows NT 4, Windows 95 */ + BMP_HDRLEN_WIN_V5 = 124 + /* BITMAPV5HEADER; since Windows 2000, Windows 98 */ +}; + + + +static __inline__ unsigned int +BMPleninfoheader(enum bmpClass const class) { unsigned int retval; switch (class) { - case C_WIN: retval = 14; break; - case C_OS2: retval = 14; break; + case BMP_C_WIN_V1: retval = BMP_HDRLEN_WIN_V1; break; + case BMP_C_WIN_V2: retval = BMP_HDRLEN_WIN_V2; break; + case BMP_C_WIN_V3: retval = BMP_HDRLEN_WIN_V3; break; + case BMP_C_WIN_V4: retval = BMP_HDRLEN_WIN_V4; break; + case BMP_C_WIN_V5: retval = BMP_HDRLEN_WIN_V5; break; + case BMP_C_OS2_1x: retval = BMP_HDRLEN_OS2_1x; break; + case BMP_C_OS2_2x: retval = BMP_HDRLEN_OS2_2x; break; } return retval; } +static __inline__ void +BMPdetermineclass(unsigned int const infoHdrLen, + enum bmpClass * const classP, + const char ** const errorP) { +/*---------------------------------------------------------------------------- + Determine the class of BMP, based on the fact that the info header is + 'infoHdrLen' bytes long. +-----------------------------------------------------------------------------*/ + switch (infoHdrLen) { + case BMP_HDRLEN_OS2_1x: *errorP = NULL; *classP = BMP_C_OS2_1x; break; + case BMP_HDRLEN_OS2_2x: *errorP = NULL; *classP = BMP_C_OS2_2x; break; + case BMP_HDRLEN_WIN_V1: *errorP = NULL; *classP = BMP_C_WIN_V1; break; + case BMP_HDRLEN_WIN_V2: *errorP = NULL; *classP = BMP_C_WIN_V2; break; + case BMP_HDRLEN_WIN_V3: *errorP = NULL; *classP = BMP_C_WIN_V3; break; + case BMP_HDRLEN_WIN_V4: *errorP = NULL; *classP = BMP_C_WIN_V4; break; + case BMP_HDRLEN_WIN_V5: *errorP = NULL; *classP = BMP_C_WIN_V5; break; + + default: + pm_asprintf(errorP, "Not one of the 7 lengths we recognize"); + } +} + + + static __inline__ unsigned int -BMPleninfoheader(enum bmpClass const class) { +BMPlenrgb(enum bmpClass const class) { - unsigned int retval; + unsigned int lenrgb; switch (class) { - case C_WIN: retval = 40; break; - case C_OS2: retval = 12; break; + case BMP_C_OS2_1x: + case BMP_C_OS2_2x: + lenrgb = 3; + break; + case BMP_C_WIN_V1: + case BMP_C_WIN_V2: + case BMP_C_WIN_V3: + case BMP_C_WIN_V4: + case BMP_C_WIN_V5: + lenrgb = 4; + break; } - return retval; + return lenrgb; } @@ -152,7 +253,6 @@ BMPlencolormap(enum bmpClass const class, 'cmapsize' == 0 means there is no palette. -----------------------------------------------------------------------------*/ - unsigned int lenrgb; unsigned int lencolormap; if (bitcount < 1) @@ -160,15 +260,10 @@ BMPlencolormap(enum bmpClass const class, else if (bitcount > 8) lencolormap = 0; else { - switch (class) { - case C_WIN: lenrgb = 4; break; - case C_OS2: lenrgb = 3; break; - } - - if (!cmapsize) - lencolormap = (1 << bitcount) * lenrgb; + if (cmapsize) + lencolormap = cmapsize * BMPlenrgb(class); else - lencolormap = cmapsize * lenrgb; + lencolormap = (1 << bitcount) * BMPlenrgb(class); } return lencolormap; } @@ -231,7 +326,7 @@ BMPoffbits(enum bmpClass const class, /*---------------------------------------------------------------------------- return the offset to the BMP image bits. -----------------------------------------------------------------------------*/ - return BMPlenfileheader(class) + return BMPlenfileheader() + BMPleninfoheader(class) + BMPlencolormap(class, bitcount, cmapsize); } diff --git a/converter/other/anytopnm b/converter/other/anytopnm index 397faae5..e5de85cc 100755 --- a/converter/other/anytopnm +++ b/converter/other/anytopnm @@ -527,14 +527,18 @@ if [ $# -gt 1 ] ; then "input file name." 1>&2 exit 1 elif [ $# -eq 1 ] ; then - inputFile="$1" + if [ $1 = "--version" -o $1 = "-version" ] ; then + pamtopnm --version ; exit $? + else + inputFile="$1" + fi else - inputFile="-" + inputFile="-" + fi -tempdir="${TMPDIR-/tmp}/anytopnm.$$" -mkdir -m 0700 $tempdir || \ - { echo "Could not create temporary file. Exiting."; exit 1;} +tempdir=$(mktemp -d "${TMPDIR:-/tmp}/anytopnm.XXXXXXXX") || + ( echo "Could not create temporary file. Exiting." 1>&2; exit 1; ) trap 'rm -rf $tempdir' 0 # Take out all spaces diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c index bb49f4a4..c39b4fd7 100644 --- a/converter/other/bmptopnm.c +++ b/converter/other/bmptopnm.c @@ -80,6 +80,19 @@ struct pixelformat { */ }; +typedef struct { + /* These are all encodings of floating point */ + unsigned long x; + unsigned long y; + unsigned long z; +} cieXyz; + +typedef struct { + cieXyz red; + cieXyz grn; + cieXyz blu; +} cieXyzTriple; + struct bmpInfoHeader { enum rowOrder rowOrder; unsigned int cols; @@ -103,6 +116,7 @@ struct bmpInfoHeader { unsigned short cPlanes; BMPCompType compression; struct pixelformat pixelformat; + cieXyzTriple endPoints; }; @@ -208,21 +222,30 @@ GetLong(FILE * const fp) { -typedef struct { - long dummy[12]; -} cieXyzTriple; +static cieXyz +GetCieXyz(FILE * const ifP) { + + cieXyz retval; + + retval.x = GetLong(ifP); + retval.y = GetLong(ifP); + retval.z = GetLong(ifP); + + return retval; +} + + static cieXyzTriple -GetCieXyzTriple(FILE * const fp) { +GetCieXyzTriple(FILE * const ifP) { - cieXyzTriple v; - unsigned int i; + cieXyzTriple retval; - for (i = 0; i < 12; ++i) - if (pm_readlittlelong(fp, &v.dummy[i]) == -1) - pm_error(er_read, ifname); + retval.red = GetCieXyz(ifP); + retval.grn = GetCieXyz(ifP); + retval.blu = GetCieXyz(ifP); - return v; + return retval; } @@ -249,11 +272,7 @@ bmpReadfileheader(FILE * const ifP, unsigned int * const bytesReadP, unsigned int * const offBitsP) { - unsigned short xHotSpot; - unsigned short yHotSpot; unsigned long offBits; - unsigned long int fileSize; - if (GetByte(ifP) != 'B') pm_error("'%s' is not a BMP file. (It doesn't start with 'BM')", @@ -263,27 +282,27 @@ bmpReadfileheader(FILE * const ifP, ifname); - fileSize = GetLong(ifP); /* This is not always reliable. */ - xHotSpot = GetShort(ifP); - yHotSpot = GetShort(ifP); + /* fileSize = */ GetLong(ifP); /* This is not always reliable. */ + /* xHotSpot = */ GetShort(ifP); + /* yHotSpot = */ GetShort(ifP); offBits = GetLong(ifP); *offBitsP = offBits; + assert(BMPlenfileheader() == 14); + *bytesReadP = 14; } static void -readOs2InfoHeader(FILE * const ifP, - struct bmpInfoHeader * const headerP) { +readOs2InfoHeaderRest(FILE * const ifP, + struct bmpInfoHeader * const headerP) { unsigned short colsField, rowsField; unsigned short planesField, bitCountField; - headerP->class = C_OS2; - pm_readlittleshortu(ifP, &colsField); if (colsField == 0) pm_error("Invalid BMP file: says width is zero"); @@ -319,9 +338,6 @@ readOs2InfoHeader(FILE * const ifP, headerP->cBitCount); headerP->compression = BMPCOMP_RGB; - - pm_message("OS/2 BMP, %dx%dx%d", - headerP->cols, headerP->rows, headerP->cBitCount); } @@ -366,12 +382,9 @@ readWindowsBasic40ByteInfoHeader(FILE * const ifP, Return the information from the info header as *headerP. -----------------------------------------------------------------------------*/ - int colorsimportant; /* ColorsImportant value from header */ int colorsused; /* ColorsUsed value from header */ unsigned short planesField, bitCountField; - headerP->class = C_WIN; - headerP->cols = GetLong(ifP); if (headerP->cols == 0) pm_error("Invalid BMP file: says width is zero"); @@ -410,7 +423,7 @@ readWindowsBasic40ByteInfoHeader(FILE * const ifP, /* See comments in bmp.h for info about the definition of the following word and its relationship to the color map size (headerP->cmapsize). */ - colorsimportant = GetLong(ifP); /* ColorsImportant */ + /* colorsimportant = */ GetLong(ifP); /* ColorsImportant */ if (headerP->cBitCount <= 8) { if (colorsused != 0) { @@ -544,7 +557,15 @@ defaultPixelformat(unsigned int const bitCount) { static void readV4InfoHeaderExtension(FILE * const ifP, - struct bmpInfoHeader * const headerP) { + struct bmpInfoHeader * const headerP, + unsigned int * const bytesReadP) { + + unsigned long redMsk, grnMsk, bluMsk, trnMsk; + + redMsk = GetLong(ifP); + grnMsk = GetLong(ifP); + bluMsk = GetLong(ifP); + trnMsk = GetLong(ifP); if (headerP->bitFields) { /* A document from Microsoft says on Windows 95 there is no @@ -552,25 +573,44 @@ readV4InfoHeaderExtension(FILE * const ifP, (5,5,5) or (5,6,5) for 16 bit and (8,8,8) for 32 bit. It calls these RGB555, RGB565, RGB888. */ - headerP->pixelformat.red = bitPositionFromMask(GetLong(ifP)); - headerP->pixelformat.grn = bitPositionFromMask(GetLong(ifP)); - headerP->pixelformat.blu = bitPositionFromMask(GetLong(ifP)); - headerP->pixelformat.trn = bitPositionFromMask(GetLong(ifP)); + headerP->pixelformat.red = bitPositionFromMask(redMsk); + headerP->pixelformat.grn = bitPositionFromMask(grnMsk); + headerP->pixelformat.blu = bitPositionFromMask(bluMsk); + headerP->pixelformat.trn = bitPositionFromMask(trnMsk); computeConventionalBgr(&headerP->pixelformat, headerP->cBitCount); } else headerP->pixelformat = defaultPixelformat(headerP->cBitCount); GetLong(ifP); /* Color space */ - GetCieXyzTriple(ifP); /* Endpoints */ + + headerP->endPoints = GetCieXyzTriple(ifP); /* 36 bytes */ + GetLong(ifP); /* GammaRed */ GetLong(ifP); /* GammaGreen */ GetLong(ifP); /* GammaBlue */ + + *bytesReadP = 68; } static void +readV5InfoHeaderExtension(FILE * const ifP, + struct bmpInfoHeader * const headerP, + unsigned int * const bytesReadP) { + + GetLong(ifP); /* Intent */ + GetLong(ifP); /* ProfileData */ + GetLong(ifP); /* ProfileSize */ + GetLong(ifP); /* Reserved */ + + *bytesReadP = 16; +} + + + +static void defaultV4InfoHeaderExtension(struct bmpInfoHeader * const headerP) { headerP->pixelformat = defaultPixelformat(headerP->cBitCount); @@ -580,9 +620,9 @@ defaultV4InfoHeaderExtension(struct bmpInfoHeader * const headerP) { static void -readWindowsInfoHeader(FILE * const ifP, - unsigned int const cInfoHeaderSize, - struct bmpInfoHeader * const headerP) { +readWindowsInfoHeaderRest(FILE * const ifP, + unsigned int const cInfoHeaderSize, + struct bmpInfoHeader * const headerP) { /* There are 3 major formats of Windows BMP, identified by the 3 info header lengths. The original @@ -590,23 +630,34 @@ readWindowsInfoHeader(FILE * const ifP, new with Windows 95 and NT 4.0. The "V5 header" is 124 bytes and was new with Windows 98 and Windows 2000. */ + unsigned int bytesRead; + readWindowsBasic40ByteInfoHeader(ifP, headerP); - if (cInfoHeaderSize >= 108) - readV4InfoHeaderExtension(ifP, headerP); - else + bytesRead = 40; + + if (cInfoHeaderSize >= BMP_HDRLEN_WIN_V4) { + unsigned int v4BytesRead; + readV4InfoHeaderExtension(ifP, headerP, &v4BytesRead); + bytesRead += v4BytesRead; + + assert(bytesRead == BMP_HDRLEN_WIN_V4); + } else defaultV4InfoHeaderExtension(headerP); - if (cInfoHeaderSize >= 124) { - /* Read off the V5 info header extension. */ - GetLong(ifP); /* Intent */ - GetLong(ifP); /* ProfileData */ - GetLong(ifP); /* ProfileSize */ - GetLong(ifP); /* Reserved */ + if (cInfoHeaderSize >= BMP_HDRLEN_WIN_V5) { + unsigned int v5BytesRead; + readV5InfoHeaderExtension(ifP, headerP, &v5BytesRead); + bytesRead += v5BytesRead; + assert(bytesRead == BMP_HDRLEN_WIN_V5); } - pm_message("Windows BMP, %dx%dx%d", - headerP->cols, headerP->rows, headerP->cBitCount); + for (; bytesRead < cInfoHeaderSize;) { + GetByte(ifP); + ++bytesRead; + } + + assert(bytesRead == cInfoHeaderSize); } @@ -614,38 +665,43 @@ readWindowsInfoHeader(FILE * const ifP, static void bmpReadinfoheader(FILE * const ifP, unsigned int * const bytesReadP, - struct bmpInfoHeader * const headerP) { + struct bmpInfoHeader * const headerP, + const char ** const errorP) { unsigned int const cInfoHeaderSize = GetLong(ifP); - switch (cInfoHeaderSize) { - case 12: - readOs2InfoHeader(ifP, headerP); - break; - case 40: - readWindowsInfoHeader(ifP, cInfoHeaderSize, headerP); - break; - case 108: - pm_error("%s: this is a Version 4 Windows BMP; " - "this program knows only Version 1"); - break; - case 124: - pm_error("%s: this is a Version 5 Windows BMP; " - "this program knows only Version 1"); - break; - default: - pm_error("%s: unknown Info Header size: %u bytes", - ifname, cInfoHeaderSize); - break; + const char * error; + + BMPdetermineclass(cInfoHeaderSize, &headerP->class, &error); + + if (error) { + pm_asprintf(errorP, "Cannot determine the class of BMP from the " + "info header size %u. %s", cInfoHeaderSize, error); + pm_strfree(error); + } else { + switch (headerP->class) { + case BMP_C_WIN_V1: + case BMP_C_WIN_V2: + case BMP_C_WIN_V3: + case BMP_C_WIN_V4: + case BMP_C_WIN_V5: + readWindowsInfoHeaderRest(ifP, cInfoHeaderSize, headerP); + break; + case BMP_C_OS2_1x: + case BMP_C_OS2_2x: + readOs2InfoHeaderRest(ifP, headerP); + break; + } + *errorP = NULL; + *bytesReadP = cInfoHeaderSize; } - *bytesReadP = cInfoHeaderSize; } static void bmpReadColormap(FILE * const ifP, - int const class, + enum bmpClass const class, xel ** const colormapP, unsigned int const cmapsize, unsigned int * const bytesReadP) { @@ -661,36 +717,32 @@ bmpReadColormap(FILE * const ifP, 'class' is the class of BMP image - Windows or OS/2. -----------------------------------------------------------------------------*/ - + xel * const colormap = pnm_allocrow(MAX(1, cmapsize)); + unsigned int i; - - xel * colormap; unsigned int bytesRead; - colormap = pnm_allocrow(MAX(1,cmapsize)); - - bytesRead = 0; /* initial value */ - - for (i = 0; i < cmapsize; ++i) { + for (i = 0, bytesRead = 0; i < cmapsize; ++i) { /* There is a document that says the bytes are ordered R,G,B,Z, but in practice it appears to be the following instead: */ - unsigned int r, g, b; - - b = GetByte(ifP); - g = GetByte(ifP); - r = GetByte(ifP); + unsigned int const b = GetByte(ifP); + unsigned int const g = GetByte(ifP); + unsigned int const r = GetByte(ifP); + + unsigned int j; PNM_ASSIGN(colormap[i], r, g, b); bytesRead += 3; - if (class == C_WIN) { + for (j = 3; j < BMPlenrgb(class); ++j) { GetByte(ifP); bytesRead += 1; } } - *colormapP = colormap; + + *colormapP = colormap; *bytesReadP = bytesRead; } @@ -1199,22 +1251,28 @@ bmpReadraster(FILE * const ifP, static void reportHeader(struct bmpInfoHeader const header, - unsigned int const offBits) { + unsigned int const offBits, + bool const verbose) { - pm_message("BMP image header says:"); - pm_message(" Class of BMP: %s", - header.class == C_WIN ? "Windows" : - header.class == C_OS2 ? "OS/2" : - "???"); - pm_message(" Width: %d pixels", header.cols); - pm_message(" Height: %d pixels", header.rows); - pm_message(" Depth: %d planes", header.cPlanes); - pm_message(" Row order: %s", - header.rowOrder == BOTTOMUP ? "bottom up" : "top down"); - pm_message(" Byte offset of raster within file: %u", offBits); - pm_message(" Bits per pixel in raster: %u", header.cBitCount); - pm_message(" Compression: %s", BMPCompTypeName(header.compression)); - pm_message(" Colors in color map: %u", header.cmapsize); + if (verbose) { + pm_message("BMP image header says:"); + pm_message(" Class of BMP: %s", BMPClassName(header.class)); + pm_message(" Width: %d pixels", header.cols); + pm_message(" Height: %d pixels", header.rows); + pm_message(" Depth: %d planes", header.cPlanes); + pm_message(" Row order: %s", + header.rowOrder == BOTTOMUP ? "bottom up" : "top down"); + pm_message(" Byte offset of raster within file: %u", offBits); + pm_message(" Bits per pixel in raster: %u", header.cBitCount); + pm_message(" Compression: %s", BMPCompTypeName(header.compression)); + pm_message(" Colors in color map: %u", header.cmapsize); + } else { + pm_message("%s BMP, %ux%ux%u", + BMPClassName(header.class), + header.cols, + header.rows, + header.cBitCount); + } } @@ -1352,14 +1410,18 @@ readBmp(FILE * const ifP, } { unsigned int bytesRead; - bmpReadinfoheader(ifP, &bytesRead, &bmpHeader); + const char * error; + bmpReadinfoheader(ifP, &bytesRead, &bmpHeader, &error); + if (error) + pm_error("Failed to read the BMP info header. Image may " + "not be a valid BMP. %s", error); + if (verbose) pm_message("Read %u bytes of header", bytesRead); pos += bytesRead; } - if (verbose) - reportHeader(bmpHeader, offBits); + reportHeader(bmpHeader, offBits, verbose); warnIfOffBitsWrong(bmpHeader, offBits); diff --git a/converter/other/cameratopam/camera.c b/converter/other/cameratopam/camera.c index a1adba95..04a6ed01 100644 --- a/converter/other/cameratopam/camera.c +++ b/converter/other/cameratopam/camera.c @@ -1504,12 +1504,12 @@ get_timestamp(FILE * const ifp) static void parse_exif(FILE * const ifp, int base) { - int entries, tag, type, len, val, save; + int entries, tag, len, val, save; entries = get2(ifp); while (entries--) { tag = get2(ifp); - type = get2(ifp); + /* type = */ get2(ifp); len = get4(ifp); val = get4(ifp); save = ftell(ifp); diff --git a/converter/other/fiasco/binerror.c b/converter/other/fiasco/binerror.c index 77243c64..80a2e461 100644 --- a/converter/other/fiasco/binerror.c +++ b/converter/other/fiasco/binerror.c @@ -7,8 +7,8 @@ * Credits: Modelled after variable argument routines from Jef * Poskanzer's pbmplus package. * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/binerror.h b/converter/other/fiasco/binerror.h index e7ff43c9..4f313aca 100644 --- a/converter/other/fiasco/binerror.h +++ b/converter/other/fiasco/binerror.h @@ -4,8 +4,8 @@ * Written by: Stefan Frank * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/buttons.c b/converter/other/fiasco/buttons.c index 82ed18cd..fc54d84a 100644 --- a/converter/other/fiasco/buttons.c +++ b/converter/other/fiasco/buttons.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/buttons.h b/converter/other/fiasco/buttons.h index a09f3423..079715f5 100644 --- a/converter/other/fiasco/buttons.h +++ b/converter/other/fiasco/buttons.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/approx.c b/converter/other/fiasco/codec/approx.c index 5072fae3..d47bac62 100644 --- a/converter/other/fiasco/codec/approx.c +++ b/converter/other/fiasco/codec/approx.c @@ -1,10 +1,10 @@ /* - * approx.c: Approximation of range images with matching pursuit + * approx.c: Approximation of range images with matching pursuit * - * Written by: 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> + * Written by: Ullrich Hafner + * + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* @@ -34,7 +34,7 @@ /***************************************************************************** - local variables + local variables *****************************************************************************/ @@ -52,227 +52,205 @@ typedef struct mp /***************************************************************************** - prototypes + prototypes *****************************************************************************/ static void orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm, - const word_t *domain_blocks, const coding_t *c); + const word_t *domain_blocks, const coding_t *c); 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, - const wfa_t *wfa, const coding_t *c); + unsigned max_edges, int y_state, const range_t *range, + const domain_pool_t *domain_pool, const coeff_t *coeff, + const wfa_t *wfa, const coding_t *c); /***************************************************************************** - public code + public code *****************************************************************************/ 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 - * 'matching_pursuit()' for more details about parameters. - * - * Return value: - * approximation costs - */ -{ - mp_t mp; - bool_t success = NO; - - /* - * First approximation attempt: default matching pursuit algorithm. - */ - mp.exclude [0] = NO_EDGE; - matching_pursuit (&mp, c->options.full_search, price, max_edges, - y_state, range, domain_pool, coeff, wfa, c); - - /* - * Next approximation attempt: remove domain block mp->indices [0] - * from domain pool (vector with smallest costs) and run the - * matching pursuit again. - */ - if (c->options.second_domain_block) - { - mp_t tmp_mp = mp; + 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 + 'matching_pursuit()' for more details about parameters. + + Return value: approximation costs +-----------------------------------------------------------------------------*/ + mp_t mp; + + /* + * First approximation attempt: default matching pursuit algorithm. + */ + mp.exclude [0] = NO_EDGE; + matching_pursuit(&mp, c->options.full_search, price, max_edges, + y_state, range, domain_pool, coeff, wfa, c); + + /* + * Next approximation attempt: remove domain block mp->indices [0] + * from domain pool (vector with smallest costs) and run the + * matching pursuit again. + */ + if (c->options.second_domain_block) { + mp_t tmp_mp; - 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 */ - { - success = YES; - mp = tmp_mp; - } - } - - /* - * Next approximation attempt: check whether some coefficients have - * been quantized to zero. Vectors causing the underflow are - * removed from the domain pool and then the matching pursuit - * algorithm is run again (until underflow doesn't occur anymore). - */ - if (c->options.check_for_underflow) - { - int iteration = -1; - mp_t tmp_mp = mp; - - 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); - if (tmp_mp.costs < mp.costs) /* success */ - { - success = YES; - mp = tmp_mp; - } - } - } while (isdomain (tmp_mp.exclude [iteration]) - && iteration < MAXEDGES - 1); - } - - /* - * Next approximation attempt: check whether some coefficients have - * been quantized to +/- max-value. Vectors causing the overflow are - * removed from the domain pool and then the matching pursuit - * algorithm is run again (until overflow doesn't occur anymore). - */ - if (c->options.check_for_overflow) - { - int iteration = -1; - mp_t tmp_mp = 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 */ + mp = tmp_mp; + } + + /* + * Next approximation attempt: check whether some coefficients have + * been quantized to zero. Vectors causing the underflow are + * removed from the domain pool and then the matching pursuit + * algorithm is run again (until underflow doesn't occur anymore). + */ + if (c->options.check_for_underflow) { + mp_t tmp_mp; + int iteration; + + tmp_mp = mp; /* initial value */ + iteration = -1; /* initial value */ - do - { - int i; + 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); + if (tmp_mp.costs < mp.costs) /* success */ + mp = tmp_mp; + } + } while (isdomain (tmp_mp.exclude [iteration]) + && iteration < MAXEDGES - 1); + } + + /* + * Next approximation attempt: check whether some coefficients have + * been quantized to +/- max-value. Vectors causing the overflow are + * removed from the domain pool and then the matching pursuit + * algorithm is run again (until overflow doesn't occur anymore). + */ + if (c->options.check_for_overflow) { + mp_t tmp_mp; + int iteration; + + 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++) - { - rpf_t *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; - } - } + ++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); - if (tmp_mp.costs < mp.costs) /* success */ - { - success = YES; - mp = tmp_mp; - } - } - } while (isdomain (tmp_mp.exclude [iteration]) - && iteration < MAXEDGES - 1); - } - - /* - * Finally, check whether the best approximation has costs - * smaller than 'max_costs'. - */ - if (mp.costs < max_costs) - { - int edge; - bool_t overflow = NO; - bool_t underflow = NO; - int new_index, old_index; - - new_index = 0; - for (old_index = 0; isdomain (mp.indices [old_index]); old_index++) - if (mp.weight [old_index] != 0) - { - rpf_t *rpf = mp.indices [old_index] ? coeff->rpf : coeff->dc_rpf; - - if (mp.weight [old_index] == btor (rtob (200, rpf), rpf) - || mp.weight [old_index] == btor (rtob (-200, rpf), rpf)) - overflow = YES; - - mp.indices [new_index] = mp.indices [old_index]; - mp.into [new_index] = mp.into [old_index]; - mp.weight [new_index] = mp.weight [old_index]; - new_index++; - } - else - underflow = YES; + 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); + if (tmp_mp.costs < mp.costs) /* success */ + mp = tmp_mp; + } + } while (isdomain (tmp_mp.exclude [iteration]) + && iteration < MAXEDGES - 1); + } + + /* + * Finally, check whether the best approximation has costs + * smaller than 'max_costs'. + */ + if (mp.costs < max_costs) { + int edge; + int new_index, old_index; + + new_index = 0; + for (old_index = 0; isdomain (mp.indices[old_index]); ++old_index) { + if (mp.weight [old_index] != 0) { + mp.indices [new_index] = mp.indices [old_index]; + mp.into [new_index] = mp.into [old_index]; + mp.weight [new_index] = mp.weight [old_index]; + ++new_index; + } + } + mp.indices [new_index] = NO_EDGE; + mp.into [new_index] = NO_EDGE; + + /* + * Update of probability models + */ + { + word_t * const domain_blocks = + domain_pool->generate(range->level, y_state, + wfa, + domain_pool->model); + domain_pool->update(domain_blocks, mp.indices, + range->level, y_state, wfa, + domain_pool->model); + coeff->update (mp.weight, mp.into, range->level, coeff); + + Free(domain_blocks); + } - mp.indices [new_index] = NO_EDGE; - mp.into [new_index] = NO_EDGE; - - /* - * Update of probability models - */ - { - word_t *domain_blocks = domain_pool->generate (range->level, y_state, - wfa, - domain_pool->model); - domain_pool->update (domain_blocks, mp.indices, - 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]; - } - range->into [edge] = NO_EDGE; - range->matrix_bits = mp.matrix_bits; - range->weights_bits = mp.weights_bits; - range->err = mp.err; - } - else - { - range->into [0] = NO_EDGE; - mp.costs = MAXCOSTS; - } + for (edge = 0; isedge (mp.indices [edge]); ++edge) { + range->into [edge] = mp.into [edge]; + range->weight [edge] = mp.weight [edge]; + } + range->into [edge] = NO_EDGE; + range->matrix_bits = mp.matrix_bits; + range->weights_bits = mp.weights_bits; + range->err = mp.err; + } else { + range->into [0] = NO_EDGE; + mp.costs = MAXCOSTS; + } - return mp.costs; + return mp.costs; } + + /***************************************************************************** - local variables + local variables *****************************************************************************/ @@ -310,15 +288,15 @@ static bool_t used [MAXSTATES]; /***************************************************************************** - private code + private code *****************************************************************************/ 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, - const wfa_t *wfa, const coding_t *c) + unsigned max_edges, int y_state, const range_t *range, + const domain_pool_t *domain_pool, const coeff_t *coeff, + const wfa_t *wfa, const coding_t *c) /* * Find an approximation of the current 'range' with a linear * combination of vectors of the 'domain_pool'. The linear @@ -339,38 +317,38 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price, * No return value. * * Side effects: - * vectors, factors, rate, distortion and costs are stored in 'mp' + * vectors, factors, rate, distortion and costs are stored in 'mp' */ { - unsigned n; /* current vector of the OB */ - int index; /* best fitting domain image */ - unsigned domain; /* counter */ - real_t norm; /* norm of range image */ - real_t additional_bits; /* bits for mc, nd, and tree */ - word_t *domain_blocks; /* current set of domain images */ - const real_t min_norm = 2e-3; /* lower bound of norm */ - unsigned best_n = 0; - unsigned size = size_of_level (range->level); + unsigned n; /* current vector of the OB */ + int index; /* best fitting domain image */ + unsigned domain; /* counter */ + real_t norm; /* norm of range image */ + real_t additional_bits; /* bits for mc, nd, and tree */ + word_t *domain_blocks; /* current set of domain images */ + 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 */ domain_blocks = domain_pool->generate (range->level, y_state, wfa, - domain_pool->model); + domain_pool->model); for (domain = 0; domain_blocks [domain] >= 0; domain++) { used [domain] = NO; - rem_denominator [domain] /* norm of domain */ - = get_ip_state_state (domain_blocks [domain], domain_blocks [domain], - range->level, c); + rem_denominator [domain] /* norm of domain */ + = get_ip_state_state (domain_blocks [domain], domain_blocks [domain], + range->level, c); if (rem_denominator [domain] / size < min_norm) - used [domain] = YES; /* don't use domains with small norm */ + used [domain] = YES; /* don't use domains with small norm */ else - rem_numerator [domain] /* inner product <s_domain, b> */ - = get_ip_image_state (range->image, range->address, - range->level, domain_blocks [domain], c); + rem_numerator [domain] /* inner product <s_domain, b> */ + = get_ip_image_state (range->image, range->address, + range->level, domain_blocks [domain], c); if (!used [domain] && fabs (rem_numerator [domain]) < min_norm) - used [domain] = YES; + used [domain] = YES; } /* @@ -389,15 +367,15 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price, norm += square (c->pixels [range->address * size + n]); additional_bits = range->tree_bits + range->mv_tree_bits - + range->mv_coord_bits + range->nd_tree_bits - + range->nd_weights_bits; + + range->mv_coord_bits + range->nd_tree_bits + + range->nd_weights_bits; mp->err = norm; mp->weights_bits = 0; mp->matrix_bits = domain_pool->bits (domain_blocks, NULL, range->level, - y_state, wfa, domain_pool->model); + y_state, wfa, domain_pool->model); mp->costs = (mp->matrix_bits + mp->weights_bits - + additional_bits) * price + mp->err; + + additional_bits) * price + mp->err; n = 0; do @@ -406,7 +384,7 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price, * Current approximation is: b = d_0 o_0 + ... + d_(n-1) o_(n-1) * with corresponding costs 'range->err + range->bits * p'. * For all remaining state images s_i (used[s_i] == NO) set - * o_n : = s_i - \sum(k = 0, ... , n-1) {(<s_i, o_k> / ||o_k||^2) o_k} + * o_n : = s_i - \sum(k = 0, ... , n-1) {(<s_i, o_k> / ||o_k||^2) o_k} * and try to beat current costs. * Choose that vector for the next orthogonalization step, * which has minimal costs: s_index. @@ -415,235 +393,235 @@ matching_pursuit (mp_t *mp, bool_t full_search, real_t price, real_t min_matrix_bits = 0; real_t min_weights_bits = 0; - real_t min_error = 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]) - { - real_t matrix_bits, weights_bits; - /* - * To speed up the search through the domain images, - * the costs of using domain image 'domain' as next vector - * can be approximated in a first step: - * improvement of image quality - * <= square (rem_numerator[domain]) / rem_denominator[domain] - */ - { - word_t vectors [MAXEDGES + 1]; - 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) - { - vectors [i] = mp->indices [k]; - states [i] = domain_blocks [vectors [i]]; - weights [i] = mp->weight [k]; - i++; - } - vectors [i] = domain; - states [i] = domain_blocks [domain]; - weights [i] = 0.5; - vectors [i + 1] = -1; - states [i + 1] = -1; - - weights_bits = coeff->bits (weights, states, range->level, - coeff); - matrix_bits = domain_pool->bits (domain_blocks, vectors, - range->level, y_state, - wfa, domain_pool->model); - } - if (((matrix_bits + weights_bits + additional_bits) * price + - mp->err - - square (rem_numerator [domain]) / rem_denominator [domain]) - < min_costs) - { - /* - * 1.) Compute the weights (linear factors) c_i of the - * linear combination - * b = c_0 v_0 + ... + c_(n-1) v_(n-1) + c_n v_'domain' - * Use backward substitution to obtain c_i from the linear - * factors of the lin. comb. b = d_0 o_0 + ... + d_n o_n - * of the corresponding orthogonal vectors {o_0, ..., o_n}. - * Vector o_n of the orthogonal basis is obtained by using - * vector 'v_domain' in step n of the Gram Schmidt - * orthogonalization (see above for definition of o_n). - * Recursive formula for the coefficients c_i: - * c_n := <b, o_n> / ||o_n||^2 - * for i = n - 1, ... , 0: - * c_i := <b, o_i> / ||o_i||^2 + - * \sum (k = i + 1, ... , n){ c_k <v_k, o_i> - * / ||o_i||^2 } - * 2.) Because linear factors are stored with reduced precision - * factor c_i is rounded with the given precision in step i - * of the recursive formula. - */ - - unsigned k; /* counter */ - int l; /* counter */ - real_t m_bits; /* number of matrix bits to store */ - real_t w_bits; /* number of weights bits to store */ - real_t r [MAXEDGES]; /* rounded linear factors */ - real_t f [MAXEDGES]; /* linear factors */ - int v [MAXEDGES]; /* mapping of domains to vectors */ - real_t costs; /* current approximation costs */ - real_t m_err; /* current approximation error */ - - f [n] = rem_numerator [domain] / rem_denominator [domain]; - v [n] = domain; /* corresponding mapping */ - for (k = 0; k < n; k++) - { - f [k] = ip_image_ortho_vector [k] / norm_ortho_vector [k]; - v [k] = mp->indices [k]; - } - - for (l = n; l >= 0; l--) - { - rpf_t *rpf = domain_blocks [v [l]] - ? coeff->rpf : coeff->dc_rpf; - - r [l] = f [l] = btor (rtob (f [l], rpf), rpf); - - for (k = 0; k < (unsigned) l; k++) - f [k] -= f [l] * ip_domain_ortho_vector [v [l]][k] - / norm_ortho_vector [k] ; - } - - /* - * Compute the number of output bits of the linear combination - * and store the weights with reduced precision. The - * resulting linear combination is - * b = r_0 v_0 + ... + r_(n-1) v_(n-1) + r_n v_'domain' - */ - { - word_t vectors [MAXEDGES + 1]; - word_t states [MAXEDGES + 1]; - real_t weights [MAXEDGES + 1]; - int i; - - for (i = 0, k = 0; k <= n; k++) - if (f [k] != 0) - { - vectors [i] = v [k]; - states [i] = domain_blocks [v [k]]; - weights [i] = f [k]; - i++; - } - vectors [i] = -1; - states [i] = -1; - - w_bits = coeff->bits (weights, states, range->level, coeff); - m_bits = domain_pool->bits (domain_blocks, vectors, - range->level, y_state, - wfa, domain_pool->model); - } - - /* - * To compute the approximation error, the corresponding - * 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: - * r_i := r_i + - * \sum (k = i + 1, ... , n) { r_k <v_k, o_i> - * / ||o_i||^2 } - */ - for (l = 0; (unsigned) l <= n; l++) - { - /* - * compute <v_n, o_n> - */ - real_t a; - - a = get_ip_state_state (domain_blocks [v [l]], - domain_blocks [domain], - range->level, c); - for (k = 0; k < n; k++) - a -= ip_domain_ortho_vector [v [l]][k] - / norm_ortho_vector [k] - * ip_domain_ortho_vector [domain][k]; - ip_domain_ortho_vector [v [l]][n] = a; - } - 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] - / norm_ortho_vector [k]; - /* - * Compute approximation error: - * error := ||b||^2 + - * \sum (k = 0, ... , n){r_k^2 ||o_k||^2 - 2 r_k <b, o_k>} - */ - m_err = norm; - for (k = 0; k <= n; k++) - m_err += square (r [k]) * norm_ortho_vector [k] - - 2 * r [k] * ip_image_ortho_vector [k]; - if (m_err < 0) /* TODO: return MAXCOSTS */ - warning ("Negative image norm: %f" - " (current domain: %d, level = %d)", - (double) m_err, domain, range->level); - - costs = (m_bits + w_bits + additional_bits) * price + m_err; - if (costs < min_costs) /* found a better approximation */ - { - index = domain; - min_costs = costs; - min_matrix_bits = m_bits; - min_weights_bits = w_bits; - min_error = m_err; - for (k = 0; k <= n; k++) - min_weight [k] = f [k]; - } - } - } + if (!used [domain]) + { + real_t matrix_bits, weights_bits; + /* + * To speed up the search through the domain images, + * the costs of using domain image 'domain' as next vector + * can be approximated in a first step: + * improvement of image quality + * <= square (rem_numerator[domain]) / rem_denominator[domain] + */ + { + word_t vectors [MAXEDGES + 1]; + 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) + { + vectors [i] = mp->indices [k]; + states [i] = domain_blocks [vectors [i]]; + weights [i] = mp->weight [k]; + i++; + } + vectors [i] = domain; + states [i] = domain_blocks [domain]; + weights [i] = 0.5; + vectors [i + 1] = -1; + states [i + 1] = -1; + + weights_bits = coeff->bits (weights, states, range->level, + coeff); + matrix_bits = domain_pool->bits (domain_blocks, vectors, + range->level, y_state, + wfa, domain_pool->model); + } + if (((matrix_bits + weights_bits + additional_bits) * price + + mp->err - + square (rem_numerator [domain]) / rem_denominator [domain]) + < min_costs) + { + /* + * 1.) Compute the weights (linear factors) c_i of the + * linear combination + * b = c_0 v_0 + ... + c_(n-1) v_(n-1) + c_n v_'domain' + * Use backward substitution to obtain c_i from the linear + * factors of the lin. comb. b = d_0 o_0 + ... + d_n o_n + * of the corresponding orthogonal vectors {o_0, ..., o_n}. + * Vector o_n of the orthogonal basis is obtained by using + * vector 'v_domain' in step n of the Gram Schmidt + * orthogonalization (see above for definition of o_n). + * Recursive formula for the coefficients c_i: + * c_n := <b, o_n> / ||o_n||^2 + * for i = n - 1, ... , 0: + * c_i := <b, o_i> / ||o_i||^2 + + * \sum (k = i + 1, ... , n){ c_k <v_k, o_i> + * / ||o_i||^2 } + * 2.) Because linear factors are stored with reduced precision + * factor c_i is rounded with the given precision in step i + * of the recursive formula. + */ + + unsigned k; /* counter */ + int l; /* counter */ + real_t m_bits; /* number of matrix bits to store */ + real_t w_bits; /* number of weights bits to store */ + real_t r [MAXEDGES]; /* rounded linear factors */ + real_t f [MAXEDGES]; /* linear factors */ + int v [MAXEDGES]; /* mapping of domains to vectors */ + real_t costs; /* current approximation costs */ + real_t m_err; /* current approximation error */ + + f [n] = rem_numerator [domain] / rem_denominator [domain]; + v [n] = domain; /* corresponding mapping */ + for (k = 0; k < n; k++) + { + f [k] = ip_image_ortho_vector [k] / norm_ortho_vector [k]; + v [k] = mp->indices [k]; + } + + for (l = n; l >= 0; l--) + { + rpf_t *rpf = domain_blocks [v [l]] + ? coeff->rpf : coeff->dc_rpf; + + r [l] = f [l] = btor (rtob (f [l], rpf), rpf); + + for (k = 0; k < (unsigned) l; k++) + f [k] -= f [l] * ip_domain_ortho_vector [v [l]][k] + / norm_ortho_vector [k] ; + } + + /* + * Compute the number of output bits of the linear combination + * and store the weights with reduced precision. The + * resulting linear combination is + * b = r_0 v_0 + ... + r_(n-1) v_(n-1) + r_n v_'domain' + */ + { + word_t vectors [MAXEDGES + 1]; + word_t states [MAXEDGES + 1]; + real_t weights [MAXEDGES + 1]; + int i; + + for (i = 0, k = 0; k <= n; k++) + if (f [k] != 0) + { + vectors [i] = v [k]; + states [i] = domain_blocks [v [k]]; + weights [i] = f [k]; + i++; + } + vectors [i] = -1; + states [i] = -1; + + w_bits = coeff->bits (weights, states, range->level, coeff); + m_bits = domain_pool->bits (domain_blocks, vectors, + range->level, y_state, + wfa, domain_pool->model); + } + + /* + * To compute the approximation error, the corresponding + * 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: + * r_i := r_i + + * \sum (k = i + 1, ... , n) { r_k <v_k, o_i> + * / ||o_i||^2 } + */ + for (l = 0; (unsigned) l <= n; l++) + { + /* + * compute <v_n, o_n> + */ + real_t a; + + a = get_ip_state_state (domain_blocks [v [l]], + domain_blocks [domain], + range->level, c); + for (k = 0; k < n; k++) + a -= ip_domain_ortho_vector [v [l]][k] + / norm_ortho_vector [k] + * ip_domain_ortho_vector [domain][k]; + ip_domain_ortho_vector [v [l]][n] = a; + } + 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] + / norm_ortho_vector [k]; + /* + * Compute approximation error: + * error := ||b||^2 + + * \sum (k = 0, ... , n){r_k^2 ||o_k||^2 - 2 r_k <b, o_k>} + */ + m_err = norm; + for (k = 0; k <= n; k++) + m_err += square (r [k]) * norm_ortho_vector [k] + - 2 * r [k] * ip_image_ortho_vector [k]; + if (m_err < 0) /* TODO: return MAXCOSTS */ + warning ("Negative image norm: %f" + " (current domain: %d, level = %d)", + (double) m_err, domain, range->level); + + costs = (m_bits + w_bits + additional_bits) * price + m_err; + if (costs < min_costs) /* found a better approximation */ + { + index = domain; + min_costs = costs; + min_matrix_bits = m_bits; + min_weights_bits = w_bits; + min_error = m_err; + for (k = 0; k <= n; k++) + min_weight [k] = f [k]; + } + } + } - if (index >= 0) /* found a better approximation */ + 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 - */ - orthogonalize (index, n, range->level, min_norm, domain_blocks, c); - n++; - } + 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 + */ + 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; + + mp->err; Free (domain_blocks); } static void orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm, - const word_t *domain_blocks, const coding_t *c) + const word_t *domain_blocks, const coding_t *c) /* * Step 'n' of the Gram-Schmidt orthogonalization procedure: * vector 'index' is orthogonalized with respect to the set @@ -655,8 +633,8 @@ orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm, * No return value. * * Side effects: - * The remainder values (numerator and denominator) of - * all 'domain_blocks' are updated. + * The remainder values (numerator and denominator) of + * all 'domain_blocks' are updated. */ { unsigned domain; @@ -676,25 +654,25 @@ orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm, 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++) - tmp -= ip_domain_ortho_vector [domain][k] / norm_ortho_vector [k] - * ip_domain_ortho_vector [index][k]; - ip_domain_ortho_vector [domain][n] = tmp; - rem_denominator [domain] -= square (tmp) / norm_ortho_vector [n]; - rem_numerator [domain] -= ip_image_ortho_vector [n] - / norm_ortho_vector [n] - * ip_domain_ortho_vector [domain][n] ; - - /* - * Exclude vectors with small denominator - */ - if (!used [domain]) - if (rem_denominator [domain] / size_of_level (level) < min_norm) - used [domain] = YES; + unsigned k; + real_t tmp = get_ip_state_state (domain_blocks [index], + domain_blocks [domain], level, c); + + 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; + rem_denominator [domain] -= square (tmp) / norm_ortho_vector [n]; + rem_numerator [domain] -= ip_image_ortho_vector [n] + / norm_ortho_vector [n] + * ip_domain_ortho_vector [domain][n] ; + + /* + * Exclude vectors with small denominator + */ + 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 c54b78c9..42f1458a 100644 --- a/converter/other/fiasco/codec/approx.h +++ b/converter/other/fiasco/codec/approx.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/bintree.c b/converter/other/fiasco/codec/bintree.c index ddd74e15..b050ab63 100644 --- a/converter/other/fiasco/codec/bintree.c +++ b/converter/other/fiasco/codec/bintree.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/bintree.h b/converter/other/fiasco/codec/bintree.h index cdb80c94..3dc88ac1 100644 --- a/converter/other/fiasco/codec/bintree.h +++ b/converter/other/fiasco/codec/bintree.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/coder.c b/converter/other/fiasco/codec/coder.c index 94e367dd..ce4a24f1 100644 --- a/converter/other/fiasco/codec/coder.c +++ b/converter/other/fiasco/codec/coder.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/coder.h b/converter/other/fiasco/codec/coder.h index c6f4bb7c..2fe81d81 100644 --- a/converter/other/fiasco/codec/coder.h +++ b/converter/other/fiasco/codec/coder.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 0cd64f17..6d33bad5 100644 --- a/converter/other/fiasco/codec/coeff.c +++ b/converter/other/fiasco/codec/coeff.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/codec/coeff.h index 118cd0fc..6193e2ee 100644 --- a/converter/other/fiasco/codec/coeff.h +++ b/converter/other/fiasco/codec/coeff.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/control.c b/converter/other/fiasco/codec/control.c index 94c23c83..2ea06052 100644 --- a/converter/other/fiasco/codec/control.c +++ b/converter/other/fiasco/codec/control.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/control.h b/converter/other/fiasco/codec/control.h index f601d8b8..6c0834a1 100644 --- a/converter/other/fiasco/codec/control.h +++ b/converter/other/fiasco/codec/control.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/cwfa.h b/converter/other/fiasco/codec/cwfa.h index 9c4e7fee..dd86fbfc 100644 --- a/converter/other/fiasco/codec/cwfa.h +++ b/converter/other/fiasco/codec/cwfa.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/decoder.c b/converter/other/fiasco/codec/decoder.c index 26284596..8e2855ef 100644 --- a/converter/other/fiasco/codec/decoder.c +++ b/converter/other/fiasco/codec/decoder.c @@ -4,8 +4,8 @@ * Written by: Ullrich Hafner * Michael Unger * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* @@ -603,7 +603,6 @@ decode_range (unsigned range_state, unsigned range_label, unsigned range_level, * 'wfa->level_of_state []' is changed */ { - unsigned root_state [3]; /* dummy (for alloc_state_images) */ image_t *state_image; /* regenerated state image */ word_t **images; /* pointer to array of pointers to state images */ @@ -613,7 +612,6 @@ decode_range (unsigned range_state, unsigned range_label, unsigned range_level, enlarge_image (range_level - (wfa->level_of_state [range_state] - 1), FORMAT_4_4_4, -1, wfa); - root_state [0] = range_state; state_image = alloc_image (width_of_level (range_level + 1), height_of_level (range_level + 1), NO, FORMAT_4_4_4); diff --git a/converter/other/fiasco/codec/decoder.h b/converter/other/fiasco/codec/decoder.h index 8cd211e0..7823ab91 100644 --- a/converter/other/fiasco/codec/decoder.h +++ b/converter/other/fiasco/codec/decoder.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/dfiasco.c b/converter/other/fiasco/codec/dfiasco.c index 2fdec573..d45c9e39 100644 --- a/converter/other/fiasco/codec/dfiasco.c +++ b/converter/other/fiasco/codec/dfiasco.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/dfiasco.h b/converter/other/fiasco/codec/dfiasco.h index bcc3c7f9..eed12b6b 100644 --- a/converter/other/fiasco/codec/dfiasco.h +++ b/converter/other/fiasco/codec/dfiasco.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/domain-pool.c b/converter/other/fiasco/codec/domain-pool.c index 7cc3900e..1c14a30c 100644 --- a/converter/other/fiasco/codec/domain-pool.c +++ b/converter/other/fiasco/codec/domain-pool.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/domain-pool.h b/converter/other/fiasco/codec/domain-pool.h index d1488779..a2c46141 100644 --- a/converter/other/fiasco/codec/domain-pool.h +++ b/converter/other/fiasco/codec/domain-pool.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/ip.c b/converter/other/fiasco/codec/ip.c index ade0d916..56b0ae9a 100644 --- a/converter/other/fiasco/codec/ip.c +++ b/converter/other/fiasco/codec/ip.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/ip.h b/converter/other/fiasco/codec/ip.h index e5e4dd65..0c693826 100644 --- a/converter/other/fiasco/codec/ip.h +++ b/converter/other/fiasco/codec/ip.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/motion.c b/converter/other/fiasco/codec/motion.c index 876a2998..0d1fa099 100644 --- a/converter/other/fiasco/codec/motion.c +++ b/converter/other/fiasco/codec/motion.c @@ -4,8 +4,8 @@ * Written by: Ullrich Hafner * Michael Unger * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/motion.h b/converter/other/fiasco/codec/motion.h index 2ea382f7..82d1f1ec 100644 --- a/converter/other/fiasco/codec/motion.h +++ b/converter/other/fiasco/codec/motion.h @@ -4,8 +4,8 @@ * Written by: Ullrich Hafner * Michael Unger * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/mwfa.c b/converter/other/fiasco/codec/mwfa.c index 43a7dae2..0be08a4f 100644 --- a/converter/other/fiasco/codec/mwfa.c +++ b/converter/other/fiasco/codec/mwfa.c @@ -4,8 +4,8 @@ * Written by: Michael Unger * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/mwfa.h b/converter/other/fiasco/codec/mwfa.h index 52f41866..2c1e7c9f 100644 --- a/converter/other/fiasco/codec/mwfa.h +++ b/converter/other/fiasco/codec/mwfa.h @@ -4,8 +4,8 @@ * Written by: Michael Unger * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/options.c b/converter/other/fiasco/codec/options.c index c8e4d2e2..af2cfb48 100644 --- a/converter/other/fiasco/codec/options.c +++ b/converter/other/fiasco/codec/options.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/options.h b/converter/other/fiasco/codec/options.h index 3af6be01..783c41ef 100644 --- a/converter/other/fiasco/codec/options.h +++ b/converter/other/fiasco/codec/options.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/prediction.c b/converter/other/fiasco/codec/prediction.c index e056d10f..e78e5acc 100644 --- a/converter/other/fiasco/codec/prediction.c +++ b/converter/other/fiasco/codec/prediction.c @@ -4,8 +4,8 @@ * Written by: Ullrich Hafner * Michael Unger * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/prediction.h b/converter/other/fiasco/codec/prediction.h index 1068501a..0646dfd8 100644 --- a/converter/other/fiasco/codec/prediction.h +++ b/converter/other/fiasco/codec/prediction.h @@ -4,8 +4,8 @@ * Written by: Ullrich Hafner * Michael Unger * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/subdivide.c b/converter/other/fiasco/codec/subdivide.c index 2ace18e4..348f838a 100644 --- a/converter/other/fiasco/codec/subdivide.c +++ b/converter/other/fiasco/codec/subdivide.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/subdivide.h b/converter/other/fiasco/codec/subdivide.h index b6840e58..bd9cd10e 100644 --- a/converter/other/fiasco/codec/subdivide.h +++ b/converter/other/fiasco/codec/subdivide.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/tiling.c b/converter/other/fiasco/codec/tiling.c index 21e4428a..9af43da0 100644 --- a/converter/other/fiasco/codec/tiling.c +++ b/converter/other/fiasco/codec/tiling.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/tiling.h b/converter/other/fiasco/codec/tiling.h index 2eb04fe0..6668ad8b 100644 --- a/converter/other/fiasco/codec/tiling.h +++ b/converter/other/fiasco/codec/tiling.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/wfa.h b/converter/other/fiasco/codec/wfa.h index 9253affd..59020fc1 100644 --- a/converter/other/fiasco/codec/wfa.h +++ b/converter/other/fiasco/codec/wfa.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/wfalib.c b/converter/other/fiasco/codec/wfalib.c index 61d64d2f..75792627 100644 --- a/converter/other/fiasco/codec/wfalib.c +++ b/converter/other/fiasco/codec/wfalib.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/codec/wfalib.h b/converter/other/fiasco/codec/wfalib.h index 4622fcd2..5c1e0907 100644 --- a/converter/other/fiasco/codec/wfalib.h +++ b/converter/other/fiasco/codec/wfalib.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/display.c b/converter/other/fiasco/display.c index cf160329..d8d32fa6 100644 --- a/converter/other/fiasco/display.c +++ b/converter/other/fiasco/display.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 diff --git a/converter/other/fiasco/display.h b/converter/other/fiasco/display.h index 5f30b117..8049456a 100644 --- a/converter/other/fiasco/display.h +++ b/converter/other/fiasco/display.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/doc/README.LIB b/converter/other/fiasco/doc/README.LIB index 4bf8c382..ce8a6b2b 100644 --- a/converter/other/fiasco/doc/README.LIB +++ b/converter/other/fiasco/doc/README.LIB @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- - FIASCO («F»ractal «I»mage «A»nd «S»equence «CO»dec) + FIASCO (Fractal Image And Sequence COdec) Copyright (C) 1994-2000 Ullrich Hafner <hafner@bigfoot.de>, http://ulli.linuxave.net Version 1.0 diff --git a/converter/other/fiasco/doc/fiasco_c_options_new.3 b/converter/other/fiasco/doc/fiasco_c_options_new.3 index 52efb86c..d873b642 100644 --- a/converter/other/fiasco/doc/fiasco_c_options_new.3 +++ b/converter/other/fiasco/doc/fiasco_c_options_new.3 @@ -429,4 +429,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_coder.3 b/converter/other/fiasco/doc/fiasco_coder.3 index 3d1c6b87..9f2e0f8e 100644 --- a/converter/other/fiasco/doc/fiasco_coder.3 +++ b/converter/other/fiasco/doc/fiasco_coder.3 @@ -103,4 +103,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_d_options_new.3 b/converter/other/fiasco/doc/fiasco_d_options_new.3 index 4294330a..d7f2181a 100644 --- a/converter/other/fiasco/doc/fiasco_d_options_new.3 +++ b/converter/other/fiasco/doc/fiasco_d_options_new.3 @@ -119,4 +119,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_decoder_new.3 b/converter/other/fiasco/doc/fiasco_decoder_new.3 index 05e981a9..5d1d0d08 100644 --- a/converter/other/fiasco/doc/fiasco_decoder_new.3 +++ b/converter/other/fiasco/doc/fiasco_decoder_new.3 @@ -191,4 +191,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_get_error_message.3 b/converter/other/fiasco/doc/fiasco_get_error_message.3 index 09d593fb..ce53e6d9 100644 --- a/converter/other/fiasco/doc/fiasco_get_error_message.3 +++ b/converter/other/fiasco/doc/fiasco_get_error_message.3 @@ -38,4 +38,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_image_new.3 b/converter/other/fiasco/doc/fiasco_image_new.3 index 10625b63..ac3297bf 100644 --- a/converter/other/fiasco/doc/fiasco_image_new.3 +++ b/converter/other/fiasco/doc/fiasco_image_new.3 @@ -92,4 +92,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_options_new.3 b/converter/other/fiasco/doc/fiasco_options_new.3 index 26e070ca..f26586a7 100644 --- a/converter/other/fiasco/doc/fiasco_options_new.3 +++ b/converter/other/fiasco/doc/fiasco_options_new.3 @@ -438,4 +438,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_renderer_new.3 b/converter/other/fiasco/doc/fiasco_renderer_new.3 index b24d8462..8b5e47cd 100644 --- a/converter/other/fiasco/doc/fiasco_renderer_new.3 +++ b/converter/other/fiasco/doc/fiasco_renderer_new.3 @@ -122,4 +122,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/doc/fiasco_set_verbosity.3 b/converter/other/fiasco/doc/fiasco_set_verbosity.3 index 746854b1..3e88399a 100644 --- a/converter/other/fiasco/doc/fiasco_set_verbosity.3 +++ b/converter/other/fiasco/doc/fiasco_set_verbosity.3 @@ -43,4 +43,4 @@ Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR -Ullrich Hafner <hafner@bigfoot.de> +Ullrich Hafner diff --git a/converter/other/fiasco/fiasco.h b/converter/other/fiasco/fiasco.h index 59367bb8..88f999fc 100644 --- a/converter/other/fiasco/fiasco.h +++ b/converter/other/fiasco/fiasco.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/converter/other/fiasco/fiascotopnm.c b/converter/other/fiasco/fiascotopnm.c index dfba2256..503d023f 100644 --- a/converter/other/fiasco/fiascotopnm.c +++ b/converter/other/fiasco/fiascotopnm.c @@ -4,8 +4,8 @@ * Written by: Ullrich Hafner * Michael Unger * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* @@ -361,6 +361,8 @@ video_decoder (const char *wfa_name, const char *image_name, bool_t panel, while (prg_timer (&fps_timer, STOP) < frame_time) /* wait */ ; } +#else + if (frame_time) {/* defeat compiler warning */} #endif /* not X_DISPLAY_MISSING */ } free (filename); diff --git a/converter/other/fiasco/input/basis.c b/converter/other/fiasco/input/basis.c index 4a748f61..aa371ea1 100644 --- a/converter/other/fiasco/input/basis.c +++ b/converter/other/fiasco/input/basis.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/input/basis.h b/converter/other/fiasco/input/basis.h index fa26bca2..e2242198 100644 --- a/converter/other/fiasco/input/basis.h +++ b/converter/other/fiasco/input/basis.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 47cde1aa..388855ea 100644 --- a/converter/other/fiasco/input/matrices.c +++ b/converter/other/fiasco/input/matrices.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/input/matrices.h index ba8fd9bf..6d1cef15 100644 --- a/converter/other/fiasco/input/matrices.h +++ b/converter/other/fiasco/input/matrices.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 070d839e..2d4a073d 100644 --- a/converter/other/fiasco/input/mc.c +++ b/converter/other/fiasco/input/mc.c @@ -4,8 +4,8 @@ * written by: Michael Unger * 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> + * 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.h b/converter/other/fiasco/input/mc.h index 1e14d287..9d9d714d 100644 --- a/converter/other/fiasco/input/mc.h +++ b/converter/other/fiasco/input/mc.h @@ -4,8 +4,8 @@ * written by: Michael Unger * 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> + * 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 1a68bfbf..52d48e61 100644 --- a/converter/other/fiasco/input/nd.c +++ b/converter/other/fiasco/input/nd.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/input/nd.h index 2c2fff4b..0fe06cf1 100644 --- a/converter/other/fiasco/input/nd.h +++ b/converter/other/fiasco/input/nd.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 e6e2d7e8..862fec39 100644 --- a/converter/other/fiasco/input/read.c +++ b/converter/other/fiasco/input/read.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/input/read.h index d0d0ee13..1f59f103 100644 --- a/converter/other/fiasco/input/read.h +++ b/converter/other/fiasco/input/read.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 e3e7117e..0ac2b6ae 100644 --- a/converter/other/fiasco/input/tree.c +++ b/converter/other/fiasco/input/tree.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/input/tree.h index e4b5f2d8..f743ee98 100644 --- a/converter/other/fiasco/input/tree.h +++ b/converter/other/fiasco/input/tree.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 15c35731..8a1e8899 100644 --- a/converter/other/fiasco/input/weights.c +++ b/converter/other/fiasco/input/weights.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/input/weights.h index 1e2285a9..36cea5c2 100644 --- a/converter/other/fiasco/input/weights.h +++ b/converter/other/fiasco/input/weights.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 dc35d1d1..825d4757 100644 --- a/converter/other/fiasco/lib/arith.c +++ b/converter/other/fiasco/lib/arith.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/lib/arith.h index 744eb9d7..04297eb5 100644 --- a/converter/other/fiasco/lib/arith.h +++ b/converter/other/fiasco/lib/arith.h @@ -1,8 +1,8 @@ /* * arith.h * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/bit-io.c b/converter/other/fiasco/lib/bit-io.c index 1bfef598..fdcd70b9 100644 --- a/converter/other/fiasco/lib/bit-io.c +++ b/converter/other/fiasco/lib/bit-io.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/bit-io.h b/converter/other/fiasco/lib/bit-io.h index d37cc47c..08029824 100644 --- a/converter/other/fiasco/lib/bit-io.h +++ b/converter/other/fiasco/lib/bit-io.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/dither.c b/converter/other/fiasco/lib/dither.c index accd9dd6..669bb16c 100644 --- a/converter/other/fiasco/lib/dither.c +++ b/converter/other/fiasco/lib/dither.c @@ -3,8 +3,8 @@ * * Adapted by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* @@ -713,15 +713,11 @@ display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage, 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; - unsigned int *r_table, *g_table, *b_table; Cr_g_tab = private->Cr_g_tab; Cr_r_tab = private->Cr_r_tab; Cb_b_tab = private->Cb_b_tab; Cb_g_tab = private->Cb_g_tab; - r_table = private->r_table; - g_table = private->g_table; - b_table = private->b_table; yptr = image->pixels [Y]; cbptr = image->pixels [Cb]; crptr = image->pixels [Cr]; @@ -1044,9 +1040,7 @@ display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage, { 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]; @@ -1164,15 +1158,11 @@ display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage, 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; - unsigned int *r_table, *g_table, *b_table; Cr_g_tab = private->Cr_g_tab; Cr_r_tab = private->Cr_r_tab; Cb_b_tab = private->Cb_b_tab; Cb_g_tab = private->Cb_g_tab; - r_table = private->r_table; - g_table = private->g_table; - b_table = private->b_table; yptr = image->pixels [Y]; cbptr = image->pixels [Cb]; crptr = image->pixels [Cr]; @@ -1495,9 +1485,7 @@ display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage, { 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]; diff --git a/converter/other/fiasco/lib/dither.h b/converter/other/fiasco/lib/dither.h index 71f9d3c3..767bca28 100644 --- a/converter/other/fiasco/lib/dither.h +++ b/converter/other/fiasco/lib/dither.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/error.c b/converter/other/fiasco/lib/error.c index ee3afe1f..aeb6eaf9 100644 --- a/converter/other/fiasco/lib/error.c +++ b/converter/other/fiasco/lib/error.c @@ -7,8 +7,8 @@ * Credits: Modelled after variable argument routines from Jef * Poskanzer's pbmplus package. * - * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner "int dummy = " change to int dummy; dummy =" for Netpbm to avoid unused variable warning. @@ -64,118 +64,107 @@ jmp_buf env; *****************************************************************************/ void -set_error (const char *format, ...) -/* - * Set error text to given string. - */ -{ - va_list args; - unsigned len = 0; - const char *str = format; +set_error(const char *format, ...) { +/*---------------------------------------------------------------------------- + Set error text to given string. +-----------------------------------------------------------------------------*/ + va_list args; + unsigned len; + const char * str; + + len = 0; /* initial value */ + str = format; /* initial value */ + + VA_START (args, format); + + len = strlen (format); + while ((str = strchr (str, '%'))) { + ++str; + if (*str == 's') { + char * const vstring = va_arg (args, char *); + len += strlen(vstring); + } else if (*str == 'd') { + va_arg (args, int); + len += 10; + } else if (*str == 'c') { + va_arg (args, int); + len += 1; + } else + return; + ++str; + } + va_end(args); + + VA_START(args, format); + + if (error_message) + Free(error_message); + error_message = Calloc(len, sizeof (char)); - VA_START (args, format); - - len = strlen (format); - while ((str = strchr (str, '%'))) - { - str++; - if (*str == 's') - { - char *vstring = va_arg (args, char *); - len += strlen (vstring); - } - else if (*str == 'd') - { - int dummy; - dummy = va_arg (args, int); - len += 10; - } - else if (*str == 'c') - { - int dummy; - dummy = va_arg (args, int); - len += 1; - } - else - return; - str++; - } - va_end(args); + vsprintf(error_message, format, args); - VA_START (args, format); + va_end(args); +} - if (error_message) - Free (error_message); - error_message = Calloc (len, sizeof (char)); - - vsprintf (error_message, format, args); - va_end (args); -} void -error (const char *format, ...) -/* - * Set error text to given string. - */ -{ - va_list args; - unsigned len = 0; - const char *str = format; +error(const char *format, ...) { +/*---------------------------------------------------------------------------- + Set error text to given string. + -----------------------------------------------------------------------------*/ + va_list args; + unsigned len; + const char * str; - VA_START (args, format); - - len = strlen (format); - while ((str = strchr (str, '%'))) - { - str++; - if (*str == 's') - { - char *vstring = va_arg (args, char *); - len += strlen (vstring); - } - else if (*str == 'd') - { - int dummy; - dummy = va_arg (args, int); - len += 10; - } - else if (*str == 'c') - { - int dummy; - dummy = va_arg (args, int); - len += 1; - } - else - { + len = 0; /* initial value */ + str = &format[0]; /* initial value */ + + VA_START (args, format); + + len = strlen (format); + while ((str = strchr (str, '%'))) { + ++str; + if (*str == 's') { + char * const vstring = va_arg (args, char *); + len += strlen(vstring); + } else if (*str == 'd') { + va_arg (args, int); + len += 10; + } else if (*str == 'c') { + va_arg (args, int); + len += 1; + } else { #if HAVE_SETJMP_H - longjmp (env, 1); -#else /* not HAVE_SETJMP_H */ - exit (1); -#endif /* HAVE_SETJMP_H */ - }; + longjmp(env, 1); +#else + exit(1); +#endif + }; - str++; - } - va_end(args); + ++str; + } + va_end(args); - VA_START (args, format); + VA_START(args, format); - if (error_message) - Free (error_message); - error_message = Calloc (len, sizeof (char)); + if (error_message) + Free(error_message); + error_message = Calloc(len, sizeof (char)); - vsprintf (error_message, format, args); + vsprintf(error_message, format, args); - va_end (args); + va_end(args); #if HAVE_SETJMP_H - longjmp (env, 1); -#else /* not HAVE_SETJMP_H */ - exit (1); -#endif /* HAVE_SETJMP_H */ + longjmp(env, 1); +#else + exit(1); +#endif } + + const char * fiasco_get_error_message (void) /* diff --git a/converter/other/fiasco/lib/error.h b/converter/other/fiasco/lib/error.h index 288b25f4..4159ccd2 100644 --- a/converter/other/fiasco/lib/error.h +++ b/converter/other/fiasco/lib/error.h @@ -4,8 +4,8 @@ * Written by: Stefan Frank * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ #ifndef ERROR_H_INCLUDED diff --git a/converter/other/fiasco/lib/image.c b/converter/other/fiasco/lib/image.c index fa3b2db5..a700fe88 100644 --- a/converter/other/fiasco/lib/image.c +++ b/converter/other/fiasco/lib/image.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/image.h b/converter/other/fiasco/lib/image.h index 00978526..a87a3c05 100644 --- a/converter/other/fiasco/lib/image.h +++ b/converter/other/fiasco/lib/image.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/list.c b/converter/other/fiasco/lib/list.c index bb4efae1..b67ff4b8 100644 --- a/converter/other/fiasco/lib/list.c +++ b/converter/other/fiasco/lib/list.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/list.h b/converter/other/fiasco/lib/list.h index db7c08b2..68577dfd 100644 --- a/converter/other/fiasco/lib/list.h +++ b/converter/other/fiasco/lib/list.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/macros.h b/converter/other/fiasco/lib/macros.h index 9968110a..0bc80e7c 100644 --- a/converter/other/fiasco/lib/macros.h +++ b/converter/other/fiasco/lib/macros.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/misc.c b/converter/other/fiasco/lib/misc.c index 782ed1e9..c5629c5c 100644 --- a/converter/other/fiasco/lib/misc.c +++ b/converter/other/fiasco/lib/misc.c @@ -6,8 +6,8 @@ * Written by: Stefan Frank * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/misc.h b/converter/other/fiasco/lib/misc.h index 28fd8b5a..6f643b7a 100644 --- a/converter/other/fiasco/lib/misc.h +++ b/converter/other/fiasco/lib/misc.h @@ -4,8 +4,8 @@ * Written by: Stefan Frank * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/rpf.c b/converter/other/fiasco/lib/rpf.c index 84c1f9b6..e6ff6e09 100644 --- a/converter/other/fiasco/lib/rpf.c +++ b/converter/other/fiasco/lib/rpf.c @@ -1,10 +1,10 @@ /* - * rpf.c: Conversion of float to reduced precision format values + * rpf.c: Conversion of float to reduced precision format values * - * Written by: Stefan Frank - * Richard Krampfl - * Ullrich Hafner - * + * 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> */ @@ -18,6 +18,7 @@ #include "pm_config.h" #include "config.h" +#include "mallocvar.h" #include "types.h" #include "macros.h" @@ -26,39 +27,37 @@ #include "misc.h" #include "rpf.h" -/* - * CAUTION: The IEEE float format must be used by your compiler, - * or all following code is void! - */ +int const RPF_ZERO = -1; -#if BYTE_ORDER == BIG_ENDIAN -/* - * Big-Endian Architecture (e.g. SUN, Motorola) - * Memory representation of integer 0x00112233 is 00,11,22,33 - */ +/***************************************************************************** -enum real_bytes {BYTE_0, BYTE_1, BYTE_2, BYTE_3}; + private code + +*****************************************************************************/ -#else -/* - * Little-Endian Architecture (e.g. Intel, VAX, Alpha) - * Memory representation of integer 0x00112233 is 33,22,11,00 - */ -enum real_bytes {BYTE_3, BYTE_2, BYTE_1, BYTE_0}; +typedef struct { + double fraction; + int exponent; +} FracExp; -#endif -const int RPF_ZERO = -1; -/***************************************************************************** +static FracExp +fracExpFromDouble(double const x) { + + FracExp retval; + + retval.fraction = frexp(x, &retval.exponent); + + return retval; +} + - private code - -*****************************************************************************/ int -rtob (real_t f, const rpf_t *rpf) +rtob (real_t const f, + const rpf_t * const rpfP) /* * Convert real number 'f' into fixed point format. * The real number in [-'range'; +'range'] is scaled to [-1 ; +1]. @@ -66,111 +65,98 @@ rtob (real_t f, const rpf_t *rpf) * packed into one integer. * * Return value: - * real value in reduced precision format + * real value in reduced precision format */ { - unsigned int mantissa; - int exponent, sign; - union - { - float f; - unsigned char c[4]; - } v; /* conversion dummy */ - - f /= rpf->range; /* scale f to [-1,+1] */ - v.f = f; - - /* - * Extract mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit) - */ - - mantissa = ((((v.c[BYTE_1] & 127) << 8 ) | v.c[BYTE_2]) << 8) | v.c[BYTE_3]; - exponent = (((v.c[BYTE_0] & 127) << 1) | (v.c[BYTE_1] & 128 ? 1 : 0)) - 126; - sign = v.c[BYTE_0] & 128 ? 1 : 0; - - /* - * Generate reduced precision mantissa. - */ - mantissa >>= 1; /* shift 1 into from left */ - mantissa |= (1 << 22); - if (exponent > 0) - mantissa <<= exponent; - else - mantissa >>= -exponent; + /* + * Extract mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit) + */ + + double const normalized = f / rpfP->range; + /* '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; + } else { + mantissa = +signedMantissa; + sign = 0; + } + + /* + * Generate reduced precision mantissa. + */ + if (fracExp.exponent > 0) + mantissa <<= fracExp.exponent; + else + mantissa >>= -fracExp.exponent; + + mantissa >>= (23 - rpfP->mantissa_bits - 1); + + mantissa += 1; /* Round last bit. */ + mantissa >>= 1; - mantissa >>= (23 - rpf->mantissa_bits - 1); - - mantissa += 1; /* Round last bit. */ - mantissa >>= 1; - - if (mantissa == 0) /* close to zero */ - return RPF_ZERO; - else if (mantissa >= (1U << rpf->mantissa_bits)) /* overflow */ - return sign; - else - return ((mantissa & ((1U << rpf->mantissa_bits) - 1)) << 1) | sign; + if (mantissa == 0) /* close to zero */ + return RPF_ZERO; + else if (mantissa >= (1U << rpfP->mantissa_bits)) /* overflow */ + return sign; + else + return ((mantissa & ((1U << rpfP->mantissa_bits) - 1)) << 1) | sign; } + + float -btor (int binary, const rpf_t *rpf) +btor (int const binary, + const rpf_t * const rpfP) /* * Convert value 'binary' in reduced precision format to a real value. - * For more information refer to function lin_rtob() above. + * For more information refer to function rtob() above. * * Return value: - * converted value + * converted value */ { - unsigned int mantissa; - int sign, exponent; - union - { - float f; - unsigned char c[4]; - } value; - - if (binary == RPF_ZERO) - return 0; - - if (binary < 0 || binary >= 1 << (rpf->mantissa_bits + 1)) - error ("Reduced precision format: value %d out of range.", binary); - - /* - * Restore IEEE float format: - * mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit) - */ + unsigned int mantissa; + float sign; + float f; + + if (binary == RPF_ZERO) + return 0; + + if (binary < 0 || binary >= 1 << (rpfP->mantissa_bits + 1)) + error ("Reduced precision format: value %d out of range.", binary); + + /* + * Restore IEEE float format: + * mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit) + */ - sign = binary & 1; - mantissa = (binary & ((1 << (rpf->mantissa_bits + 1)) - 1)) >> 1; - mantissa <<= (23 - rpf->mantissa_bits); - exponent = 0; - - if (mantissa == 0) - { - value.f = (sign ? -1.0 : 1.0); - } - else - { - while (!(mantissa & (1 << 22))) /* normalize mantissa */ - { - exponent--; - mantissa <<= 1; - } - mantissa <<= 1; - - value.c[BYTE_0] = (sign << 7) | ((exponent + 126) >> 1); - value.c[BYTE_1] = (((exponent + 126) & 1) << 7) - | ((mantissa >> 16) & 127); - value.c[BYTE_2] = (mantissa >> 8) & 255; - value.c[BYTE_3] = mantissa & 255; - } + sign = (binary & 0x1) == 0 ? 1.0 : -1.0; + mantissa = (binary & ((0x1 << (rpfP->mantissa_bits + 1)) - 1)) >> 1; + mantissa <<= (23 - rpfP->mantissa_bits); + + if (mantissa == 0) + f = sign; + else + f = sign * (float) mantissa / 8388608; - return value.f * rpf->range; /* expand [ -1 ; +1 ] to - [ -range ; +range ] */ + return f * rpfP->range; /* expand [ -1 ; +1 ] to + [ -range ; +range ] */ } + + + rpf_t * -alloc_rpf (unsigned mantissa, fiasco_rpf_range_e range) +alloc_rpf (unsigned const mantissa, + fiasco_rpf_range_e const range) /* * Reduced precision format constructor. * Allocate memory for the rpf_t structure. @@ -180,45 +166,47 @@ alloc_rpf (unsigned mantissa, fiasco_rpf_range_e range) * returned. * * Return value - * pointer to the new rpf structure + * pointer to the new rpf structure */ { - rpf_t *rpf = Calloc (1, sizeof (rpf_t)); + 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")); - mantissa = 2; - } - else if (mantissa > 8) - { - warning (_("Size of RPF mantissa has to be in the interval [2,8]. " - "Using maximum value 8.\n")); - mantissa = 2; - } - - rpf->mantissa_bits = mantissa; - rpf->range_e = range; - switch (range) - { - case FIASCO_RPF_RANGE_0_75: - rpf->range = 0.75; - break; - case FIASCO_RPF_RANGE_1_50: - rpf->range = 1.50; - break; - case FIASCO_RPF_RANGE_2_00: - rpf->range = 2.00; - break; - case FIASCO_RPF_RANGE_1_00: - rpf->range = 1.00; - break; - default: - warning (_("Invalid RPF range specified. Using default value 1.0.")); - rpf->range = 1.00; - rpf->range_e = FIASCO_RPF_RANGE_1_00; - break; - } - return rpf; + if (mantissa < 2) { + warning (_("Size of RPF mantissa has to be in the interval [2,8]. " + "Using minimum value 2.\n")); + rpfP->mantissa_bits = 2; + } else if (mantissa > 8) { + warning (_("Size of RPF mantissa has to be in the interval [2,8]. " + "Using maximum value 8.\n")); + rpfP->mantissa_bits = 2; + } else + rpfP->mantissa_bits = mantissa; + + switch (range) { + case FIASCO_RPF_RANGE_0_75: + rpfP->range = 0.75; + rpfP->range_e = range; + break; + case FIASCO_RPF_RANGE_1_50: + rpfP->range = 1.50; + rpfP->range_e = range; + break; + case FIASCO_RPF_RANGE_2_00: + rpfP->range = 2.00; + rpfP->range_e = range; + break; + case FIASCO_RPF_RANGE_1_00: + rpfP->range = 1.00; + rpfP->range_e = range; + break; + default: + warning (_("Invalid RPF range specified. Using default value 1.0.")); + rpfP->range = 1.00; + rpfP->range_e = FIASCO_RPF_RANGE_1_00; + break; + } + return rpfP; } + diff --git a/converter/other/fiasco/lib/rpf.h b/converter/other/fiasco/lib/rpf.h index ba3ff6be..e543f855 100644 --- a/converter/other/fiasco/lib/rpf.h +++ b/converter/other/fiasco/lib/rpf.h @@ -5,8 +5,8 @@ * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/lib/types.h b/converter/other/fiasco/lib/types.h index 16d8028c..02e40a90 100644 --- a/converter/other/fiasco/lib/types.h +++ b/converter/other/fiasco/lib/types.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 01189669..7dc0e6d9 100644 --- a/converter/other/fiasco/output/matrices.c +++ b/converter/other/fiasco/output/matrices.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* NETPBM: When you call delta_encoding() with last_domain < 4, it diff --git a/converter/other/fiasco/output/matrices.h b/converter/other/fiasco/output/matrices.h index f880fef8..44671496 100644 --- a/converter/other/fiasco/output/matrices.h +++ b/converter/other/fiasco/output/matrices.h @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/output/mc.c b/converter/other/fiasco/output/mc.c index afff586b..d048bef5 100644 --- a/converter/other/fiasco/output/mc.c +++ b/converter/other/fiasco/output/mc.c @@ -4,8 +4,8 @@ * Written by: Michael Unger * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/output/mc.h b/converter/other/fiasco/output/mc.h index b7843fd8..cacddfe7 100644 --- a/converter/other/fiasco/output/mc.h +++ b/converter/other/fiasco/output/mc.h @@ -4,8 +4,8 @@ * Written by: Michael Unger * 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> + * 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 a09ff762..65a85467 100644 --- a/converter/other/fiasco/output/nd.c +++ b/converter/other/fiasco/output/nd.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/output/nd.h index 600b3d73..01a37838 100644 --- a/converter/other/fiasco/output/nd.h +++ b/converter/other/fiasco/output/nd.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 0056d7dd..2eae2df9 100644 --- a/converter/other/fiasco/output/tree.c +++ b/converter/other/fiasco/output/tree.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/output/tree.h index 6f8a3800..50fe2279 100644 --- a/converter/other/fiasco/output/tree.h +++ b/converter/other/fiasco/output/tree.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 5aa17674..0203fef0 100644 --- a/converter/other/fiasco/output/weights.c +++ b/converter/other/fiasco/output/weights.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/output/weights.h index 271203ad..f22bd9f8 100644 --- a/converter/other/fiasco/output/weights.h +++ b/converter/other/fiasco/output/weights.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 e6185ad3..d6faee26 100644 --- a/converter/other/fiasco/output/write.c +++ b/converter/other/fiasco/output/write.c @@ -3,8 +3,8 @@ * * Written by: 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> + * 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.h b/converter/other/fiasco/output/write.h index a3ede1f4..6bdc2f1b 100644 --- a/converter/other/fiasco/output/write.h +++ b/converter/other/fiasco/output/write.h @@ -3,8 +3,8 @@ * * Written by: 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> + * 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 afacbada..14f1529e 100644 --- a/converter/other/fiasco/params.c +++ b/converter/other/fiasco/params.c @@ -4,8 +4,8 @@ * Written by: Stefan Frank * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* @@ -325,8 +325,17 @@ parseargs (param_t *usr_params, NO, sys_path, usr_file_name); else if (streq (params [param_index].name, "version")) { - fprintf (stderr, "%s " VERSION "\n", argv [0]); - exit (2); + fprintf (stderr, "%s " VERSION "\n", argv [0]); + { + /* Kludge for standard Netpbm version announcement */ + char * modified_argv[2]; + int argc; + modified_argv[0] = argv[0]; + modified_argv[1] = (char *) "--version"; + argc = 2; + pm_proginit(&argc, (const char **) modified_argv); + } + exit (2); } else if (streq (params [param_index].name, "verbose")) fiasco_set_verbosity ( diff --git a/converter/other/fiasco/params.h b/converter/other/fiasco/params.h index 810a9ff0..a1164cf7 100644 --- a/converter/other/fiasco/params.h +++ b/converter/other/fiasco/params.h @@ -4,8 +4,8 @@ * Written by: Stefan Frank * 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/pnmtofiasco.c b/converter/other/fiasco/pnmtofiasco.c index eebd09a9..e2656c71 100644 --- a/converter/other/fiasco/pnmtofiasco.c +++ b/converter/other/fiasco/pnmtofiasco.c @@ -3,8 +3,8 @@ * * Written by: 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> + * This file is part of FIASCO (Fractal Image And Sequence COdec) + * Copyright (C) 1994-2000 Ullrich Hafner */ /* diff --git a/converter/other/fiasco/system.fiascorc b/converter/other/fiasco/system.fiascorc index 86ff2da2..77d60603 100644 --- a/converter/other/fiasco/system.fiascorc +++ b/converter/other/fiasco/system.fiascorc @@ -3,8 +3,8 @@ # # Written by: 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> +# This file is part of FIASCO (Fractal Image And Sequence COdec) +# Copyright (C) 1994-2000 Ullrich Hafner # # $Date: 2000/06/25 16:38:01 $ diff --git a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c index 91ce6c51..a9463a57 100644 --- a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c +++ b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c @@ -110,16 +110,6 @@ * __END_OF_JASPER_LICENSE__ */ -/* - * JP2 Library - * - * $Id$ - */ - -/******************************************************************************\ -* Includes. -\******************************************************************************/ - #include "jasper/jas_image.h" #include "jasper/jas_stream.h" #include "jasper/jas_math.h" @@ -130,520 +120,548 @@ #include "jp2_cod.h" #include "jp2_dec.h" -#define JP2_VALIDATELEN (JAS_MIN(JP2_JP_LEN + 16, JAS_STREAM_MAXPUTBACK)) - -static jp2_dec_t *jp2_dec_create(void); -static void jp2_dec_destroy(jp2_dec_t *dec); -static int jp2_getcs(jp2_colr_t *colr); -static int jp2_getct(int colorspace, int type, int assoc); -static int fromiccpcs(int cs); - -/******************************************************************************\ -* Functions. -\******************************************************************************/ - -jas_image_t *jp2_decode(jas_stream_t *in, char *optstr) -{ - jp2_box_t *box; - int found; - jas_image_t *image; - jp2_dec_t *dec; - bool samedtype; - int dtype; - int i; - jp2_cmap_t *cmapd; - jp2_pclr_t *pclrd; - jp2_cdef_t *cdefd; - int channo; - int newcmptno; - int_fast32_t *lutents; - jp2_cmapent_t *cmapent; - unsigned char *iccp; - int cs; - - dec = 0; - box = 0; - image = 0; - - if (!(dec = jp2_dec_create())) { - goto error; - } - - /* Get the first box. This should be a JP box. */ - if (!(box = jp2_box_get(in))) { - jas_eprintf("error: cannot get box\n"); - goto error; - } - if (box->type != JP2_BOX_JP) { - jas_eprintf("error: expecting signature box\n"); - goto error; - } - if (box->data.jp.magic != JP2_JP_MAGIC) { - jas_eprintf("incorrect magic number\n"); - goto error; - } - jp2_box_destroy(box); - box = 0; - - /* Get the second box. This should be a FTYP box. */ - if (!(box = jp2_box_get(in))) { - goto error; - } - if (box->type != JP2_BOX_FTYP) { - jas_eprintf("expecting file type box\n"); - goto error; - } - jp2_box_destroy(box); - box = 0; - - /* Get more boxes... */ - found = 0; - while ((box = jp2_box_get(in))) { - if (jas_getdbglevel() >= 1) { - fprintf(stderr, "box type %s\n", box->info->name); - } - switch (box->type) { - case JP2_BOX_JP2C: - found = 1; - break; - case JP2_BOX_IHDR: - if (!dec->ihdr) { - dec->ihdr = box; - box = 0; - } - break; - case JP2_BOX_BPCC: - if (!dec->bpcc) { - dec->bpcc = box; - box = 0; - } - break; - case JP2_BOX_CDEF: - if (!dec->cdef) { - dec->cdef = box; - box = 0; - } - break; - case JP2_BOX_PCLR: - if (!dec->pclr) { - dec->pclr = box; - box = 0; - } - break; - case JP2_BOX_CMAP: - if (!dec->cmap) { - dec->cmap = box; - box = 0; - } - break; - case JP2_BOX_COLR: - if (!dec->colr) { - dec->colr = box; - box = 0; - } - break; - } - if (box) { - jp2_box_destroy(box); - box = 0; - } - if (found) { - break; - } - } - - if (!found) { - jas_eprintf("error: no code stream found\n"); - goto error; - } - - if (!(dec->image = jpc_decode(in, optstr))) { - jas_eprintf("error: cannot decode code stream\n"); - goto error; - } - - /* An IHDR box must be present. */ - if (!dec->ihdr) { - jas_eprintf("error: missing IHDR box\n"); - goto error; - } - - /* Does the number of components indicated in the IHDR box match - the value specified in the code stream? */ - if (dec->ihdr->data.ihdr.numcmpts != jas_image_numcmpts(dec->image)) { - jas_eprintf("warning: number of components mismatch\n"); - } - - /* At least one component must be present. */ - if (!jas_image_numcmpts(dec->image)) { - jas_eprintf("error: no components\n"); - goto error; - } - - /* Determine if all components have the same data type. */ - samedtype = true; - dtype = jas_image_cmptdtype(dec->image, 0); - for (i = 1; i < jas_image_numcmpts(dec->image); ++i) { - if (jas_image_cmptdtype(dec->image, i) != dtype) { - samedtype = false; - break; - } - } - - /* Is the component data type indicated in the IHDR box consistent - with the data in the code stream? */ - if ((samedtype && dec->ihdr->data.ihdr.bpc != JP2_DTYPETOBPC(dtype)) || - (!samedtype && dec->ihdr->data.ihdr.bpc != JP2_IHDR_BPCNULL)) { - jas_eprintf("warning: component data type mismatch\n"); - } - - /* Can we handle the compression type? */ - if (dec->ihdr->data.ihdr.comptype != JP2_IHDR_COMPTYPE) { - jas_eprintf("error: not capable of this compression type\n"); - goto error; - } - - if (dec->bpcc) { - /* Is the number of components indicated in the BPCC box - consistent with the code stream data? */ - if (dec->bpcc->data.bpcc.numcmpts != jas_image_numcmpts( - dec->image)) { - jas_eprintf("warning: number of components mismatch\n"); - } - /* Is the component data type information indicated in the BPCC - box consistent with the code stream data? */ - if (!samedtype) { - for (i = 0; i < jas_image_numcmpts(dec->image); ++i) { - if (jas_image_cmptdtype(dec->image, i) != JP2_BPCTODTYPE(dec->bpcc->data.bpcc.bpcs[i])) { - jas_eprintf("warning: component data type mismatch\n"); - } - } - } else { - jas_eprintf("warning: superfluous BPCC box\n"); - } - } - - /* A COLR box must be present. */ - if (!dec->colr) { - jas_eprintf("error: no COLR box\n"); - goto error; - } - - switch (dec->colr->data.colr.method) { - case JP2_COLR_ENUM: - jas_image_setcolorspace(dec->image, jp2_getcs(&dec->colr->data.colr)); - break; - case JP2_COLR_ICC: - if (dec->colr->data.colr.iccplen < 128) { - abort(); - } - iccp = dec->colr->data.colr.iccp; - cs = (iccp[16] << 24) | (iccp[17] << 16) | (iccp[18] << 8) | - iccp[19]; - if (jas_getdbglevel() > 1) - jas_eprintf("ICC Profile CS %08x\n", cs); - jas_image_setcolorspace(dec->image, fromiccpcs(cs)); - break; - } - - /* If a CMAP box is present, a PCLR box must also be present. */ - if (dec->cmap && !dec->pclr) { - jas_eprintf("warning: missing PCLR box or superfluous CMAP box\n"); - jp2_box_destroy(dec->cmap); - dec->cmap = 0; - } - - /* If a CMAP box is not present, a PCLR box must not be present. */ - if (!dec->cmap && dec->pclr) { - jas_eprintf("warning: missing CMAP box or superfluous PCLR box\n"); - jp2_box_destroy(dec->pclr); - dec->pclr = 0; - } - - /* 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 : jas_image_numcmpts(dec->image); - - /* Perform a basic sanity check on the CMAP box if present. */ - if (dec->cmap) { - for (i = 0; i < dec->numchans; ++i) { - /* Is the component number reasonable? */ - if (dec->cmap->data.cmap.ents[i].cmptno >= jas_image_numcmpts(dec->image)) { - jas_eprintf("error: invalid component number in CMAP box\n"); - goto error; - } - /* Is the LUT index reasonable? */ - if (dec->cmap->data.cmap.ents[i].pcol >= dec->pclr->data.pclr.numchans) { - jas_eprintf("error: invalid CMAP LUT index\n"); - goto error; - } - } - } - - /* Allocate space for the channel-number to component-number LUT. */ - if (!(dec->chantocmptlut = jas_malloc(dec->numchans * sizeof(uint_fast16_t)))) { - jas_eprintf("error: no memory\n"); - goto error; - } - - if (!dec->cmap) { - for (i = 0; i < dec->numchans; ++i) { - dec->chantocmptlut[i] = i; - } - } else { - cmapd = &dec->cmap->data.cmap; - pclrd = &dec->pclr->data.pclr; - cdefd = &dec->cdef->data.cdef; - for (channo = 0; channo < cmapd->numchans; ++channo) { - cmapent = &cmapd->ents[channo]; - if (cmapent->map == JP2_CMAP_DIRECT) { - dec->chantocmptlut[channo] = channo; - } else if (cmapent->map == JP2_CMAP_PALETTE) { - lutents = jas_malloc(pclrd->numlutents * sizeof(int_fast32_t)); - for (i = 0; i < pclrd->numlutents; ++i) { - lutents[i] = pclrd->lutdata[cmapent->pcol + i * pclrd->numchans]; - } - newcmptno = jas_image_numcmpts(dec->image); - jas_image_depalettize(dec->image, cmapent->cmptno, pclrd->numlutents, lutents, JP2_BPCTODTYPE(pclrd->bpc[cmapent->pcol]), newcmptno); - dec->chantocmptlut[channo] = newcmptno; - jas_free(lutents); -#if 0 - if (dec->cdef) { - cdefent = jp2_cdef_lookup(cdefd, channo); - if (!cdefent) { - abort(); - } - jas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_colorspace(dec->image), cdefent->type, cdefent->assoc)); - } else { - jas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_colorspace(dec->image), 0, channo + 1)); - } -#endif - } - } - } - - /* Mark all components as being of unknown type. */ - - for (i = 0; i < jas_image_numcmpts(dec->image); ++i) { - jas_image_setcmpttype(dec->image, i, JAS_IMAGE_CT_UNKNOWN); - } - - /* Determine the type of each component. */ - if (dec->cdef) { - for (i = 0; i < dec->numchans; ++i) { - jas_image_setcmpttype(dec->image, - dec->chantocmptlut[dec->cdef->data.cdef.ents[i].channo], - jp2_getct(jas_image_colorspace(dec->image), - dec->cdef->data.cdef.ents[i].type, dec->cdef->data.cdef.ents[i].assoc)); - } - } else { - for (i = 0; i < dec->numchans; ++i) { - jas_image_setcmpttype(dec->image, dec->chantocmptlut[i], - jp2_getct(jas_image_colorspace(dec->image), 0, i + 1)); - } - } - - /* Delete any components that are not of interest. */ - for (i = jas_image_numcmpts(dec->image) - 1; i >= 0; --i) { - if (jas_image_cmpttype(dec->image, i) == JAS_IMAGE_CT_UNKNOWN) { - jas_image_delcmpt(dec->image, i); - } - } - - /* Ensure that some components survived. */ - if (!jas_image_numcmpts(dec->image)) { - jas_eprintf("error: no components\n"); - goto error; - } - - /* Prevent the image from being destroyed later. */ - image = dec->image; - dec->image = 0; - - jp2_dec_destroy(dec); - - return image; +#define JP2_VALIDATELEN (JAS_MIN(JP2_JP_LEN + 16, JAS_STREAM_MAXPUTBACK)) -error: - if (box) { - jp2_box_destroy(box); - } - if (dec) { - jp2_dec_destroy(dec); - } - return 0; + + +static jp2_dec_t * +jp2_dec_create(void) { + + jp2_dec_t *dec; + + dec = jas_malloc(sizeof(jp2_dec_t)); + if (dec) { + dec->ihdr = 0; + dec->bpcc = 0; + dec->cdef = 0; + dec->pclr = 0; + dec->image = 0; + dec->chantocmptlut = 0; + dec->cmap = 0; + dec->colr = 0; + } + return dec; } -int jp2_validate(jas_stream_t *in) -{ - char buf[JP2_VALIDATELEN]; - int i; - int n; - - assert(JAS_STREAM_MAXPUTBACK >= JP2_VALIDATELEN); - - /* Read the validation data (i.e., the data used for detecting - the format). */ - if ((n = jas_stream_read(in, buf, JP2_VALIDATELEN)) < 0) { - return -1; - } - - /* Put the validation data back onto the stream, so that the - stream position will not be changed. */ - for (i = n - 1; i >= 0; --i) { - if (jas_stream_ungetc(in, buf[i]) == EOF) { - return -1; - } - } - - /* Did we read enough data? */ - if (n < JP2_VALIDATELEN) { - return -1; - } - - /* Is the box type correct? */ - if (((buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]) != - JP2_BOX_JP) - { - return -1; - } - - return 0; + + +static void +jp2_dec_destroy(jp2_dec_t *dec) { + + if (dec->ihdr) + jp2_box_destroy(dec->ihdr); + + if (dec->bpcc) + jp2_box_destroy(dec->bpcc); + + if (dec->cdef) + jp2_box_destroy(dec->cdef); + + if (dec->pclr) + jp2_box_destroy(dec->pclr); + + if (dec->image) + jas_image_destroy(dec->image); + + if (dec->cmap) + jp2_box_destroy(dec->cmap); + + if (dec->colr) + jp2_box_destroy(dec->colr); + + if (dec->chantocmptlut) + jas_free(dec->chantocmptlut); + + jas_free(dec); } -static jp2_dec_t *jp2_dec_create(void) -{ - jp2_dec_t *dec; - - if (!(dec = jas_malloc(sizeof(jp2_dec_t)))) { - return 0; - } - dec->ihdr = 0; - dec->bpcc = 0; - dec->cdef = 0; - dec->pclr = 0; - dec->image = 0; - dec->chantocmptlut = 0; - dec->cmap = 0; - dec->colr = 0; - return dec; + + +static int +jp2_getct(int colorspace, int type, int assoc) { + + if (type == 1 && assoc == 0) + return JAS_IMAGE_CT_OPACITY; + + if (type == 0 && assoc >= 1 && assoc <= 65534) { + switch (colorspace) { + case JAS_IMAGE_CS_RGB: + switch (assoc) { + case JP2_CDEF_RGB_R: + return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_R); + break; + case JP2_CDEF_RGB_G: + return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_G); + break; + case JP2_CDEF_RGB_B: + return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_B); + break; + } + break; + case JAS_IMAGE_CS_YCBCR: + switch (assoc) { + case JP2_CDEF_YCBCR_Y: + return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_Y); + break; + case JP2_CDEF_YCBCR_CB: + return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CB); + break; + case JP2_CDEF_YCBCR_CR: + return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CR); + break; + } + break; + case JAS_IMAGE_CS_GRAY: + switch (assoc) { + case JP2_CDEF_GRAY_Y: + return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y); + break; + } + break; +#if 0 + case JAS_IMAGE_CS_ICC: +#endif + default: + return JAS_IMAGE_CT_COLOR(assoc - 1); + break; + } + } + return JAS_IMAGE_CT_UNKNOWN; } -static void jp2_dec_destroy(jp2_dec_t *dec) -{ - if (dec->ihdr) { - jp2_box_destroy(dec->ihdr); - } - if (dec->bpcc) { - jp2_box_destroy(dec->bpcc); - } - if (dec->cdef) { - jp2_box_destroy(dec->cdef); - } - if (dec->pclr) { - jp2_box_destroy(dec->pclr); - } - if (dec->image) { - jas_image_destroy(dec->image); - } - if (dec->cmap) { - jp2_box_destroy(dec->cmap); - } - if (dec->colr) { - jp2_box_destroy(dec->colr); - } - if (dec->chantocmptlut) { - jas_free(dec->chantocmptlut); - } - jas_free(dec); + + +static int +jp2_getcs(jp2_colr_t *colr) { + + if (colr->method == JP2_COLR_ENUM) { + switch (colr->csid) { + case JP2_COLR_SRGB: + return JAS_IMAGE_CS_RGB; + break; + case JP2_COLR_SYCC: + return JAS_IMAGE_CS_YCBCR; + break; + case JP2_COLR_SGRAY: + return JAS_IMAGE_CS_GRAY; + break; + } + } + return JAS_IMAGE_CS_UNKNOWN; } +static int +fromiccpcs(int cs) { + + switch (cs) { + case ICC_CS_RGB: + return JAS_IMAGE_CS_RGB; + break; + case ICC_CS_YCBCR: + return JAS_IMAGE_CS_YCBCR; + break; + case ICC_CS_GRAY: + return JAS_IMAGE_CS_GRAY; + break; + } + return JAS_IMAGE_CS_UNKNOWN; +} -static int jp2_getct(int colorspace, int type, int assoc) -{ - if (type == 1 && assoc == 0) { - return JAS_IMAGE_CT_OPACITY; - } - if (type == 0 && assoc >= 1 && assoc <= 65534) { - switch (colorspace) { - case JAS_IMAGE_CS_RGB: - switch (assoc) { - case JP2_CDEF_RGB_R: - return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_R); - break; - case JP2_CDEF_RGB_G: - return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_G); - break; - case JP2_CDEF_RGB_B: - return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_B); - break; - } - break; - case JAS_IMAGE_CS_YCBCR: - switch (assoc) { - case JP2_CDEF_YCBCR_Y: - return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_Y); - break; - case JP2_CDEF_YCBCR_CB: - return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CB); - break; - case JP2_CDEF_YCBCR_CR: - return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_YCBCR_CR); - break; - } - break; - case JAS_IMAGE_CS_GRAY: - switch (assoc) { - case JP2_CDEF_GRAY_Y: - return JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y); - break; - } - break; +jas_image_t * +jp2_decode(jas_stream_t *in, char *optstr) { + + jp2_box_t *box; + int found; + jas_image_t *image; + jp2_dec_t *dec; + bool samedtype; + int dtype; + int i; + jp2_cmap_t *cmapd; + jp2_pclr_t *pclrd; + int channo; + int newcmptno; + int_fast32_t *lutents; + jp2_cmapent_t *cmapent; + unsigned char *iccp; + int cs; + + dec = 0; + box = 0; + image = 0; + + if (!(dec = jp2_dec_create())) { + goto error; + } + + /* Get the first box. This should be a JP box. */ + if (!(box = jp2_box_get(in))) { + jas_eprintf("error: cannot get box\n"); + goto error; + } + if (box->type != JP2_BOX_JP) { + jas_eprintf("error: expecting signature box\n"); + goto error; + } + if (box->data.jp.magic != JP2_JP_MAGIC) { + jas_eprintf("incorrect magic number\n"); + goto error; + } + jp2_box_destroy(box); + box = 0; + + /* Get the second box. This should be a FTYP box. */ + if (!(box = jp2_box_get(in))) { + goto error; + } + if (box->type != JP2_BOX_FTYP) { + jas_eprintf("expecting file type box\n"); + goto error; + } + jp2_box_destroy(box); + box = 0; + + /* Get more boxes... */ + found = 0; + while ((box = jp2_box_get(in))) { + if (jas_getdbglevel() >= 1) { + fprintf(stderr, "box type %s\n", box->info->name); + } + switch (box->type) { + case JP2_BOX_JP2C: + found = 1; + break; + case JP2_BOX_IHDR: + if (!dec->ihdr) { + dec->ihdr = box; + box = 0; + } + break; + case JP2_BOX_BPCC: + if (!dec->bpcc) { + dec->bpcc = box; + box = 0; + } + break; + case JP2_BOX_CDEF: + if (!dec->cdef) { + dec->cdef = box; + box = 0; + } + break; + case JP2_BOX_PCLR: + if (!dec->pclr) { + dec->pclr = box; + box = 0; + } + break; + case JP2_BOX_CMAP: + if (!dec->cmap) { + dec->cmap = box; + box = 0; + } + break; + case JP2_BOX_COLR: + if (!dec->colr) { + dec->colr = box; + box = 0; + } + break; + } + if (box) { + jp2_box_destroy(box); + box = 0; + } + if (found) { + break; + } + } + + if (!found) { + jas_eprintf("error: no code stream found\n"); + goto error; + } + + if (!(dec->image = jpc_decode(in, optstr))) { + jas_eprintf("error: cannot decode code stream\n"); + goto error; + } + + /* An IHDR box must be present. */ + if (!dec->ihdr) { + jas_eprintf("error: missing IHDR box\n"); + goto error; + } + + /* Does the number of components indicated in the IHDR box match + the value specified in the code stream? */ + if (dec->ihdr->data.ihdr.numcmpts != jas_image_numcmpts(dec->image)) { + jas_eprintf("warning: number of components mismatch\n"); + } + + /* At least one component must be present. */ + if (!jas_image_numcmpts(dec->image)) { + jas_eprintf("error: no components\n"); + goto error; + } + + /* Determine if all components have the same data type. */ + samedtype = true; + dtype = jas_image_cmptdtype(dec->image, 0); + for (i = 1; i < jas_image_numcmpts(dec->image); ++i) { + if (jas_image_cmptdtype(dec->image, i) != dtype) { + samedtype = false; + break; + } + } + + /* Is the component data type indicated in the IHDR box consistent + with the data in the code stream? */ + if ((samedtype && dec->ihdr->data.ihdr.bpc != JP2_DTYPETOBPC(dtype)) || + (!samedtype && dec->ihdr->data.ihdr.bpc != JP2_IHDR_BPCNULL)) { + jas_eprintf("warning: component data type mismatch\n"); + } + + /* Can we handle the compression type? */ + if (dec->ihdr->data.ihdr.comptype != JP2_IHDR_COMPTYPE) { + jas_eprintf("error: not capable of this compression type\n"); + goto error; + } + + if (dec->bpcc) { + /* Is the number of components indicated in the BPCC box + consistent with the code stream data? */ + if (dec->bpcc->data.bpcc.numcmpts != jas_image_numcmpts( + dec->image)) { + jas_eprintf("warning: number of components mismatch\n"); + } + /* Is the component data type information indicated in the BPCC + box consistent with the code stream data? */ + if (!samedtype) { + for (i = 0; i < jas_image_numcmpts(dec->image); ++i) { + if (jas_image_cmptdtype(dec->image, i) != + JP2_BPCTODTYPE(dec->bpcc->data.bpcc.bpcs[i])) { + jas_eprintf("warning: component data type mismatch\n"); + } + } + } else { + jas_eprintf("warning: superfluous BPCC box\n"); + } + } + + /* A COLR box must be present. */ + if (!dec->colr) { + jas_eprintf("error: no COLR box\n"); + goto error; + } + + switch (dec->colr->data.colr.method) { + case JP2_COLR_ENUM: + jas_image_setcolorspace(dec->image, jp2_getcs(&dec->colr->data.colr)); + break; + case JP2_COLR_ICC: + if (dec->colr->data.colr.iccplen < 128) { + abort(); + } + iccp = dec->colr->data.colr.iccp; + cs = (iccp[16] << 24) | (iccp[17] << 16) | (iccp[18] << 8) | + iccp[19]; + if (jas_getdbglevel() > 1) + jas_eprintf("ICC Profile CS %08x\n", cs); + jas_image_setcolorspace(dec->image, fromiccpcs(cs)); + break; + } + + /* If a CMAP box is present, a PCLR box must also be present. */ + if (dec->cmap && !dec->pclr) { + jas_eprintf("warning: missing PCLR box or superfluous CMAP box\n"); + jp2_box_destroy(dec->cmap); + dec->cmap = 0; + } + + /* If a CMAP box is not present, a PCLR box must not be present. */ + if (!dec->cmap && dec->pclr) { + jas_eprintf("warning: missing CMAP box or superfluous PCLR box\n"); + jp2_box_destroy(dec->pclr); + dec->pclr = 0; + } + + /* 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 : + jas_image_numcmpts(dec->image); + + /* Perform a basic sanity check on the CMAP box if present. */ + if (dec->cmap) { + for (i = 0; i < dec->numchans; ++i) { + /* Is the component number reasonable? */ + if (dec->cmap->data.cmap.ents[i].cmptno >= + jas_image_numcmpts(dec->image)) { + jas_eprintf("error: invalid component number in CMAP box\n"); + goto error; + } + /* Is the LUT index reasonable? */ + if (dec->cmap->data.cmap.ents[i].pcol >= + dec->pclr->data.pclr.numchans) { + jas_eprintf("error: invalid CMAP LUT index\n"); + goto error; + } + } + } + + /* Allocate space for the channel-number to component-number LUT. */ + dec->chantocmptlut = jas_malloc(dec->numchans * sizeof(uint_fast16_t)); + if (!dec->chantocmptlut) { + jas_eprintf("error: no memory\n"); + goto error; + } + + if (!dec->cmap) { + for (i = 0; i < dec->numchans; ++i) { + dec->chantocmptlut[i] = i; + } + } else { + cmapd = &dec->cmap->data.cmap; + pclrd = &dec->pclr->data.pclr; + for (channo = 0; channo < cmapd->numchans; ++channo) { + cmapent = &cmapd->ents[channo]; + if (cmapent->map == JP2_CMAP_DIRECT) { + dec->chantocmptlut[channo] = channo; + } else if (cmapent->map == JP2_CMAP_PALETTE) { + lutents = jas_malloc(pclrd->numlutents * sizeof(int_fast32_t)); + for (i = 0; i < pclrd->numlutents; ++i) { + lutents[i] = + pclrd->lutdata[cmapent->pcol + i * pclrd->numchans]; + } + newcmptno = jas_image_numcmpts(dec->image); + jas_image_depalettize( + dec->image, cmapent->cmptno, pclrd->numlutents, lutents, + JP2_BPCTODTYPE(pclrd->bpc[cmapent->pcol]), newcmptno); + dec->chantocmptlut[channo] = newcmptno; + jas_free(lutents); #if 0 - case JAS_IMAGE_CS_ICC: + if (dec->cdef) { + jp2_cdef_t * const cdefd = &dec->cdef->data.cdef; + cdefent = jp2_cdef_lookup(cdefd, channo); + if (!cdefent) { + abort(); + } + jas_image_setcmpttype( + dec->image, newcmptno, + jp2_getct(jas_image_colorspace(dec->image), + cdefent->type, cdefent->assoc)); + } else { + jas_image_setcmpttype( + dec->image, newcmptno, + jp2_getct(jas_image_colorspace(dec->image), + 0, + channo + 1)); + } #endif - default: - return JAS_IMAGE_CT_COLOR(assoc - 1); - break; - } - } - return JAS_IMAGE_CT_UNKNOWN; -} + } + } + } + + /* Mark all components as being of unknown type. */ + + for (i = 0; i < jas_image_numcmpts(dec->image); ++i) { + jas_image_setcmpttype(dec->image, i, JAS_IMAGE_CT_UNKNOWN); + } + + /* Determine the type of each component. */ + if (dec->cdef) { + unsigned int i; + for (i = 0; i < dec->numchans; ++i) { + jas_image_setcmpttype( + dec->image, + dec->chantocmptlut[dec->cdef->data.cdef.ents[i].channo], + jp2_getct(jas_image_colorspace(dec->image), + dec->cdef->data.cdef.ents[i].type, + dec->cdef->data.cdef.ents[i].assoc)); + } + } else { + unsigned int i; + for (i = 0; i < dec->numchans; ++i) { + jas_image_setcmpttype(dec->image, dec->chantocmptlut[i], + jp2_getct(jas_image_colorspace(dec->image), 0, i + 1)); + } + } + + /* Delete any components that are not of interest. */ + for (i = jas_image_numcmpts(dec->image) - 1; i >= 0; --i) { + if (jas_image_cmpttype(dec->image, i) == JAS_IMAGE_CT_UNKNOWN) { + jas_image_delcmpt(dec->image, i); + } + } + + /* Ensure that some components survived. */ + if (!jas_image_numcmpts(dec->image)) { + jas_eprintf("error: no components\n"); + goto error; + } + + /* Prevent the image from being destroyed later. */ + image = dec->image; + dec->image = 0; + + jp2_dec_destroy(dec); + + return image; -static int jp2_getcs(jp2_colr_t *colr) -{ - if (colr->method == JP2_COLR_ENUM) { - switch (colr->csid) { - case JP2_COLR_SRGB: - return JAS_IMAGE_CS_RGB; - break; - case JP2_COLR_SYCC: - return JAS_IMAGE_CS_YCBCR; - break; - case JP2_COLR_SGRAY: - return JAS_IMAGE_CS_GRAY; - break; - } - } - return JAS_IMAGE_CS_UNKNOWN; +error: + if (box) { + jp2_box_destroy(box); + } + if (dec) { + jp2_dec_destroy(dec); + } + return 0; } -static int fromiccpcs(int cs) -{ - switch (cs) { - case ICC_CS_RGB: - return JAS_IMAGE_CS_RGB; - break; - case ICC_CS_YCBCR: - return JAS_IMAGE_CS_YCBCR; - break; - case ICC_CS_GRAY: - return JAS_IMAGE_CS_GRAY; - break; - } - return JAS_IMAGE_CS_UNKNOWN; + + +int +jp2_validate(jas_stream_t *in) { + + char buf[JP2_VALIDATELEN]; + int i; + int n; + + assert(JAS_STREAM_MAXPUTBACK >= JP2_VALIDATELEN); + + /* Read the validation data (i.e., the data used for detecting + the format). */ + if ((n = jas_stream_read(in, buf, JP2_VALIDATELEN)) < 0) { + return -1; + } + + /* Put the validation data back onto the stream, so that the + stream position will not be changed. */ + for (i = n - 1; i >= 0; --i) { + if (jas_stream_ungetc(in, buf[i]) == EOF) { + return -1; + } + } + + /* Did we read enough data? */ + if (n < JP2_VALIDATELEN) { + return -1; + } + + /* Is the box type correct? */ + if (((buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]) != + JP2_BOX_JP) + { + return -1; + } + + return 0; } + + + diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c index 72bd0126..cada97f8 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c @@ -458,6 +458,12 @@ static int jpc_dec_decode(jpc_dec_t *dec) static int jpc_dec_process_crg(jpc_dec_t *dec, jpc_ms_t *ms) { + /* Ignore the information in the CRG marker segment for now. + This information serves no useful purpose for decoding anyhow. + Some other parts of the code need to be changed if these lines + are enabled. + */ +#ifdef USING_CRG uint_fast16_t cmptno; jpc_dec_cmpt_t *cmpt; jpc_crg_t *crg; @@ -465,14 +471,10 @@ static int jpc_dec_process_crg(jpc_dec_t *dec, jpc_ms_t *ms) crg = &ms->parms.crg; for (cmptno = 0, cmpt = dec->cmpts; cmptno < dec->numcomps; ++cmptno, ++cmpt) { - /* Ignore the information in the CRG marker segment for now. - This information serves no useful purpose for decoding anyhow. - Some other parts of the code need to be changed if these lines - are uncommented. cmpt->hsubstep = crg->comps[cmptno].hoff; cmpt->vsubstep = crg->comps[cmptno].voff; - */ } +#endif return 0; } @@ -701,7 +703,6 @@ static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile) uint_fast32_t tlcbgxstart; uint_fast32_t tlcbgystart; uint_fast32_t brcbgxend; - uint_fast32_t brcbgyend; uint_fast32_t cbgxstart; uint_fast32_t cbgystart; uint_fast32_t cbgxend; @@ -792,14 +793,12 @@ rlvl->bands = 0; tlcbgxstart = tlprcxstart; tlcbgystart = tlprcystart; brcbgxend = brprcxend; - brcbgyend = brprcyend; rlvl->cbgwidthexpn = rlvl->prcwidthexpn; rlvl->cbgheightexpn = rlvl->prcheightexpn; } else { tlcbgxstart = JPC_CEILDIVPOW2(tlprcxstart, 1); tlcbgystart = JPC_CEILDIVPOW2(tlprcystart, 1); brcbgxend = JPC_CEILDIVPOW2(brprcxend, 1); - brcbgyend = JPC_CEILDIVPOW2(brprcyend, 1); rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c index d17e9aa3..9db41ca2 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c @@ -73,9 +73,9 @@ int ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size); static void pass_destroy(jpc_enc_pass_t *pass); void jpc_enc_dump(jpc_enc_t *enc); -/******************************************************************************\ +/*****************************************************************************\ * Local prototypes. -\******************************************************************************/ +\*****************************************************************************/ void quantize(jas_matrix_t *data, jpc_fix_t stepsize); static int jpc_enc_encodemainhdr(jpc_enc_t *enc); @@ -90,8 +90,11 @@ int setins(int numvalues, jpc_flt_t *values, jpc_flt_t value); static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image); void jpc_enc_cp_destroy(jpc_enc_cp_t *cp); -static uint_fast32_t jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn) -{ + + +static uint_fast32_t +jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn) { + int p; uint_fast32_t mant; uint_fast32_t expn; @@ -111,6 +114,8 @@ static uint_fast32_t jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn) return JPC_QCX_EXPN(expn) | JPC_QCX_MANT(mant); } + + typedef enum { OPT_DEBUG, OPT_IMGAREAOFFX, @@ -199,6 +204,7 @@ jas_taginfo_t modetab[] = { }; + static void tracev(const char * const fmt, va_list args) { @@ -224,12 +230,9 @@ trace(const char * const fmt, ...) { -/******************************************************************************\ -* The main encoder entry point. -\******************************************************************************/ +int +jpc_encode(jas_image_t *image, jas_stream_t *out, char *optstr) { -int jpc_encode(jas_image_t *image, jas_stream_t *out, char *optstr) -{ jpc_enc_t *enc; jpc_enc_cp_t *cp; @@ -287,12 +290,15 @@ error: return -1; } -/******************************************************************************\ + + +/*****************************************************************************\ * Option parsing code. -\******************************************************************************/ +\*****************************************************************************/ + +static jpc_enc_cp_t * +cp_create(char *optstr, jas_image_t *image) { -static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) -{ jpc_enc_cp_t *cp; jas_tvparser_t *tvp; int ret; @@ -343,10 +349,12 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) hsteplcm = 1; vsteplcm = 1; for (cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) { - if (jas_image_cmptbrx(image, cmptno) + jas_image_cmpthstep(image, cmptno) <= + if (jas_image_cmptbrx(image, cmptno) + + jas_image_cmpthstep(image, cmptno) <= jas_image_brx(image) || jas_image_cmptbry(image, cmptno) + jas_image_cmptvstep(image, cmptno) <= jas_image_bry(image)) { - fprintf(stderr, "We don't know how to interpret this image type\n"); + fprintf(stderr, + "We don't know how to interpret this image type\n"); goto error; } /* Note: We ought to be calculating the LCMs here. Fix some day. */ @@ -495,7 +503,8 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) if (jpc_atoaf(jas_tvparser_getval(tvp), &numilyrrates, &ilyrrates)) { fprintf(stderr, - "warning: invalid intermediate layer rates specifier ignored (%s)\n", + "warning: invalid intermediate layer rates specifier " + "ignored (%s)\n", jas_tvparser_getval(tvp)); } break; @@ -552,20 +561,26 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) if (cp->numcmpts == 3) { mctvalid = true; for (cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) { - if (jas_image_cmptprec(image, cmptno) != jas_image_cmptprec(image, 0) || - jas_image_cmptsgnd(image, cmptno) != jas_image_cmptsgnd(image, 0) || - jas_image_cmptwidth(image, cmptno) != jas_image_cmptwidth(image, 0) || - jas_image_cmptheight(image, cmptno) != jas_image_cmptheight(image, 0)) { + if (jas_image_cmptprec(image, cmptno) != + jas_image_cmptprec(image, 0) || + jas_image_cmptsgnd(image, cmptno) != + jas_image_cmptsgnd(image, 0) || + jas_image_cmptwidth(image, cmptno) != + jas_image_cmptwidth(image, 0) || + jas_image_cmptheight(image, cmptno) != + jas_image_cmptheight(image, 0)) { mctvalid = false; } } } else { mctvalid = false; } - if (mctvalid && enablemct && jas_image_colorspace(image) != JAS_IMAGE_CS_RGB) { + if (mctvalid && enablemct && jas_image_colorspace(image) != + JAS_IMAGE_CS_RGB) { fprintf(stderr, "warning: color model apparently not RGB\n"); } - if (mctvalid && enablemct && jas_image_colorspace(image) == JAS_IMAGE_CS_RGB) { + if (mctvalid && enablemct && jas_image_colorspace(image) == + JAS_IMAGE_CS_RGB) { tcp->mctid = (tcp->intmode) ? (JPC_MCT_RCT) : (JPC_MCT_ICT); } else { tcp->mctid = JPC_MCT_NONE; @@ -682,16 +697,20 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) /* The intermediate layers rates must increase monotonically. */ for (lyrno = 0; lyrno + 2 < tcp->numlyrs; ++lyrno) { if (tcp->ilyrrates[lyrno] >= tcp->ilyrrates[lyrno + 1]) { - fprintf(stderr, "intermediate layer rates must increase monotonically\n"); + fprintf(stderr, + "intermediate layer rates must increase " + "monotonically\n"); goto error; } } /* The intermediate layer rates must be less than the overall rate. */ if (cp->totalsize != UINT_FAST32_MAX) { for (lyrno = 0; lyrno < tcp->numlyrs - 1; ++lyrno) { - if (jpc_fixtodbl(tcp->ilyrrates[lyrno]) > ((double) cp->totalsize) - / cp->rawsize) { - fprintf(stderr, "warning: intermediate layer rates must be less than overall rate\n"); + if (jpc_fixtodbl(tcp->ilyrrates[lyrno]) > + ((double) cp->totalsize) / cp->rawsize) { + fprintf(stderr, + "warning: intermediate layer rates must be " + "less than overall rate\n"); goto error; } } @@ -718,8 +737,11 @@ error: return 0; } -void jpc_enc_cp_destroy(jpc_enc_cp_t *cp) -{ + + +void +jpc_enc_cp_destroy(jpc_enc_cp_t *cp) { + if (cp->ccps) { if (cp->tcp.ilyrrates) { jas_free(cp->tcp.ilyrrates); @@ -729,8 +751,11 @@ void jpc_enc_cp_destroy(jpc_enc_cp_t *cp) jas_free(cp); } -int ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size) -{ + + +int +ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size) { + char *cp; jpc_flt_t f; @@ -750,12 +775,13 @@ int ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size) return 0; } -/******************************************************************************\ +/*****************************************************************************\ * Encoder constructor and destructor. -\******************************************************************************/ +\*****************************************************************************/ + +jpc_enc_t * +jpc_enc_create(jpc_enc_cp_t *cp, jas_stream_t *out, jas_image_t *image) { -jpc_enc_t *jpc_enc_create(jpc_enc_cp_t *cp, jas_stream_t *out, jas_image_t *image) -{ jpc_enc_t *enc; enc = 0; @@ -788,11 +814,15 @@ error: return 0; } -void jpc_enc_destroy(jpc_enc_t *enc) -{ + + +void +jpc_enc_destroy(jpc_enc_t *enc) { + /* The image object (i.e., enc->image) and output stream object - (i.e., enc->out) are created outside of the encoder. - Therefore, they must not be destroyed here. */ + (i.e., enc->out) are created outside of the encoder. + Therefore, they must not be destroyed here. + */ if (enc->curtile) { jpc_enc_tile_destroy(enc->curtile); @@ -810,24 +840,22 @@ void jpc_enc_destroy(jpc_enc_t *enc) jas_free(enc); } -/******************************************************************************\ -* Code. -\******************************************************************************/ -static int jpc_enc_encodemainhdr(jpc_enc_t *enc) -{ + +static int +jpc_enc_encodemainhdr(jpc_enc_t *enc) { + jpc_siz_t *siz; jpc_cod_t *cod; jpc_qcd_t *qcd; int i; -long startoff; -long mainhdrlen; + long startoff; + long mainhdrlen; jpc_enc_cp_t *cp; jpc_qcc_t *qcc; jpc_enc_tccp_t *tccp; uint_fast16_t cmptno; jpc_tsfb_band_t bandinfos[JPC_MAXBANDS]; - jpc_fix_t mctsynweight; jpc_enc_tcp_t *tcp; jpc_tsfb_t *tsfb; jpc_tsfb_band_t *bandinfo; @@ -841,7 +869,7 @@ long mainhdrlen; cp = enc->cp; -startoff = jas_stream_getrwcount(enc->out); + startoff = jas_stream_getrwcount(enc->out); /* Write SOC marker segment. */ if (!(enc->mrk = jpc_ms_create(JPC_MS_SOC))) { @@ -922,7 +950,6 @@ startoff = jas_stream_getrwcount(enc->out); jpc_tsfb_getbands(tsfb, 0, 0, 1 << tccp->maxrlvls, 1 << tccp->maxrlvls, bandinfos); jpc_tsfb_destroy(tsfb); - mctsynweight = jpc_mct_getsynweight(tcp->mctid, cmptno); numbands = 3 * tccp->maxrlvls - 2; for (bandno = 0, bandinfo = bandinfos; bandno < numbands; ++bandno, ++bandinfo) { @@ -953,14 +980,17 @@ startoff = jas_stream_getrwcount(enc->out); cod->prg = cp->tcp.prg; cod->numlyrs = cp->tcp.numlyrs; cod->compparms.cblkwidthval = JPC_COX_CBLKSIZEEXPN(cp->tccp.cblkwidthexpn); - cod->compparms.cblkheightval = JPC_COX_CBLKSIZEEXPN(cp->tccp.cblkheightexpn); + cod->compparms.cblkheightval = + JPC_COX_CBLKSIZEEXPN(cp->tccp.cblkheightexpn); cod->compparms.cblksty = cp->tccp.cblksty; cod->compparms.qmfbid = cp->tccp.qmfbid; cod->mctrans = (cp->tcp.mctid != JPC_MCT_NONE); if (tccp->csty & JPC_COX_PRT) { for (rlvlno = 0; rlvlno < tccp->maxrlvls; ++rlvlno) { - cod->compparms.rlvls[rlvlno].parwidthval = tccp->prcwidthexpns[rlvlno]; - cod->compparms.rlvls[rlvlno].parheightval = tccp->prcheightexpns[rlvlno]; + cod->compparms.rlvls[rlvlno].parwidthval = + tccp->prcwidthexpns[rlvlno]; + cod->compparms.rlvls[rlvlno].parheightval = + tccp->prcheightexpns[rlvlno]; } } if (jpc_putms(enc->out, enc->cstate, enc->mrk)) { @@ -1023,17 +1053,23 @@ startoff = jas_stream_getrwcount(enc->out); return 0; } -int jpc_enc_encodetiledata(jpc_enc_t *enc) -{ -assert(enc->tmpstream); + + +int +jpc_enc_encodetiledata(jpc_enc_t *enc) { + + assert(enc->tmpstream); if (jpc_enc_encpkts(enc, enc->tmpstream)) { return -1; } return 0; } -void quantize(jas_matrix_t *data, jpc_fix_t stepsize) -{ + + +void +quantize(jas_matrix_t *data, jpc_fix_t stepsize) { + int i; int j; jpc_fix_t t; @@ -1059,8 +1095,11 @@ void quantize(jas_matrix_t *data, jpc_fix_t stepsize) } } -static void calcrdslopes(jpc_enc_cblk_t *cblk) -{ + + +static void +calcrdslopes(jpc_enc_cblk_t *cblk) { + jpc_enc_pass_t *endpasses; jpc_enc_pass_t *pass0; jpc_enc_pass_t *pass1; @@ -1113,10 +1152,12 @@ static void calcrdslopes(jpc_enc_cblk_t *cblk) #if 0 for (pass0 = cblk->passes; pass0 != endpasses; ++pass0) { -if (pass0->rdslope > 0.0) { - fprintf(stderr, "pass %02d nmsedec=%lf dec=%lf end=%d %lf\n", pass0 - cblk->passes, - fixtodbl(pass0->nmsedec), pass0->wmsedec, pass0->end, pass0->rdslope); -} + if (pass0->rdslope > 0.0) { + fprintf(stderr, "pass %02d nmsedec=%lf dec=%lf end=%d %lf\n", + pass0 - cblk->passes, + fixtodbl(pass0->nmsedec), pass0->wmsedec, + pass0->end, pass0->rdslope); + } } #endif } @@ -1196,8 +1237,8 @@ computeLayerSizes(jpc_enc_t * const encP, -static void dump_layeringinfo(jpc_enc_t *enc) -{ +static void +dump_layeringinfo(jpc_enc_t *enc) { jpc_enc_tcmpt_t *tcmpt; uint_fast16_t tcmptno; @@ -1626,12 +1667,15 @@ performTier2Coding(jpc_enc_t * const encP, JAS_DBGLOG(10, ("done doing rateallocation\n")); } + + /*****************************************************************************\ * Tile constructors and destructors. \*****************************************************************************/ -jpc_enc_tile_t *jpc_enc_tile_create(jpc_enc_cp_t *cp, jas_image_t *image, int tileno) -{ +jpc_enc_tile_t * +jpc_enc_tile_create(jpc_enc_cp_t *cp, jas_image_t *image, int tileno) { + jpc_enc_tile_t *tile; uint_fast32_t htileno; uint_fast32_t vtileno; @@ -1733,8 +1777,11 @@ error: return 0; } -void jpc_enc_tile_destroy(jpc_enc_tile_t *tile) -{ + + +void +jpc_enc_tile_destroy(jpc_enc_tile_t *tile) { + jpc_enc_tcmpt_t *tcmpt; uint_fast16_t cmptno; @@ -1754,9 +1801,14 @@ void jpc_enc_tile_destroy(jpc_enc_tile_t *tile) jas_free(tile); } -static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, - jas_image_t *image, jpc_enc_tile_t *tile) -{ + + +static jpc_enc_tcmpt_t * +tcmpt_create(jpc_enc_tcmpt_t * const tcmpt, + jpc_enc_cp_t * const cp, + jas_image_t * const image, + jpc_enc_tile_t * const tile) { + uint_fast16_t cmptno; uint_fast16_t rlvlno; jpc_enc_rlvl_t *rlvl; @@ -1787,15 +1839,15 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, bry = JPC_CEILDIV(tile->bry, ccp->sampgrdstepy); /* Create a sequence to hold the tile-component sample data. */ - if (!(tcmpt->data = jas_seq2d_create(tlx, tly, brx, bry))) { + tcmpt->data = jas_seq2d_create(tlx, tly, brx, bry); + if (!tcmpt->data) goto error; - } /* Get the image data associated with this tile-component. */ cmpttlx = JPC_CEILDIV(cp->imgareatlx, ccp->sampgrdstepx); cmpttly = JPC_CEILDIV(cp->imgareatly, ccp->sampgrdstepy); if (jas_image_readcmpt(image, cmptno, tlx - cmpttlx, tly - cmpttly, - brx - tlx, bry - tly, tcmpt->data)) { + brx - tlx, bry - tly, tcmpt->data)) { goto error; } @@ -1803,9 +1855,11 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, tcmpt->qmfbid = cp->tccp.qmfbid; tcmpt->numrlvls = cp->tccp.maxrlvls; tcmpt->numbands = 3 * tcmpt->numrlvls - 2; - if (!(tcmpt->tsfb = jpc_cod_gettsfb(tcmpt->qmfbid, tcmpt->numrlvls - 1))) { + + tcmpt->tsfb = jpc_cod_gettsfb(tcmpt->qmfbid, tcmpt->numrlvls - 1); + + if (!tcmpt->tsfb) goto error; - } for (rlvlno = 0; rlvlno < tcmpt->numrlvls; ++rlvlno) { tcmpt->prcwidthexpns[rlvlno] = cp->tccp.prcwidthexpns[rlvlno]; @@ -1818,17 +1872,19 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, tcmpt->numstepsizes = tcmpt->numbands; assert(tcmpt->numstepsizes <= JPC_MAXBANDS); - memset(tcmpt->stepsizes, 0, sizeof(tcmpt->numstepsizes * - sizeof(uint_fast16_t))); + memset(tcmpt->stepsizes, 0, + sizeof(tcmpt->numstepsizes * sizeof(uint_fast16_t))); /* Retrieve information about the various bands. */ jpc_tsfb_getbands(tcmpt->tsfb, jas_seq2d_xstart(tcmpt->data), - jas_seq2d_ystart(tcmpt->data), jas_seq2d_xend(tcmpt->data), - jas_seq2d_yend(tcmpt->data), bandinfos); + jas_seq2d_ystart(tcmpt->data), + jas_seq2d_xend(tcmpt->data), + jas_seq2d_yend(tcmpt->data), bandinfos); - if (!(tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)))) { + tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)); + if (!tcmpt->rlvls) goto error; - } + for (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls; ++rlvlno, ++rlvl) { rlvl->bands = 0; @@ -1850,8 +1906,11 @@ error: } -static void tcmpt_destroy(jpc_enc_tcmpt_t *tcmpt) -{ + + +static void +tcmpt_destroy(jpc_enc_tcmpt_t *tcmpt) { + jpc_enc_rlvl_t *rlvl; uint_fast16_t rlvlno; @@ -1871,9 +1930,12 @@ static void tcmpt_destroy(jpc_enc_tcmpt_t *tcmpt) } } -static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, - jpc_enc_tcmpt_t *tcmpt, jpc_tsfb_band_t *bandinfos) -{ + + +static jpc_enc_rlvl_t * +rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, + jpc_enc_tcmpt_t *tcmpt, jpc_tsfb_band_t *bandinfos) { + uint_fast16_t rlvlno; uint_fast32_t tlprctlx; uint_fast32_t tlprctly; @@ -1891,14 +1953,18 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, /* Compute the coordinates of the top-left and bottom-right corners of the tile-component at this resolution. */ - rlvl->tlx = JPC_CEILDIVPOW2(jas_seq2d_xstart(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); - rlvl->tly = JPC_CEILDIVPOW2(jas_seq2d_ystart(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); - rlvl->brx = JPC_CEILDIVPOW2(jas_seq2d_xend(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); - rlvl->bry = JPC_CEILDIVPOW2(jas_seq2d_yend(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); + rlvl->tlx = + JPC_CEILDIVPOW2(jas_seq2d_xstart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->tly = + JPC_CEILDIVPOW2(jas_seq2d_ystart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->brx = + JPC_CEILDIVPOW2(jas_seq2d_xend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->bry = + JPC_CEILDIVPOW2(jas_seq2d_yend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); if (rlvl->tlx >= rlvl->brx || rlvl->tly >= rlvl->bry) { rlvl->numhprcs = 0; @@ -1917,8 +1983,10 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; } - rlvl->cblkwidthexpn = JAS_MIN(cp->tccp.cblkwidthexpn, rlvl->cbgwidthexpn); - rlvl->cblkheightexpn = JAS_MIN(cp->tccp.cblkheightexpn, rlvl->cbgheightexpn); + rlvl->cblkwidthexpn = + JAS_MIN(cp->tccp.cblkwidthexpn, rlvl->cbgwidthexpn); + rlvl->cblkheightexpn = + JAS_MIN(cp->tccp.cblkheightexpn, rlvl->cbgheightexpn); /* Compute the number of precincts. */ tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); @@ -1926,20 +1994,22 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, brprcbrx = JPC_CEILTOMULTPOW2(rlvl->brx, rlvl->prcwidthexpn); brprcbry = JPC_CEILTOMULTPOW2(rlvl->bry, rlvl->prcheightexpn); rlvl->numhprcs = JPC_FLOORDIVPOW2(brprcbrx - tlprctlx, rlvl->prcwidthexpn); - rlvl->numvprcs = JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn); + rlvl->numvprcs = + JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn); rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs; - if (!(rlvl->bands = jas_malloc(rlvl->numbands * sizeof(jpc_enc_band_t)))) { + rlvl->bands = jas_malloc(rlvl->numbands * sizeof(jpc_enc_band_t)); + if (!rlvl->bands) goto error; - } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; - ++bandno, ++band) { + ++bandno, ++band) { band->prcs = 0; band->data = 0; band->rlvl = rlvl; } for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; - ++bandno, ++band) { + ++bandno, ++band) { if (!band_create(band, cp, rlvl, bandinfos)) { goto error; } @@ -1952,8 +2022,11 @@ error: return 0; } -static void rlvl_destroy(jpc_enc_rlvl_t *rlvl) -{ + + +static void +rlvl_destroy(jpc_enc_rlvl_t *rlvl) { + jpc_enc_band_t *band; uint_fast16_t bandno; @@ -1966,9 +2039,12 @@ static void rlvl_destroy(jpc_enc_rlvl_t *rlvl) } } -static jpc_enc_band_t *band_create(jpc_enc_band_t *band, jpc_enc_cp_t *cp, - jpc_enc_rlvl_t *rlvl, jpc_tsfb_band_t *bandinfos) -{ + + +static jpc_enc_band_t * +band_create(jpc_enc_band_t *band, jpc_enc_cp_t *cp, + jpc_enc_rlvl_t *rlvl, jpc_tsfb_band_t *bandinfos) { + uint_fast16_t bandno; uint_fast16_t gblbandno; uint_fast16_t rlvlno; @@ -1989,42 +2065,46 @@ static jpc_enc_band_t *band_create(jpc_enc_band_t *band, jpc_enc_cp_t *cp, bandinfo = &bandinfos[gblbandno]; -if (bandinfo->xstart != bandinfo->xend && bandinfo->ystart != bandinfo->yend) { - if (!(band->data = jas_seq2d_create(0, 0, 0, 0))) { - goto error; + if (bandinfo->xstart != bandinfo->xend && + bandinfo->ystart != bandinfo->yend) { + band->data = jas_seq2d_create(0, 0, 0, 0); + if (!band->data) + goto error; + jas_seq2d_bindsub(band->data, tcmpt->data, bandinfo->locxstart, + bandinfo->locystart, bandinfo->locxend, + bandinfo->locyend); + jas_seq2d_setshift(band->data, bandinfo->xstart, bandinfo->ystart); } - jas_seq2d_bindsub(band->data, tcmpt->data, bandinfo->locxstart, - bandinfo->locystart, bandinfo->locxend, bandinfo->locyend); - jas_seq2d_setshift(band->data, bandinfo->xstart, bandinfo->ystart); -} band->orient = bandinfo->orient; band->analgain = JPC_NOMINALGAIN(cp->tccp.qmfbid, tcmpt->numrlvls, rlvlno, - band->orient); + band->orient); band->numbps = 0; band->absstepsize = 0; band->stepsize = 0; band->synweight = bandinfo->synenergywt; -if (band->data) { - if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_enc_prc_t)))) { - goto error; - } - for (prcno = 0, prc = band->prcs; prcno < rlvl->numprcs; ++prcno, - ++prc) { - prc->cblks = 0; - prc->incltree = 0; - prc->nlibtree = 0; - prc->savincltree = 0; - prc->savnlibtree = 0; - prc->band = band; - } - for (prcno = 0, prc = band->prcs; prcno < rlvl->numprcs; ++prcno, - ++prc) { - if (!prc_create(prc, cp, band)) { + if (band->data) { + band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_enc_prc_t)); + if (!band->prcs) goto error; + for (prcno = 0, prc = band->prcs; + prcno < rlvl->numprcs; + ++prcno, ++prc) { + prc->cblks = 0; + prc->incltree = 0; + prc->nlibtree = 0; + prc->savincltree = 0; + prc->savnlibtree = 0; + prc->band = band; + } + for (prcno = 0, prc = band->prcs; + prcno < rlvl->numprcs; + ++prcno, ++prc) { + if (!prc_create(prc, cp, band)) { + goto error; + } } } -} return band; @@ -2033,8 +2113,11 @@ error: return 0; } -static void band_destroy(jpc_enc_band_t *band) -{ + + +static void +band_destroy(jpc_enc_band_t *band) { + jpc_enc_prc_t *prc; jpc_enc_rlvl_t *rlvl; uint_fast32_t prcno; @@ -2052,8 +2135,11 @@ static void band_destroy(jpc_enc_band_t *band) } } -static jpc_enc_prc_t *prc_create(jpc_enc_prc_t *prc, jpc_enc_cp_t *cp, jpc_enc_band_t *band) -{ + + +static jpc_enc_prc_t * +prc_create(jpc_enc_prc_t *prc, jpc_enc_cp_t *cp, jpc_enc_band_t *band) { + uint_fast32_t prcno; uint_fast32_t prcxind; uint_fast32_t prcyind; @@ -2081,32 +2167,34 @@ static jpc_enc_prc_t *prc_create(jpc_enc_prc_t *prc, jpc_enc_cp_t *cp, jpc_enc_b rlvl = band->rlvl; tcmpt = rlvl->tcmpt; -rlvlno = rlvl - tcmpt->rlvls; + rlvlno = rlvl - tcmpt->rlvls; prcno = prc - band->prcs; prcxind = prcno % rlvl->numhprcs; prcyind = prcno / rlvl->numhprcs; prc->band = band; -tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); -tlprctly = JPC_FLOORTOMULTPOW2(rlvl->tly, rlvl->prcheightexpn); -if (!rlvlno) { - tlcbgtlx = tlprctlx; - tlcbgtly = tlprctly; -} else { - tlcbgtlx = JPC_CEILDIVPOW2(tlprctlx, 1); - tlcbgtly = JPC_CEILDIVPOW2(tlprctly, 1); -} + tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); + tlprctly = JPC_FLOORTOMULTPOW2(rlvl->tly, rlvl->prcheightexpn); - /* Compute the coordinates of the top-left and bottom-right - corners of the precinct. */ + if (!rlvlno) { + tlcbgtlx = tlprctlx; + tlcbgtly = tlprctly; + } else { + tlcbgtlx = JPC_CEILDIVPOW2(tlprctlx, 1); + tlcbgtly = JPC_CEILDIVPOW2(tlprctly, 1); + } + + /* Compute the coordinates of the top-left and bottom-right corners of the + precinct. + */ cbgtlx = tlcbgtlx + (prcxind << rlvl->cbgwidthexpn); cbgtly = tlcbgtly + (prcyind << rlvl->cbgheightexpn); prc->tlx = JAS_MAX(jas_seq2d_xstart(band->data), cbgtlx); prc->tly = JAS_MAX(jas_seq2d_ystart(band->data), cbgtly); prc->brx = JAS_MIN(jas_seq2d_xend(band->data), cbgtlx + - (1 << rlvl->cbgwidthexpn)); + (1 << rlvl->cbgwidthexpn)); prc->bry = JAS_MIN(jas_seq2d_yend(band->data), cbgtly + - (1 << rlvl->cbgheightexpn)); + (1 << rlvl->cbgheightexpn)); if (prc->tlx < prc->brx && prc->tly < prc->bry) { /* The precinct contains at least one code block. */ @@ -2116,33 +2204,35 @@ if (!rlvlno) { brcblkbrx = JPC_CEILTOMULTPOW2(prc->brx, rlvl->cblkwidthexpn); brcblkbry = JPC_CEILTOMULTPOW2(prc->bry, rlvl->cblkheightexpn); prc->numhcblks = JPC_FLOORDIVPOW2(brcblkbrx - tlcblktlx, - rlvl->cblkwidthexpn); + rlvl->cblkwidthexpn); prc->numvcblks = JPC_FLOORDIVPOW2(brcblkbry - tlcblktly, - rlvl->cblkheightexpn); + rlvl->cblkheightexpn); prc->numcblks = prc->numhcblks * prc->numvcblks; if (!(prc->incltree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } if (!(prc->nlibtree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } if (!(prc->savincltree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } if (!(prc->savnlibtree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } - if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_enc_cblk_t)))) { + prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_enc_cblk_t)); + + if (!prc->cblks) goto error; - } - for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; - ++cblkno, ++cblk) { + for (cblkno = 0, cblk = prc->cblks; + cblkno < prc->numcblks; + ++cblkno, ++cblk) { cblk->passes = 0; cblk->stream = 0; cblk->mqenc = 0; @@ -2150,8 +2240,9 @@ if (!rlvlno) { cblk->flags = 0; cblk->prc = prc; } - for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; - ++cblkno, ++cblk) { + for (cblkno = 0, cblk = prc->cblks; + cblkno < prc->numcblks; + ++cblkno, ++cblk) { if (!cblk_create(cblk, cp, prc)) { goto error; } @@ -2177,8 +2268,11 @@ error: return 0; } -static void prc_destroy(jpc_enc_prc_t *prc) -{ + + +static void +prc_destroy(jpc_enc_prc_t *prc) { + jpc_enc_cblk_t *cblk; uint_fast32_t cblkno; @@ -2203,8 +2297,11 @@ static void prc_destroy(jpc_enc_prc_t *prc) } } -static jpc_enc_cblk_t *cblk_create(jpc_enc_cblk_t *cblk, jpc_enc_cp_t *cp, jpc_enc_prc_t *prc) -{ + + +static jpc_enc_cblk_t * +cblk_create(jpc_enc_cblk_t *cblk, jpc_enc_cp_t *cp, jpc_enc_prc_t *prc) { + jpc_enc_band_t *band; uint_fast32_t cblktlx; uint_fast32_t cblktly; @@ -2241,18 +2338,22 @@ static jpc_enc_cblk_t *cblk_create(jpc_enc_cblk_t *cblk, jpc_enc_cp_t *cp, jpc_e band = prc->band; tlcblktlx = JPC_FLOORTOMULTPOW2(prc->tlx, rlvl->cblkwidthexpn); tlcblktly = JPC_FLOORTOMULTPOW2(prc->tly, rlvl->cblkheightexpn); - cblktlx = JAS_MAX(tlcblktlx + (cblkxind << rlvl->cblkwidthexpn), prc->tlx); - cblktly = JAS_MAX(tlcblktly + (cblkyind << rlvl->cblkheightexpn), prc->tly); - cblkbrx = JAS_MIN(tlcblktlx + ((cblkxind + 1) << rlvl->cblkwidthexpn), - prc->brx); - cblkbry = JAS_MIN(tlcblktly + ((cblkyind + 1) << rlvl->cblkheightexpn), - prc->bry); + cblktlx = + JAS_MAX(tlcblktlx + (cblkxind << rlvl->cblkwidthexpn), prc->tlx); + cblktly = + JAS_MAX(tlcblktly + (cblkyind << rlvl->cblkheightexpn), prc->tly); + cblkbrx = + JAS_MIN(tlcblktlx + ((cblkxind + 1) << rlvl->cblkwidthexpn), prc->brx); + cblkbry = + JAS_MIN(tlcblktly + ((cblkyind + 1) << rlvl->cblkheightexpn), + prc->bry); assert(cblktlx < cblkbrx && cblktly < cblkbry); - if (!(cblk->data = jas_seq2d_create(0, 0, 0, 0))) { + cblk->data = jas_seq2d_create(0, 0, 0, 0); + if (!cblk->data) goto error; - } - jas_seq2d_bindsub(cblk->data, band->data, cblktlx, cblktly, cblkbrx, cblkbry); + jas_seq2d_bindsub(cblk->data, band->data, + cblktlx, cblktly, cblkbrx, cblkbry); return cblk; @@ -2261,8 +2362,11 @@ error: return 0; } -static void cblk_destroy(jpc_enc_cblk_t *cblk) -{ + + +static void +cblk_destroy(jpc_enc_cblk_t *cblk) { + uint_fast16_t passno; jpc_enc_pass_t *pass; if (cblk->passes) { @@ -2286,13 +2390,19 @@ static void cblk_destroy(jpc_enc_cblk_t *cblk) } } -static void pass_destroy(jpc_enc_pass_t *pass) -{ + + +static void +pass_destroy(jpc_enc_pass_t *pass) { + /* XXX - need to free resources here */ } -void jpc_enc_dump(jpc_enc_t *enc) -{ + + +void +jpc_enc_dump(jpc_enc_t *enc) { + jpc_enc_tile_t *tile; jpc_enc_tcmpt_t *tcmpt; jpc_enc_rlvl_t *rlvl; @@ -2358,11 +2468,10 @@ void jpc_enc_dump(jpc_enc_t *enc) -static int jpc_enc_encodemainbody(jpc_enc_t *enc) -{ +static int +jpc_enc_encodemainbody(jpc_enc_t *enc) { + int tileno; - int tilex; - int tiley; int i; jpc_sot_t *sot; jpc_enc_tcmpt_t *comp; @@ -2376,7 +2485,6 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) int adjust; int j; int absbandno; - long numbytes; long tilehdrlen; long tilelen; jpc_enc_tile_t *tile; @@ -2398,13 +2506,7 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) cp = enc->cp; - /* Avoid compile warnings. */ - numbytes = 0; - for (tileno = 0; tileno < cp->numtiles; ++tileno) { - tilex = tileno % cp->numhtiles; - tiley = tileno / cp->numhtiles; - enc->curtile = jpc_enc_tile_create(enc->cp, enc->image, tileno); if (!enc->curtile) abort(); @@ -2459,7 +2561,6 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) } - endcomps = &tile->tcmpts[tile->numtcmpts]; for (cmptno = 0, comp = tile->tcmpts; comp != endcomps; @@ -2544,15 +2645,16 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) return -1; } - if (!(enc->tmpstream = jas_stream_memopen(0, 0))) { + enc->tmpstream = jas_stream_memopen(0, 0); + if (!enc->tmpstream) { fprintf(stderr, "cannot open tmp file\n"); return -1; } /* Write the tile header. */ - if (!(enc->mrk = jpc_ms_create(JPC_MS_SOT))) { + enc->mrk = jpc_ms_create(JPC_MS_SOT); + if (!enc->mrk) return -1; - } sot = &enc->mrk->parms.sot; sot->len = 0; sot->tileno = tileno; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c index 8aa024a9..e1af0f61 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c @@ -1,4 +1,4 @@ -/* + /* * Copyright (c) 1999-2000 Image Power, Inc. and the University of * British Columbia. * Copyright (c) 2001-2002 Michael David Adams. @@ -156,853 +156,872 @@ static int jpc_encrawrefpass(jpc_bitstream_t *out, int bitpos, int, /* Encode all of the code blocks associated with the current tile. */ int jpc_enc_enccblks(jpc_enc_t *enc) { - jpc_enc_tcmpt_t *tcmpt; - 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; - int i; - int j; - int mx; - int bmx; - int v; - jpc_enc_tile_t *tile; - uint_fast32_t prcno; - jpc_enc_prc_t *prc; - - tile = enc->curtile; - - endcomps = &tile->tcmpts[tile->numtcmpts]; - for (tcmpt = tile->tcmpts; tcmpt != endcomps; ++tcmpt) { - endlvls = &tcmpt->rlvls[tcmpt->numrlvls]; - for (lvl = tcmpt->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; - } - bmx = 0; - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - mx = 0; - for (i = 0; i < jas_matrix_numrows(cblk->data); ++i) { - for (j = 0; j < jas_matrix_numcols(cblk->data); ++j) { - v = abs(jas_matrix_get(cblk->data, i, j)); - if (v > mx) { - mx = v; - } - } - } - if (mx > bmx) { - bmx = mx; - } - cblk->numbps = JAS_MAX(jpc_firstone(mx) + 1 - JPC_NUMEXTRABITS, 0); - } - - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - cblk->numimsbs = band->numbps - cblk->numbps; - assert(cblk->numimsbs >= 0); - } - - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - if (jpc_enc_enccblk(enc, cblk->stream, tcmpt, band, cblk)) { - return -1; - } - } - } - } - } - } - return 0; + jpc_enc_tcmpt_t *tcmpt; + 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; + int i; + int j; + int mx; + int bmx; + int v; + jpc_enc_tile_t *tile; + uint_fast32_t prcno; + jpc_enc_prc_t *prc; + + tile = enc->curtile; + + endcomps = &tile->tcmpts[tile->numtcmpts]; + for (tcmpt = tile->tcmpts; tcmpt != endcomps; ++tcmpt) { + endlvls = &tcmpt->rlvls[tcmpt->numrlvls]; + for (lvl = tcmpt->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; + } + bmx = 0; + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + mx = 0; + for (i = 0; i < jas_matrix_numrows(cblk->data); ++i) { + for (j = 0; j < jas_matrix_numcols(cblk->data); ++j) { + v = abs(jas_matrix_get(cblk->data, i, j)); + if (v > mx) { + mx = v; + } + } + } + if (mx > bmx) { + bmx = mx; + } + cblk->numbps = JAS_MAX(jpc_firstone(mx) + 1 - JPC_NUMEXTRABITS, 0); + } + + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + cblk->numimsbs = band->numbps - cblk->numbps; + assert(cblk->numimsbs >= 0); + } + + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + if (jpc_enc_enccblk(enc, cblk->stream, tcmpt, band, cblk)) { + return -1; + } + } + } + } + } + } + return 0; } static int getthebyte(jas_stream_t *in, long off) { - int c; - long oldpos; - oldpos = jas_stream_tell(in); - assert(oldpos >= 0); - jas_stream_seek(in, off, SEEK_SET); - c = jas_stream_peekc(in); - jas_stream_seek(in, oldpos, SEEK_SET); - return c; + int c; + long oldpos; + oldpos = jas_stream_tell(in); + assert(oldpos >= 0); + jas_stream_seek(in, off, SEEK_SET); + c = jas_stream_peekc(in); + jas_stream_seek(in, oldpos, SEEK_SET); + return c; } -/* Encode a single code block. */ -int jpc_enc_enccblk(jpc_enc_t *enc, jas_stream_t *out, jpc_enc_tcmpt_t *tcmpt, jpc_enc_band_t *band, jpc_enc_cblk_t *cblk) -{ - jpc_enc_pass_t *pass; - jpc_enc_pass_t *endpasses; - int bitpos; - int n; - int adjust; - int ret; - int passtype; - int t; - jpc_bitstream_t *bout; - jpc_enc_pass_t *termpass; - jpc_enc_rlvl_t *rlvl; - int vcausal; - int segsym; - int termmode; - int c; - - bout = 0; - rlvl = band->rlvl; - - cblk->stream = jas_stream_memopen(0, 0); - assert(cblk->stream); - cblk->mqenc = jpc_mqenc_create(JPC_NUMCTXS, cblk->stream); - assert(cblk->mqenc); - jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); - - cblk->numpasses = (cblk->numbps > 0) ? (3 * cblk->numbps - 2) : 0; - if (cblk->numpasses > 0) { - cblk->passes = jas_malloc(cblk->numpasses * sizeof(jpc_enc_pass_t)); - assert(cblk->passes); - } else { - cblk->passes = 0; - } - endpasses = &cblk->passes[cblk->numpasses]; - for (pass = cblk->passes; pass != endpasses; ++pass) { - pass->start = 0; - pass->end = 0; - pass->term = JPC_ISTERMINATED(pass - cblk->passes, 0, cblk->numpasses, (tcmpt->cblksty & JPC_COX_TERMALL) != 0, (tcmpt->cblksty & JPC_COX_LAZY) != 0); - pass->type = JPC_SEGTYPE(pass - cblk->passes, 0, (tcmpt->cblksty & JPC_COX_LAZY) != 0); - pass->lyrno = -1; -if (pass == endpasses - 1) { -assert(pass->term == 1); - pass->term = 1; -} - } - - cblk->flags = jas_matrix_create(jas_matrix_numrows(cblk->data) + 2, - jas_matrix_numcols(cblk->data) + 2); - assert(cblk->flags); - - bitpos = cblk->numbps - 1; - pass = cblk->passes; - n = cblk->numpasses; - while (--n >= 0) { - if (pass->type == JPC_SEG_MQ) { - /* NOP */ - } else { - assert(pass->type == JPC_SEG_RAW); - if (!bout) { - bout = jpc_bitstream_sopen(cblk->stream, "w"); - assert(bout); - } - } +int +jpc_enc_enccblk(jpc_enc_t *enc, jas_stream_t *out, jpc_enc_tcmpt_t *tcmpt, + jpc_enc_band_t *band, jpc_enc_cblk_t *cblk) { +/*---------------------------------------------------------------------------- + Encode a single code block. +-----------------------------------------------------------------------------*/ + jpc_enc_pass_t *pass; + jpc_enc_pass_t *endpasses; + int bitpos; + int n; + int adjust; + int passtype; + int t; + jpc_bitstream_t *bout; + jpc_enc_pass_t *termpass; + int vcausal; + int segsym; + int termmode; + int c; + + bout = 0; + + cblk->stream = jas_stream_memopen(0, 0); + assert(cblk->stream); + cblk->mqenc = jpc_mqenc_create(JPC_NUMCTXS, cblk->stream); + assert(cblk->mqenc); + jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); + + cblk->numpasses = (cblk->numbps > 0) ? (3 * cblk->numbps - 2) : 0; + if (cblk->numpasses > 0) { + cblk->passes = jas_malloc(cblk->numpasses * sizeof(jpc_enc_pass_t)); + assert(cblk->passes); + } else { + cblk->passes = 0; + } + endpasses = &cblk->passes[cblk->numpasses]; + for (pass = cblk->passes; pass != endpasses; ++pass) { + pass->start = 0; + pass->end = 0; + pass->term = + JPC_ISTERMINATED(pass - cblk->passes, 0, + cblk->numpasses, + (tcmpt->cblksty & JPC_COX_TERMALL) != 0, + (tcmpt->cblksty & JPC_COX_LAZY) != 0); + pass->type = JPC_SEGTYPE(pass - cblk->passes, 0, + (tcmpt->cblksty & JPC_COX_LAZY) != 0); + pass->lyrno = -1; + if (pass == endpasses - 1) { + assert(pass->term == 1); + pass->term = 1; + } + } + + cblk->flags = jas_matrix_create(jas_matrix_numrows(cblk->data) + 2, + jas_matrix_numcols(cblk->data) + 2); + assert(cblk->flags); + + + bitpos = cblk->numbps - 1; + pass = cblk->passes; + n = cblk->numpasses; + while (--n >= 0) { + + if (pass->type == JPC_SEG_MQ) { + /* NOP */ + } else { + assert(pass->type == JPC_SEG_RAW); + if (!bout) { + bout = jpc_bitstream_sopen(cblk->stream, "w"); + assert(bout); + } + } #if 1 - passtype = (pass - cblk->passes + 2) % 3; + passtype = (pass - cblk->passes + 2) % 3; #else - passtype = JPC_PASSTYPE(pass - cblk->passes + 2); + passtype = JPC_PASSTYPE(pass - cblk->passes + 2); #endif - pass->start = jas_stream_tell(cblk->stream); + pass->start = jas_stream_tell(cblk->stream); #if 0 assert(jas_stream_tell(cblk->stream) == jas_stream_getrwcount(cblk->stream)); #endif - assert(bitpos >= 0); - vcausal = (tcmpt->cblksty & JPC_COX_VSC) != 0; - segsym = (tcmpt->cblksty & JPC_COX_SEGSYM) != 0; - if (pass->term) { - termmode = ((tcmpt->cblksty & JPC_COX_PTERM) ? - JPC_MQENC_PTERM : JPC_MQENC_DEFTERM) + 1; - } else { - termmode = 0; - } - switch (passtype) { - case JPC_SIGPASS: - ret = (pass->type == JPC_SEG_MQ) ? jpc_encsigpass(cblk->mqenc, - bitpos, band->orient, vcausal, cblk->flags, - cblk->data, termmode, &pass->nmsedec) : - jpc_encrawsigpass(bout, bitpos, vcausal, cblk->flags, - cblk->data, termmode, &pass->nmsedec); - break; - case JPC_REFPASS: - ret = (pass->type == JPC_SEG_MQ) ? jpc_encrefpass(cblk->mqenc, - bitpos, vcausal, cblk->flags, cblk->data, termmode, - &pass->nmsedec) : jpc_encrawrefpass(bout, bitpos, - vcausal, cblk->flags, cblk->data, termmode, - &pass->nmsedec); - break; - case JPC_CLNPASS: - assert(pass->type == JPC_SEG_MQ); - ret = jpc_encclnpass(cblk->mqenc, bitpos, band->orient, - vcausal, segsym, cblk->flags, cblk->data, termmode, - &pass->nmsedec); - break; - default: - assert(0); - break; - } - - if (pass->type == JPC_SEG_MQ) { - if (pass->term) { - jpc_mqenc_init(cblk->mqenc); - } - jpc_mqenc_getstate(cblk->mqenc, &pass->mqencstate); - pass->end = jas_stream_tell(cblk->stream); - if (tcmpt->cblksty & JPC_COX_RESET) { - jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); - } - } else { - if (pass->term) { - if (jpc_bitstream_pending(bout)) { - jpc_bitstream_outalign(bout, 0x2a); - } - jpc_bitstream_close(bout); - bout = 0; - pass->end = jas_stream_tell(cblk->stream); - } else { - pass->end = jas_stream_tell(cblk->stream) + - jpc_bitstream_pending(bout); -/* NOTE - This will not work. need to adjust by # of pending output bytes */ - } - } + assert(bitpos >= 0); + vcausal = (tcmpt->cblksty & JPC_COX_VSC) != 0; + segsym = (tcmpt->cblksty & JPC_COX_SEGSYM) != 0; + if (pass->term) { + termmode = ((tcmpt->cblksty & JPC_COX_PTERM) ? + JPC_MQENC_PTERM : JPC_MQENC_DEFTERM) + 1; + } else { + termmode = 0; + } + switch (passtype) { + case JPC_SIGPASS: + if (pass->type == JPC_SEG_MQ) + jpc_encsigpass(cblk->mqenc, + bitpos, band->orient, vcausal, cblk->flags, + cblk->data, termmode, &pass->nmsedec); + else + jpc_encrawsigpass(bout, bitpos, vcausal, cblk->flags, + cblk->data, termmode, &pass->nmsedec); + break; + case JPC_REFPASS: + if (pass->type == JPC_SEG_MQ) + jpc_encrefpass( + cblk->mqenc, + bitpos, vcausal, cblk->flags, cblk->data, termmode, + &pass->nmsedec); + else + jpc_encrawrefpass(bout, bitpos, + vcausal, cblk->flags, cblk->data, termmode, + &pass->nmsedec); + break; + case JPC_CLNPASS: + assert(pass->type == JPC_SEG_MQ); + jpc_encclnpass( + cblk->mqenc, bitpos, band->orient, + vcausal, segsym, cblk->flags, cblk->data, termmode, + &pass->nmsedec); + break; + default: + assert(false); + break; + } + + if (pass->type == JPC_SEG_MQ) { + if (pass->term) { + jpc_mqenc_init(cblk->mqenc); + } + jpc_mqenc_getstate(cblk->mqenc, &pass->mqencstate); + pass->end = jas_stream_tell(cblk->stream); + if (tcmpt->cblksty & JPC_COX_RESET) { + jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); + } + } else { + if (pass->term) { + if (jpc_bitstream_pending(bout)) { + jpc_bitstream_outalign(bout, 0x2a); + } + jpc_bitstream_close(bout); + bout = 0; + pass->end = jas_stream_tell(cblk->stream); + } else { + pass->end = jas_stream_tell(cblk->stream) + + jpc_bitstream_pending(bout); + /* NOTE - This will not work. need to adjust by # of pending + output bytes + */ + } + } #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) == jas_stream_getrwcount(cblk->stream)); + /* 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) == + jas_stream_getrwcount(cblk->stream)); #endif - pass->wmsedec = jpc_fixtodbl(band->rlvl->tcmpt->synweight) * - jpc_fixtodbl(band->rlvl->tcmpt->synweight) * - jpc_fixtodbl(band->synweight) * - jpc_fixtodbl(band->synweight) * - jpc_fixtodbl(band->absstepsize) * jpc_fixtodbl(band->absstepsize) * - ((double) (1 << bitpos)) * ((double)(1 << bitpos)) * - jpc_fixtodbl(pass->nmsedec); - pass->cumwmsedec = pass->wmsedec; - if (pass != cblk->passes) { - pass->cumwmsedec += pass[-1].cumwmsedec; - } - if (passtype == JPC_CLNPASS) { - --bitpos; - } - ++pass; - } + pass->wmsedec = jpc_fixtodbl(band->rlvl->tcmpt->synweight) * + jpc_fixtodbl(band->rlvl->tcmpt->synweight) * + jpc_fixtodbl(band->synweight) * + jpc_fixtodbl(band->synweight) * + jpc_fixtodbl(band->absstepsize) * jpc_fixtodbl(band->absstepsize) * + ((double) (1 << bitpos)) * ((double)(1 << bitpos)) * + jpc_fixtodbl(pass->nmsedec); + pass->cumwmsedec = pass->wmsedec; + if (pass != cblk->passes) { + pass->cumwmsedec += pass[-1].cumwmsedec; + } + if (passtype == JPC_CLNPASS) { + --bitpos; + } + ++pass; + } #if 0 -dump_passes(cblk->passes, cblk->numpasses, cblk); + dump_passes(cblk->passes, cblk->numpasses, cblk); #endif - n = 0; - endpasses = &cblk->passes[cblk->numpasses]; - for (pass = cblk->passes; pass != endpasses; ++pass) { - if (pass->start < n) { - pass->start = n; - } - if (pass->end < n) { - pass->end = n; - } - if (!pass->term) { - termpass = pass; - while (termpass - pass < cblk->numpasses && - !termpass->term) { - ++termpass; - } - if (pass->type == JPC_SEG_MQ) { - t = (pass->mqencstate.lastbyte == 0xff) ? 1 : 0; - if (pass->mqencstate.ctreg >= 5) { - adjust = 4 + t; - } else { - adjust = 5 + t; - } - pass->end += adjust; - } - if (pass->end > termpass->end) { - pass->end = termpass->end; - } - if ((c = getthebyte(cblk->stream, pass->end - 1)) == EOF) { - abort(); - } - if (c == 0xff) { - ++pass->end; - } - n = JAS_MAX(n, pass->end); - } else { - n = JAS_MAX(n, pass->end); - } - } + n = 0; + endpasses = &cblk->passes[cblk->numpasses]; + for (pass = cblk->passes; pass != endpasses; ++pass) { + if (pass->start < n) { + pass->start = n; + } + if (pass->end < n) { + pass->end = n; + } + if (!pass->term) { + termpass = pass; + while (termpass - pass < cblk->numpasses && + !termpass->term) { + ++termpass; + } + if (pass->type == JPC_SEG_MQ) { + t = (pass->mqencstate.lastbyte == 0xff) ? 1 : 0; + if (pass->mqencstate.ctreg >= 5) { + adjust = 4 + t; + } else { + adjust = 5 + t; + } + pass->end += adjust; + } + if (pass->end > termpass->end) { + pass->end = termpass->end; + } + if ((c = getthebyte(cblk->stream, pass->end - 1)) == EOF) { + abort(); + } + if (c == 0xff) { + ++pass->end; + } + n = JAS_MAX(n, pass->end); + } else { + n = JAS_MAX(n, pass->end); + } + } #if 0 -dump_passes(cblk->passes, cblk->numpasses, cblk); + dump_passes(cblk->passes, cblk->numpasses, cblk); #endif - if (bout) { - jpc_bitstream_close(bout); - } + if (bout) { + jpc_bitstream_close(bout); + } - return 0; + return 0; } -/******************************************************************************\ + + +/*****************************************************************************\ * Code for significance pass. -\******************************************************************************/ +\*****************************************************************************/ -#define sigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, orient, mqenc, vcausalflag) \ +#define sigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, orient, mqenc, vcausalflag) \ { \ - int f; \ - int v; \ - f = *(fp); \ - if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ - v = (abs(*(dp)) & (one)) ? 1 : 0; \ - jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ - jpc_mqenc_putbit(mqenc, v); \ - if (v) { \ - *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ - v = ((*(dp) < 0) ? 1 : 0); \ - jpc_mqenc_setcurctx(mqenc, JPC_GETSCCTXNO(f)); \ - jpc_mqenc_putbit(mqenc, v ^ JPC_GETSPB(f)); \ - JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ - *(fp) |= JPC_SIG; \ - } \ - *(fp) |= JPC_VISIT; \ - } \ + int f; \ + int v; \ + f = *(fp); \ + if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ + v = (abs(*(dp)) & (one)) ? 1 : 0; \ + jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ + jpc_mqenc_putbit(mqenc, v); \ + if (v) { \ + *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ + v = ((*(dp) < 0) ? 1 : 0); \ + jpc_mqenc_setcurctx(mqenc, JPC_GETSCCTXNO(f)); \ + jpc_mqenc_putbit(mqenc, v ^ JPC_GETSPB(f)); \ + JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ + *(fp) |= JPC_SIG; \ + } \ + *(fp) |= JPC_VISIT; \ + } \ } static int jpc_encsigpass(jpc_mqenc_t *mqenc, int bitpos, int orient, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int one; - int vscanlen; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fp; - jpc_fix_t *dp; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - int k; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, 0); - - } - } - - if (term) { - jpc_mqenc_flush(mqenc, term - 1); - } - - return jpc_mqenc_error(mqenc) ? (-1) : 0; + int i; + int j; + int one; + int vscanlen; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fp; + jpc_fix_t *dp; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + int k; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, 0); + + } + } + + if (term) { + jpc_mqenc_flush(mqenc, term - 1); + } + + return jpc_mqenc_error(mqenc) ? (-1) : 0; } -#define rawsigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, out, vcausalflag) \ +#define rawsigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, out, vcausalflag) \ { \ - jpc_fix_t f = *(fp); \ - jpc_fix_t v; \ - if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ - v = (abs(*(dp)) & (one)) ? 1 : 0; \ - if ((jpc_bitstream_putbit((out), v)) == EOF) { \ - return -1; \ - } \ - if (v) { \ - *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ - v = ((*(dp) < 0) ? 1 : 0); \ - if (jpc_bitstream_putbit(out, v) == EOF) { \ - return -1; \ - } \ - JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ - *(fp) |= JPC_SIG; \ - } \ - *(fp) |= JPC_VISIT; \ - } \ + jpc_fix_t f = *(fp); \ + jpc_fix_t v; \ + if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ + v = (abs(*(dp)) & (one)) ? 1 : 0; \ + if ((jpc_bitstream_putbit((out), v)) == EOF) { \ + return -1; \ + } \ + if (v) { \ + *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ + v = ((*(dp) < 0) ? 1 : 0); \ + if (jpc_bitstream_putbit(out, v) == EOF) { \ + return -1; \ + } \ + JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ + *(fp) |= JPC_SIG; \ + } \ + *(fp) |= JPC_VISIT; \ + } \ } static int jpc_encrawsigpass(jpc_bitstream_t *out, int bitpos, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int k; - int one; - int vscanlen; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fp; - jpc_fix_t *dp; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - } - } - - if (term) { - jpc_bitstream_outalign(out, 0x2a); - } - - return 0; + int i; + int j; + int k; + int one; + int vscanlen; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fp; + jpc_fix_t *dp; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + } + } + + if (term) { + jpc_bitstream_outalign(out, 0x2a); + } + + return 0; } /******************************************************************************\ * Code for refinement pass. \******************************************************************************/ -#define refpass_step(fp, dp, bitpos, one, nmsedec, mqenc, vcausalflag) \ +#define refpass_step(fp, dp, bitpos, one, nmsedec, mqenc, vcausalflag) \ { \ - int v; \ - if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ - (d) = *(dp); \ - *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ - jpc_mqenc_setcurctx((mqenc), JPC_GETMAGCTXNO(*(fp))); \ - v = (abs(d) & (one)) ? 1 : 0; \ - jpc_mqenc_putbit((mqenc), v); \ - *(fp) |= JPC_REFINE; \ - } \ + int v; \ + if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ + (d) = *(dp); \ + *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ + jpc_mqenc_setcurctx((mqenc), JPC_GETMAGCTXNO(*(fp))); \ + v = (abs(d) & (one)) ? 1 : 0; \ + jpc_mqenc_putbit((mqenc), v); \ + *(fp) |= JPC_REFINE; \ + } \ } static int jpc_encrefpass(jpc_mqenc_t *mqenc, int bitpos, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int one; - int vscanlen; - int d; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - jpc_fix_t *dp; - jpc_fix_t *fp; + int i; + int j; + int one; + int vscanlen; + int d; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + jpc_fix_t *dp; + jpc_fix_t *fp; int k; - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, 0); - - } - } - - if (term) { - jpc_mqenc_flush(mqenc, term - 1); - } - - return jpc_mqenc_error(mqenc) ? (-1) : 0; + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, 0); + + } + } + + if (term) { + jpc_mqenc_flush(mqenc, term - 1); + } + + return jpc_mqenc_error(mqenc) ? (-1) : 0; } -#define rawrefpass_step(fp, dp, bitpos, one, nmsedec, out, vcausalflag) \ +#define rawrefpass_step(fp, dp, bitpos, one, nmsedec, out, vcausalflag) \ { \ - jpc_fix_t d; \ - jpc_fix_t v; \ - if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ - d = *(dp); \ - *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ - v = (abs(d) & (one)) ? 1 : 0; \ - if (jpc_bitstream_putbit((out), v) == EOF) { \ - return -1; \ - } \ - *(fp) |= JPC_REFINE; \ - } \ + jpc_fix_t d; \ + jpc_fix_t v; \ + if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ + d = *(dp); \ + *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ + v = (abs(d) & (one)) ? 1 : 0; \ + if (jpc_bitstream_putbit((out), v) == EOF) { \ + return -1; \ + } \ + *(fp) |= JPC_REFINE; \ + } \ } static int jpc_encrawrefpass(jpc_bitstream_t *out, int bitpos, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int k; - int one; - int vscanlen; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - jpc_fix_t *dp; - jpc_fix_t *fp; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - - } - } - - if (term) { - jpc_bitstream_outalign(out, 0x2a); - } - - return 0; + int i; + int j; + int k; + int one; + int vscanlen; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + jpc_fix_t *dp; + jpc_fix_t *fp; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + + } + } + + if (term) { + jpc_bitstream_outalign(out, 0x2a); + } + + return 0; } /******************************************************************************\ * Code for cleanup pass. \******************************************************************************/ -#define clnpass_step(fp, frowstep, dp, bitpos, one, orient, nmsedec, mqenc, label1, label2, vcausalflag) \ +#define clnpass_step(fp, frowstep, dp, bitpos, one, orient, nmsedec, mqenc, label1, label2, vcausalflag) \ { \ - int f; \ - int v; \ + int f; \ + int v; \ label1 \ - f = *(fp); \ - if (!(f & (JPC_SIG | JPC_VISIT))) { \ - jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ - v = (abs(*(dp)) & (one)) ? 1 : 0; \ - jpc_mqenc_putbit((mqenc), v); \ - if (v) { \ + f = *(fp); \ + if (!(f & (JPC_SIG | JPC_VISIT))) { \ + jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ + v = (abs(*(dp)) & (one)) ? 1 : 0; \ + jpc_mqenc_putbit((mqenc), v); \ + if (v) { \ label2 \ - f = *(fp); \ - /* Coefficient is significant. */ \ - *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ - jpc_mqenc_setcurctx((mqenc), JPC_GETSCCTXNO(f)); \ - v = ((*(dp) < 0) ? 1 : 0); \ - jpc_mqenc_putbit((mqenc), v ^ JPC_GETSPB(f)); \ - JPC_UPDATEFLAGS4((fp), (frowstep), v, vcausalflag); \ - *(fp) |= JPC_SIG; \ - } \ - } \ - *(fp) &= ~JPC_VISIT; \ + f = *(fp); \ + /* Coefficient is significant. */ \ + *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ + jpc_mqenc_setcurctx((mqenc), JPC_GETSCCTXNO(f)); \ + v = ((*(dp) < 0) ? 1 : 0); \ + jpc_mqenc_putbit((mqenc), v ^ JPC_GETSPB(f)); \ + JPC_UPDATEFLAGS4((fp), (frowstep), v, vcausalflag); \ + *(fp) |= JPC_SIG; \ + } \ + } \ + *(fp) &= ~JPC_VISIT; \ } static int jpc_encclnpass(jpc_mqenc_t *mqenc, int bitpos, int orient, int vcausalflag, int segsymflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int k; - int vscanlen; - int v; - int runlen; - jpc_fix_t *fp; - int width; - int height; - jpc_fix_t *dp; - int one; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - - fp = fvscanstart; - if (vscanlen >= 4 && !((*fp) & (JPC_SIG | JPC_VISIT | - JPC_OTHSIGMSK)) && (fp += frowstep, !((*fp) & (JPC_SIG | - JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) & - (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, - !((*fp) & (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK)))) { - dp = dvscanstart; - for (k = 0; k < vscanlen; ++k) { - v = (abs(*dp) & one) ? 1 : 0; - if (v) { - break; - } - dp += drowstep; - } - runlen = k; - if (runlen >= 4) { - jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); - jpc_mqenc_putbit(mqenc, 0); - continue; - } - jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); - jpc_mqenc_putbit(mqenc, 1); - jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); - jpc_mqenc_putbit(mqenc, runlen >> 1); - jpc_mqenc_putbit(mqenc, runlen & 1); - fp = fvscanstart + frowstep * runlen; - dp = dvscanstart + drowstep * runlen; - k = vscanlen - runlen; - switch (runlen) { - case 0: - goto clnpass_partial0; - break; - case 1: - goto clnpass_partial1; - break; - case 2: - goto clnpass_partial2; - break; - case 3: - goto clnpass_partial3; - break; - } - } else { - runlen = 0; - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - goto clnpass_full0; - } - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, clnpass_full0:, clnpass_partial0:, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, ;, clnpass_partial1:, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, ;, clnpass_partial2:, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, ;, clnpass_partial3:, 0); - } - } - - if (segsymflag) { - jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); - jpc_mqenc_putbit(mqenc, 1); - jpc_mqenc_putbit(mqenc, 0); - jpc_mqenc_putbit(mqenc, 1); - jpc_mqenc_putbit(mqenc, 0); - } - - if (term) { - jpc_mqenc_flush(mqenc, term - 1); - } - - return jpc_mqenc_error(mqenc) ? (-1) : 0; + int i; + int j; + int k; + int vscanlen; + int v; + int runlen; + jpc_fix_t *fp; + int width; + int height; + jpc_fix_t *dp; + int one; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + + fp = fvscanstart; + if (vscanlen >= 4 && !((*fp) & (JPC_SIG | JPC_VISIT | + JPC_OTHSIGMSK)) && (fp += frowstep, !((*fp) & (JPC_SIG | + JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) & + (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, + !((*fp) & (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK)))) { + dp = dvscanstart; + for (k = 0; k < vscanlen; ++k) { + v = (abs(*dp) & one) ? 1 : 0; + if (v) { + break; + } + dp += drowstep; + } + runlen = k; + if (runlen >= 4) { + jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); + jpc_mqenc_putbit(mqenc, 0); + continue; + } + jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); + jpc_mqenc_putbit(mqenc, 1); + jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); + jpc_mqenc_putbit(mqenc, runlen >> 1); + jpc_mqenc_putbit(mqenc, runlen & 1); + fp = fvscanstart + frowstep * runlen; + dp = dvscanstart + drowstep * runlen; + k = vscanlen - runlen; + switch (runlen) { + case 0: + goto clnpass_partial0; + break; + case 1: + goto clnpass_partial1; + break; + case 2: + goto clnpass_partial2; + break; + case 3: + goto clnpass_partial3; + break; + } + } else { + runlen = 0; + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + goto clnpass_full0; + } + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, clnpass_full0:, clnpass_partial0:, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, ;, clnpass_partial1:, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, ;, clnpass_partial2:, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, ;, clnpass_partial3:, 0); + } + } + + if (segsymflag) { + jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); + jpc_mqenc_putbit(mqenc, 1); + jpc_mqenc_putbit(mqenc, 0); + jpc_mqenc_putbit(mqenc, 1); + jpc_mqenc_putbit(mqenc, 0); + } + + if (term) { + jpc_mqenc_flush(mqenc, term - 1); + } + + return jpc_mqenc_error(mqenc) ? (-1) : 0; } diff --git a/converter/other/pamtopnm.c b/converter/other/pamtopnm.c index f043d721..f0ad451a 100644 --- a/converter/other/pamtopnm.c +++ b/converter/other/pamtopnm.c @@ -96,7 +96,7 @@ validateTupleType(struct pam const inpam, /* It's a PPMable image */ } else pm_error("PAM image does not have a depth and tuple_type " - "consistent with a PNM image." + "consistent with a PNM image. " "According to its " "header, depth is %d and tuple_type is '%s'. " "Use the -assume option to convert anyway.", diff --git a/converter/other/pamtosvg/pxl-outline.c b/converter/other/pamtosvg/pxl-outline.c index 456f41e1..19451c04 100644 --- a/converter/other/pamtosvg/pxl-outline.c +++ b/converter/other/pamtosvg/pxl-outline.c @@ -206,10 +206,8 @@ next_unmarked_pixel(unsigned int * const row, direction_type const orig_dir = *dir; direction_type test_dir; - pixel color; test_dir = *dir; /* initial value */ - color = getBitmapColor(bitmap, *row, *col); do { if (is_valid_dir(orig_row, orig_col, test_dir, bitmap, *marked)) { diff --git a/converter/other/pamtowinicon.c b/converter/other/pamtowinicon.c index 7e2c9e86..3d77d731 100644 --- a/converter/other/pamtowinicon.c +++ b/converter/other/pamtowinicon.c @@ -643,7 +643,7 @@ writePng(const struct pam * const pamP, if (haveAlpha || haveAnd) { const char * alphaFileName; - const char * command; + const char * alphaOpt; if (haveAlpha) makeAlphaFile(pamP, tuples, alphaPlane, &alphaFileName); @@ -653,19 +653,19 @@ writePng(const struct pam * const pamP, strcpy (pam.tuple_type, pam.depth == 3 ? PAM_PPM_TUPLETYPE: PAM_PGM_TUPLETYPE); - pm_asprintf(&command, "pnmtopng -alpha=\"%s\"", alphaFileName); + pm_asprintf(&alphaOpt, "-alpha=%s", alphaFileName); - pm_system(pm_feed_from_pamtuples, &pamTuples, - acceptToFile, &acceptParm, - command); + pm_system_lp("pnmtopng", pm_feed_from_pamtuples, &pamTuples, + acceptToFile, &acceptParm, + "pnmtopng", alphaOpt, NULL); - pm_strfree(command); + pm_strfree(alphaOpt); unlink(alphaFileName); } else { - pm_system(pm_feed_from_pamtuples, &pamTuples, - acceptToFile, &acceptParm, - "pnmtopng"); + pm_system_lp("pnmtopng", pm_feed_from_pamtuples, &pamTuples, + acceptToFile, &acceptParm, + "pnmtopng", NULL); } *sizeP = pngSize; diff --git a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c index ae8c8524..ac02e425 100644 --- a/converter/other/pnmtoddif.c +++ b/converter/other/pnmtoddif.c @@ -538,15 +538,12 @@ convertRaster(FILE * const ifP, unsigned int const bytesPerLine) { unsigned char * data; - unsigned char * p; MALLOCARRAY(data, bytesPerLine); if (data == NULL) pm_error("Couldn't allocate %u-byte line buffer", bytesPerLine); - p = data; /* initial value */ - switch (PNM_FORMAT_TYPE(format)) { case PBM_TYPE: convertPbmRaster(ifP, format, cols, rows, ofP, bytesPerLine, data); diff --git a/converter/other/pnmtoplainpnm b/converter/other/pnmtoplainpnm index 87c58597..4f5378b2 100755 --- a/converter/other/pnmtoplainpnm +++ b/converter/other/pnmtoplainpnm @@ -1,3 +1,3 @@ #! /bin/sh -pnmtopnm -plain $@ +pamtopnm -plain $@ diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index ac171453..cf053f7e 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -1842,9 +1842,9 @@ buildColorLookup(pixel palette_pnm[], static void -buildColorAlphaLookup(pixel palette_pnm[], +buildColorAlphaLookup(pixel palettePnm[], unsigned int const paletteSize, - gray trans_pnm[], + gray transPnm[], unsigned int const transSize, gray const alphaMaxval, coloralphahash_table * const cahtP) { @@ -1857,12 +1857,12 @@ buildColorAlphaLookup(pixel palette_pnm[], gray paletteTrans; if (paletteIndex < transSize) - paletteTrans = alphaMaxval; + paletteTrans = transPnm[paletteIndex]; else - paletteTrans = trans_pnm[paletteIndex]; + paletteTrans = alphaMaxval; - addtocoloralphahash(caht, &palette_pnm[paletteIndex], - &trans_pnm[paletteIndex], paletteIndex); + addtocoloralphahash(caht, &palettePnm[paletteIndex], + &paletteTrans, paletteIndex); } *cahtP = caht; } diff --git a/converter/other/pnmtosir.c b/converter/other/pnmtosir.c index c8dec5b6..20bb6178 100644 --- a/converter/other/pnmtosir.c +++ b/converter/other/pnmtosir.c @@ -1,5 +1,5 @@ /* pnmtosir.c - read a portable anymap and produce a Solitaire Image Recorder -** file (MGI TYPE 11 or MGI TYPE 17) +** file (MGI TYPE 11 or MGI TYPE 17) ** ** Copyright (C) 1991 by Marvin Landis ** @@ -11,67 +11,63 @@ ** implied warranty. */ +#include <stdbool.h> #include "pnm.h" #define MAXCOLORS 256 -int main(int argc, char * argv[]) { - FILE* ifp; - xel** xels; - register xel* xP; - const char* dumpname; - int rows, cols, format, row, col; - int m, n; - int grayscale; + + +int +main(int argc, const char * argv[]) { + + FILE * ifP; + xel ** xels; + int rows, cols, format; + unsigned int n; + bool isGrayscale; xelval maxval; - const char* const usage = "[pnmfile]"; - unsigned char ub; unsigned short Header[16]; unsigned short LutHeader[16]; unsigned short Lut[2048]; - pnm_init( &argc, argv ); + pm_proginit(&argc, argv); - if ( argc > 2 ) - pm_usage( usage ); + if (argc-1 > 1) + pm_error("There is only one possible argument: the input file. " + "You specified %d", argc-1); - if ( argc == 2 ) - { - dumpname = argv[1]; - ifp = pm_openr( argv[1] ); - } - else - { - dumpname = "Standard Input"; - ifp = stdin; - } + if (argc-1 > 0) { + const char * const inputFileName = argv[1]; + ifP = pm_openr(inputFileName); + } else { + ifP = stdin; + } - xels = pnm_readpnm( ifp, &cols, &rows, &maxval, &format ); - pm_close( ifp ); + xels = pnm_readpnm(ifP, &cols, &rows, &maxval, &format); /* Figure out the colormap. */ - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - grayscale = 0; - pm_message( "Writing a 24-bit SIR format (MGI TYPE 11)" ); + switch (PNM_FORMAT_TYPE(format) ) { + case PPM_TYPE: + isGrayscale = false; + pm_message("Writing a 24-bit SIR format (MGI TYPE 11)"); break; case PGM_TYPE: - grayscale = 1; - pm_message( "Writing a grayscale SIR format (MGI TYPE 17)" ); + isGrayscale = true; + pm_message("Writing a grayscale SIR format (MGI TYPE 17)"); break; - default: - grayscale = 1; - pm_message( "Writing a monochrome SIR format (MGI TYPE 17)" ); + default: + isGrayscale = true; + pm_message("Writing a monochrome SIR format (MGI TYPE 17)"); break; - } + } /* Set up the header. */ Header[0] = 0x3a4f; Header[1] = 0; - if (grayscale) + if (isGrayscale) Header[2] = 17; else Header[2] = 11; @@ -93,54 +89,65 @@ int main(int argc, char * argv[]) { LutHeader[2] = 5; LutHeader[3] = 256; LutHeader[4] = 256; - for (n = 0; n < 5; n++) + for (n = 0; n < 5; ++n) pm_writelittleshort(stdout,LutHeader[n]); - for (n = 5; n < 256; n++) + for (n = 5; n < 256; ++n) pm_writelittleshort(stdout,0); - for(n = 0; n < 3; n ++) - for (m = 0; m < 256; m++) + for (n = 0; n < 3; ++n) { + unsigned int m; + for (m = 0; m < 256; ++m) Lut[m * 4 + n] = m << 8; - for (n = 0; n < 1024; n++) + } + for (n = 0; n < 1024; ++n) pm_writelittleshort(stdout,Lut[n]); /* Finally, write out the data. */ - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - for ( row = 0; row < rows; ++row ) - for ( col = 0, xP = xels[row]; col < cols; ++col, ++xP ) - { - ub = (char) ( PPM_GETR( *xP ) * ( 255 / maxval ) ); - fputc( ub, stdout ); + switch (PNM_FORMAT_TYPE(format)) { + case PPM_TYPE: { + unsigned int row; + for (row = 0; row < rows; ++row) { + unsigned int col; + for (col = 0; col < cols; ++col) { + unsigned char const ub = + (char) (PPM_GETR(xels[row][col]) * (255 / maxval)); + fputc(ub, stdout); } - for ( row = 0; row < rows; ++row ) - for ( col = 0, xP = xels[row]; col < cols; ++col, ++xP ) - { - ub = (char) ( PPM_GETG( *xP ) * ( 255 / maxval ) ); - fputc( ub, stdout ); + } + for (row = 0; row < rows; ++row) { + unsigned int col; + for (col = 0; col < cols; ++col) { + unsigned const char ub = + (char) (PPM_GETG(xels[row][col]) * (255 / maxval)); + fputc(ub, stdout); } - for ( row = 0; row < rows; ++row ) - for ( col = 0, xP = xels[row]; col < cols; ++col, ++xP ) - { - ub = (char) ( PPM_GETB( *xP ) * ( 255 / maxval ) ); - fputc( ub, stdout ); + } + for (row = 0; row < rows; ++row) { + unsigned int col; + for (col = 0; col < cols; ++col) { + unsigned const char ub = + (char) (PPM_GETB(xels[row][col]) * (255 / maxval)); + fputc(ub, stdout); } - break; + } + } break; - default: - for ( row = 0; row < rows; ++row ) - for ( col = 0, xP = xels[row]; col < cols; ++col, ++xP ) - { - register unsigned long val; - - val = PNM_GET1( *xP ); - ub = (char) ( val * ( 255 / maxval ) ); - fputc( ub, stdout ); + default: { + unsigned int row; + for (row = 0; row < rows; ++row) { + unsigned int col; + for (col = 0; col < cols; ++col) { + unsigned long const val = PNM_GET1(xels[row][col]); + unsigned const char ub = (char) (val * (255 / maxval)); + fputc(ub, stdout); } - break; + } + } break; } + + pm_close(ifP); - exit( 0 ); + return 0; } + diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c index b253442f..016db2f6 100644 --- a/converter/other/pstopnm.c +++ b/converter/other/pstopnm.c @@ -784,12 +784,11 @@ execGhostscript(int const inputPipeFd, const char * gopt; const char * ropt; const char * textalphabitsopt; - int rc; findGhostscriptProg(&ghostscriptProg); /* Put the input pipe on Standard Input */ - rc = dup2(inputPipeFd, STDIN_FILENO); + dup2(inputPipeFd, STDIN_FILENO); close(inputPipeFd); pm_asprintf(&arg0, "gs"); diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c index 99959141..ff37cfe4 100644 --- a/converter/other/rletopnm.c +++ b/converter/other/rletopnm.c @@ -264,7 +264,8 @@ writePpmRaster(FILE * const imageoutFileP, pixel *pixelrow; gray *alpharow; - int scan, x, y; + int scan; + int x; /* * Allocate some stuff. */ @@ -280,9 +281,9 @@ writePpmRaster(FILE * const imageoutFileP, /* * Loop through those scan lines. */ - for (scan = 0; scan < height; scan++) - y = rle_getrow(&hdr, scanlines[height - scan - 1]); - for (scan = 0; scan < height; scan++) { + for (scan = 0; scan < height; ++scan) + rle_getrow(&hdr, scanlines[height - scan - 1]); + for (scan = 0; scan < height; ++scan) { scanline = scanlines[scan]; switch (visual) { case GRAYSCALE: /* 8 bits without colormap */ @@ -366,7 +367,6 @@ writePgmRaster(FILE * const imageoutFileP, gray * pixelrow; gray * alpharow; int scan; - int y; /* * Allocate some stuff. */ @@ -383,7 +383,7 @@ writePgmRaster(FILE * const imageoutFileP, * Loop through those scan lines. */ for (scan = 0; scan < height; ++scan) - y = rle_getrow(&hdr, scanlines[height - scan - 1]); + rle_getrow(&hdr, scanlines[height - scan - 1]); for (scan = 0; scan < height; ++scan) { int x; diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c index 0d6494f9..f9e602ff 100644 --- a/converter/other/tifftopnm.c +++ b/converter/other/tifftopnm.c @@ -782,14 +782,22 @@ spawnWithInputPipe(const char * const shellCmd, else *errorP = NULL; } else { - int rc; + int terminationStatus; close(fd[PIPE_WRITE]); close(STDIN_FILENO); dup2(fd[PIPE_READ], STDIN_FILENO); - rc = system(shellCmd); + terminationStatus = system(shellCmd); - exit(rc); + if (WIFSIGNALED(terminationStatus)) + pm_error("Shell process was killed " + "by a Class %u signal.", + WTERMSIG(terminationStatus)); + else if (!WIFEXITED(terminationStatus)) + pm_error("Shell process died, but its termination status " + "0x%x doesn't make sense", terminationStatus); + else + exit(WEXITSTATUS(terminationStatus)); } } } diff --git a/converter/other/winicontopam.c b/converter/other/winicontopam.c index 664b4ef9..69ce7f05 100644 --- a/converter/other/winicontopam.c +++ b/converter/other/winicontopam.c @@ -1156,9 +1156,9 @@ convertPng(const unsigned char * const image, imageBuffer.buffer = (unsigned char *)image; fflush (stdout); - pm_system(pm_feed_from_memory, &imageBuffer, - NULL /* stdout accepter */, NULL, - "pngtopam -alphapam"); + pm_system_lp("pngtopam", pm_feed_from_memory, &imageBuffer, + NULL /* stdout accepter */, NULL, + "pngtopam", "-alphapam", NULL); } diff --git a/converter/pbm/pbmtomgr.c b/converter/pbm/pbmtomgr.c index e8e30148..0e529740 100644 --- a/converter/pbm/pbmtomgr.c +++ b/converter/pbm/pbmtomgr.c @@ -40,7 +40,7 @@ putinit(unsigned int const rows, int main(int argc, - char * argv[]) { + const char * argv[]) { FILE * ifP; unsigned char * bitrow; @@ -50,15 +50,11 @@ main(int argc, unsigned int row; unsigned int bytesPerRow; /* Number of packed bytes (8 columns per byte) in a row. */ - unsigned int padright; - /* Number of columns added to the right of each row to get up to - a multiple of 8, i.e. an integral number of packed bytes. - */ const char * inputFileName; unsigned int const maxDimension = 4095; /* Dimensions are 2 characters of the header -- 12 bits */ - pbm_init(&argc, argv); + pm_proginit(&argc, argv); if (argc-1 > 1) pm_error("Too many arguments (%u). " @@ -78,7 +74,6 @@ main(int argc, bitrow = pbm_allocrow_packed(cols); bytesPerRow = pbm_packed_bytes(cols); - padright = bytesPerRow * 8 - cols; putinit(rows, cols); diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c index bf3b9e41..e803e413 100644 --- a/converter/pbm/pbmtonokia.c +++ b/converter/pbm/pbmtonokia.c @@ -321,10 +321,8 @@ convertToNol(bit ** const image, /* image */ for (row = 0; row < rows; ++row) { unsigned int col; - unsigned int p; - unsigned int c; - for (p = 0, c = 0, col = 0; col < cols; ++col) { + for (col = 0; col < cols; ++col) { char const output = image[row][col] == PBM_BLACK ? '1' : '0'; putc(output, ofP); @@ -374,10 +372,8 @@ convertToNgg(bit ** const image, for (row = 0; row < rows; ++row) { unsigned int col; - unsigned int p; - unsigned int c; - for (p = 0, c = 0, col = 0; col < cols; ++col) { + for (col = 0; col < cols; ++col) { char const output = image[row][col] == PBM_BLACK ? '1' : '0'; putc(output, ofP); diff --git a/converter/pbm/pbmtox10bm b/converter/pbm/pbmtox10bm index 9a1a7286..6e1a12a2 100644 --- a/converter/pbm/pbmtox10bm +++ b/converter/pbm/pbmtox10bm @@ -14,6 +14,19 @@ use strict; use File::Basename; use Cwd 'abs_path'; +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('pbmtoxbm', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + +doVersionHack(\@ARGV); + my $infile; foreach (@ARGV) { diff --git a/converter/pgm/sbigtopgm.c b/converter/pgm/sbigtopgm.c index 3c223c47..7833cb62 100644 --- a/converter/pgm/sbigtopgm.c +++ b/converter/pgm/sbigtopgm.c @@ -54,7 +54,6 @@ parseCommandLine(int argc, const char ** argv, MALLOCARRAY_NOFAIL(option_def, 100); - option_def_index = 0; /* incremented by OPTENT3 */ OPTENTINIT; opt.opt_table = option_def; diff --git a/converter/ppm/hpcdtoppm/hpcdtoppm b/converter/ppm/hpcdtoppm/hpcdtoppm index cb6d084b..2af4a384 100755 --- a/converter/ppm/hpcdtoppm/hpcdtoppm +++ b/converter/ppm/hpcdtoppm/hpcdtoppm @@ -1,24 +1,24 @@ #!/bin/sh cat <<EOF 1>&2 -You are running a program named 'hpcdtoppm' that stands in for the -real program by that name. +You are running a program named 'hpcdtoppm' that stands in for the real +program by that name. -The real 'hpcdtoppm' is a program that converts an image from Photo CD -format to PPM format. The program you are running now just issues the -message you are reading. +The real 'hpcdtoppm' is a program that converts an image from Photo CD format +to PPM format. The program you are running now just issues the message you +are reading. Please get a copy of Hpcdtoppm from - ftp://ibiblio.org/pub/linux/graphics/convert + http://terasaur.org/item/show/hpcdtoppm-netpbm-convert-photo-cd/4967 and replace this stand-in program with the real one. -The point of this is that this stand-in 'hpcdtoppm' is distributed -with Netpbm on Sourceforge. Hpcdtoppm does not meet the requirements -to be distributed on Sourceforge because a copyright holder does not -permit people to sell copies. In the past the real Hpcdtoppm was -distributed with Netpbm on Sourceforge by mistake. +The point of this is that this stand-in 'hpcdtoppm' is distributed with Netpbm +on Sourceforge. Hpcdtoppm does not meet the requirements to be distributed on +Sourceforge because a copyright holder does not permit people to sell copies. +At one time, the real Hpcdtoppm was distributed with Netpbm on Sourceforge by +mistake. EOF diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c index 828d5270..d412038c 100644 --- a/converter/ppm/picttoppm.c +++ b/converter/ppm/picttoppm.c @@ -1577,7 +1577,6 @@ doBlit(struct Rect const srcRect, int dstoff; int xsize; int ysize; - int srcadd; transfer_func trf; if (verbose) { @@ -1598,7 +1597,6 @@ doBlit(struct Rect const srcRect, src = srcplane.bytes + srcRowNumber * srcplane.rowSize + srcRowOffset; xsize = rectwidth(&srcRect); ysize = rectheight(&srcRect); - srcadd = srcplane.rowSize - xsize * pkpixsize; } dstoff = (dstRect.top - dstBounds.top) * dstwid + @@ -2180,14 +2178,9 @@ unpackBuf(unsigned char * const packed, 'packedLen' must not be greater than 256. -----------------------------------------------------------------------------*/ static unsigned char expanded[256 * 8]; - unsigned char * src; - unsigned char * dst; assert(packedLen <= 256); - src = &packed[0]; - dst = &expanded[0]; - switch (bitsPerPixel) { case 8: case 16: @@ -3712,13 +3705,11 @@ directBits(struct canvas * const canvasP, struct Rect dstRect; struct raster raster; Word mode; - unsigned int rectWidth; /* skip fake len, and fake EOF */ skip(4); /* Ptr baseAddr == 0x000000ff */ readWord(); /* version */ readRect(&p.Bounds); - rectWidth = p.Bounds.right - p.Bounds.left; p.packType = readWord(); p.packSize = readLong(); p.hRes = readLong(); diff --git a/converter/ppm/ppmtobmp.c b/converter/ppm/ppmtobmp.c index 6d65d744..6bdec8c3 100644 --- a/converter/ppm/ppmtobmp.c +++ b/converter/ppm/ppmtobmp.c @@ -29,9 +29,9 @@ #define MAXCOLORS 256 -enum colortype {TRUECOLOR, PALETTE}; +typedef enum {TRUECOLOR, PALETTE} Colortype; -struct rgb { +struct Rgb { unsigned char red; unsigned char grn; unsigned char blu; @@ -50,13 +50,13 @@ typedef struct { colorhash_table cht; /* Indices in the following array are the same as in 'cht', above. */ - struct rgb bmpMap[MAXCOLORS]; -} colorMap; + struct Rgb bmpMap[MAXCOLORS]; +} ColorMap; static void -freeColorMap(const colorMap * const colorMapP) { +freeColorMap(const ColorMap * const colorMapP) { if (colorMapP->cht) ppm_freecolorhash(colorMapP->cht); @@ -68,11 +68,11 @@ struct CmdlineInfo { /* All the information the user supplied in the command line, in a form easy for the program to use. */ - const char * inputFilename; - int class; /* C_WIN or C_OS2 */ - unsigned int bppSpec; - unsigned int bpp; - const char * mapfile; + const char * inputFilename; + enum bmpClass class; + unsigned int bppSpec; + unsigned int bpp; + const char * mapfile; }; @@ -113,11 +113,11 @@ parseCommandLine(int argc, const char ** argv, if (windowsSpec && os2Spec) pm_error("Can't specify both -windows and -os2 options."); else if (windowsSpec) - cmdlineP->class = C_WIN; + cmdlineP->class = BMP_C_WIN_V1; else if (os2Spec) - cmdlineP->class = C_OS2; + cmdlineP->class = BMP_C_OS2_1x; else - cmdlineP->class = C_WIN; + cmdlineP->class = BMP_C_WIN_V1; if (cmdlineP->bppSpec) { @@ -153,7 +153,7 @@ freeCommandLine(struct CmdlineInfo const cmdline) { static void -PutByte(FILE * const fp, unsigned char const v) { +putByte(FILE * const fp, unsigned char const v) { if (putc(v, fp) == EOF) pm_error("Write of a byte to a file failed."); @@ -168,7 +168,7 @@ PutByte(FILE * const fp, unsigned char const v) { static void -PutShort(FILE * const fp, short const v) { +putShort(FILE * const fp, short const v) { if (pm_writelittleshort(fp, v) == -1) pm_error("Write of a halfword to a file failed."); } @@ -176,131 +176,158 @@ PutShort(FILE * const fp, short const v) { static void -PutLong(FILE * const fp, long const v) { +putLong(FILE * const fp, long const v) { if (pm_writelittlelong(fp, v) == -1) pm_error("Write of a word to a file failed."); } - -/* - * BMP writing - */ +/*---------------------------------------------------------------------------- + BMP writing +-----------------------------------------------------------------------------*/ static unsigned int -BMPwritefileheader(FILE * const fp, +bmpWriteFileHeader(FILE * const fp, unsigned int const cbSize, unsigned int const offBits) { /*---------------------------------------------------------------------------- Return the number of bytes written. -----------------------------------------------------------------------------*/ - PutByte(fp, 'B'); - PutByte(fp, 'M'); + putByte(fp, 'B'); + putByte(fp, 'M'); /* cbSize */ - PutLong(fp, cbSize); + putLong(fp, cbSize); /* xHotSpot */ - PutShort(fp, 0); + putShort(fp, 0); /* yHotSpot */ - PutShort(fp, 0); + putShort(fp, 0); /* offBits */ - PutLong(fp, offBits); + putLong(fp, offBits); + + assert(BMPlenfileheader() == 14); return 14; } -static int -BMPwriteinfoheader(FILE * const fp, - int const class, +static unsigned int +bmpWriteInfoHeader(FILE * const fp, + enum bmpClass const class, unsigned long const bitcount, unsigned long const x, unsigned long const y) { /*---------------------------------------------------------------------------- + Write the INFO header. + Return the number of bytes written. ----------------------------------------------------------------------------*/ unsigned int cbFix; switch (class) { - case C_WIN: { - cbFix = 40; - PutLong(fp, cbFix); - - PutLong(fp, x); /* cx */ - PutLong(fp, y); /* cy */ - PutShort(fp, 1); /* cPlanes */ - PutShort(fp, bitcount); /* cBitCount */ + case BMP_C_WIN_V1: + case BMP_C_WIN_V2: + case BMP_C_WIN_V3: + case BMP_C_WIN_V4: + case BMP_C_WIN_V5: + { + cbFix = BMP_HDRLEN_WIN_V1; + putLong(fp, cbFix); + + putLong(fp, x); /* cx */ + putLong(fp, y); /* cy */ + putShort(fp, 1); /* cPlanes */ + putShort(fp, bitcount); /* cBitCount */ /* * We've written 16 bytes so far, need to write 24 more * for the required total of 40. */ - PutLong(fp, 0); /* Compression */ - PutLong(fp, 0); /* ImageSize */ - PutLong(fp, 0); /* XpixelsPerMeter */ - PutLong(fp, 0); /* YpixelsPerMeter */ - PutLong(fp, 0); /* ColorsUsed */ - PutLong(fp, 0); /* ColorsImportant */ + putLong(fp, 0); /* Compression */ + putLong(fp, 0); /* ImageSize */ + putLong(fp, 0); /* XpixelsPerMeter */ + putLong(fp, 0); /* YpixelsPerMeter */ + putLong(fp, 0); /* ColorsUsed */ + putLong(fp, 0); /* ColorsImportant */ + + assert(BMP_HDRLEN_WIN_V1 == 40); /* We wrote 40 bytes */ + + if (class != BMP_C_WIN_V1) { + /* Invalid call to this function - we don't know how to write + these header extensions. + */ + assert(false); + } } break; - case C_OS2: { - cbFix = 12; - PutLong(fp, cbFix); - - PutShort(fp, x); /* cx */ - PutShort(fp, y); /* cy */ - PutShort(fp, 1); /* cPlanes */ - PutShort(fp, bitcount); /* cBitCount */ + case BMP_C_OS2_1x: { + cbFix = BMP_HDRLEN_OS2_1x; + putLong(fp, cbFix); + + putShort(fp, x); /* cx */ + putShort(fp, y); /* cy */ + putShort(fp, 1); /* cPlanes */ + putShort(fp, bitcount); /* cBitCount */ + + assert(BMP_HDRLEN_OS2_1x == 12); /* We wrote 12 bytes */ } break; - default: - pm_error(er_internal, "BMPwriteinfoheader"); + case BMP_C_OS2_2x: + /* Invalid call to this function */ + assert(false); + break; } - return cbFix; } -static int -BMPwriteRgb(FILE * const fp, - int const class, - pixval const R, - pixval const G, - pixval const B) { +static unsigned int +bmpWriteRgb(FILE * const fp, + enum bmpClass const class, + pixval const R, + pixval const G, + pixval const B) { /*---------------------------------------------------------------------------- Return the number of bytes written. -----------------------------------------------------------------------------*/ + unsigned int retval; + switch (class) { - case C_WIN: - PutByte(fp, B); - PutByte(fp, G); - PutByte(fp, R); - PutByte(fp, 0); - return 4; - case C_OS2: - PutByte(fp, B); - PutByte(fp, G); - PutByte(fp, R); - return 3; - default: - pm_error(er_internal, "BMPwriteRgb"); - return -1; /* avoid compiler warning. */ + case BMP_C_WIN_V1: + case BMP_C_WIN_V2: + case BMP_C_WIN_V3: + case BMP_C_WIN_V4: + case BMP_C_WIN_V5: + putByte(fp, B); + putByte(fp, G); + putByte(fp, R); + putByte(fp, 0); + retval = 4; + break; + case BMP_C_OS2_1x: + case BMP_C_OS2_2x: + putByte(fp, B); + putByte(fp, G); + putByte(fp, R); + retval = 3; + break; } + return retval; } -static int -BMPwriteColormap(FILE * const ifP, - int const class, +static unsigned int +bmpWriteColormap(FILE * const ifP, + enum bmpClass const class, int const bpp, - const colorMap * const colorMapP) { + const ColorMap * const colorMapP) { /*---------------------------------------------------------------------------- Return the number of bytes written. -----------------------------------------------------------------------------*/ @@ -314,12 +341,12 @@ BMPwriteColormap(FILE * const ifP, nbyte = 0; for (i = 0; i < colorMapP->count; ++i) { - const struct rgb * const mapEntryP = &colorMapP->bmpMap[i]; - nbyte += BMPwriteRgb(ifP, class, + const struct Rgb * const mapEntryP = &colorMapP->bmpMap[i]; + nbyte += bmpWriteRgb(ifP, class, mapEntryP->red, mapEntryP->grn, mapEntryP->blu); } for (; i < ncolors; ++i) - nbyte += BMPwriteRgb(ifP, class, 0, 0, 0); + nbyte += bmpWriteRgb(ifP, class, 0, 0, 0); return nbyte; } @@ -388,7 +415,7 @@ bmpWriteRow_palette(FILE * const fp, /* Make sure we write a multiple of 4 bytes. */ while (nbyte % 4 != 0) { - PutByte(fp, 0); + putByte(fp, 0); ++nbyte; } *nBytesP = nbyte; @@ -424,9 +451,9 @@ bmpWriteRow_truecolor(FILE * const fp, nbyte = 0; /* initial value */ for (col = 0; col < cols; ++col) { /* We scale to the BMP maxval, which is always 255. */ - PutByte(fp, PPM_GETB(row[col]) * 255 / maxval); - PutByte(fp, PPM_GETG(row[col]) * 255 / maxval); - PutByte(fp, PPM_GETR(row[col]) * 255 / maxval); + putByte(fp, PPM_GETB(row[col]) * 255 / maxval); + putByte(fp, PPM_GETG(row[col]) * 255 / maxval); + putByte(fp, PPM_GETR(row[col]) * 255 / maxval); nbyte += 3; } @@ -434,7 +461,7 @@ bmpWriteRow_truecolor(FILE * const fp, * Make sure we write a multiple of 4 bytes. */ while (nbyte % 4) { - PutByte(fp, 0); + putByte(fp, 0); ++nbyte; } @@ -443,16 +470,18 @@ bmpWriteRow_truecolor(FILE * const fp, -static int -BMPwritebits(FILE * const fp, - unsigned long const cols, - unsigned long const rows, - enum colortype const colortype, - unsigned short const cBitCount, - const pixel ** const pixels, - pixval const maxval, - colorhash_table const cht) { +static unsigned int +bmpWriteRaster(FILE * const fp, + unsigned long const cols, + unsigned long const rows, + Colortype const colortype, + unsigned short const cBitCount, + const pixel ** const pixels, + pixval const maxval, + colorhash_table const cht) { /*---------------------------------------------------------------------------- + Write the raster. + Return the number of bytes written. -----------------------------------------------------------------------------*/ unsigned int nbyte; @@ -487,14 +516,14 @@ BMPwritebits(FILE * const fp, static void bmpEncode(FILE * const ifP, - int const class, - enum colortype const colortype, + enum bmpClass const class, + Colortype const colortype, unsigned int const bpp, int const x, int const y, const pixel ** const pixels, pixval const maxval, - const colorMap * const colorMapP) { + const ColorMap * const colorMapP) { /*---------------------------------------------------------------------------- Write a BMP file of the given class. -----------------------------------------------------------------------------*/ @@ -509,16 +538,16 @@ bmpEncode(FILE * const ifP, pm_message("Writing %u bits per pixel truecolor (no palette)", bpp); nbyte = 0; /* initial value */ - nbyte += BMPwritefileheader(ifP, cbSize, offbits); - nbyte += BMPwriteinfoheader(ifP, class, bpp, x, y); + nbyte += bmpWriteFileHeader(ifP, cbSize, offbits); + nbyte += bmpWriteInfoHeader(ifP, class, bpp, x, y); if (colortype == PALETTE) - nbyte += BMPwriteColormap(ifP, class, bpp, colorMapP); + nbyte += bmpWriteColormap(ifP, class, bpp, colorMapP); if (nbyte != offbits) pm_error(er_internal, "BmpEncode 1"); - nbyte += BMPwritebits(ifP, x, y, colortype, bpp, pixels, maxval, - colorMapP->cht); + nbyte += bmpWriteRaster(ifP, x, y, colortype, bpp, pixels, maxval, + colorMapP->cht); if (nbyte != cbSize) pm_error(er_internal, "BmpEncode 2"); } @@ -526,7 +555,7 @@ bmpEncode(FILE * const ifP, static void -makeBilevelColorMap(colorMap * const colorMapP) { +makeBilevelColorMap(ColorMap * const colorMapP) { colorMapP->count = 2; colorMapP->cht = NULL; @@ -542,7 +571,7 @@ makeBilevelColorMap(colorMap * const colorMapP) { static void bmpEncodePbm(FILE * const ifP, - int const class, + enum bmpClass const class, int const cols, int const rows, unsigned char ** const bitrow) { @@ -559,19 +588,19 @@ bmpEncodePbm(FILE * const ifP, unsigned int const packedBytes = adjustedCols / 8; unsigned long nbyte; - colorMap bilevelColorMap; + ColorMap bilevelColorMap; unsigned int row; /* colortype == PALETTE */ pm_message("Writing 1 bit per pixel with a black-white palette"); nbyte = 0; /* initial value */ - nbyte += BMPwritefileheader(ifP, cbSize, offbits); - nbyte += BMPwriteinfoheader(ifP, class, 1, cols, rows); + nbyte += bmpWriteFileHeader(ifP, cbSize, offbits); + nbyte += bmpWriteInfoHeader(ifP, class, 1, cols, rows); makeBilevelColorMap(&bilevelColorMap); - nbyte += BMPwriteColormap(ifP, class, 1, &bilevelColorMap); + nbyte += bmpWriteColormap(ifP, class, 1, &bilevelColorMap); if (nbyte != offbits) pm_error(er_internal, "bmpEncodePbm 1"); @@ -597,7 +626,7 @@ bmpEncodePbm(FILE * const ifP, static void -makeHashFromBmpMap(const struct rgb * const bmpMap, +makeHashFromBmpMap(const struct Rgb * const bmpMap, unsigned int const nColors, colorhash_table * const chtP) { @@ -607,7 +636,7 @@ makeHashFromBmpMap(const struct rgb * const bmpMap, MALLOCARRAY_NOFAIL(chv, nColors); for (i = 0; i < nColors; ++i) { - const struct rgb * const mapEntryP = &bmpMap[i]; + const struct Rgb * const mapEntryP = &bmpMap[i]; PPM_ASSIGN(chv[i].color, mapEntryP->red, mapEntryP->grn, mapEntryP->blu); @@ -646,7 +675,7 @@ minBmpBitsForColorCount(unsigned int const colorCount) { static void getMapFile(const char * const mapFileName, unsigned int * const minimumBppP, - colorMap * const colorMapP) { + ColorMap * const colorMapP) { /*---------------------------------------------------------------------------- Get the color map (palette) for the BMP from file 'mapFileName'. @@ -655,7 +684,6 @@ getMapFile(const char * const mapFileName, Return as *minimumBppP the minimum number of bits per pixel it will take to represent all the colors in the map in the BMP format. -----------------------------------------------------------------------------*/ - FILE * mapFileP; int cols, rows; pixval maxval; @@ -680,7 +708,7 @@ getMapFile(const char * const mapFileName, unsigned int col; for (col = 0; col < cols; ++col) { pixel const color = pixels[row][col]; - struct rgb * const mapEntryP = &colorMapP->bmpMap[count++]; + struct Rgb * const mapEntryP = &colorMapP->bmpMap[count++]; assert(count <= ARRAY_SIZE(colorMapP->bmpMap)); @@ -708,7 +736,7 @@ analyzeColors(const pixel ** const pixels, int const rows, pixval const maxval, unsigned int * const minimumBppP, - colorMap * const colorMapP) { + ColorMap * const colorMapP) { /*---------------------------------------------------------------------------- Look at the colors in the image 'pixels' and compute values to use in representing those colors in a BMP image. @@ -751,7 +779,7 @@ analyzeColors(const pixel ** const pixels, * Now scale the maxval to 255 as required by BMP format. */ for (i = 0; i < colorMapP->count; ++i) { - struct rgb * const mapEntryP = &colorMapP->bmpMap[i]; + struct Rgb * const mapEntryP = &colorMapP->bmpMap[i]; mapEntryP->red = (pixval) PPM_GETR(chv[i].color) * 255 / maxval; mapEntryP->grn = (pixval) PPM_GETG(chv[i].color) * 255 / maxval; mapEntryP->blu = (pixval) PPM_GETB(chv[i].color) * 255 / maxval; @@ -769,7 +797,7 @@ static void chooseColortypeBpp(bool const userRequestsBpp, unsigned int const requestedBpp, unsigned int const minimumBpp, - enum colortype * const colortypeP, + Colortype * const colortypeP, unsigned int * const bitsPerPixelP) { /*---------------------------------------------------------------------------- Determine whether the BMP raster should contain RGB values or palette @@ -818,12 +846,12 @@ chooseColortypeBpp(bool const userRequestsBpp, static void -doPbm(FILE * const ifP, - unsigned int const cols, - unsigned int const rows, - int const format, - int const class, - FILE * const ofP) { +doPbm(FILE * const ifP, + unsigned int const cols, + unsigned int const rows, + int const format, + enum bmpClass const class, + FILE * const ofP) { /* We read the raster directly from the input with pbm_readpbmrow_packed(). The raster format is almost @@ -872,16 +900,16 @@ doPbm(FILE * const ifP, static void -doPgmPpm(FILE * const ifP, - unsigned int const cols, - unsigned int const rows, - pixval const maxval, - int const ppmFormat, - int const class, - bool const userRequestsBpp, - unsigned int const requestedBpp, - const char * const mapFileName, - FILE * const ofP) { +doPgmPpm(FILE * const ifP, + unsigned int const cols, + unsigned int const rows, + pixval const maxval, + int const ppmFormat, + enum bmpClass const class, + bool const userRequestsBpp, + unsigned int const requestedBpp, + const char * const mapFileName, + FILE * const ofP) { /* PGM and PPM. We read the input image into a PPM array, scan it to analyze the colors, and convert it to a BMP raster. Logic @@ -889,11 +917,11 @@ doPgmPpm(FILE * const ifP, */ unsigned int minimumBpp; unsigned int bitsPerPixel; - enum colortype colortype; + Colortype colortype; unsigned int row; pixel ** pixels; - colorMap colorMap; + ColorMap colorMap; pixels = ppm_allocarray(cols, rows); @@ -952,3 +980,6 @@ main(int argc, return 0; } + + + diff --git a/converter/ppm/ppmtoicr.c b/converter/ppm/ppmtoicr.c index 3c8be421..1720f790 100644 --- a/converter/ppm/ppmtoicr.c +++ b/converter/ppm/ppmtoicr.c @@ -53,35 +53,6 @@ makeIcrColormap(colorhist_vector const chv, static int -bppFromColorCt(unsigned int const colorCt) { - - unsigned int bpp; - - if (colorCt <= 2) - bpp = 1; - else if (colorCt <= 4) - bpp = 2; - else if (colorCt <= 8) - bpp = 3; - else if (colorCt <= 16) - bpp = 4; - else if (colorCt <= 32) - bpp = 5; - else if (colorCt <= 64) - bpp = 6; - else if (colorCt <= 128) - bpp = 7; - else if (colorCt <= 256) - bpp = 8; - else - assert(false); - - return bpp; -} - - - -static int colorIndexAtPosition(unsigned int const x, unsigned int const y, pixel ** const pixels, @@ -166,7 +137,6 @@ main(int argc, const char ** const argv) { int rows, cols; int colorCt; int argn; - unsigned int bitsPerPixel; pixval maxval; colorhist_vector chv; char rgb[CLUTCOLORCT]; @@ -235,8 +205,6 @@ main(int argc, const char ** const argv) { makeIcrColormap(chv, colorCt, maxval, rgb); - bitsPerPixel = bppFromColorCt(colorCt); - /* And make a hash table for fast lookup. */ cht = ppm_colorhisttocolorhash(chv, colorCt); diff --git a/converter/ppm/ppmtompeg/frame.c b/converter/ppm/ppmtompeg/frame.c index 75b209f8..f91f2cc6 100644 --- a/converter/ppm/ppmtompeg/frame.c +++ b/converter/ppm/ppmtompeg/frame.c @@ -82,8 +82,10 @@ Resize_Array_Width(uint8 ** const inarray, int out_total; uint8 *inptr; uint8 *outptr; +#ifdef DOING_INTERPOLATION uint8 pointA,pointB; - /* double slope,diff; */ + double slope,diff; +#endif for (i = 0; i < in_y; ++i) { /* For each row */ unsigned int j; @@ -105,11 +107,15 @@ Resize_Array_Width(uint8 ** const inarray, --inptr; } } else { +#ifdef DOING_INTERPOLATION pointA = *inptr; +#endif ++inptr; +#ifdef DOING_INTERPOLATION pointB = *inptr; +#endif --inptr; -#if 0 +#ifdef DOING_INTERPOLATION /*Interpolative solution */ slope = ((double)(pointB -pointA))/((double)(out_x)); diff = (((double)(out_total - in_total))); @@ -159,8 +165,10 @@ Resize_Array_Height(uint8 ** const inarray, for(i=0; i < in_x; ++i){ /* for each column */ int in_total; int out_total; +#ifdef DOING_INTERPOLATION uint8 pointA, pointB; double slope, diff; +#endif unsigned int j; int k; @@ -180,15 +188,17 @@ Resize_Array_Height(uint8 ** const inarray, --k; } } else { +#ifdef DOING_INTERPOLATION pointA = inarray[k][i]; - if (k != (in_y -1)) { + if (k != (in_y - 1)) { pointB = inarray[k+1][i]; } else pointB = pointA; /* Interpolative case */ slope = ((double)(pointB -pointA))/(double)(out_y); diff = (double)(out_total - in_total); - /* outarray[j][i] = (inarray[k][i] + (uint8)(slope*diff)); */ + outarray[j][i] = (inarray[k][i] + (uint8)(slope*diff)); +#endif /* Non-Interpolative case */ outarray[j][i] = inarray[k][i]; out_total = out_total + in_y; diff --git a/converter/ppm/ppmtompeg/frametype.c b/converter/ppm/ppmtompeg/frametype.c index b7daacc9..09afa403 100644 --- a/converter/ppm/ppmtompeg/frametype.c +++ b/converter/ppm/ppmtompeg/frametype.c @@ -264,7 +264,7 @@ ComputeFrameTable(unsigned int const numFramesArg) { 'numFrames' == 0 means number of frames is not known at this time. -----------------------------------------------------------------------------*/ int index; - FrameTable *lastI, *lastIP, *firstB, *secondIP; + FrameTable *lastIP, *firstB, *secondIP; FrameTable *ptr; char typ; int table_size; @@ -278,7 +278,6 @@ ComputeFrameTable(unsigned int const numFramesArg) { MALLOCARRAY_NOFAIL(frameTable, 1 + table_size); - lastI = NULL; lastIP = NULL; firstB = NULL; secondIP = NULL; diff --git a/converter/ppm/ppmtompeg/parallel.c b/converter/ppm/ppmtompeg/parallel.c index 2835c67c..e3bcec1a 100644 --- a/converter/ppm/ppmtompeg/parallel.c +++ b/converter/ppm/ppmtompeg/parallel.c @@ -2149,7 +2149,6 @@ DecodeServer(int const numInputFiles, int otherSock; int decodePortNum; int frameReady; - boolean *ready; int *waitMachine; int *waitPort; int *waitList; @@ -2162,7 +2161,6 @@ DecodeServer(int const numInputFiles, /* should keep list of port numbers to notify when frames become ready */ - ready = (boolean *) calloc(numInputFiles, sizeof(boolean)); waitMachine = (int *) calloc(numInputFiles, sizeof(int)); waitPort = (int *) malloc(numMachines*sizeof(int)); waitList = (int *) calloc(numMachines, sizeof(int)); diff --git a/converter/ppm/ppmtompeg/ppmtompeg.c b/converter/ppm/ppmtompeg/ppmtompeg.c index cd94db39..46224e84 100644 --- a/converter/ppm/ppmtompeg/ppmtompeg.c +++ b/converter/ppm/ppmtompeg/ppmtompeg.c @@ -190,16 +190,17 @@ parseArgs(int const argc, ++idx; } else if (streq(argv[idx], "-child")) { if (idx+7 < argc-1) { - int combinePortNumber; - /* This used to be important information, when the child - notified the combine server. Now the master notifies - the combine server after the child notifies the master - it is done. So this value is unused. - */ cmdlineP->masterHostname = argv[idx+1]; cmdlineP->masterPortNumber = atoi(argv[idx+2]); ioPortNumber = atoi(argv[idx+3]); - combinePortNumber = atoi(argv[idx+4]); + /* + combinePortNumber = atoi(argv[idx+4]); + + This used to be important information, when the child + notified the combine server. Now the master notifies + the combine server after the child notifies the master + it is done. So this value is unused. + */ decodePortNumber = atoi(argv[idx+5]); machineNumber = atoi(argv[idx+6]); remoteIO = atoi(argv[idx+7]); diff --git a/converter/ppm/ppmtompeg/rate.c b/converter/ppm/ppmtompeg/rate.c index c775e055..6ec330cf 100644 --- a/converter/ppm/ppmtompeg/rate.c +++ b/converter/ppm/ppmtompeg/rate.c @@ -389,7 +389,6 @@ targetRateControl(MpegFrame * const frame) { float tempX, tempY, tempZ; int result; int frameType; - const char *strPtr; minimumBits = (bit_rate / (8 * frameRateRounded)); @@ -445,14 +444,18 @@ targetRateControl(MpegFrame * const frame) { Qscale = (mquant > 31 ? 31 : mquant); Qscale = (Qscale < 1 ? 1 : Qscale); - /* Print headers for Frame info */ - strPtr = Frame_header1; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_header2; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_header3; - DBG_PRINT(("%s\n",strPtr)); - +#ifdef HEINOUS_DEBUG_MODE + { + const char * strPtr; + /* Print headers for Frame info */ + strPtr = Frame_header1; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_header2; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_header3; + DBG_PRINT(("%s\n",strPtr)); + } +#endif /* Print Frame info */ sprintf(rc_buffer, "%4d %1c %4d %6d %7d " "%2d %2d %2d %2.2f %6d %4d %3d", @@ -467,10 +470,13 @@ targetRateControl(MpegFrame * const frame) { /* Print headers for Macroblock info */ if (RC_MB_SAMPLE_RATE) { +#ifdef HEINOUS_DEBUG_MODE + const char * strPtr; strPtr = MB_header1; DBG_PRINT(("%s\n",strPtr)); strPtr = MB_header2; DBG_PRINT(("%s\n",strPtr)); +#endif } } @@ -519,7 +525,6 @@ void updateRateControl(int const type) { int totalBits, frameComplexity, pctAllocUsed, pctGOPUsed; float avgQuant; - const char *strPtr; totalBits = rc_totalFrameBits; avgQuant = ((float) rc_totalQuant / (float) rc_numBlocks); @@ -559,15 +564,18 @@ updateRateControl(int const type) { break; } - - /* Print Frame info */ - strPtr = Frame_trailer1; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_trailer2; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_trailer3; - DBG_PRINT(("%s\n",strPtr)); - +#ifdef HEINOUS_DEBUG_MODE + { + /* Print Frame info */ + const char * strPtr; + strPtr = Frame_trailer1; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_trailer2; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_trailer3; + DBG_PRINT(("%s\n",strPtr)); + } +#endif sprintf(rc_buffer, "%6d %2.2f %6d %3d %2.2f %7d " "%3d %7d %3d %6d %6d", totalBits, avgQuant, frameComplexity, avg_act, N_act, diff --git a/converter/ppm/ppmtompeg/specifics.c b/converter/ppm/ppmtompeg/specifics.c index fb5e3649..1a1fda44 100644 --- a/converter/ppm/ppmtompeg/specifics.c +++ b/converter/ppm/ppmtompeg/specifics.c @@ -36,6 +36,7 @@ * HEADER FILES * *==============*/ +#include "netpbm/mallocvar.h" #include "all.h" #include "mtypes.h" #include "frames.h" @@ -239,7 +240,6 @@ FILE *fp; FrameSpecList *current, *new; char typ; int fnum,snum, bnum, qs, newqs; - int num_scanned; fsl = MakeFslEntry(); current = fsl; @@ -274,7 +274,7 @@ FILE *fp; break; case 'B': lp += 6; - num_scanned = sscanf(lp, "%d %d", &bnum, &newqs); + sscanf(lp, "%d %d", &bnum, &newqs); if (qs == newqs) break; qs = newqs; AddBs(current, bnum, FALSE, qs); @@ -289,116 +289,140 @@ FILE *fp; } -/* Version 2 */ -void Parse_Specifics_File_v2(fp) -FILE *fp; -{ - char line[1024], *lp; - FrameSpecList *current, *new; - char typ; - int fnum, snum, bnum, qs, newqs; - int num_scanned, fx=0, fy=0, sx=0, sy=0; - char kind[100]; - Block_Specifics *new_blk; - boolean relative; - fsl = MakeFslEntry(); - current = fsl; - while ((fgets(line,1023,fp))!=NULL) { - lp = &line[0]; - while ((*lp == ' ') || (*lp == '\t')) lp++; - if (( *lp == '#' ) || (*lp=='\n')) { - continue; +void +Parse_Specifics_File_v2(FILE * const fP) { +/*---------------------------------------------------------------------------- + Parse Version 2 specific file. +-----------------------------------------------------------------------------*/ + char line[1024]; + FrameSpecList * current; + int qs; + int numScanned; + int fx, fy, sx, sy; + char kind[100]; + Block_Specifics *new_blk; + boolean relative; + + fx = fy = sx = sy = 0; /* initial value */ + + fsl = MakeFslEntry(); + current = fsl; + + while ((fgets(line,1023, fP))!=NULL) { + const char * lp; + + lp = &line[0]; /* initial value */ + + while ((*lp == ' ') || (*lp == '\t')) + ++lp; + if (*lp == '#' || *lp == '\n') { + /* comment or blank line */ + } else { + switch (my_upper(*lp)) { + case 'F': { + char typ; + FrameSpecList * new; + int fnum; + + lp += 6; + sscanf(lp,"%d %c %d", &fnum, &typ, &qs); + new = MakeFslEntry(); + if (current->framenum != -1) { + current->next = new; + current = new; + } + current->framenum = fnum; + current->frametype = CvtType(typ); + if (qs <= 0) + qs = -1; + current->qscale = qs; + } break; + case 'S': { + int snum; + int newqs; + lp += 6; + sscanf(lp,"%d %d", &snum, &newqs); + if (qs == newqs) + break; + qs = newqs; + AddSlc(current, snum, qs); + } break; + case 'B': { + int bnum; + int newqs; + lp += 6; + numScanned = 0; + bnum = atoi(lp); + SkipToSpace(lp); + while ((*lp != '-') && (*lp != '+') && + ((*lp < '0') || (*lp > '9'))) + ++lp; + relative = (*lp == '-' || *lp == '+'); + newqs = atoi(lp); + SkipToSpace(lp); + if (EndString(lp)) { + numScanned = 2; + } else { + numScanned = + 2 + sscanf(lp, "%s %d %d %d %d", + kind, &fx, &fy, &sx, &sy); + } + + qs = newqs; + new_blk = AddBs(current, bnum, relative, qs); + if (numScanned > 2) { + BlockMV * tmp; + + MALLOCVAR(tmp); + + switch (numScanned) { + case 7: + tmp->typ = TYP_BOTH; + tmp->fx = fx; + tmp->fy = fy; + tmp->bx = sx; + tmp->by = sy; + new_blk->mv = tmp; + break; + case 3: + tmp->typ = TYP_SKIP; + new_blk->mv = tmp; + break; + case 5: + if (my_upper(kind[0]) == 'B') { + tmp->typ = TYP_BACK; + tmp->bx = fx; + tmp->by = fy; + } else { + tmp->typ = TYP_FORW; + tmp->fx = fx; + tmp->fy = fy; + } + new_blk->mv = tmp; + break; + default: + fprintf(stderr, + "Bug in specifics file! " + "Skipping short/long entry: %s\n",line); + break; + } + } else + new_blk->mv = NULL; + + } break; + case 'V': + fprintf(stderr, + "Cannot specify version twice! Taking first (%d).\n", + version); + break; + default: + printf("What? *%s*\n",line); + break; + } + } } - - switch (my_upper(*lp)) { - case 'F': - lp += 6; - sscanf(lp,"%d %c %d", &fnum, &typ, &qs); - new = MakeFslEntry(); - if (current->framenum != -1) { - current->next = new; - current = new; - } - current->framenum = fnum; - current->frametype = CvtType(typ); - if (qs <= 0) qs = -1; - current->qscale = qs; - break; - case 'S': - lp += 6; - sscanf(lp,"%d %d", &snum, &newqs); - if (qs == newqs) break; - qs = newqs; - AddSlc(current, snum, qs); - break; - case 'B': - lp += 6; - num_scanned = 0; - bnum = atoi(lp); - SkipToSpace(lp); - while ((*lp != '-') && (*lp != '+') && - ((*lp < '0') || (*lp > '9'))) lp++; - relative = ((*lp == '-') || (*lp == '+')); - newqs = atoi(lp); - SkipToSpace(lp); - if (EndString(lp)) { - num_scanned = 2; - } else { - num_scanned = 2+sscanf(lp, "%s %d %d %d %d", kind, &fx, &fy, &sx, &sy); - } - - qs = newqs; - new_blk = AddBs(current, bnum, relative, qs); - if (num_scanned > 2) { - BlockMV *tmp; - tmp = (BlockMV *) malloc(sizeof(BlockMV)); - switch (num_scanned) { - case 7: - tmp->typ = TYP_BOTH; - tmp->fx = fx; - tmp->fy = fy; - tmp->bx = sx; - tmp->by = sy; - new_blk->mv = tmp; - break; - case 3: - tmp->typ = TYP_SKIP; - new_blk->mv = tmp; - break; - case 5: - if (my_upper(kind[0]) == 'B') { - tmp->typ = TYP_BACK; - tmp->bx = fx; - tmp->by = fy; - } else { - tmp->typ = TYP_FORW; - tmp->fx = fx; - tmp->fy = fy; - } - new_blk->mv = tmp; - break; - default: - fprintf(stderr, - "Bug in specifics file! Skipping short/long entry: %s\n",line); - break; - } - } else { - new_blk->mv = (BlockMV *) NULL; - } - - break; - case 'V': - fprintf(stderr, - "Cannot specify version twice! Taking first (%d).\n", - version); - break; - default: - printf("What? *%s*\n",line); - break; - }} - } diff --git a/converter/ppm/yuvtoppm.c b/converter/ppm/yuvtoppm.c index 151ff9f9..9c5d79c4 100644 --- a/converter/ppm/yuvtoppm.c +++ b/converter/ppm/yuvtoppm.c @@ -45,6 +45,7 @@ parseCommandLine(int argc, const char ** argv, optEntry * option_def; /* Instructions to OptParseOptions3 on how to parse our options */ optStruct3 opt; + unsigned int option_def_index; MALLOCARRAY_NOFAIL(option_def, 100); diff --git a/doc/HISTORY b/doc/HISTORY index 5eca3563..6d43d7cb 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,48 +4,83 @@ Netpbm. CHANGE HISTORY -------------- -16.06.25 BJH Release 10.74.05 +16.06.26 BJH Release 10.75.00 - pamarith: fix incorrect output when maxvals differ, for - -add, -multiply, -mean, -min, -max. Broken in Neptbm 10.41 - (December 2007). + pbmtextps: Add -leftmargin, -rightmargin, -topmargin, + -bottommargin, -ascent, -descent, -pad, -crop. -16.06.12 BJH Release 10.74.04 + pbmtextps: Add -dump-ps. pbmtextps: Abort with error instead of generating single space when user supplies no text. + pbmtextps: Accept fractional -fontsize. + + pbmtextps: Change margins for non-default fonts. + + pbmtextps: Minor output changes caused by code cleanup. + + bmptopnm: Add ability to convert Version 4 and 5 Windows BMP. + + pbmtext: remove undocumented -dump option; add 'genfontc' + development tool (buildtools/ directory) to replace it. + + pbmtext: Add -dry-run + + pbmtext: Add -dump-sheet + + pbmtext: Speedup: renders directly in raw PBM. + + pbmreduce: add -randomseed. + + anytopnm, pnmmargin, pnmquant, ppmquant, pnmquantall, pgmcrater, + ppmfade, ppmrainbow, ppmshadow, pbmtox10bm, pamstretch-gen: + Add -version. + + fiascotopnm: change -version to include Netpbm version. + + libnetpbm: Add pm_system2(), pm_system2_lp(), pm_system2_vp() - + same as pm_system(), etc. but returns the termination status. + + pamarith: fix incorrect output when maxvals differ, for + -add, -multiply, -mean, -min, -max. Broken in Netpbm 10.41 + (December 2007). + pbmtextps: Fix bug: input text or font name with Postscript control characters messes up the Postscript program. -16.05.09 BJH Release 10.74.03 - - bmptopnm: fail properly with Version 4, 5 Windows BMP. + hpcdtoppm dummy version: update web link to real version. ppmhist: fix incorrect color names. Introduced in Netpbm 10.19 (November 2003). + ppmshadow: fix bug: don't ignore invalid option. Introduced in + Netpbm 10.9 (September 2002). + pnmpaste: fix possible invalid memory access. Introduced in Netpbm 1.44 (September 2008). pbmreduce: fix undefined behavior when scale factor argument is too big. Always present (pbmreduce was new in September 1989). + pbmtext: Fix bug: invalid memory reference when text contains + code points > 127. Broken in 10.74. + + pnmtofiasco, fiascotopnm: Fix incorrect math on systems with + unusual floating point representation. Always broken (programs + were new in Netpbm 9.6 (July 2000). + cameratopam: fix invalid memory reference; effect unknown. Introduced in Netpbm 10.68 (September 2014). Install on Windows: fix backward compatibility symlinks for pnmtoplainpnm, pnmquantall. -16.04.13 BJH Release 10.74.02 - - pbmtext: Fix bug: invalid memory reference when text contains - code points > 127. Broken in 10.74.00 - -16.03.31 BJH Release 10.74.01 - Build: Remove use of strndup so it compiles on Mac OS X 10.6. - Broken in 10.74.00. + Broken in 10.74. + + Build: Remove use of isfinite so it compiles with C89 standard + compiler. 16.03.27 BJH Release 10.74.00 @@ -53,12 +88,12 @@ CHANGE HISTORY explicitly set to the width you get when you don't specify width. - pbmtext: ignore -nomargins with -width is specified. + pbmtext: ignore -nomargins when -width is specified. pbmtext: report when line ends are dropped because of truncation. - pbmtext: Fix bug: if input has an code point that is not in the + pbmtext: Fix bug: if input has a code point that is not in the font, Pbmtext substitutes space, but behavior is undefined if font doesn't have space either. Now it aborts the program in that case. @@ -972,7 +1007,7 @@ CHANGE HISTORY pngtopam: fix crash with invalid tIME chunk. Always broken. - pamarith: fix wrong result with -multiply. Broken in Neptbm + pamarith: fix wrong result with -multiply. Broken in Netpbm 10.41. pamscale: fix all black output with resampling. Always broken. @@ -1017,7 +1052,7 @@ CHANGE HISTORY "from bottom edge." ppmcie: fix bug: fails with "X coordinate out of range" error. - Introduced in Neptbm 10.51. + Introduced in Netpbm 10.51. bmptopnm: Fail properly with BMP that indicates an illegal bits per pixel. diff --git a/editor/pamrubber.c b/editor/pamrubber.c index 4378c340..e7abd789 100644 --- a/editor/pamrubber.c +++ b/editor/pamrubber.c @@ -1405,7 +1405,7 @@ main(int argc, const char ** const argv) { setGlobalCP(cmdline); - srand(cmdline.randseedSpec ? cmdline.randseed : time(NULL)); + srand(cmdline.randseedSpec ? cmdline.randseed : pm_randseed()); ifP = pm_openr(cmdline.fileName); diff --git a/editor/pamstretch-gen b/editor/pamstretch-gen index ba0e8188..dac3da7f 100755 --- a/editor/pamstretch-gen +++ b/editor/pamstretch-gen @@ -25,15 +25,17 @@ # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # +if [ "$1" = "--version" -o "$1" = "-version" ]; then + pamstretch --version; exit $?; +fi if [ "$1" = "" ]; then echo 'usage: pamstretch-gen N [pnmfile]' exit 1 fi -tempdir="${TMPDIR-/tmp}/pamstretch-gen.$$" -mkdir -m 0700 $tempdir || \ - { echo "Could not create temporary file. Exiting."; exit 1;} +tempdir=$(mktemp -d "${TMPDIR:-/tmp}/netpbm.XXXXXXXX") || + ( echo "Could not create temporary file. Exiting." 1>&2; exit 1; ) trap 'rm -rf $tempdir' 0 1 3 15 tempfile=$tempdir/pnmig diff --git a/editor/pamundice.c b/editor/pamundice.c index 9a80e46d..dbe0a8df 100644 --- a/editor/pamundice.c +++ b/editor/pamundice.c @@ -271,12 +271,11 @@ computeInputFileName(const char * const pattern, const char ** const fileNameP) { struct buffer buffer; - unsigned int inCursor, outCursor; + unsigned int inCursor; buffer_init(&buffer); inCursor = 0; - outCursor = 0; while (pattern[inCursor] != '\0') { if (pattern[inCursor] == '%') { diff --git a/editor/pbmreduce.c b/editor/pbmreduce.c index ee4a4fbd..3a0968fe 100644 --- a/editor/pbmreduce.c +++ b/editor/pbmreduce.c @@ -10,203 +10,345 @@ ** implied warranty. */ -#include <limits.h> +#include "pm_c_util.h" #include "pbm.h" #include "mallocvar.h" +#include "shhopt.h" +#include <assert.h> -int -main( argc, argv ) - int argc; - char* argv[]; - { - FILE* ifp; - register bit** bitslice; - register bit* newbitrow; - register bit* nbP; - int argn, n, rows, cols, format, newrows, newcols; - int row, col, limitcol, subrow, subcol, count, direction; - const char* const usage = "[-floyd|-fs | -threshold] [-value <val>] N [pbmfile]"; - int halftone; -#define QT_FS 1 -#define QT_THRESH 2 #define SCALE 1024 #define HALFSCALE 512 - long threshval, sum; - long* thiserr; /* used for Floyd-Steinberg stuff */ - long* nexterr; /* used for Floyd-Steinberg stuff */ - long* temperr; - - - pbm_init( &argc, argv ); - - argn = 1; - halftone = QT_FS; - threshval = HALFSCALE; - - while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) - { - if ( pm_keymatch( argv[argn], "-fs", 2 ) || - pm_keymatch( argv[argn], "-floyd", 2 ) ) - halftone = QT_FS; - else if ( pm_keymatch( argv[argn], "-threshold", 2 ) ) - halftone = QT_THRESH; - else if ( pm_keymatch( argv[argn], "-value", 2 ) ) - { - float f; - - ++argn; - if ( argn == argc || sscanf( argv[argn], "%f", &f ) != 1 || - f < 0.0 || f > 1.0 ) - pm_usage( usage ); - threshval = f * SCALE; - } - else - pm_usage( usage ); - ++argn; - } - - if ( argn == argc ) - pm_usage( usage ); - if ( sscanf( argv[argn], "%d", &n ) != 1 ) - pm_usage( usage ); - if ( n < 2 ) - pm_error( "N must be greater than 1" ); - if (n > INT_MAX / n) - pm_error("Scale argument too large. You specified %d", n); - ++argn; - - if ( argn == argc ) - ifp = stdin; - else - { - ifp = pm_openr( argv[argn] ); - ++argn; - } - - if ( argn != argc ) - pm_usage( usage ); - - pbm_readpbminit( ifp, &cols, &rows, &format ); - bitslice = pbm_allocarray( cols, n ); - - newrows = rows / n; - newcols = cols / n; + + +enum Halftone {QT_FS, QT_THRESH}; + +struct CmdlineInfo { + /* All the information the user supplied in the command line, + in a form easy for the program to use. + */ + const char * inputFilespec; + enum Halftone halftone; + int value; + unsigned int randomseed; + unsigned int randomseedSpec; + int scale; +}; + + + +static void +parseCommandLine(int argc, const char ** argv, + struct CmdlineInfo *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 pm_optParseOptions3 on how to parse our options. + */ + optStruct3 opt; + + unsigned int option_def_index; + unsigned int floydOpt, thresholdOpt; + unsigned int valueSpec; + float value; + + MALLOCARRAY_NOFAIL(option_def, 100); + + option_def_index = 0; /* incremented by OPTENTRY */ + OPTENT3(0, "floyd", OPT_FLAG, NULL, + &floydOpt, 0); + OPTENT3(0, "fs", OPT_FLAG, NULL, + &floydOpt, 0); + OPTENT3(0, "threshold", OPT_FLAG, NULL, + &thresholdOpt, 0); + OPTENT3(0, "value", OPT_FLOAT, &value, + &valueSpec, 0); + OPTENT3(0, "randomseed", OPT_UINT, &cmdlineP->randomseed, + &cmdlineP->randomseedSpec, 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 (floydOpt + thresholdOpt == 0) + cmdlineP->halftone = QT_FS; + else if (!!floydOpt + !!thresholdOpt > 1) + pm_error("Cannot specify both floyd and threshold"); + else { + if (floydOpt) + cmdlineP->halftone = QT_FS; + else { + cmdlineP->halftone = QT_THRESH; + if (cmdlineP->randomseedSpec) + pm_message("-randomseed value has no effect with -threshold"); + } + } + + if (!valueSpec) + cmdlineP->value = HALFSCALE; + else { + if (value < 0.0) + pm_error("-value cannot be negative. You specified %f", value); + if (value > 1.0) + pm_error("-value cannot be greater than one. You specified %f", + value); + else + cmdlineP->value = value * SCALE; + } + + if (argc-1 > 0) { + char * endptr; /* ptr to 1st invalid character in scale arg */ + unsigned int scale; + + scale = strtol(argv[1], &endptr, 10); + if (*argv[1] == '\0') + pm_error("Scale argument is a null string. Must be a number."); + else if (*endptr != '\0') + pm_error("Scale argument contains non-numeric character '%c'.", + *endptr); + else if (scale < 2) + pm_error("Scale argument must be at least 2. " + "You specified %d", scale); + else if (scale > INT_MAX / scale) + pm_error("Scale argument too large. You specified %d", scale); + else + cmdlineP->scale = scale; + + if (argc-1 > 1) { + cmdlineP->inputFilespec = argv[2]; + + if (argc-1 > 2) + pm_error("Too many arguments (%d). There are at most two " + "non-option arguments: " + "scale factor and the file name", + argc-1); + } else + cmdlineP->inputFilespec = "-"; + } else + pm_error("You must specify the scale factor as an argument"); + + free(option_def); +} + + + +struct FS { + int * thiserr; + int * nexterr; +}; + + +static void +initializeFloydSteinberg(struct FS * const fsP, + int const newcols, + unsigned int const seed, + bool const seedSpec) { + + unsigned int col; + + MALLOCARRAY(fsP->thiserr, newcols + 2); + MALLOCARRAY(fsP->nexterr, newcols + 2); + + if (fsP->thiserr == NULL || fsP->nexterr == NULL) + pm_error("out of memory"); + + srand(seedSpec ? seed : pm_randseed()); + + for (col = 0; col < newcols + 2; ++col) + fsP->thiserr[col] = (rand() % SCALE - HALFSCALE) / 4; + /* (random errors in [-SCALE/8 .. SCALE/8]) */ +} + + + +/* + Scanning method + + In Floyd-Steinberg dithering mode horizontal direction of scan alternates + between rows; this is called "serpentine scanning". + + Example input (14 x 7), N=3: + + 111222333444xx Fractional pixels on the right edge and bottom edge (x) + 111222333444xx are ignored; their values do not influence output. + 111222333444xx + 888777666555xx + 888777666555xx + 888777666555xx + xxxxxxxxxxxxxx + + Output (4 x 2): + + 1234 + 8765 + +*/ + + + +enum Direction { RIGHT_TO_LEFT, LEFT_TO_RIGHT }; + + +static enum Direction +oppositeDir(enum Direction const arg) { + + switch (arg) { + case LEFT_TO_RIGHT: return RIGHT_TO_LEFT; + case RIGHT_TO_LEFT: return LEFT_TO_RIGHT; + } + assert(false); /* All cases handled above */ +} + + + +int +main(int argc, const char * argv[]) { + + FILE * ifP; + struct CmdlineInfo cmdline; + bit ** bitslice; + bit * newbitrow; + int rows, cols; + int format; + unsigned int newrows, newcols; + unsigned int row; + enum Direction direction; + struct FS fs; + + pm_proginit(&argc, argv); + + parseCommandLine(argc, argv, &cmdline); + + ifP = pm_openr(cmdline.inputFilespec); + + pbm_readpbminit(ifP, &cols, &rows, &format); + + bitslice = pbm_allocarray(cols, cmdline.scale); + + if (rows < cmdline.scale || cols < cmdline.scale) + pm_error("Scale argument (%u) too large for image", cmdline.scale); + else { + newrows = rows / cmdline.scale; + newcols = cols / cmdline.scale; + } pbm_writepbminit( stdout, newcols, newrows, 0 ); - newbitrow = pbm_allocrow( newcols ); + newbitrow = pbm_allocrow_packed( newcols ); - if (halftone == QT_FS) { - unsigned int col; - /* Initialize Floyd-Steinberg. */ - MALLOCARRAY(thiserr, newcols + 2); - MALLOCARRAY(nexterr, newcols + 2); - if (thiserr == NULL || nexterr == NULL) - pm_error("out of memory"); - - srand(pm_randseed()); - for (col = 0; col < newcols + 2; ++col) - thiserr[col] = (rand() % SCALE - HALFSCALE) / 4; - /* (random errors in [-SCALE/8 .. SCALE/8]) */ - } else { + if (cmdline.halftone == QT_FS) + initializeFloydSteinberg(&fs, newcols, + cmdline.randomseed, cmdline.randomseedSpec); + else { /* These variables are meaningless in this case, and the values should never be used. */ - thiserr = NULL; - nexterr = NULL; + fs.thiserr = NULL; + fs.nexterr = NULL; } - direction = 1; - - for ( row = 0; row < newrows; ++row ) - { - for ( subrow = 0; subrow < n; ++subrow ) - pbm_readpbmrow( ifp, bitslice[subrow], cols, format ); - - if ( halftone == QT_FS ) - for ( col = 0; col < newcols + 2; ++col ) - nexterr[col] = 0; - if ( direction ) - { - col = 0; - limitcol = newcols; - nbP = newbitrow; - } - else - { - col = newcols - 1; - limitcol = -1; - nbP = &(newbitrow[col]); - } - - do - { - sum = 0; - count = 0; - for ( subrow = 0; subrow < n; ++subrow ) - for ( subcol = 0; subcol < n; ++subcol ) - if ( row * n + subrow < rows && col * n + subcol < cols ) - { - count += 1; - if ( bitslice[subrow][col * n + subcol] == PBM_WHITE ) - sum += 1; - } - sum = ( sum * SCALE ) / count; - - if ( halftone == QT_FS ) - sum += thiserr[col + 1]; - - if ( sum >= threshval ) - { - *nbP = PBM_WHITE; - if ( halftone == QT_FS ) - sum = sum - threshval - HALFSCALE; - } - else - *nbP = PBM_BLACK; - - if ( halftone == QT_FS ) - { - if ( direction ) - { - thiserr[col + 2] += ( sum * 7 ) / 16; - nexterr[col ] += ( sum * 3 ) / 16; - nexterr[col + 1] += ( sum * 5 ) / 16; - nexterr[col + 2] += ( sum ) / 16; - } - else - { - thiserr[col ] += ( sum * 7 ) / 16; - nexterr[col + 2] += ( sum * 3 ) / 16; - nexterr[col + 1] += ( sum * 5 ) / 16; - nexterr[col ] += ( sum ) / 16; - } - } - if ( direction ) - { - ++col; - ++nbP; - } - else - { - --col; - --nbP; - } - } - while ( col != limitcol ); - - pbm_writepbmrow( stdout, newbitrow, newcols, 0 ); - - if ( halftone == QT_FS ) - { - temperr = thiserr; - thiserr = nexterr; - nexterr = temperr; - direction = ! direction; - } - } - - pm_close( ifp ); - pm_close( stdout ); - - exit( 0 ); + + for (row = 0, direction = LEFT_TO_RIGHT; row < newrows; ++row) { + unsigned int const colChars = pbm_packed_bytes(newcols); + + unsigned int colChar; + unsigned int subrow; + unsigned int col; + int limitCol; + int startCol; + int step; + + for (colChar = 0; colChar < colChars; ++colChar) + newbitrow[colChar] = 0x00; /* Clear to white */ + + for (subrow = 0; subrow < cmdline.scale; ++subrow) + pbm_readpbmrow(ifP, bitslice[subrow], cols, format); + + if (cmdline.halftone == QT_FS) { + unsigned int col; + for (col = 0; col < newcols + 2; ++col) + fs.nexterr[col] = 0; + } + switch (direction) { + case LEFT_TO_RIGHT: { + startCol = 0; + limitCol = newcols; + step = +1; + } break; + case RIGHT_TO_LEFT: { + startCol = newcols - 1; + limitCol = -1; + step = -1; + } break; + } + + for (col = startCol; col != limitCol; col += step) { + int const n = cmdline.scale; + unsigned int sum; + int sumScaled; + unsigned int subrow; + + for (subrow = 0, sum = 0; subrow < n; ++subrow) { + unsigned int subcol; + for (subcol = 0; subcol < n; ++subcol) { + assert(row * n + subrow < rows); + assert(col * n + subcol < cols); + if (bitslice[subrow][col * n + subcol] == PBM_WHITE) + ++sum; + } + } + + sumScaled = (sum * SCALE) / (SQR(n)); + + if (cmdline.halftone == QT_FS) + sumScaled += fs.thiserr[col + 1]; + + if (sumScaled >= cmdline.value) { + if (cmdline.halftone == QT_FS) + sumScaled = sumScaled - cmdline.value - HALFSCALE; + } else + newbitrow[col/8] |= (PBM_BLACK << (7 - col%8)); + + if (cmdline.halftone == QT_FS) { + switch (direction) { + case LEFT_TO_RIGHT: { + fs.thiserr[col + 2] += ( sumScaled * 7 ) / 16; + fs.nexterr[col ] += ( sumScaled * 3 ) / 16; + fs.nexterr[col + 1] += ( sumScaled * 5 ) / 16; + fs.nexterr[col + 2] += ( sumScaled ) / 16; + break; + } + case RIGHT_TO_LEFT: { + fs.thiserr[col ] += ( sumScaled * 7 ) / 16; + fs.nexterr[col + 2] += ( sumScaled * 3 ) / 16; + fs.nexterr[col + 1] += ( sumScaled * 5 ) / 16; + fs.nexterr[col ] += ( sumScaled ) / 16; + break; + } + } + } + } + + pbm_writepbmrow_packed(stdout, newbitrow, newcols, 0); + + if (cmdline.halftone == QT_FS) { + int * const temperr = fs.thiserr; + fs.thiserr = fs.nexterr; + fs.nexterr = temperr; + direction = oppositeDir(direction); + } } + free(fs.thiserr); + free(fs.nexterr); + + pbm_freerow(newbitrow); + pbm_freearray(bitslice, cmdline.scale); + pm_close(ifP); + pm_close(stdout); + + return 0; +} + diff --git a/editor/pgmmedian.c b/editor/pgmmedian.c index 9d90b6b3..4648af68 100644 --- a/editor/pgmmedian.c +++ b/editor/pgmmedian.c @@ -132,13 +132,12 @@ select489(gray * const a, gray t; int i, j, l, r; - int ptmp, ttmp; + int ptmp; l = 0; r = n - 1; while ( r > l ) { t = a[parray[k]]; - ttmp = parray[k]; i = l; j = r; ptmp = parray[l]; diff --git a/editor/pnmmargin b/editor/pnmmargin index 0f57d1d4..9dbe24b7 100755 --- a/editor/pnmmargin +++ b/editor/pnmmargin @@ -11,9 +11,8 @@ # documentation. This software is provided "as is" without express or # implied warranty. -tempdir="${TMPDIR-/tmp}/pnmmargin.$$" -mkdir -m 0700 $tempdir || \ - { echo "Could not create temporary file. Exiting." 1>&2; exit 1;} +tempdir=$(mktemp -d "${TMPDIR:-/tmp}/netpbm.XXXXXXXX") || + ( echo "Could not create temporary file. Exiting." 1>&2; exit 1; ) trap 'rm -rf $tempdir' 0 1 3 15 tmp1=$tempdir/pnmm1 @@ -27,6 +26,9 @@ plainopt="" # Parse args. while true ; do case "$1" in + -version|--version ) + pnmpad --version; exit $?; + ;; -p|-pl|-pla|-plai|-plain ) plainopt="-plain" shift diff --git a/editor/pnmquant b/editor/pnmquant index 93d452cd..35a75e96 100755 --- a/editor/pnmquant +++ b/editor/pnmquant @@ -42,6 +42,21 @@ my ($TRUE, $FALSE) = (1,0); my ($SEEK_SET, $SEEK_CUR, $SEEK_END) = (0, 1, 2); + + +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('pnmcolormap', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + + + sub tempFile($) { # We trust Perl's File::Temp to do a better job of creating the temp @@ -93,7 +108,7 @@ sub parseCommandLine(@) { scalar(@ARGV), "\n"); exit(1); } - if (@ARGV < 1) { + elsif (@ARGV < 1) { print(STDERR "You must specify the number of colors as an argument.\n"); exit(1); @@ -267,6 +282,8 @@ sub remap($$$$) { # MAIN PROGRAM ############################################################################## +doVersionHack(\@ARGV); + my $cmdlineR = parseCommandLine(@ARGV); openSeekableAsStdin($cmdlineR->{infile}); diff --git a/editor/pnmquantall b/editor/pnmquantall index 0890383e..844fc13d 100755 --- a/editor/pnmquantall +++ b/editor/pnmquantall @@ -61,6 +61,19 @@ my $TRUE=1; my $FALSE = 0; +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('pnmcolormap', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + + + sub parseArgs($$$$) { my ($argvR, $extR, $newColorCtR, $fileNamesR) = @_; @@ -179,6 +192,8 @@ sub remapFiles($$$$) { my $progError; +doVersionHack(\@ARGV); + parseArgs(\@ARGV, \my $ext, \my $newColorCt, \my @fileNames); my ($colorMapFh, $colorMapFileName) = tempFile("pnm"); diff --git a/editor/ppmfade b/editor/ppmfade index 027fc793..dcd7bf26 100755 --- a/editor/ppmfade +++ b/editor/ppmfade @@ -41,6 +41,19 @@ exec perl -w -x -S -- "$0" "$@" ############################################################################## use strict; +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('ppmmix', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + + + my $SPREAD = 1; my $SHIFT = 2; my $RELIEF = 3; @@ -59,6 +72,7 @@ my $base_name = "fade"; # default base name of output files my $image = "ppm"; # default output storage format my $mode = $SPREAD; # default fading mode +doVersionHack(\@ARGV); my $n; # argument number @@ -98,8 +112,6 @@ for ($n = 0; $n < @ARGV; $n++) { $mode = $BLOCK; } elsif ("$ARGV[$n]" eq "-mix") { $mode = $MIX; - } elsif ($ARGV[$n] eq "-help" || $ARGV[$n] eq "-h") { - usage(); } else { print "Unknown argument: $ARGV[$n]\n"; exit 100; diff --git a/editor/ppmquant b/editor/ppmquant index 57963982..fe8ca046 100755 --- a/editor/ppmquant +++ b/editor/ppmquant @@ -35,6 +35,19 @@ exec perl -w -x -S -- "$0" "$@" use strict; +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('pnmquant', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + +doVersionHack(\@ARGV); + use Getopt::Long; my @ppmquantArgv = @ARGV; diff --git a/editor/ppmshadow b/editor/ppmshadow index 62cdf8b8..39a23df9 100755 --- a/editor/ppmshadow +++ b/editor/ppmshadow @@ -48,6 +48,7 @@ exec perl -w -x -S -- "$0" "$@" ############################################################################## use strict; +use File::Temp; require 5.0; # The good open() syntax, with the mode separate from the file name, # came after 5.0. So did mkdir() with default mode. @@ -55,6 +56,20 @@ require 5.0; my $true=1; my $false=0; + +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('pamarith', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + + + sub getDimensions($) { my ($fileName) = @_; #----------------------------------------------------------------------------- @@ -95,15 +110,10 @@ sub makeConvolutionKernel($$) { # MAINLINE ############################################################################## - -my $tmpdir = $ENV{TMPDIR} || "/tmp"; -my $ourtmp = "$tmpdir/ppmshadow$$"; -mkdir($ourtmp, 0777) or - die("Unable to create directory for temporary files '$ourtmp"); +doVersionHack(\@ARGV); # Process command line options - my $ifile; # Input file name my ($xoffset, $yoffset); @@ -113,6 +123,7 @@ my $translucent = $false; # Default not translucent while (@ARGV) { my $arg = shift; + if ((substr($arg, 0, 1) eq '-') && (length($arg) > 1)) { my $opt; $opt = substr($arg, 1, 1); @@ -142,6 +153,8 @@ while (@ARGV) { if ($yoffset < 0) { $yoffset = -$xoffset; } + } else { + die("Unknown option '$opt'\n"); } } else { if (defined $ifile) { @@ -151,6 +164,19 @@ while (@ARGV) { } } +# Create temporary directory + +my $tmpdir = $ENV{TMPDIR} || "/tmp"; +my $ourtmp; + +if ($keeptemp) { + $ourtmp = "$tmpdir/ppmshadow$$"; + mkdir($ourtmp, 0777) or + die("Unable to create directory for temporary files '$ourtmp"); +} else { + $ourtmp = File::Temp::tempdir("$tmpdir/ppmshadowXXXX", UNLINK=>1); +} + # Apply defaults for arguments not specified if (!(defined $xoffset)) { diff --git a/editor/specialty/pampaintspill.c b/editor/specialty/pampaintspill.c index 745c9b68..eb1888f7 100644 --- a/editor/specialty/pampaintspill.c +++ b/editor/specialty/pampaintspill.c @@ -253,7 +253,7 @@ locatePaintSources(struct pam * const pamP, if (downsample > 0 && downsample < paintSources.size) { unsigned int i; - srand(time(NULL)); + srand(pm_randseed()); for (i = 0; i < downsample; ++i) { unsigned int const swapIdx = diff --git a/editor/specialty/pgmabel.c b/editor/specialty/pgmabel.c index 1764c5d7..1a6e481f 100644 --- a/editor/specialty/pgmabel.c +++ b/editor/specialty/pgmabel.c @@ -171,7 +171,6 @@ int main( argc, argv ) float pixsize=0.1; /* no verbose, calculating both sides */ int verb = FALSE, left = TRUE, right = TRUE; - int nologo = FALSE; const char* const usage = "[-help] [-axis N] [-factor N] [-pixsize N] [-left|-right] [-verbose] [pgmfile]"; pgm_init( &argc, argv ); @@ -213,10 +212,6 @@ int main( argc, argv ) if ( right ) left = FALSE; else pm_usage( usage ); } - else if ( pm_keymatch( argv[argn], "-nologo", 4 ) ) - { - nologo = TRUE; - } else pm_usage( usage ); ++ argn; diff --git a/editor/specialty/ppmntsc.c b/editor/specialty/ppmntsc.c index a721b891..b44c64aa 100644 --- a/editor/specialty/ppmntsc.c +++ b/editor/specialty/ppmntsc.c @@ -392,14 +392,11 @@ convertOneImage(FILE * const ifP, pixel * const inputRow = ppm_allocrow(cols); pixel * const outputRow = ppm_allocrow(cols); - pixel lastIllegalPixel; - /* Value of the illegal pixel we most recently processed */ pixel black; /* A constant - black pixel */ PPM_ASSIGN(black, 0, 0, 0); - PPM_ASSIGN(lastIllegalPixel, 0, 0, 0); /* initial value */ { unsigned int row; diff --git a/generator/Makefile b/generator/Makefile index d0ea6b60..5120008c 100644 --- a/generator/Makefile +++ b/generator/Makefile @@ -16,10 +16,13 @@ include $(BUILDDIR)/config.mk PORTBINARIES = pamcrater pamgauss pamgradient \ pamseq pamshadedrelief pamstereogram \ - pbmpage pbmmake pbmtext pbmtextps pbmupc \ + pbmpage pbmmake pbmtext pbmupc \ pgmkernel pgmmake pgmnoise pgmramp \ ppmcie ppmcolors ppmforge ppmmake ppmpat ppmrough ppmwheel \ +ifneq ($(DONT_HAVE_PROCESS_MGMT),Y) +PORTBINARIES += pbmtextps +endif # We don't include programs that have special library dependencies in the # merge scheme, because we don't want those dependencies to prevent us # from building all the other programs. diff --git a/generator/pbmtext.c b/generator/pbmtext.c index 8ae28616..cfb858a6 100644 --- a/generator/pbmtext.c +++ b/generator/pbmtext.c @@ -20,6 +20,7 @@ #include "pm_c_util.h" #include "mallocvar.h" +#include "nstring.h" #include "shhopt.h" #include "pbm.h" #include "pbmfont.h" @@ -33,13 +34,14 @@ struct CmdlineInfo { const char * text; /* text from command line or NULL if none */ const char * font; /* -font option value or NULL if none */ const char * builtin; /* -builtin option value or NULL if none */ - unsigned int dump; - /* undocumented dump option for installing a new built-in font */ - float space; /* -space option value or default */ - unsigned int width; /* -width option value or zero */ - int lspace; /* lspace option value or default */ - unsigned int nomargins; /* -nomargins */ - unsigned int verbose; + float space; /* -space option value or default */ + int lspace; /* -lspace option value or default */ + unsigned int width; /* -width option value or zero */ + unsigned int nomargins; /* -nomargins option specified */ + unsigned int dryrun; /* -dry-run option specified */ + unsigned int verbose; /* -verbose option specified */ + /* undocumented option */ + unsigned int dumpsheet; /* font data sheet in PBM format for -font */ }; @@ -61,21 +63,22 @@ parseCommandLine(int argc, const char ** argv, MALLOCARRAY_NOFAIL(option_def, 100); option_def_index = 0; /* incremented by OPTENTRY */ - OPTENT3(0, "font", OPT_STRING, &cmdlineP->font, NULL, 0); - OPTENT3(0, "builtin", OPT_STRING, &cmdlineP->builtin, NULL, 0); - OPTENT3(0, "dump", OPT_FLAG, NULL, &cmdlineP->dump, 0); - OPTENT3(0, "space", OPT_FLOAT, &cmdlineP->space, NULL, 0); - OPTENT3(0, "width", OPT_UINT, &cmdlineP->width, NULL, 0); - OPTENT3(0, "lspace", OPT_INT, &cmdlineP->lspace, NULL, 0); - OPTENT3(0, "nomargins", OPT_FLAG, NULL, &cmdlineP->nomargins, 0); - OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); + OPTENT3(0, "font", OPT_STRING, &cmdlineP->font, NULL, 0); + OPTENT3(0, "builtin", OPT_STRING, &cmdlineP->builtin, NULL, 0); + OPTENT3(0, "space", OPT_FLOAT, &cmdlineP->space, NULL, 0); + OPTENT3(0, "lspace", OPT_INT, &cmdlineP->lspace, NULL, 0); + OPTENT3(0, "width", OPT_UINT, &cmdlineP->width, NULL, 0); + OPTENT3(0, "nomargins", OPT_FLAG, NULL, &cmdlineP->nomargins, 0); + OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); + OPTENT3(0, "dry-run", OPT_FLAG, NULL, &cmdlineP->dryrun, 0); + OPTENT3(0, "dump-sheet", OPT_FLAG, NULL, &cmdlineP->dumpsheet, 0); /* Set the defaults */ - cmdlineP->font = NULL; + cmdlineP->font = NULL; cmdlineP->builtin = NULL; - cmdlineP->space = 0.0; - cmdlineP->width = 0; - cmdlineP->lspace = 0; + cmdlineP->space = 0.0; + cmdlineP->width = 0; + cmdlineP->lspace = 0; opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ @@ -128,6 +131,7 @@ parseCommandLine(int argc, const char ** argv, } cmdlineP->text = text; } + free(option_def); } @@ -170,16 +174,12 @@ computeFont(struct CmdlineInfo const cmdline, if (cmdline.verbose) reportFont(fontP); - if (cmdline.dump) { - pbm_dumpfont(fontP); - exit(0); - } *fontPP = fontP; } -struct text { +struct Text { char ** textArray; /* malloc'ed */ unsigned int allocatedLineCount; unsigned int lineCount; @@ -188,7 +188,7 @@ struct text { static void -allocTextArray(struct text * const textP, +allocTextArray(struct Text * const textP, unsigned int const maxLineCount, unsigned int const maxColumnCount) { @@ -198,7 +198,7 @@ allocTextArray(struct text * const textP, MALLOCARRAY_NOFAIL(textP->textArray, maxLineCount); for (line = 0; line < maxLineCount; ++line) { - if(maxColumnCount > 0) + if (maxColumnCount > 0) MALLOCARRAY_NOFAIL(textP->textArray[line], maxColumnCount+1); else textP->textArray[line] = NULL; @@ -209,7 +209,7 @@ allocTextArray(struct text * const textP, static void -freeTextArray(struct text const text) { +freeTextArray(struct Text const text) { unsigned int line; @@ -221,10 +221,16 @@ freeTextArray(struct text const text) { +enum FixMode {SILENT, /* convert silently */ + WARN, /* output message to stderr */ + QUIT /* abort */ }; + + static void fixControlChars(const char * const input, struct font * const fontP, - const char ** const outputP) { + const char ** const outputP, + enum FixMode const fixMode) { /*---------------------------------------------------------------------------- Return a translation of input[] that can be rendered as glyphs in the font 'fontP'. Return it as newly malloced *outputP. @@ -233,9 +239,10 @@ fixControlChars(const char * const input, Remove any trailing newline. (But leave intermediate ones as line delimiters). - - Turn anything that isn't a code point in the font to a single space - (which isn't guaranteed to be in the font either, of course). + + Depending on value of fixMode, turn anything that isn't a code point + in the font to a single space (which isn't guaranteed to be in the + font either, of course). -----------------------------------------------------------------------------*/ /* We don't know in advance how big the output will be because of the tab expansions. So we make sure before processing each input @@ -281,10 +288,17 @@ fixControlChars(const char * const input, output[outCursor++] = ' '; } else if (!fontP->glyph[(unsigned char)input[inCursor]]) { /* Turn this unknown char into a single space. */ - if(fontP->glyph[(unsigned char) ' '] == NULL) + if (fontP->glyph[(unsigned char) ' '] == NULL) pm_error("space character not defined in font"); - else + else if (fixMode == QUIT) + pm_error("character %d not defined in font", + (unsigned int )input[inCursor] ); + else { + if (fixMode == WARN) + pm_message("converting character %d to space", + (unsigned int) input[inCursor] ); output[outCursor++] = ' '; + } } else output[outCursor++] = input[inCursor]; @@ -300,17 +314,16 @@ fixControlChars(const char * const input, static void -fillRect(bit** const bits, - int const height, - int const width, - bit const color) { +clearBackground(bit ** const bits, + int const cols, + int const rows) { unsigned int row; - - for (row = 0; row < height; ++row) { - unsigned int col; - for (col = 0; col < width; ++col) - bits[row][col] = color; + + for (row = 0; row < rows; ++row) { + unsigned int colChar; + for (colChar = 0; colChar < pbm_packed_bytes(cols); ++colChar) + bits[row][colChar] = 0x00; } } @@ -514,7 +527,7 @@ getCharsWithinWidth(char const line[], static void -insertCharacter(const struct glyph * const glyph, +insertCharacter(const struct glyph * const glyphP, int const toprow, int const leftcol, unsigned int const cols, @@ -526,19 +539,20 @@ insertCharacter(const struct glyph * const glyph, -----------------------------------------------------------------------------*/ unsigned int glyph_y; /* Y position within the glyph */ - if (leftcol + glyph->x < 0 || - leftcol + glyph->x + glyph->width > cols || + if (leftcol + glyphP->x < 0 || + leftcol + glyphP->x + glyphP->width > cols || toprow < 0 || - toprow + glyph->height >rows ) + toprow + glyphP->height >rows ) pm_error("internal error. Rendering out of bounds"); - for (glyph_y = 0; glyph_y < glyph->height; ++glyph_y) { + for (glyph_y = 0; glyph_y < glyphP->height; ++glyph_y) { unsigned int glyph_x; /* position within the glyph */ - for (glyph_x = 0; glyph_x < glyph->width; ++glyph_x) { - if (glyph->bmap[glyph_y * glyph->width + glyph_x]) - bits[toprow + glyph_y][leftcol + glyph->x + glyph_x] = - PBM_BLACK; + for (glyph_x = 0; glyph_x < glyphP->width; ++glyph_x) { + if (glyphP->bmap[glyph_y * glyphP->width + glyph_x]) { + unsigned int const col = leftcol + glyphP->x + glyph_x; + bits[toprow+glyph_y][col/8] |= PBM_BLACK << (7-col%8); + } } } } @@ -547,14 +561,15 @@ insertCharacter(const struct glyph * const glyph, static void insertCharacters(bit ** const bits, - struct text const lp, + struct Text const lp, struct font * const fontP, int const topmargin, int const leftmargin, float const intercharacter_space, unsigned int const cols, unsigned int const rows, - int const lspace) { + int const lspace, + bool const fixedAdvance) { /*---------------------------------------------------------------------------- Render the text 'lp' into the image 'bits' using font *fontP and putting 'intercharacter_space' pixels between characters and @@ -581,14 +596,17 @@ insertCharacters(bit ** const bits, char const currentChar = lp.textArray[line][cursor]; unsigned int const glyphIndex = (unsigned char) currentChar; struct glyph * const glyphP = fontP->glyph[glyphIndex]; - int const toprow = row + fontP->maxheight + fontP->y - - glyphP->height - glyphP->y; + int const toprow = + row + fontP->maxheight + fontP->y - glyphP->height - glyphP->y; /* row number in image of top row in glyph */ assert(glyphP != NULL); insertCharacter(glyphP, toprow, leftcol, cols, rows, bits); + if (fixedAdvance) + leftcol += fontP->maxwidth; + else advancePosition(leftcol, currentChar, glyphP, intercharacter_space, accumulatedIcs, &leftcol, &accumulatedIcs); @@ -599,11 +617,11 @@ insertCharacters(bit ** const bits, static void -flowText(struct text const inputText, +flowText(struct Text const inputText, int const targetWidth, struct font * const fontP, float const intercharacterSpace, - struct text * const outputTextP, + struct Text * const outputTextP, unsigned int * const maxleftbP) { unsigned int outputLineNum; @@ -650,7 +668,7 @@ flowText(struct text const inputText, static void -truncateText(struct text const inputText, +truncateText(struct Text const inputText, unsigned int const targetWidth, struct font * const fontP, float const intercharacterSpace, @@ -685,16 +703,17 @@ truncateText(struct text const inputText, static void getText(char const cmdlineText[], struct font * const fontP, - struct text * const inputTextP) { + struct Text * const inputTextP, + enum FixMode const fixMode) { - struct text inputText; + struct Text inputText; if (cmdlineText) { MALLOCARRAY_NOFAIL(inputText.textArray, 1); inputText.allocatedLineCount = 1; inputText.lineCount = 1; fixControlChars(cmdlineText, fontP, - (const char**)&inputText.textArray[0]); + (const char**)&inputText.textArray[0], fixMode); } else { /* Read text from stdin. */ @@ -730,7 +749,8 @@ getText(char const cmdlineText[], if (textArray == NULL) pm_error("out of memory"); } - fixControlChars(buf, fontP, (const char **)&textArray[lineCount]); + fixControlChars(buf, fontP, + (const char **)&textArray[lineCount], fixMode); if (textArray[lineCount] == NULL) pm_error("out of memory"); ++lineCount; @@ -745,7 +765,62 @@ getText(char const cmdlineText[], static void -computeImageHeight(struct text const formattedText, +computeMargins(struct CmdlineInfo const cmdline, + struct Text const inputText, + struct font * const fontP, + unsigned int * const vmarginP, + unsigned int * const hmarginP) { + + if (cmdline.nomargins) { + *vmarginP = 0; + *hmarginP = 0; + } else { + if (inputText.lineCount == 1) { + *vmarginP = fontP->maxheight / 2; + *hmarginP = fontP->maxwidth; + } else { + *vmarginP = fontP->maxheight; + *hmarginP = 2 * fontP->maxwidth; + } + } +} + + + +static void +formatText(struct CmdlineInfo const cmdline, + struct Text const inputText, + struct font * const fontP, + unsigned int const hmargin, + struct Text * const formattedTextP, + unsigned int * const maxleftb0P) { +/*---------------------------------------------------------------------------- + Flow or truncate lines to meet user's width request. +-----------------------------------------------------------------------------*/ + if (cmdline.width > 0) { + unsigned int const fontMargin = fontP->x < 0 ? -fontP->x : 0; + + if (cmdline.width > INT_MAX -10) + pm_error("-width value too large: %u", cmdline.width); + else if (cmdline.width < 2 * hmargin) + pm_error("-width value too small: %u", cmdline.width); + else if (inputText.lineCount == 1) { + flowText(inputText, cmdline.width - fontMargin, + fontP, cmdline.space, formattedTextP, maxleftb0P); + freeTextArray(inputText); + } else { + truncateText(inputText, cmdline.width - fontMargin, + fontP, cmdline.space, maxleftb0P); + *formattedTextP = inputText; + } + } else + *formattedTextP = inputText; +} + + + +static void +computeImageHeight(struct Text const formattedText, const struct font * const fontP, int const interlineSpace, unsigned int const vmargin, @@ -769,7 +844,7 @@ computeImageHeight(struct text const formattedText, static void -computeImageWidth(struct text const formattedText, +computeImageWidth(struct Text const formattedText, const struct font * const fontP, float const intercharacterSpace, unsigned int const hmargin, @@ -817,98 +892,180 @@ computeImageWidth(struct text const formattedText, -int -main(int argc, const char *argv[]) { +static void +renderText(unsigned int const cols, + unsigned int const rows, + struct font * const fontP, + unsigned int const hmargin, + unsigned int const vmargin, + struct Text const formattedText, + unsigned int const maxleftb, + float const space, + int const lspace, + bool const fixedAdvance, + FILE * const ofP) { + + bit ** const bits = pbm_allocarray(pbm_packed_bytes(cols), rows); + + /* Fill background with white */ + clearBackground(bits, cols, rows); + + /* Put the text in */ + insertCharacters(bits, formattedText, fontP, vmargin, hmargin + maxleftb, + space, cols, rows, lspace, fixedAdvance); + + { + unsigned int row; + + pbm_writepbminit(ofP, cols, rows, 0); + + for (row = 0; row < rows; ++row) + pbm_writepbmrow_packed(ofP, bits[row], cols, 0); + } + + pbm_freearray(bits, rows); +} + + + +static char const * sheetTextArray[] = { +"M \",/^_[`jpqy| M", +" ", +"/ !\"#$%&'()*+ /", +"< ,-./01234567 <", +"> 89:;<=>?@ABC >", +"@ DEFGHIJKLMNO @", +"_ PQRSTUVWXYZ[ _", +"{ \\]^_`abcdefg {", +"} hijklmnopqrs }", +"~ tuvwxyz{|}~ ~", +" ", +"M \",/^_[`jpqy| M" }; + + + +static void +validateText(const char ** const textArray, + struct font * const fontP) { +/*---------------------------------------------------------------------------- + Abort the program if there are characters in 'textArray' which cannot be + rendered in font *fontP. +-----------------------------------------------------------------------------*/ + const char * output; + unsigned int textRow; + + for (textRow = 0; textRow < 12; ++textRow) + fixControlChars(textArray[textRow], fontP, &output, QUIT); + + pm_strfree(output); +} + + + +static void +renderSheet(struct font * const fontP, + FILE * const ofP) { + + int const cols = fontP->maxwidth * 16; + int const rows = fontP->maxheight * 12; + struct Text const sheetText = { (char ** const) sheetTextArray, 12, 12}; + + validateText(sheetTextArray, fontP); + + renderText(cols, rows, fontP, 0, 0, sheetText, MAX(-(fontP->x),0), + 0.0, 0, TRUE, ofP); +} + + + +static void +dryrunOutput(unsigned int const cols, + unsigned int const rows, + FILE * const ofP) { + + fprintf(ofP, "%u %u\n", cols, rows); +} + + + +static void +pbmtext(struct CmdlineInfo const cmdline, + struct font * const fontP, + FILE * const ofP) { - struct CmdlineInfo cmdline; - bit ** bits; unsigned int rows, cols; - struct font * fontP; - unsigned int vmargin, hmargin, fontMargin; - struct text inputText; - struct text formattedText; + /* Dimensions in pixels of the output image */ + unsigned int cols0; + unsigned int vmargin, hmargin; + /* Margins in pixels we add to the output image */ + unsigned int hmargin0; + struct Text inputText; + struct Text formattedText; unsigned int maxleftb, maxleftb0; - pm_proginit(&argc, argv); + getText(cmdline.text, fontP, &inputText, + cmdline.verbose ? WARN : SILENT); - parseCommandLine(argc, argv, &cmdline); - - computeFont(cmdline, &fontP); + computeMargins(cmdline, inputText, fontP, &vmargin, &hmargin0); - getText(cmdline.text, fontP, &inputText); - - if (cmdline.nomargins) { - vmargin = 0; - hmargin = 0; - } else { - if (inputText.lineCount == 1) { - vmargin = fontP->maxheight / 2; - hmargin = fontP->maxwidth; - } else { - vmargin = fontP->maxheight; - hmargin = 2 * fontP->maxwidth; - } - } - - if (cmdline.width > 0) { - fontMargin = fontP->x < 0 ? -fontP->x : 0; + formatText(cmdline, inputText, fontP, hmargin0, + &formattedText, &maxleftb0); - if (cmdline.width > INT_MAX -10) - pm_error("-width value too large: %u", cmdline.width); - else if (cmdline.width < 2 * hmargin) - pm_error("-width value too small: %u", cmdline.width); - /* Flow or truncate lines to meet user's width request */ - else if (inputText.lineCount == 1) { - flowText(inputText, cmdline.width - fontMargin, - fontP, cmdline.space, &formattedText, &maxleftb0); - freeTextArray(inputText); - } else { - truncateText(inputText, cmdline.width - fontMargin, - fontP, cmdline.space, &maxleftb0); - formattedText = inputText; - } - } else - formattedText = inputText; - if (formattedText.lineCount == 0) pm_error("No input text"); - computeImageHeight(formattedText, fontP, cmdline.lspace, vmargin, - &rows); + computeImageHeight(formattedText, fontP, cmdline.lspace, vmargin, &rows); computeImageWidth(formattedText, fontP, cmdline.space, - cmdline.width > 0 ? 0 : hmargin, &cols, &maxleftb); + cmdline.width > 0 ? 0 : hmargin0, &cols0, &maxleftb); - if (cols == 0 || rows == 0) + if (cols0 == 0 || rows == 0) pm_error("Input is all whitespace and/or non-renderable characters."); - if (cmdline.width > 0) { - if(cmdline.width < cols) - pm_error("internal error: calculated image width (%u) exceeds " - "specified -width value: %u", - cols, cmdline.width); - else if(maxleftb0 != maxleftb) - pm_error("internal error: contradicting backup values"); - else { - hmargin = MIN(hmargin, (cmdline.width - cols) / 2); - cols = cmdline.width; - } + if (cmdline.width == 0) { + cols = cols0; + hmargin = hmargin0; + } else { + if (cmdline.width < cols0) + pm_error("internal error: calculated image width (%u) exceeds " + "specified -width value: %u", + cols0, cmdline.width); + else if (maxleftb0 != maxleftb) + pm_error("internal error: contradicting backup values"); + else { + hmargin = MIN(hmargin0, (cmdline.width - cols0) / 2); + cols = cmdline.width; + } } - bits = pbm_allocarray(cols, rows); + if (cmdline.dryrun) + dryrunOutput(cols, rows, ofP); + else + renderText(cols, rows, fontP, hmargin, vmargin, formattedText, + maxleftb, cmdline.space, cmdline.lspace, FALSE, ofP); - /* Fill background with white */ - fillRect(bits, rows, cols, PBM_WHITE); + freeTextArray(formattedText); +} - /* Put the text in */ - insertCharacters(bits, formattedText, fontP, vmargin, hmargin + maxleftb, - cmdline.space, cols, rows, cmdline.lspace); - pbm_writepbm(stdout, bits, cols, rows, 0); - pbm_freearray(bits, rows); +int +main(int argc, const char *argv[]) { + + struct CmdlineInfo cmdline; + struct font * fontP; + + pm_proginit(&argc, argv); + + parseCommandLine(argc, argv, &cmdline); + + computeFont(cmdline, &fontP); + + if (cmdline.dumpsheet) + renderSheet(fontP, stdout); + else + pbmtext(cmdline, fontP, stdout); - freeTextArray(formattedText); pm_close(stdout); return 0; diff --git a/generator/pbmtextps.c b/generator/pbmtextps.c index e6367530..fb55fa0a 100644 --- a/generator/pbmtextps.c +++ b/generator/pbmtextps.c @@ -1,4 +1,4 @@ -/* + /* * pbmtextps.c - render text into a bitmap using a postscript interpreter * * Copyright (C) 2002 by James McCann. @@ -14,7 +14,17 @@ * * Additions by Bryan Henderson contributed to public domain by author. * + * PostScript(R) Language Reference, Third Edition (a.k.a. "Red Book") + * http://www.adobe.com/products/postscript/pdfs/PLRM.pdf + * ISBN 0-201-37922-8 + * + * Postscript Font Naming Issues: + * https://partners.adobe.com/public/developer/en/font/5088.FontNames.pdf + * + * Other resources: + * http://partners.adobe.com/public/developer/ps/index_specs.html */ + #define _XOPEN_SOURCE /* Make sure popen() is in stdio.h */ #define _BSD_SOURCE /* Make sure stdrup() is in string.h */ #include <unistd.h> @@ -22,60 +32,15 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <assert.h> #include "pm_c_util.h" #include "mallocvar.h" #include "nstring.h" #include "shhopt.h" +#include "pm_system.h" #include "pbm.h" - -#define BUFFER_SIZE 2048 - -struct cmdlineInfo { - /* All the information the user supplied in the command line, - in a form easy for the program to use. - */ - unsigned int res; /* resolution, DPI */ - unsigned int fontsize; /* Size of font in points */ - const char * font; /* Name of postscript font */ - float stroke; - /* Width of stroke in points (only for outline font) */ - unsigned int verbose; - const char * text; -}; - - - -static void -writeFileToStdout(const char * const fileName){ - /* simple pbmtopbm */ - - FILE * ifP; - int format; - int cols, rows, row ; - unsigned char * bitrow; - - ifP = pm_openr(fileName); - pbm_readpbminit(ifP, &cols, &rows, &format); - - if (cols==0 || rows==0 || cols>INT_MAX-10 || rows>INT_MAX-10) - pm_error("Abnormal output from gs program. " - "width x height = %u x %u", cols, rows); - - pbm_writepbminit(stdout, cols, rows, 0); - - bitrow = pbm_allocrow_packed(cols); - - for (row = 0; row < rows; ++row) { - pbm_readpbmrow_packed(ifP, bitrow, cols, format); - pbm_writepbmrow_packed(stdout, bitrow, cols, 0); - } - pbm_freerow_packed(bitrow); -} - - - static void validateFontName(const char * const name) { /*----------------------------------------------------------------------------- @@ -132,7 +97,7 @@ asciiHexEncode(char * const inbuff, static void buildTextFromArgs(int const argc, - char ** const argv, + const char ** const argv, const char ** const asciiHexTextP) { /*---------------------------------------------------------------------------- Build the array of text to be included in the Postscript program to @@ -186,9 +151,31 @@ buildTextFromArgs(int const argc, +struct CmdlineInfo { + /* All the information the user supplied in the command line, + in a form easy for the program to use. + */ + unsigned int res; + float fontsize; + const char * font; + float stroke; + float ascent; + float descent; + float leftmargin; + float rightmargin; + float topmargin; + float bottommargin; + unsigned int pad; + unsigned int verbose; + unsigned int dump; + const char * text; +}; + + + static void -parseCommandLine(int argc, char ** argv, - struct cmdlineInfo *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. @@ -199,37 +186,104 @@ parseCommandLine(int argc, char ** argv, optStruct3 opt; unsigned int option_def_index; + unsigned int cropSpec, ascentSpec, descentSpec; + unsigned int leftmarginSpec, rightmarginSpec; + unsigned int topmarginSpec, bottommarginSpec; MALLOCARRAY(option_def, 100); option_def_index = 0; /* incremented by OPTENTRY */ - OPTENT3(0, "resolution", OPT_UINT, &cmdlineP->res, NULL, 0); - OPTENT3(0, "font", OPT_STRING, &cmdlineP->font, NULL, 0); - OPTENT3(0, "fontsize", OPT_UINT, &cmdlineP->fontsize, NULL, 0); - OPTENT3(0, "stroke", OPT_FLOAT, &cmdlineP->stroke, NULL, 0); - OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); + OPTENT3(0, "resolution", OPT_UINT, + &cmdlineP->res, NULL, 0); + OPTENT3(0, "font", OPT_STRING, + &cmdlineP->font, NULL, 0); + OPTENT3(0, "fontsize", OPT_FLOAT, + &cmdlineP->fontsize, NULL, 0); + OPTENT3(0, "stroke", OPT_FLOAT, + &cmdlineP->stroke, NULL, 0); + OPTENT3(0, "ascent", OPT_FLOAT, + &cmdlineP->ascent, &ascentSpec, 0); + OPTENT3(0, "descent", OPT_FLOAT, + &cmdlineP->descent, &descentSpec, 0); + OPTENT3(0, "leftmargin", OPT_FLOAT, + &cmdlineP->leftmargin, &leftmarginSpec, 0); + OPTENT3(0, "rightmargin", OPT_FLOAT, + &cmdlineP->rightmargin, &rightmarginSpec, 0); + OPTENT3(0, "topmargin", OPT_FLOAT, + &cmdlineP->topmargin, &topmarginSpec, 0); + OPTENT3(0, "bottommargin", OPT_FLOAT, + &cmdlineP->bottommargin, &bottommarginSpec, 0); + OPTENT3(0, "crop", OPT_FLAG, + NULL, &cropSpec, 0); + OPTENT3(0, "pad", OPT_FLAG, + NULL, &cmdlineP->pad, 0); + OPTENT3(0, "verbose", OPT_FLAG, + NULL, &cmdlineP->verbose, 0); + OPTENT3(0, "dump-ps", OPT_FLAG, + NULL, &cmdlineP->dump, 0); /* Set the defaults */ cmdlineP->res = 150; cmdlineP->fontsize = 24; cmdlineP->font = "Times-Roman"; - cmdlineP->stroke = -1; + cmdlineP->stroke = -1; + cmdlineP->ascent = 0; + cmdlineP->descent = 0; + cmdlineP->rightmargin = 0; + cmdlineP->leftmargin = 0; + cmdlineP->topmargin = 0; + cmdlineP->bottommargin = 0; + cropSpec = FALSE; + cmdlineP->pad = FALSE; opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; - pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0); + pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); validateFontName(cmdlineP->font); + if (cmdlineP->fontsize <= 0) + pm_error("-fontsize must be positive"); + if (cmdlineP->ascent < 0) + pm_error("-ascent must not be negative"); + if (cmdlineP->descent < 0) + pm_error("-descent must not be negative"); + if (cmdlineP->leftmargin <0) + pm_error("-leftmargin must not be negative"); + if (cmdlineP->rightmargin <0) + pm_error("-rightmargin must not be negative"); + if (cmdlineP->topmargin <0) + pm_error("-topmargin must not be negative"); + if (cmdlineP->bottommargin <0) + pm_error("-bottommargin must not be negative"); + + if (cropSpec == TRUE) { + if (ascentSpec || descentSpec || + leftmarginSpec || rightmarginSpec || + topmarginSpec || bottommarginSpec || + cmdlineP->pad) + pm_error("-crop cannot be specified with -ascent, -descent, " + "-leftmargin, -rightmargin, " + "-topmargin, -bottommargin or -pad"); + } else { + if (!descentSpec && !bottommarginSpec && !cmdlineP->pad) + cmdlineP->descent = cmdlineP->fontsize * 1.5; + + if (!leftmarginSpec) + cmdlineP->leftmargin = cmdlineP->fontsize / 2; + } + buildTextFromArgs(argc, argv, &cmdlineP->text); + + free(option_def); } static void -termCmdline(struct cmdlineInfo const cmdline) { +termCmdline(struct CmdlineInfo const cmdline) { pm_strfree(cmdline.text); } @@ -237,305 +291,431 @@ termCmdline(struct cmdlineInfo const cmdline) { static const char * -construct_postscript(struct cmdlineInfo const cmdline) { +postscriptProgram(struct CmdlineInfo const cmdline) { +/*----------------------------------------------------------------------------- + In Postscript, the bottom of the page is row zero. Postscript allows + negative values but negative regions are clipped from the output image. + We make adjustments to ensure that nothing is lost. + + Postscript also allow fonts to have negative values in the bounding box + coordinates. The bottom edge of "L" is row zero: this row is called the + "baseline". The feet of "g" "p" "y" extend into negative region. In a + similar manner the left edge of the bounding box may be negative. We add + margins on the left and the bottom with "xorigin" and "yorigin" to + provide for such characters. + + The sequence "textstring false charpath flattenpath pathbbox" determines + the bounding box of the entire text when rendered. +-----------------------------------------------------------------------------*/ + + /* C89 limits the size of a string constant, so we have to build the + Postscript command in pieces. + + psVariable, psTemplate: Set variables. + psFixed1: Scale font. Calculate pad metrics. + psFixed2: Determine width, height, xorigin, yorigin. + psFixed3: Render. + psFixed4: Verbose mode: Report font name, metrics. + We could add code to psFixed2 for handling right-to-left writing + (Hebrew, Arabic) and vertical writing (Chinese, Korean, Japanese). + */ + + const char * const psTemplate = + "/FindFont {/%s findfont} def\n" + "/fontsize %f def\n" + "/pensize %f def\n" + "/textstring <%s> def\n" + "/ascent %f def\n" + "/descent %f def\n" + "/leftmargin %f def\n" + "/rightmargin %f def\n" + "/topmargin %f def\n" + "/bottommargin %f def\n" + "/pad %s def\n" + "/verbose %s def\n"; + + const char * const psFixed1 = + "FindFont fontsize scalefont\n" + "pad { dup dup\n" + " /FontMatrix get 3 get /yscale exch def\n" + " /FontBBox get dup\n" + " 1 get yscale mul neg /padbottom exch def\n" + " 3 get yscale mul /padtop exch def}\n" + " {/padbottom 0 def /padtop 0 def}\n" + " ifelse\n" + "setfont\n"; + + const char * const psFixed2 = + "0 0 moveto\n" + "textstring false charpath flattenpath pathbbox\n" + "/BBtop exch def\n" + "/BBright exch def\n" + "/BBbottom exch neg def\n" + "/BBleft exch neg def\n" + "/max { 2 copy lt { exch } if pop } bind def\n" + "/yorigin descent padbottom max BBbottom max bottommargin add def\n" + "/xorigin leftmargin BBleft max def\n" + "/width xorigin BBright add rightmargin add def\n" + "/height ascent BBtop max padtop max topmargin add yorigin add def\n"; + + const char * const psFixed3 = + "<</PageSize [width height]>> setpagedevice\n" + "xorigin yorigin moveto\n" + "pensize 0 lt\n" + " {textstring show}\n" + " {pensize setlinewidth 0 setgray\n" + " textstring true charpath stroke}\n" + " ifelse\n" + "showpage\n"; + + const char * const psFixed4 = + "verbose\n" + " {xorigin yorigin moveto\n" + " [(width height) width height] ==\n" + " [(ascent descent) height yorigin sub yorigin] ==\n" + " [(bounding box) \n" + " textstring false charpath flattenpath pathbbox] ==\n" + " [(Fontname) FindFont dup /FontName\n" + " known\n" + " {/FontName get}\n" + " {pop (anonymous)}\n" + " ifelse] ==}\n" + " if"; + const char * retval; - const char * template; - - if (cmdline.stroke < 0) - template = - "/%s findfont\n" - "%d scalefont\n" - "setfont\n" - "12 36 moveto\n" - "<%s> show\n" - "showpage\n"; - else - template = - "/%s findfont\n" - "%d scalefont\n" - "setfont\n" - "12 36 moveto\n" - "%f setlinewidth\n" - "0 setgray\n" - "<%s> true charpath\n" - "stroke\n" - "showpage\n"; - - if (cmdline.stroke < 0) - pm_asprintf(&retval, template, cmdline.font, cmdline.fontsize, - cmdline.text); - else - pm_asprintf(&retval, template, cmdline.font, cmdline.fontsize, - cmdline.stroke, cmdline.text); + const char * psVariable; + + pm_asprintf(&psVariable, psTemplate, cmdline.font, + cmdline.fontsize, cmdline.stroke, cmdline.text, + cmdline.ascent, cmdline.descent, + cmdline.leftmargin, cmdline.rightmargin, + cmdline.topmargin, cmdline.bottommargin, + cmdline.pad ? "true" : "false", + cmdline.verbose ? "true" : "false" ); + pm_asprintf(&retval, "%s%s%s%s%s", psVariable, + psFixed1, psFixed2, psFixed3, psFixed4); + + pm_strfree(psVariable); + return retval; } -static const char * -gsExecutableName() { +static const char ** +gsArgList(const char * const outputFilename, + struct CmdlineInfo const cmdline) { - const char * const which = "which gs"; + unsigned int const maxArgCt = 50; + + const char ** retval; + unsigned int argCt; /* Number of arguments in 'retval' so far */ - static char buffer[BUFFER_SIZE]; + if (cmdline.res <= 0) + pm_error("Resolution (dpi) must be positive."); + + if (cmdline.fontsize <= 0) + pm_error("Font size must be positive."); + + MALLOCARRAY_NOFAIL(retval, maxArgCt+2); - FILE * f; + argCt = 0; /* initial value */ - memset(buffer, 0, BUFFER_SIZE); + pm_asprintf(&retval[argCt++], "ghostscript"); + pm_asprintf(&retval[argCt++], "-r%d", cmdline.res); + pm_asprintf(&retval[argCt++], "-sDEVICE=pbmraw"); + pm_asprintf(&retval[argCt++], "-sOutputFile=%s", outputFilename); + pm_asprintf(&retval[argCt++], "-q"); + pm_asprintf(&retval[argCt++], "-dBATCH"); + pm_asprintf(&retval[argCt++], "-dSAFER"); + pm_asprintf(&retval[argCt++], "-dNOPAUSE"); + pm_asprintf(&retval[argCt++], "-"); - f = popen(which, "r"); - if (!f) - pm_error("Can't find ghostscript"); + retval[argCt++] = NULL; - fread(buffer, 1, BUFFER_SIZE, f); - if (buffer[strlen(buffer) - 1] == '\n') - buffer[strlen(buffer) - 1] = '\0'; - pclose(f); - - if (buffer[0] != '/' && buffer[0] != '.') - pm_error("Can't find ghostscript"); + assert(argCt < maxArgCt); - return buffer; + return retval; } -static const char * -cropExecutableName(void) { +static void +reportGhostScript(const char * const executableNm, + const char ** const argList) { - const char * const which = "which pnmcrop"; + unsigned int i; - static char buffer[BUFFER_SIZE]; - const char * retval; + pm_message("Running Ghostscript interpreter '%s'", executableNm); - FILE * f; - - memset(buffer, 0, BUFFER_SIZE); - - f = popen(which, "r"); - if (!f) - retval = NULL; - else { - fread(buffer, 1, BUFFER_SIZE, f); - if (buffer[strlen(buffer) - 1] == '\n') - buffer[strlen(buffer) - 1] = 0; - pclose(f); - - if (buffer[0] != '/' && buffer[0] != '.') { - retval = NULL; - pm_message("Can't find pnmcrop"); - } else - retval = buffer; - } - return retval; + pm_message("Program arguments:"); + + for (i = 0; argList[i]; ++i) + pm_message(" '%s'", argList[i]); } -static const char * -gsCommand(const char * const psFname, - const char * const outputFilename, - struct cmdlineInfo const cmdline) { +static void +freeArgList(const char ** const argList) { - const char * retval; - double const x = (double) cmdline.res * 11; - double const y = (double) cmdline.res * - ((double) cmdline.fontsize * 2 + 72) / 72; - - if (cmdline.res <= 0) - pm_error("Resolution (dpi) must be positive."); - - if (cmdline.fontsize <= 0) - pm_error("Font size must be positive."); - - /* The following checks are for guarding against overflows in this - function. Huge x,y values that pass these checks may be - rejected by the 'gs' program. - */ - - if (x > (double) INT_MAX-10) - pm_error("Absurdly fine resolution: %u. Output width too large.", - cmdline.res ); - if (y > (double) INT_MAX-10) - pm_error("Absurdly fine resolution (%u) and/or huge font size (%u). " - "Output height too large.", cmdline.res, cmdline.fontsize); - - pm_asprintf(&retval, "%s -g%dx%d -r%d -sDEVICE=pbm " - "-sOutputFile=%s -q -dBATCH -dNOPAUSE %s " - "</dev/null >/dev/null", - gsExecutableName(), (int) x, (int) y, cmdline.res, - outputFilename, psFname); + unsigned int i; - return retval; + for (i = 0; argList[i]; ++i) + pm_strfree(argList[i]); + + free(argList); } -static const char * -cropCommand(const char * const inputFileName) { +static void +reportFontName(const char * const fontname) { - const char * retval; - const char * plainOpt = pm_plain_output ? "-plain" : "" ; - - if (cropExecutableName()) { - pm_asprintf(&retval, "%s -top -right %s %s", - cropExecutableName(), plainOpt, inputFileName); - if (retval == pm_strsol) - pm_error("Unable to allocate memory"); - } else - retval = NULL; + pm_message("Font: '%s'", fontname); - return retval; } static void -writeProgram(const char * const psFname, - struct cmdlineInfo const cmdline) { +reportMetrics(float const width, + float const height, + float const ascent, + float const descent, + float const BBoxleft, + float const BBoxbottom, + float const BBoxright, + float const BBoxtop) { + + pm_message("-- Metrics in points. Bottom left is (0,0) --"); + pm_message("Width: %f", width); + pm_message("Height: %f", height); + pm_message("Ascent: %f", ascent); + pm_message("Descent: %f", descent); + pm_message("BoundingBox_Left: %f", BBoxleft); + pm_message("BoundingBox_Right: %f", BBoxright); + pm_message("BoundingBox_Top: %f", BBoxtop); + pm_message("BoundingBox_Bottom: %f", BBoxbottom); - const char * ps; - FILE * psfile; +} - psfile = fopen(psFname, "w"); - if (psfile == NULL) - pm_error("Can't open temp file '%s'. Errno=%d (%s)", - psFname, errno, strerror(errno)); - ps = construct_postscript(cmdline); - if (cmdline.verbose) - pm_message("Postscript program = '%s'", ps); - - if (fwrite(ps, 1, strlen(ps), psfile) != strlen(ps)) - pm_error("Can't write postscript to temp file"); +static void +acceptGSoutput(int const pipetosuckFd, + void * const nullParams ) { +/*----------------------------------------------------------------------------- + Accept text written to stdout by the PostScript program. + + There are two kinds of output: + (1) Metrics and fontname reported, when verbose is on. + (2) Error messages from ghostscript. + + We read one line at a time. + + We cannot predict how long one line can be in case (2). In practice + the "execute stack" report gets long. We provide by setting lineBuffSize + to a large number. +-----------------------------------------------------------------------------*/ + unsigned int const lineBuffSize = 1024*32; + FILE * const inFileP = fdopen(pipetosuckFd, "r"); + + float width, height, ascent, descent; + float BBoxleft, BBoxbottom, BBoxright, BBoxtop; + char * lineBuff; /* malloc'd */ + char fontname [2048]; + bool fontnameReported, widthHeightReported; + bool ascentDescentReported, BBoxReported; + + assert(nullParams == NULL); + + fontnameReported = FALSE; /* Initial value */ + widthHeightReported = FALSE; /* Initial value */ + ascentDescentReported = FALSE; /* Initial value */ + BBoxReported = FALSE; /* Initial value */ + + MALLOCARRAY_NOFAIL(lineBuff, lineBuffSize); - fclose(psfile); + while (fgets(lineBuff, lineBuffSize, inFileP) != NULL) { + unsigned int rWidthHeight, rAscentDescent, rBBox, rFontname; - pm_strfree(ps); + rWidthHeight = sscanf(lineBuff, "[(width height) %f %f]", + &width, &height); + + rAscentDescent = sscanf(lineBuff, "[(ascent descent) %f %f]", + &ascent, &descent); + + rBBox = sscanf(lineBuff, "[(bounding box) %f %f %f %f]", + &BBoxleft, &BBoxbottom, &BBoxright, &BBoxtop); + + rFontname = sscanf(lineBuff, "[(Fontname) /%2047s", fontname); + + if (rFontname == 1) + fontnameReported = TRUE; + else if (rWidthHeight == 2) + widthHeightReported = TRUE; + else if (rAscentDescent == 2) + ascentDescentReported = TRUE; + else if (rBBox == 4) + BBoxReported = TRUE; + else + pm_message("[gs] %s", lineBuff); + } + + if (fontnameReported) { + fontname[strlen(fontname)-1] = 0; + reportFontName(fontname); + + if (widthHeightReported && ascentDescentReported && BBoxReported) + reportMetrics(width, height, ascent, descent, + BBoxleft, BBoxbottom, BBoxright, BBoxtop); + } + fclose(inFileP); + pm_strfree(lineBuff); } static void -executeProgram(const char * const psFname, +executeProgram(const char * const psProgram, const char * const outputFname, - struct cmdlineInfo const cmdline) { + struct CmdlineInfo const cmdline) { - const char * com; - int rc; + const char * const executableNm = "gs"; + const char ** const argList = gsArgList(outputFname, cmdline); + + struct bufferDesc feedBuffer; + int termStatus; + unsigned int bytesFed; + + bytesFed = 0; /* Initial value */ + + feedBuffer.buffer = (unsigned char *) psProgram; + feedBuffer.size = strlen(psProgram); + feedBuffer.bytesTransferredP = &bytesFed; - com = gsCommand(psFname, outputFname, cmdline); - if (com == NULL) - pm_error("Can't allocate memory for a 'ghostscript' command"); - if (cmdline.verbose) - pm_message("Running Postscript interpreter '%s'", com); + reportGhostScript(executableNm, argList); - rc = system(com); - if (rc != 0) - pm_error("Failed to run Ghostscript process. rc=%d", rc); + pm_system2_vp(executableNm, + argList, + &pm_feed_from_memory, &feedBuffer, + cmdline.verbose ? &acceptGSoutput : &pm_accept_null, NULL, + &termStatus); - pm_strfree(com); -} + if (termStatus != 0) { + const char * const msg = pm_termStatusDesc(termStatus); + pm_error("Failed to run Ghostscript process. %s", msg); + pm_strfree(msg); + } + freeArgList(argList); +} -static void -cropToStdout(const char * const inputFileName, - bool const verbose) { - const char * com; - com = cropCommand(inputFileName); +static void +writePbm(const char * const fileName, + FILE * const ofP) { +/*---------------------------------------------------------------------------- + Write the PBM image that is in the file named 'fileName" to file *ofP. + I.e. pbmtopbm. - if (com == NULL) { - /* No pnmcrop. So don't crop. */ - pm_message("Can't find pnmcrop command, image will be large"); - writeFileToStdout(inputFileName); - } else { - FILE * pnmcrop; + It's not a byte-for-byte copy because PBM allows the same image to be + represented many ways (all of which we can accept as our input), but we use + libnetpbm to write our output in its specific way. +----------------------------------------------------------------------------*/ + FILE * ifP; + int format; + int cols, rows, row ; + unsigned char * bitrow; + + ifP = pm_openr(fileName); + pbm_readpbminit(ifP, &cols, &rows, &format); - if (verbose) - pm_message("Running crop command '%s'", com); - - pnmcrop = popen(com, "r"); - if (pnmcrop == NULL) - pm_error("Can't run pnmcrop process"); - else { - char buf[2048]; - bool eof; - - eof = FALSE; - - while (!eof) { - int bytesRead; - - bytesRead = fread(buf, 1, sizeof(buf), pnmcrop); - if (bytesRead > 0) { - int rc; - rc = fwrite(buf, 1, bytesRead, stdout); - if (rc != bytesRead) - pm_error("Can't write to stdout"); - } else if (bytesRead == 0) - eof = TRUE; - else - pm_error("Failed to read output of Pnmcrop process. " - "Errno=%d (%s)", errno, strerror(errno)); - } - fclose(pnmcrop); - } - pm_strfree(com); + if (cols == 0 || rows == 0 || cols > INT_MAX - 10 || rows > INT_MAX - 10) + pm_error("Abnormal output from gs program. " + "width x height = %u x %u", cols, rows); + + pbm_writepbminit(ofP, cols, rows, 0); + + bitrow = pbm_allocrow_packed(cols); + + for (row = 0; row < rows; ++row) { + pbm_readpbmrow_packed(ifP, bitrow, cols, format); + pbm_writepbmrow_packed(ofP, bitrow, cols, 0); } + pbm_freerow_packed(bitrow); + pm_close(ifP); } static void -createOutputFile(struct cmdlineInfo const cmdline) { +generatePbm(struct CmdlineInfo const cmdline, + FILE * const ofP) { + + const char * const psProgram = postscriptProgram(cmdline); + + const char * tempPbmFname; + FILE * pbmFileP; + + pm_make_tmpfile(&pbmFileP, &tempPbmFname); + assert(pbmFileP != NULL && tempPbmFname != NULL); + fclose(pbmFileP); + + executeProgram(psProgram, tempPbmFname, cmdline); + + /* Although Ghostscript created a legal PBM file, it uses a different + implementation of the format from libnetpbm's canonical output format, + so instead of copying the content of 'tempPbmFname' to *ofP byte for + byte, we copy it as a PBM image. + */ + writePbm(tempPbmFname, ofP); + + unlink(tempPbmFname); + pm_strfree(tempPbmFname); + pm_strfree(psProgram); +} + - const char * const template = "./pstextpbm.%d.tmp.%s"; - - const char * psFname; - const char * uncroppedPbmFname; - pm_asprintf(&psFname, template, getpid(), "ps"); - if (psFname == NULL) - pm_error("Unable to allocate memory"); - - writeProgram(psFname, cmdline); +static void +dumpPsProgram(struct CmdlineInfo const cmdline) { - pm_asprintf(&uncroppedPbmFname, template, getpid(), "pbm"); - if (uncroppedPbmFname == NULL) - pm_error("Unable to allocate memory"); - - executeProgram(psFname, uncroppedPbmFname, cmdline); + const char * psProgram; - unlink(psFname); - pm_strfree(psFname); + psProgram = postscriptProgram(cmdline); - cropToStdout(uncroppedPbmFname, cmdline.verbose); + puts(psProgram); - unlink(uncroppedPbmFname); - pm_strfree(uncroppedPbmFname); + pm_strfree(psProgram); } int -main(int argc, char *argv[]) { +main(int argc, const char *argv[]) { - struct cmdlineInfo cmdline; + struct CmdlineInfo cmdline; - pbm_init(&argc, argv); + pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); - createOutputFile(cmdline); + if (cmdline.dump) + dumpPsProgram(cmdline); + else + generatePbm(cmdline, stdout); termCmdline(cmdline); return 0; } + + + diff --git a/generator/pgmcrater b/generator/pgmcrater index 1c22ed70..c66f5576 100755 --- a/generator/pgmcrater +++ b/generator/pgmcrater @@ -37,6 +37,26 @@ use strict; use Getopt::Long; +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('pamcrater', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + + +############################################################################## +# +# MAINLINE +# +############################################################################## + +doVersionHack(\@ARGV); + my @pgmcraterArgv = @ARGV; my $validOptions = GetOptions( diff --git a/generator/ppmrainbow b/generator/ppmrainbow index c0568d9b..a4f90a09 100755 --- a/generator/ppmrainbow +++ b/generator/ppmrainbow @@ -25,11 +25,27 @@ exec perl -w -x -S -- "$0" "$@" #!/usr/bin/perl use strict; use Getopt::Long; +use File::Temp; my ($FALSE, $TRUE) = (0,1); (my $myname = $0) =~ s#\A.*/##; + + +sub doVersionHack($) { + my ($argvR) = @_; + + my $arg1 = $argvR->[0]; + + if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { + my $termStatus = system('pgmramp', '--version'); + exit($termStatus == 0 ? 0 : 1); + } +} + + + sub fatal($) { my ($msg) = @_; @@ -37,19 +53,29 @@ sub fatal($) { exit(1); } -my ($Twid, $Thgt, $tmpdir, $norepeat, $verbose); + + +############################################################################## +# +# MAINLINE +# +############################################################################## + +doVersionHack(\@ARGV); + +my ($Twid, $Thgt, $tmpdir, $repeat, $verbose); # set defaults $Twid = 600; $Thgt = 8; $tmpdir = $ENV{"TMPDIR"} || "/tmp"; -$norepeat = $FALSE; +$repeat = $TRUE; $verbose = $FALSE; GetOptions("width=i" => \$Twid, "height=i" => \$Thgt, "tmpdir=s" => \$tmpdir, - "norepeat!" => \$norepeat, + "repeat!" => \$repeat, "verbose!" => \$verbose); if ($Twid < 1 || $Thgt < 1) { @@ -59,7 +85,7 @@ my $verboseCommand = $verbose ? "set -x;" : ""; if (@ARGV < 1) { fatal("You must specify at least one color as an argument"); -} elsif (@ARGV < 2 && $norepeat) { +} elsif (@ARGV < 2 && ! $repeat) { fatal("With the -norepeat option, you must specify at least two colors " . "as arguments."); } @@ -67,14 +93,11 @@ if (@ARGV < 1) { my @colorlist; @colorlist = @ARGV; -if (!$norepeat) { +if ($repeat) { push @colorlist, $ARGV[0]; } -my $ourtmp = "$tmpdir/ppmrainbow$$"; -mkdir($ourtmp, 0777) or - die("Unable to create directory for temporary files '$ourtmp"); - +my $ourtmp = File::Temp::tempdir("$tmpdir/ppmrainbowXXXX", UNLINK=>1); my $widthRemaining; my $n; diff --git a/lib/Makefile b/lib/Makefile index 0097a04e..7af07803 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -27,7 +27,8 @@ endif LIBOBJECTS = libpm.o pmfileio.o fileio.o colorname.o \ libpamd.o \ - libpbm1.o libpbm2.o libpbm3.o libpbmfont.o \ + libpbm1.o libpbm2.o libpbm3.o \ + libpbmfont.o pbmfontdata1.o pbmfontdata2.o \ libpgm1.o libpgm2.o \ libppm1.o libppm2.o libppmcmap.o libppmcolor.o libppmfuzzy.o \ libppmd.o ppmdfont.o standardppmdfont.o path.o \ diff --git a/lib/libpbmfont.c b/lib/libpbmfont.c index 5a604293..5193cd35 100644 --- a/lib/libpbmfont.c +++ b/lib/libpbmfont.c @@ -1,4 +1,4 @@ -/* libpbmfont.c - pbm utility library part 5 +/* ** ** Font routines. ** @@ -32,13 +32,6 @@ #include "pbmfont.h" #include "pbm.h" -/* Constants for the built-in fixed font and fonts loaded by - pbm_loadpbmfont(). - - These values are ignored when using the built-in BDF font, - or fonts loaded from files in BDF format by pbm_loadbdffont() . - For fonts loaded from BDF files code points between 0 and 255 are valid. -*/ static unsigned int const firstCodePoint = 32; /* This is the code point of the first character in a pbmfont font. In ASCII, it is a space. @@ -49,627 +42,6 @@ static unsigned int const nCharsInFont = 96; characters at position 32 (ASCII space) through 127, so that's 96. */ -/* The default font, packed in hex so this source file doesn't get huge. -** You can replace this with your own font using pbm_dumpfont(). -*/ -#define DEFAULTFONT_ROWS 155 -#define DEFAULTFONT_COLS 112 -static unsigned long int const -defaultfont_bits[DEFAULTFONT_ROWS][(DEFAULTFONT_COLS+31)/32] = { - {0x00000000L,0x20000c00L,0x10000000L,0x00000000L}, - {0xc600a000L,0x42000810L,0x00000002L,0x00000063L}, - {0x6c00a000L,0x45000810L,0x00000002L,0x00000036L}, - {0x6c00a000L,0x88800808L,0xf2e1dee2L,0x00000036L}, - {0x54000000L,0x80000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122282L,0x0000002aL}, - {0x44000102L,0x00000800L,0x11122382L,0x00000022L}, - {0xee000102L,0x00000800L,0x11e1e102L,0x00000077L}, - {0x00000204L,0x00000800L,0x11002102L,0x00000000L}, - {0x00000000L,0x00000c00L,0x11002102L,0x00000000L}, - {0x00000000L,0x003f8000L,0xe3807600L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x02000080L,0x00040000L,0x00120000L,0x00000001L}, - {0x04000082L,0x828e1838L,0x20210100L,0x00000002L}, - {0x04000082L,0x82912448L,0x20210100L,0x00000002L}, - {0x08000082L,0x8fd01940L,0x404087c2L,0x00000004L}, - {0x08000080L,0x050c0622L,0x00408102L,0x00000004L}, - {0x10000080L,0x05061874L,0x0040828fL,0x00008008L}, - {0x10000080L,0x1f912688L,0x00408002L,0x00000008L}, - {0x20000000L,0x0a11098cL,0x00408002L,0x00000010L}, - {0x20000080L,0x0a0e0672L,0x00210000L,0x00000010L}, - {0x40000000L,0x00040000L,0x00210000L,0x00000020L}, - {0x00000000L,0x00000000L,0x00120000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x004e0838L,0x7023e1cfL,0x00008000L}, - {0x00000000L,0x00913844L,0x88620208L,0x00008000L}, - {0x08000000L,0x00910844L,0x08a20401L,0x00000004L}, - {0x10000000L,0x01110844L,0x08a20401L,0x00000008L}, - {0x20000000L,0x01110808L,0x3123c781L,0x00000010L}, - {0x400003e0L,0x02110810L,0x0a202441L,0x00000020L}, - {0x20000000L,0x02110820L,0x0bf02442L,0x00000010L}, - {0x10008000L,0x04110844L,0x88242442L,0x00000008L}, - {0x08008002L,0x040e3e7cL,0x7073c382L,0x00000004L}, - {0x00010000L,0x08000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x0000e1c0L,0x00000000L,0x00000000L,0x00000000L}, - {0x00011220L,0x00000000L,0x70e38f87L,0x00000000L}, - {0x20011220L,0x00020020L,0x89108448L,0x00008010L}, - {0x10011220L,0x00040010L,0x09314448L,0x00008008L}, - {0x0800e221L,0x02083e08L,0x11514788L,0x00000004L}, - {0x040111e0L,0x00100004L,0x2153e448L,0x00000002L}, - {0x08011020L,0x00083e08L,0x213a2448L,0x00008004L}, - {0x10011040L,0x02040010L,0x01022448L,0x00008008L}, - {0x2000e381L,0x02020020L,0x20e77f87L,0x00000010L}, - {0x00000000L,0x04000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x3803e7efL,0xc73bbe3dL,0xdb863ce7L,0x0000001cL}, - {0x44011224L,0x48910808L,0x91036648L,0x00008022L}, - {0x4c011285L,0x48910808L,0xa1036648L,0x00008026L}, - {0x54011387L,0x081f0808L,0xc102a548L,0x0000802aL}, - {0x54011285L,0x09910808L,0xe102a548L,0x0000802aL}, - {0x4e011204L,0x08910848L,0x9112a4c8L,0x00008027L}, - {0x40011224L,0x08910848L,0x891224c8L,0x00008020L}, - {0x3803e7efL,0x073bbe31L,0xcff77e47L,0x0000001cL}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000003L,0x00000000L}, - {0x0003e1cfL,0x87bff7efL,0xdfbf77c2L,0x00000000L}, - {0x00013224L,0x48a4a244L,0x89122442L,0x00000000L}, - {0x00011224L,0x4824a244L,0xa8a14482L,0x00000000L}, - {0x00013227L,0x8e04226cL,0xa8414102L,0x00000000L}, - {0x0001e224L,0x83842228L,0xa8a08102L,0x00000000L}, - {0x00010224L,0x40842228L,0xd8a08242L,0x00000000L}, - {0x00010224L,0x48843638L,0x51108442L,0x00000000L}, - {0x0003c1ceL,0x6f1f1c10L,0x53b9c7c2L,0x00000000L}, - {0x00000060L,0x00000000L,0x00000002L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000003L,0x00000000L}, - {0xfe000000L,0x00000000L,0x00000000L,0x0000007fL}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00010180L,0x000000c0L,0x003001c0L,0x00000000L}, - {0x08008081L,0x00040040L,0x00100200L,0x00000004L}, - {0x10008082L,0x80040040L,0x00100200L,0x00000008L}, - {0x10004084L,0x40023c78L,0x70f1c7c7L,0x00004008L}, - {0x10004080L,0x00000244L,0x89122208L,0x00008008L}, - {0x20002080L,0x00001e44L,0x8113e208L,0x00008010L}, - {0x10002080L,0x00002244L,0x81120208L,0x00008008L}, - {0x10001080L,0x00002244L,0x89122208L,0x00008008L}, - {0x10001080L,0x00001db8L,0x70e9c787L,0x00008008L}, - {0x10000880L,0x00000000L,0x00000000L,0x00008008L}, - {0x08000180L,0x00000000L,0x00000000L,0x00008004L}, - {0x00000000L,0x1fc00000L,0x00000007L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00030080L,0x981c0000L,0x00000000L,0x00000000L}, - {0x20010000L,0x08040000L,0x00000000L,0x00000010L}, - {0x10010000L,0x08040000L,0x00000000L,0x00000008L}, - {0x10016387L,0x898474b8L,0x72e1d5c7L,0x00000008L}, - {0x10019080L,0x8a042a64L,0x89122208L,0x00008008L}, - {0x08011080L,0x8c042a44L,0x89122207L,0x00000004L}, - {0x10011080L,0x8a042a44L,0x89122200L,0x00008008L}, - {0x10011080L,0x89042a44L,0x89122208L,0x00008008L}, - {0x1003bbe0L,0x98dfebe6L,0x71e1e787L,0x00000008L}, - {0x10000000L,0x80000000L,0x01002000L,0x00000008L}, - {0x20000000L,0x80000000L,0x01002000L,0x00000010L}, - {0x00000007L,0x00000000L,0x03807000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00008000L,0x00000000L,0x10410000L,0x00000000L}, - {0x00008000L,0x00000000L,0x20408000L,0x00000000L}, - {0x0001f66eL,0xfdfbf77cL,0x20408000L,0x00000000L}, - {0x24008224L,0x488a2248L,0x20408240L,0x00000012L}, - {0x54008224L,0x4a842210L,0x40404540L,0x0000002aL}, - {0x48008222L,0x8a8a1420L,0x20408480L,0x00000024L}, - {0x00008a23L,0x85111c44L,0x20408000L,0x00000000L}, - {0x000071d1L,0x0531887cL,0x20408000L,0x00000000L}, - {0x00000000L,0x00000800L,0x20408000L,0x00000000L}, - {0x00000000L,0x00000800L,0x10410000L,0x00000000L}, - {0x00000000L,0x00003000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x20000c00L,0x10000000L,0x00000000L}, - {0xc600a000L,0x42000810L,0x00000002L,0x00000063L}, - {0x6c00a000L,0x45000810L,0x00000002L,0x00000036L}, - {0x6c00a000L,0x88800808L,0xf2e1dee2L,0x00000036L}, - {0x54000000L,0x80000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122282L,0x0000002aL}, - {0x44000102L,0x00000800L,0x11122382L,0x00000022L}, - {0xee000102L,0x00000800L,0x11e1e102L,0x00000077L}, - {0x00000204L,0x00000800L,0x11002102L,0x00000000L}, - {0x00000000L,0x00000c00L,0x11002102L,0x00000000L}, - {0x00000000L,0x003f8000L,0xe3807600L,0x00000000L} - }; - -/* A default BDF font */ -/* Not as nicely compacted as the PBM font, oh well. */ - -static struct glyph _g[190] = { - { 1, 1, 0, 0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\1\1\0\1" }, - { 6, 9, 0, 0, 6, "\0\0\0\1\0\0\0\0\1\0\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, - { 6, 9, 0, 0, 6, "\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, - { 6, 8, 0, 0, 6, "\0\1\0\1\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, - { 6, 12, 0, -3, 6, "\0\0\0\0\1\0\0\0\0\1\0\0\0\0\0\0\0\0\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" }, - { 5, 12, 0, -3, 6, "\1\1\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\1\0\0" }, - { 6, 11, 0, -3, 6, "\0\1\0\0\1\0\0\0\0\0\0\0\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" } -}; - -static struct font default_bdffont = { 14, 15, -1, -3, { - 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, - _g + 0, - _g + 1, - _g + 2, - _g + 3, - _g + 4, - _g + 5, - _g + 6, - _g + 7, - _g + 8, - _g + 9, - _g + 10, - _g + 11, - _g + 12, - _g + 13, - _g + 14, - _g + 15, - _g + 16, - _g + 17, - _g + 18, - _g + 19, - _g + 20, - _g + 21, - _g + 22, - _g + 23, - _g + 24, - _g + 25, - _g + 26, - _g + 27, - _g + 28, - _g + 29, - _g + 30, - _g + 31, - _g + 32, - _g + 33, - _g + 34, - _g + 35, - _g + 36, - _g + 37, - _g + 38, - _g + 39, - _g + 40, - _g + 41, - _g + 42, - _g + 43, - _g + 44, - _g + 45, - _g + 46, - _g + 47, - _g + 48, - _g + 49, - _g + 50, - _g + 51, - _g + 52, - _g + 53, - _g + 54, - _g + 55, - _g + 56, - _g + 57, - _g + 58, - _g + 59, - _g + 60, - _g + 61, - _g + 62, - _g + 63, - _g + 64, - _g + 65, - _g + 66, - _g + 67, - _g + 68, - _g + 69, - _g + 70, - _g + 71, - _g + 72, - _g + 73, - _g + 74, - _g + 75, - _g + 76, - _g + 77, - _g + 78, - _g + 79, - _g + 80, - _g + 81, - _g + 82, - _g + 83, - _g + 84, - _g + 85, - _g + 86, - _g + 87, - _g + 88, - _g + 89, - _g + 90, - _g + 91, - _g + 92, - _g + 93, - _g + 94, - 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, - _g + 95, - _g + 96, - _g + 97, - _g + 98, - _g + 99, - _g + 100, - _g + 101, - _g + 102, - _g + 103, - _g + 104, - _g + 105, - _g + 106, - _g + 107, - _g + 108, - _g + 109, - _g + 110, - _g + 111, - _g + 112, - _g + 113, - _g + 114, - _g + 115, - _g + 116, - _g + 117, - _g + 118, - _g + 119, - _g + 120, - _g + 121, - _g + 122, - _g + 123, - _g + 124, - _g + 125, - _g + 126, - _g + 127, - _g + 128, - _g + 129, - _g + 130, - _g + 131, - _g + 132, - _g + 133, - _g + 134, - _g + 135, - _g + 136, - _g + 137, - _g + 138, - _g + 139, - _g + 140, - _g + 141, - _g + 142, - _g + 143, - _g + 144, - _g + 145, - _g + 146, - _g + 147, - _g + 148, - _g + 149, - _g + 150, - _g + 151, - _g + 152, - _g + 153, - _g + 154, - _g + 155, - _g + 156, - _g + 157, - _g + 158, - _g + 159, - _g + 160, - _g + 161, - _g + 162, - _g + 163, - _g + 164, - _g + 165, - _g + 166, - _g + 167, - _g + 168, - _g + 169, - _g + 170, - _g + 171, - _g + 172, - _g + 173, - _g + 174, - _g + 175, - _g + 176, - _g + 177, - _g + 178, - _g + 179, - _g + 180, - _g + 181, - _g + 182, - _g + 183, - _g + 184, - _g + 185, - _g + 186, - _g + 187, - _g + 188, - _g + 189 - } -}; - - struct font * pbm_defaultfont(const char * const name) { @@ -678,39 +50,13 @@ pbm_defaultfont(const char * const name) { -----------------------------------------------------------------------------*/ struct font * retval; - if (strcmp(name, "bdf") == 0) - retval = &default_bdffont; - else { - bit** defaultfont; - unsigned int row; + if (streq(name, "bdf")) + retval = &pbm_defaultBdffont; + else if (streq(name, "fixed")) + retval = &pbm_defaultFixedfont; + else + pm_error( "built-in font name unknown, try 'bdf' or 'fixed'"); - if (strcmp(name, "fixed") != 0) - pm_error( "built-in font name unknown, try 'bdf' or 'fixed'"); - - defaultfont = pbm_allocarray(DEFAULTFONT_COLS, DEFAULTFONT_ROWS); - for (row = 0; row < DEFAULTFONT_ROWS; ++row) { - unsigned int col; - for (col = 0; col < DEFAULTFONT_COLS; col += 32) { - int scol; - unsigned long l; - - l = defaultfont_bits[row][col / 32]; /* initial value */ - - for (scol = MIN( col + 32, DEFAULTFONT_COLS) - 1; - scol >= (int)col; - --scol) { - if (l & 0x01) - defaultfont[row][scol] = 1; - else - defaultfont[row][scol] = 0; - l >>= 1; - } - } - } - retval = - pbm_dissectfont((const bit **)defaultfont, - DEFAULTFONT_ROWS, DEFAULTFONT_COLS); - } return retval; } @@ -956,38 +302,31 @@ pbm_dissectfont(const bit ** const font, -struct font* +struct font * pbm_loadfont(const char * const filename) { -/*---------------------------------------------------------------------------- -Read the head of the designated font file, determine its type and load -the font. -Note that fgets() writes nothing to the line buffer when the file exists -but is empty. -----------------------------------------------------------------------------*/ - FILE* fp; - struct font * fn; - char * line; - - MALLOCARRAY_NOFAIL(line, 10); + FILE * fileP; + struct font * fontP; + char line[256]; - line[0] = '\0'; - fp = pm_openr( filename ); - fgets(line, 10, fp); - pm_close( fp ); + fileP = pm_openr(filename); + fgets(line, 256, fileP); + pm_close(fileP); if (line[0] == PBM_MAGIC1 && (line[1] == PBM_MAGIC2 || line[1] == RPBM_MAGIC2)) { - fn = pbm_loadpbmfont( filename ); + fontP = pbm_loadpbmfont(filename); } else if (!strncmp(line, "STARTFONT", 9)) { - if (!(fn = pbm_loadbdffont( filename ))) - pm_error( "could not load BDF font file" ); + fontP = pbm_loadbdffont(filename); + if (!fontP) + pm_error("could not load BDF font file"); } else { - pm_error( "font file not in a recognized format "); - fn = NULL; /* Supress compiler error. This line never reached. */ - } - free(line); - return (fn); + pm_error("font file not in a recognized format. Does not start " + "with the signature of a PBM file or BDF font file"); + assert(false); + fontP = NULL; /* defeat compiler warning */ + } + return fontP; } @@ -1008,100 +347,73 @@ pbm_loadpbmfont(const char * const filename) { void -pbm_dumpfont( fn ) - struct font* fn; -{ - /* Dump out font as C source code. */ - int row, col, scol, lperrow; - unsigned long l; - - if (fn->oldfont) { - printf( "#define DEFAULTFONT_ROWS %d\n", fn->frows ); - printf( "#define DEFAULTFONT_COLS %d\n", fn->fcols ); - printf( "static unsigned long defaultfont_bits[DEFAULTFONT_ROWS][(DEFAULTFONT_COLS+31)/32] = {\n" ); - for ( row = 0; row < fn->frows; ++row ) - { - lperrow = 0; - for ( col = 0; col < fn->fcols; col += 32 ) - { - if ( lperrow == 0 ) - printf( " {" ); - else if ( lperrow % 6 == 0 ) - { - printf( ",\n " ); - lperrow = 0; - } - else - printf( "," ); - l = 0; - for ( scol = col; scol < MIN( col + 32, fn->fcols ); ++scol ) - { - l <<= 1; - if ( fn->oldfont[row][scol] ) - l |= 1; - } - printf( "0x%08lxL", l ); - ++lperrow; - } - printf( "}%s\n", row == fn->frows - 1 ? "" : "," ); - } - printf( " };\n" ); - } - else { - struct glyph* glyph; - int i, j, ng; +pbm_dumpfont(struct font * const fontP, + FILE * const ofP) { +/*---------------------------------------------------------------------------- + Dump out font as C source code. +-----------------------------------------------------------------------------*/ + unsigned int i; + unsigned int ng; - ng = 0; - for (i = 0; i < 256; i++) - if (fn->glyph[i]) - ng++; + if (fontP->oldfont) + pm_message("Netpbm no longer has the capability to generate " + "a font in long hexadecimal data format"); - printf("static struct glyph _g[%d] = {\n", ng); - for (i = 0; i < 256; i++) { - if (!(glyph = fn->glyph[i])) - continue; + for (i = 0, ng = 0; i < 256; ++i) { + if (fontP->glyph[i]) + ++ng; + } - printf(" { %d, %d, %d, %d, %d, \"", glyph->width, glyph->height, - glyph->x, glyph->y, glyph->xadd); + printf("static struct glyph _g[%d] = {\n", ng); - for (j = 0; j < glyph->width * glyph->height; j++) - if (glyph->bmap[j]) - printf("\\1"); - else - printf("\\0"); - - ng--; - printf("\" }%s\n", ng ? "," : ""); + for (i = 0; i < 256; ++i) { + struct glyph * const glyphP = fontP->glyph[i]; + if (glyphP) { + unsigned int j; + printf(" { %d, %d, %d, %d, %d, \"", glyphP->width, glyphP->height, + glyphP->x, glyphP->y, glyphP->xadd); + + for (j = 0; j < glyphP->width * glyphP->height; ++j) { + if (glyphP->bmap[j]) + printf("\\1"); + else + printf("\\0"); + } + --ng; + printf("\" }%s\n", ng ? "," : ""); + } } printf("};\n"); - printf("static struct font default_bdffont = { %d, %d, %d, %d, {\n", - fn->maxwidth, fn->maxheight, fn->x, fn->y); + printf("struct font XXX_font = { %d, %d, %d, %d, {\n", + fontP->maxwidth, fontP->maxheight, fontP->x, fontP->y); - for (i = 0; i < 256; i++) { - if (fn->glyph[i]) - printf(" _g + %d", ng++); - else - printf(" 0"); + { + unsigned int i; + + for (i = 0; i < 256; ++i) { + if (fontP->glyph[i]) + printf(" _g + %d", ng++); + else + printf(" NULL"); - if (i != 255) printf(","); - printf("\n"); + if (i != 255) printf(","); + printf("\n"); + } } printf(" }\n};\n"); - exit(0); - - } - } + /* Routines for loading a BDF font file */ #define MAXBDFLINE 1024 /* Official Adobe document says max length of string is 65535 characters. - However the value 1024 is sufficient for practical uses. */ + However the value 1024 is sufficient for practical uses. +*/ typedef struct { /*---------------------------------------------------------------------------- @@ -1118,12 +430,12 @@ typedef struct { */ const char * arg[32]; /* These are the words; each entry is a pointer into line[] (above) */ -} readline; +} Readline; static void -readline_init(readline * const readlineP, +readline_init(Readline * const readlineP, FILE * const ifP) { readlineP->ifP = ifP; @@ -1167,7 +479,7 @@ tokenize(char * const s, static void -readline_read(readline * const readlineP, +readline_read(Readline * const readlineP, bool * const eofP) { /*---------------------------------------------------------------------------- Read a nonblank line from the file. Make its contents available @@ -1260,7 +572,7 @@ parseBitmapRow(const char * const hex, static void -readBitmap(readline * const readlineP, +readBitmap(Readline * const readlineP, unsigned int const glyphWidth, unsigned int const glyphHeight, const char * const charName, @@ -1301,7 +613,7 @@ readBitmap(readline * const readlineP, static void createBmap(unsigned int const glyphWidth, unsigned int const glyphHeight, - readline * const readlineP, + Readline * const readlineP, const char * const charName, const char ** const bmapP) { @@ -1343,7 +655,7 @@ createBmap(unsigned int const glyphWidth, static void -readExpectedStatement(readline * const readlineP, +readExpectedStatement(Readline * const readlineP, const char * const expected) { /*---------------------------------------------------------------------------- Have the readline object *readlineP read the next line from the file, but @@ -1365,7 +677,7 @@ readExpectedStatement(readline * const readlineP, static void -skipCharacter(readline * const readlineP) { +skipCharacter(Readline * const readlineP) { /*---------------------------------------------------------------------------- In the BDF font file being read by readline object *readlineP, skip through the end of the character we are presently in. @@ -1428,7 +740,7 @@ interpEncoding(const char ** const arg, static void -readEncoding(readline * const readlineP, +readEncoding(Readline * const readlineP, unsigned int * const codepointP, bool * const badCodepointP) { @@ -1438,53 +750,56 @@ readEncoding(readline * const readlineP, } + static void validateFontLimits(const struct font * const fontP) { assert( pbm_maxfontheight() > 0 && pbm_maxfontwidth() > 0 ); - if ( fontP->maxwidth <= 0 || - fontP->maxheight <= 0 || - fontP->maxwidth > pbm_maxfontwidth() || - fontP->maxheight > pbm_maxfontheight() || - fontP->x < - fontP->maxwidth +1 || - fontP->y < - fontP->maxheight +1 || - fontP->x > fontP->maxwidth || - fontP->y > fontP->maxheight || - fontP->x + fontP->maxwidth > pbm_maxfontwidth() || + if (fontP->maxwidth <= 0 || + fontP->maxheight <= 0 || + fontP->maxwidth > pbm_maxfontwidth() || + fontP->maxheight > pbm_maxfontheight() || + fontP->x < - fontP->maxwidth +1 || + fontP->y < - fontP->maxheight +1 || + fontP->x > fontP->maxwidth || + fontP->y > fontP->maxheight || + fontP->x + fontP->maxwidth > pbm_maxfontwidth() || fontP->y + fontP->maxheight > pbm_maxfontheight() - ) + ) { - pm_error("Global font metric(s) out of bounds.\n"); + pm_error("Global font metric(s) out of bounds.\n"); + } } static void validateGlyphLimits(const struct font * const fontP, - const struct glyph * const glyphP, - const char * const charName) { - - if ( glyphP->width == 0 || - glyphP->height == 0 || - glyphP->width > fontP->maxwidth || - glyphP->height > fontP->maxheight || - glyphP->width > fontP->maxwidth || - glyphP->height > fontP->maxheight || - glyphP->x < fontP->x || - glyphP->y < fontP->y || - glyphP->x + (int) glyphP->width > fontP->x + fontP->maxwidth || - glyphP->y + (int) glyphP->height > fontP->y + fontP->maxheight || - glyphP->xadd > pbm_maxfontwidth() || - glyphP->xadd + MAX(glyphP->x,0) + (int) glyphP->width > - pbm_maxfontwidth() - ) - pm_error("Font metric(s) for char '%s' out of bounds.\n", charName); + const struct glyph * const glyphP, + const char * const charName) { + + if (glyphP->width == 0 || + glyphP->height == 0 || + glyphP->width > fontP->maxwidth || + glyphP->height > fontP->maxheight || + glyphP->x < fontP->x || + glyphP->y < fontP->y || + glyphP->x + (int) glyphP->width > fontP->x + fontP->maxwidth || + glyphP->y + (int) glyphP->height > fontP->y + fontP->maxheight || + glyphP->xadd > pbm_maxfontwidth() || + glyphP->xadd + MAX(glyphP->x,0) + (int) glyphP->width > + pbm_maxfontwidth() + ) { + + pm_error("Font metric(s) for char '%s' out of bounds.\n", charName); + } } + static void -processChars(readline * const readlineP, +processChars(Readline * const readlineP, struct font * const fontP) { /*---------------------------------------------------------------------------- Process the CHARS block in a BDF font file, assuming the file is positioned @@ -1527,9 +842,9 @@ processChars(readline * const readlineP, if (badCodepoint) skipCharacter(readlineP); - else if (fontP->glyph[codepoint] != NULL) - pm_error("Multiple definition of code point %d " - "in font file", (unsigned int) codepoint); + else if (fontP->glyph[codepoint] != NULL) + pm_error("Multiple definition of code point %d " + "in font file", (unsigned int) codepoint); else { readExpectedStatement(readlineP, "SWIDTH"); @@ -1563,7 +878,7 @@ processChars(readline * const readlineP, static void -processBdfFontLine(readline * const readlineP, +processBdfFontLine(Readline * const readlineP, struct font * const fontP, bool * const endOfFontP) { /*---------------------------------------------------------------------------- @@ -1598,13 +913,13 @@ processBdfFontLine(readline * const readlineP, validateFontLimits(fontP); } else if (streq(readlineP->arg[0], "ENDPROPERTIES")) { if (fontP->maxwidth ==0) - pm_error("Encountered ENDPROPERTIES before FONTBOUNDINGBOX " + pm_error("Encountered ENDPROPERTIES before FONTBOUNDINGBOX " "in BDF font file"); } else if (streq(readlineP->arg[0], "ENDFONT")) { *endOfFontP = true; } else if (streq(readlineP->arg[0], "CHARS")) { if (fontP->maxwidth ==0) - pm_error("Encountered CHARS before FONTBOUNDINGBOX " + pm_error("Encountered CHARS before FONTBOUNDINGBOX " "in BDF font file"); else processChars(readlineP, fontP); @@ -1619,7 +934,7 @@ struct font * pbm_loadbdffont(const char * const name) { FILE * ifP; - readline readline; + Readline readline; struct font * fontP; bool endOfFont; @@ -1660,3 +975,6 @@ pbm_loadbdffont(const char * const name) { } return fontP; } + + + diff --git a/lib/libsystem.c b/lib/libsystem.c index 77f874cb..9491c03a 100644 --- a/lib/libsystem.c +++ b/lib/libsystem.c @@ -1,12 +1,17 @@ /*============================================================================= pm_system =============================================================================== - This is the library subroutine pm_system(). It is just like Standard C - Library system(), except that you can supply routines for it to run to - generate the Standard Input for the executed shell command and to accept - the Standard Output from it. system(), by contrast, always sets up the - current Standard Input and Standard Output as the Standard Input and - Standard Output of the shell command. + This is the pm_system() family of subroutines. + + pm_system() is just like Standard C Library system(), except that you can + supply routines for it to run to generate the Standard Input for the + executed shell command and to accept the Standard Output from it. + system(), by contrast, always sets up the current Standard Input and + Standard Output as the Standard Input and Standard Output of the shell + command. + + pm_system_lp() and pm_system_vp() are similar, but exec an OS-level program + (i.e. exec a program) rather than run a shell command. By Bryan Henderson, San Jose CA 2002.12.14. @@ -26,6 +31,7 @@ #include "netpbm/pm_c_util.h" #include "netpbm/mallocvar.h" +#include "netpbm/nstring.h" #include "pm.h" #include "pm_system.h" @@ -164,7 +170,7 @@ spawnProcessor(const char * const progName, /*---------------------------------------------------------------------------- Create a process to run program 'progName' with arguments argArray[] (terminated by NULL element). Pass file descriptor - 'stdinFd' to the shell as Standard Input. + 'stdinFd' to the process as Standard Input. if 'stdoutFdP' is NULL, have that process write its Standard Output to the current process' Standard Output. @@ -313,26 +319,44 @@ signalName(unsigned int const signalClass) { -static void -cleanupProcessorProcess(pid_t const processorPid) { +const char * +pm_termStatusDesc(int const termStatusArg) { +/*---------------------------------------------------------------------------- + English description of process termination status 'termStatus'. +-----------------------------------------------------------------------------*/ + const char * retval; + + /* WIFEXITED, etc. do not work with a constant argument in older GNU C + library. Compilation fails with "attempt to assign read-only + location". This is because The GNU C library has some magic to allow + for a BSD 'union wait' (instead of int) argument to WIFEXITED. The + magic involves defining a variable with 'typeof' the argument and + assigning to that variable. + + To work around this, we make sure the argument is not constant. + */ - int terminationStatus; - waitpid(processorPid, &terminationStatus, 0); + int termStatus = termStatusArg; - if (WIFEXITED(terminationStatus)) { - int const exitStatus = WEXITSTATUS(terminationStatus); + if (WIFEXITED(termStatus)) { + int const exitStatus = WEXITSTATUS(termStatus); - if (exitStatus != 0) - pm_message("Shell process exited with abnormal exit status %u. ", - exitStatus); - } else if (WIFSIGNALED(terminationStatus)) { - pm_message("Shell process was killed by a Class %u (%s) signal.", - WTERMSIG(terminationStatus), - signalName(WTERMSIG(terminationStatus))); + if (exitStatus == 0) + pm_asprintf(&retval, "Process exited normally"); + else + pm_asprintf(&retval, + "Process exited with abnormal exit status %u. ", + exitStatus); + } else if (WIFSIGNALED(termStatus)) { + pm_asprintf(&retval, "Process was killed by a Class %u (%s) signal.", + WTERMSIG(termStatus), + signalName(WTERMSIG(termStatus))); } else { - pm_message("Shell process died, but its termination status " - "0x%x doesn't make sense", terminationStatus); + pm_asprintf(&retval, "Process died, but its termination status " + "0x%x doesn't make sense", termStatus); } + + return retval; } @@ -347,7 +371,7 @@ cleanupFeederProcess(pid_t const feederPid) { if (WTERMSIG(status) == SIGPIPE) pm_message("WARNING: " "Standard Input feeder process was terminated by a " - "SIGPIPE signal because the shell command closed its " + "SIGPIPE signal because the program closed its " "Standard Input before the Standard Input feeder was " "through feeding it."); else @@ -369,12 +393,13 @@ cleanupFeederProcess(pid_t const feederPid) { void -pm_system_vp(const char * const progName, - const char ** const argArray, - void stdinFeeder(int, void *), - void * const feederParm, - void stdoutAccepter(int, void *), - void * const accepterParm) { +pm_system2_vp(const char * const progName, + const char ** const argArray, + void stdinFeeder(int, void *), + void * const feederParm, + void stdoutAccepter(int, void *), + void * const accepterParm, + int * const termStatusP) { /*---------------------------------------------------------------------------- Run a program in a child process. Feed its Standard Input with a pipe, which is fed by the routine 'stdinFeeder' with parameter @@ -387,6 +412,9 @@ pm_system_vp(const char * const progName, Run the program 'progName' with arguments argArray[] (terminated by NULL element). That includes arg0. + + Return as *termStatusP the termination status of the processor process + (the one running the program named 'progName'). -----------------------------------------------------------------------------*/ /* If 'stdinFeeder' is non-NULL, we create a child process to run 'stdinFeeder' and create a pipe from that process as the @@ -409,6 +437,7 @@ pm_system_vp(const char * const progName, int progStdinFd; pid_t feederPid; pid_t processorPid; + int termStatus; if (stdinFeeder) createPipeFeeder(stdinFeeder, feederParm, &progStdinFd, &feederPid); @@ -440,10 +469,118 @@ pm_system_vp(const char * const progName, spawnProcessor(progName, argArray, progStdinFd, NULL, &processorPid); } - cleanupProcessorProcess(processorPid); + waitpid(processorPid, &termStatus, 0); if (feederPid) cleanupFeederProcess(feederPid); + + *termStatusP = termStatus; +} + + + +void +pm_system2_lp(const char * const progName, + void stdinFeeder(int, void *), + void * const feederParm, + void stdoutAccepter(int, void *), + void * const accepterParm, + int * const termStatusP, + ...) { +/*---------------------------------------------------------------------------- + Same as pm_system_vp() except with arguments as variable arguments + instead of an array. + + N.B. the first variable argument is the program's arg 0; the last + variable argument must be NULL. +-----------------------------------------------------------------------------*/ + va_list args; + bool endOfArgs; + const char ** argArray; + unsigned int n; + + va_start(args, termStatusP); + + endOfArgs = FALSE; + argArray = NULL; + + for (endOfArgs = FALSE, argArray = NULL, n = 0; + !endOfArgs; + ) { + const char * const arg = va_arg(args, const char *); + + REALLOCARRAY(argArray, n+1); + + argArray[n++] = arg; + + if (!arg) + endOfArgs = TRUE; + } + + va_end(args); + + pm_system2_vp(progName, argArray, + stdinFeeder, feederParm, stdoutAccepter, accepterParm, + termStatusP); + + free(argArray); +} + + + +void +pm_system2(void stdinFeeder(int, void *), + void * const feederParm, + void stdoutAccepter(int, void *), + void * const accepterParm, + const char * const shellCommand, + int * const termStatusP) { +/*---------------------------------------------------------------------------- + Run a shell and have it run command 'shellCommand'. Feed its + Standard Input with a pipe, which is fed by the routine + 'stdinFeeder' with parameter 'feederParm'. Process its Standard + Output with the routine 'stdoutAccepter' with parameter 'accepterParm'. + + But if 'stdinFeeder' is NULL, just feed the shell our own Standard + Input. And if 'stdoutFeeder' is NULL, just send its Standard Output + to our own Standard Output. + + Return as *termStatusP the termination status of the processor process + (the one running the program named 'progName'). +-----------------------------------------------------------------------------*/ + pm_system2_lp("/bin/sh", + stdinFeeder, feederParm, stdoutAccepter, accepterParm, + termStatusP, + "sh", "-c", shellCommand, NULL); +} + + + +void +pm_system_vp(const char * const progName, + const char ** const argArray, + void stdinFeeder(int, void *), + void * const feederParm, + void stdoutAccepter(int, void *), + void * const accepterParm) { +/*---------------------------------------------------------------------------- + Same as pm_system2_vp(), except instead of returning the termination + status, we just issue a message (pm_message) describing it. +-----------------------------------------------------------------------------*/ + int termStatus; + + pm_system2_vp(progName, argArray, + stdinFeeder, feederParm, + stdoutAccepter, accepterParm, + &termStatus); + + if (termStatus != 0) { + const char * const msg = pm_termStatusDesc(termStatus); + + pm_message("%s", msg); + + pm_strfree(msg); + } } @@ -456,8 +593,11 @@ pm_system_lp(const char * const progName, void * const accepterParm, ...) { /*---------------------------------------------------------------------------- - same as pm_system_vp() except with arguments as variable arguments + Same as pm_system_vp() except with arguments as variable arguments instead of an array. + + N.B. the first variable argument is the program's arg 0; the last + variable argument must be NULL. -----------------------------------------------------------------------------*/ va_list args; bool endOfArgs; @@ -499,19 +639,62 @@ pm_system(void stdinFeeder(int, void *), void * const accepterParm, const char * const shellCommand) { /*---------------------------------------------------------------------------- - Run a shell and have it run command 'shellCommand'. Feed its - Standard Input with a pipe, which is fed by the routine - 'stdinFeeder' with parameter 'feederParm'. Process its Standard - Output with the routine 'stdoutAccepter' with parameter 'accepterParm'. - - But if 'stdinFeeder' is NULL, just feed the shell our own Standard - Input. And if 'stdoutFeeder' is NULL, just send its Standard Output - to our own Standard Output. + Same as pm_system2(), except instead of returning the termination status, + we just issue a message (pm_message) describing it. -----------------------------------------------------------------------------*/ + int termStatus; + + pm_system2(stdinFeeder, feederParm, stdoutAccepter, accepterParm, + shellCommand, + &termStatus); + + if (termStatus != 0) { + const char * const msg = pm_termStatusDesc(termStatus); + + pm_message("%s", msg); + + pm_strfree(msg); + } +} + + + +void +pm_feed_null(int const pipeToFeedFd, + void * const feederParm) { + +} - pm_system_lp("/bin/sh", - stdinFeeder, feederParm, stdoutAccepter, accepterParm, - "sh", "-c", shellCommand, NULL); + + +void +pm_accept_null(int const pipetosuckFd, + void * const accepterParm ) { + + size_t const bufferSize = 4096; + + unsigned char * buffer; + + MALLOCARRAY(buffer, bufferSize); + + if (buffer) { + bool eof; + + for (eof = false; !eof; ) { + ssize_t rc; + + rc = read(pipetosuckFd, buffer, bufferSize); + + if (rc < 0) { + /* No way to report the problem; just say we're done */ + eof = true; + } else if (rc == 0) + /* eof */ + eof = true; + } + free(buffer); + } + close(pipetosuckFd); } @@ -520,7 +703,7 @@ void pm_feed_from_memory(int const pipeToFeedFd, void * const feederParm) { - struct bufferDesc * const inputBufferP = feederParm; + pm_bufferDesc * const inputBufferP = feederParm; FILE * const outFileP = fdopen(pipeToFeedFd, "w"); @@ -544,7 +727,7 @@ void pm_accept_to_memory(int const pipetosuckFd, void * const accepterParm ) { - struct bufferDesc * const outputBufferP = accepterParm; + pm_bufferDesc * const outputBufferP = accepterParm; FILE * const inFileP = fdopen(pipetosuckFd, "r"); @@ -558,3 +741,6 @@ pm_accept_to_memory(int const pipetosuckFd, if (outputBufferP->bytesTransferredP) *(outputBufferP->bytesTransferredP) = bytesTransferred; } + + + diff --git a/lib/pbmfont.h b/lib/pbmfont.h index 61c88685..5111a075 100644 --- a/lib/pbmfont.h +++ b/lib/pbmfont.h @@ -76,15 +76,29 @@ struct font { int fcols, frows; }; -struct font* pbm_defaultfont(const char* const which); -struct font* +struct font * +pbm_defaultfont(const char* const which); + +struct font * pbm_dissectfont(const bit ** const font, unsigned int const frows, unsigned int const fcols); -struct font* pbm_loadfont(const char * const filename); -struct font* pbm_loadpbmfont(const char * const filename); -struct font* pbm_loadbdffont(const char * const filename); -void pbm_dumpfont(struct font * const fnP); + +struct font * +pbm_loadfont(const char * const filename); + +struct font * +pbm_loadpbmfont(const char * const filename); + +struct font * +pbm_loadbdffont(const char * const filename); + +void +pbm_dumpfont(struct font * const fontP, + FILE * const ofP); + +extern struct font pbm_defaultFixedfont; +extern struct font pbm_defaultBdffont; #ifdef __cplusplus } diff --git a/lib/pbmfontdata1.c b/lib/pbmfontdata1.c new file mode 100644 index 00000000..8552d29e --- /dev/null +++ b/lib/pbmfontdata1.c @@ -0,0 +1,253 @@ +#include "pbmfont.h" + +/* Default fixed-width font + All glyphs fit into a 7 x 12 rectangular cell. + Raster data is provided completely. + + This kind of font, commonly used on early bitmap displays, is + sometimes called "cell-char". + + + Note: In the current version default_fixedfont is fixed data, which + means it is always accessible, without any preparatory action. + However, the storage format may change in future versions. + + To ensure future compatibility call pbm_defaultfont() before accessing + default_fixedfont. + + The Netpbm development tool 'genfontc' generates C source code like this + from a libnetpbm font file or builtin font. +*/ + +static struct glyph glFxd[96] = { +/* 32 character */ +{7,12,0,0,7,"\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\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\0\0\0\0\0\0\0\0\0\0\0\0\0\0" }, +/* 33 character ! */ +{7,12,0,0,7,"\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\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" }, +/* 34 character " */ +{7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\1\0\0\0\0\1\0\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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" }, +/* 35 character # */ +{7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\1\0\0\1\1\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\0\0\0\0\0\0\0" }, +/* 125 character } */ +{7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0" }, +/* 126 character ~ */ +{7,12,0,0,7,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\1\0\0\1\0\1\0\1\0\0\1\0\0\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\0\0" }, +/* 127 character (?) */ +{7,12,0,0,7,"\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\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\0\0\0\0\0\0\0\0\0\0\0\0\0\0" } +}; + + + +struct font pbm_defaultFixedfont = { 7, 12, 0, 0, { +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +glFxd+ 0, glFxd+ 1, glFxd+ 2, glFxd+ 3, glFxd+ 4, glFxd+ 5, +glFxd+ 6, glFxd+ 7, glFxd+ 8, glFxd+ 9, glFxd+10, glFxd+11, +glFxd+12, glFxd+13, glFxd+14, glFxd+15, glFxd+16, glFxd+17, +glFxd+18, glFxd+19, glFxd+20, glFxd+21, glFxd+22, glFxd+23, +glFxd+24, glFxd+25, glFxd+26, glFxd+27, glFxd+28, glFxd+29, +glFxd+30, glFxd+31, glFxd+32, glFxd+33, glFxd+34, glFxd+35, +glFxd+36, glFxd+37, glFxd+38, glFxd+39, glFxd+40, glFxd+41, +glFxd+42, glFxd+43, glFxd+44, glFxd+45, glFxd+46, glFxd+47, +glFxd+48, glFxd+49, glFxd+50, glFxd+51, glFxd+52, glFxd+53, +glFxd+54, glFxd+55, glFxd+56, glFxd+57, glFxd+58, glFxd+59, +glFxd+60, glFxd+61, glFxd+62, glFxd+63, glFxd+64, glFxd+65, +glFxd+66, glFxd+67, glFxd+68, glFxd+69, glFxd+70, glFxd+71, +glFxd+72, glFxd+73, glFxd+74, glFxd+75, glFxd+76, glFxd+77, +glFxd+78, glFxd+79, glFxd+80, glFxd+81, glFxd+82, glFxd+83, +glFxd+84, glFxd+85, glFxd+86, glFxd+87, glFxd+88, glFxd+89, +glFxd+90, glFxd+91, glFxd+92, glFxd+93, glFxd+94, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} +}; + + + diff --git a/lib/pbmfontdata2.c b/lib/pbmfontdata2.c new file mode 100644 index 00000000..336fc773 --- /dev/null +++ b/lib/pbmfontdata2.c @@ -0,0 +1,444 @@ +#include "pbmfont.h" + +/* Default proportional font. + BDF-style advance value, bounding box dimensions and point of origin. + + + Note: In the current version default_bdffont is fixed data, which + means it is always accessible, without any preparatory action. + However, the storage format may change in future versions. + + To ensure future compatibility call pbm_defaultfont() before accessing + default_bdffont. + + The Netpbm development tool 'genfontc' generates C source code like this + from a libnetpbm font file or builtin font. +*/ + +static struct glyph glBdf[190] = { +/* 32 character */ +{ 1, 1, 0, 0, 3, "\0" }, +/* 33 character ! */ +{ 1, 9, 1, 0, 3, "\1\1\1\1\1\1\1\0\1" }, +/* 34 character " */ +{ 3, 3, 1, 6, 5, "\1\0\1\1\0\1\1\0\1" }, +/* 35 character # */ +{ 5, 8, 0, 0, 6, "\0\1\0\1\0\0\1\0\1\0\1\1\1\1\1\0\1\0\1\0\0\1\0\1\0\1\1\1\1\1\0\1\0\1\0\0\1\0\1\0" }, +/* 36 character $ */ +{ 5, 11, 0, -1, 6, "\0\0\1\0\0\0\1\1\1\0\1\0\1\0\1\1\0\1\0\0\0\1\1\0\0\0\0\1\1\0\0\0\1\0\1\0\0\1\0\1\1\0\1\0\1\0\1\1\1\0\0\0\1\0\0" }, +/* 37 character % */ +{ 8, 9, 0, 0, 9, "\0\1\1\0\0\0\1\1\1\0\0\1\1\1\1\0\1\0\0\1\0\1\0\0\0\1\1\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\1\0\1\1\0\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\0\1\0\0\0\1\1\0" }, +/* 38 character & */ +{ 9, 9, 0, 0, 10, "\0\0\0\1\1\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\1\1\0\1\1\1\0\1\1\1\1\0\0\1\0\1\1\0\0\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\0\0\1\1\1\0\1\0\1\1\1\1\0\1\1\0" }, +/* 39 character ' */ +{ 2, 3, 1, 6, 4, "\1\1\0\1\1\0" }, +/* 40 character ( */ +{ 3, 12, 1, -3, 5, "\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\0\0\1\0\0\0\1" }, +/* 41 character ) */ +{ 3, 12, 0, -3, 5, "\1\0\0\0\1\0\0\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0" }, +/* 42 character * */ +{ 5, 5, 0, 4, 6, "\0\0\1\0\0\1\0\1\0\1\0\1\1\1\0\1\0\1\0\1\0\0\1\0\0" }, +/* 43 character + */ +{ 5, 5, 1, 1, 7, "\0\0\1\0\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\0\1\0\0" }, +/* 44 character , */ +{ 2, 3, 0, -2, 3, "\0\1\0\1\1\0" }, +/* 45 character - */ +{ 5, 1, 1, 3, 8, "\1\1\1\1\1" }, +/* 46 character . */ +{ 1, 1, 1, 0, 3, "\1" }, +/* 47 character / */ +{ 3, 9, 0, 0, 3, "\0\0\1\0\0\1\0\0\1\0\1\0\0\1\0\0\1\0\1\0\0\1\0\0\1\0\0" }, +/* 48 character 0 */ +{ 5, 9, 0, 0, 6, "\0\1\1\1\0\1\1\0\1\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\1\1\1\0\1\1\0\1\1\1\0" }, +/* 49 character 1 */ +{ 4, 9, 0, 0, 6, "\0\0\1\0\0\1\1\0\1\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\1\1\1" }, +/* 50 character 2 */ +{ 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\0\1\0\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\1\1\1\1\1" }, +/* 51 character 3 */ +{ 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\1\1\1\0\0\0\0\0\1\0\0\0\0\1\1\0\0\0\1\0\1\1\1\0" }, +/* 52 character 4 */ +{ 5, 9, 0, 0, 6, "\0\0\0\1\0\0\0\1\1\0\0\0\1\1\0\0\1\0\1\0\0\1\0\1\0\1\0\0\1\0\1\1\1\1\1\0\0\0\1\0\0\0\0\1\0" }, +/* 53 character 5 */ +{ 5, 9, 0, 0, 6, "\0\0\1\1\1\0\1\0\0\0\0\1\0\0\0\0\1\1\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\1\1\0\0\1\1\0\1\1\1\0" }, +/* 54 character 6 */ +{ 5, 9, 0, 0, 6, "\0\0\0\1\1\0\1\1\0\0\0\1\0\0\0\1\1\1\1\0\1\0\0\1\1\1\0\0\0\1\1\0\0\0\1\1\1\0\0\1\0\1\1\1\0" }, +/* 55 character 7 */ +{ 5, 9, 0, 0, 6, "\1\1\1\1\1\1\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\0\0\1\0\0\0" }, +/* 56 character 8 */ +{ 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\0\1\1\0\0\0\1\1\1\0\0\1\0\1\1\1\0\1\0\0\1\1\1\0\0\0\1\1\0\0\0\1\0\1\1\1\0" }, +/* 57 character 9 */ +{ 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\1\1\1\0\0\0\1\1\0\0\0\1\1\1\0\0\1\0\1\1\1\1\0\0\0\1\0\0\0\1\1\0\1\1\0\0\0" }, +/* 58 character : */ +{ 1, 6, 1, 0, 3, "\1\0\0\0\0\1" }, +/* 59 character ; */ +{ 2, 8, 0, -2, 3, "\0\1\0\0\0\0\0\0\0\0\0\1\0\1\1\0" }, +/* 60 character < */ +{ 6, 5, 0, 1, 8, "\0\0\0\0\1\1\0\0\1\1\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1" }, +/* 61 character = */ +{ 5, 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1\0\0\1\0\0\1" }, +/* 93 character ] */ +{ 3, 12, 0, -3, 5, "\1\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\1" }, +/* 94 character ^ */ +{ 5, 5, 0, 4, 6, "\0\0\1\0\0\0\1\0\1\0\0\1\0\1\0\1\0\0\0\1\1\0\0\0\1" }, +/* 95 character _ */ +{ 6, 1, 0, -3, 6, "\1\1\1\1\1\1" }, +/* 96 character ` */ +{ 2, 3, 1, 6, 4, "\0\1\1\0\1\1" }, +/* 97 character a */ +{ 5, 6, 1, 0, 6, "\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, +/* 98 character b */ +{ 5, 9, 0, 0, 6, "\1\1\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\1\1\0" }, +/* 99 character c */ +{ 4, 6, 1, 0, 5, "\0\1\1\0\1\0\0\1\1\0\0\0\1\0\0\0\1\0\0\1\0\1\1\0" }, +/* 100 character d */ +{ 5, 9, 1, 0, 6, "\0\0\1\1\0\0\0\0\1\0\0\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, +/* 101 character e */ +{ 5, 6, 1, 0, 6, "\0\1\1\0\0\1\0\0\1\0\1\1\1\1\0\1\0\0\0\0\1\1\0\0\1\0\1\1\1\0" }, +/* 102 character f */ +{ 3, 9, 0, 0, 3, "\0\0\1\0\1\0\0\1\0\1\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0" }, +/* 103 character g */ +{ 5, 9, 1, -3, 6, "\0\1\1\1\1\1\0\0\1\0\1\0\0\1\0\1\1\1\0\0\0\1\0\0\0\0\1\1\1\0\1\0\0\0\1\1\0\0\0\1\0\1\1\1\0" }, +/* 104 character h */ +{ 6, 9, 0, 0, 6, "\1\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1\0\1\1" }, +/* 105 character i */ +{ 3, 9, 0, 0, 3, "\0\1\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, +/* 106 character j */ +{ 2, 12, 0, -3, 3, "\0\1\0\0\0\0\1\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\0" }, +/* 107 character k */ +{ 6, 9, 0, 0, 6, "\1\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\1\0\0\1\0\1\0\0\0\1\1\0\0\0\0\1\0\1\0\0\0\1\0\0\1\0\0\1\0\0\1\1" }, +/* 108 character l */ +{ 3, 9, 0, 0, 3, "\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, +/* 109 character m */ +{ 9, 6, 0, 0, 9, "\1\0\1\1\0\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1\0\1\1\0\1\1" }, +/* 110 character n */ +{ 6, 6, 0, 0, 6, "\1\0\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1\0\1\1" }, +/* 111 character o */ +{ 4, 6, 1, 0, 6, "\0\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, +/* 112 character p */ +{ 5, 9, 0, -3, 6, "\1\1\1\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\1\0\0" }, +/* 113 character q */ +{ 5, 9, 1, -3, 6, "\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\1\0\0\0\0\1\0\0\0\0\1\0\0\0\1\1\1" }, +/* 114 character r */ +{ 4, 6, 0, 0, 4, "\1\0\1\1\0\1\1\0\0\1\0\0\0\1\0\0\0\1\0\0\1\1\1\0" }, +/* 115 character s */ +{ 4, 6, 1, 0, 6, "\0\1\1\1\1\0\0\1\1\1\0\0\0\0\1\1\1\0\0\1\1\1\1\0" }, +/* 116 character t */ +{ 4, 7, 0, 0, 4, "\0\1\0\0\1\1\1\1\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\1\1" }, +/* 117 character u */ +{ 6, 6, 0, 0, 6, "\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, +/* 118 character v */ +{ 6, 6, 0, 0, 6, "\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0" }, +/* 119 character w */ +{ 9, 6, 0, 0, 9, "\1\1\1\0\1\1\0\1\1\0\1\0\0\1\0\0\1\0\0\1\1\0\1\0\1\1\0\0\0\1\0\1\0\1\0\0\0\0\1\1\0\1\0\0\0\0\0\1\0\0\1\0\0\0" }, +/* 120 character x */ +{ 5, 6, 1, 0, 6, "\1\1\0\1\1\0\1\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\1\0\1\1\0\1\1" }, +/* 121 character y */ +{ 6, 9, 0, -3, 6, "\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" }, +/* 122 character z */ +{ 4, 6, 1, 0, 6, "\1\1\1\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\1\1" }, +/* 123 character { */ +{ 4, 12, 1, -3, 6, "\0\0\1\1\0\1\0\0\0\1\0\0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3, { +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +glBdf+ 0, glBdf+ 1, glBdf+ 2, glBdf+ 3, glBdf+ 4, glBdf+ 5, +glBdf+ 6, glBdf+ 7, glBdf+ 8, glBdf+ 9, glBdf+10, glBdf+11, +glBdf+12, glBdf+13, glBdf+14, glBdf+15, glBdf+16, glBdf+17, +glBdf+18, glBdf+19, glBdf+20, glBdf+21, glBdf+22, glBdf+23, +glBdf+24, glBdf+25, glBdf+26, glBdf+27, glBdf+28, glBdf+29, +glBdf+30, glBdf+31, glBdf+32, glBdf+33, glBdf+34, glBdf+35, +glBdf+36, glBdf+37, glBdf+38, glBdf+39, glBdf+40, glBdf+41, +glBdf+42, glBdf+43, glBdf+44, glBdf+45, glBdf+46, glBdf+47, +glBdf+48, glBdf+49, glBdf+50, glBdf+51, glBdf+52, glBdf+53, +glBdf+54, glBdf+55, glBdf+56, glBdf+57, glBdf+58, glBdf+59, +glBdf+60, glBdf+61, glBdf+62, glBdf+63, glBdf+64, glBdf+65, +glBdf+66, glBdf+67, glBdf+68, glBdf+69, glBdf+70, glBdf+71, +glBdf+72, glBdf+73, glBdf+74, glBdf+75, glBdf+76, glBdf+77, +glBdf+78, glBdf+79, glBdf+80, glBdf+81, glBdf+82, glBdf+83, +glBdf+84, glBdf+85, glBdf+86, glBdf+87, glBdf+88, glBdf+89, +glBdf+90, glBdf+91, glBdf+92, glBdf+93, glBdf+94, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +glBdf+95, glBdf+96, glBdf+97, glBdf+98, glBdf+99, glBdf+100, +glBdf+101, glBdf+102, glBdf+103, glBdf+104, glBdf+105, glBdf+106, +glBdf+107, glBdf+108, glBdf+109, glBdf+110, glBdf+111, glBdf+112, +glBdf+113, glBdf+114, glBdf+115, glBdf+116, glBdf+117, glBdf+118, +glBdf+119, glBdf+120, glBdf+121, glBdf+122, glBdf+123, glBdf+124, +glBdf+125, glBdf+126, glBdf+127, glBdf+128, glBdf+129, glBdf+130, +glBdf+131, glBdf+132, glBdf+133, glBdf+134, glBdf+135, glBdf+136, +glBdf+137, glBdf+138, glBdf+139, glBdf+140, glBdf+141, glBdf+142, +glBdf+143, glBdf+144, glBdf+145, glBdf+146, glBdf+147, glBdf+148, +glBdf+149, glBdf+150, glBdf+151, glBdf+152, glBdf+153, glBdf+154, +glBdf+155, glBdf+156, glBdf+157, glBdf+158, glBdf+159, glBdf+160, +glBdf+161, glBdf+162, glBdf+163, glBdf+164, glBdf+165, glBdf+166, +glBdf+167, glBdf+168, glBdf+169, glBdf+170, glBdf+171, glBdf+172, +glBdf+173, glBdf+174, glBdf+175, glBdf+176, glBdf+177, glBdf+178, +glBdf+179, glBdf+180, glBdf+181, glBdf+182, glBdf+183, glBdf+184, +glBdf+185, glBdf+186, glBdf+187, glBdf+188, glBdf+189 } +}; + + + diff --git a/lib/pm_system.h b/lib/pm_system.h index a7560f48..dfcd5b3f 100644 --- a/lib/pm_system.h +++ b/lib/pm_system.h @@ -10,6 +10,32 @@ extern "C" { void +pm_system2_vp(const char * const progName, + const char ** const argArray, + void stdinFeeder(int, void *), + void * const feederParm, + void stdoutAccepter(int, void *), + void * const accepterParm, + int * const termStatusP); + +void +pm_system2_lp(const char * const progName, + void stdinFeeder(int, void *), + void * const feederParm, + void stdoutAccepter(int, void *), + void * const accepterParm, + int * const termStatusP, + ...); + +void +pm_system2(void stdinFeeder(int, void *), + void * const feederParm, + void stdoutAccepter(int, void *), + void * const accepterParm, + const char * const shellCommand, + int * const termStatusP); + +void pm_system_vp(const char * const progName, const char ** const argArray, void stdinFeeder(int, void *), @@ -32,6 +58,21 @@ pm_system(void stdinFeeder(int, void *), void * const accepterParm, const char * const shellCommand); +const char * +pm_termStatusDesc(int const termStatus); + + +/* The following are Standard Input feeders and Standard Output accepters + for pm_system() etc. +*/ +void +pm_feed_null(int const pipeToFeedFd, + void * const feederParm); + +void +pm_accept_null(int const pipetosuckFd, + void * const accepterParm); + struct bufferDesc { /* This is just a parameter for the routines below */ unsigned int size; @@ -40,9 +81,11 @@ struct bufferDesc { }; -/* The following are a Standard Input feeder and a Standard Output accepter - for pm_system(). +/* The struct name "bufferDesc", without the "pm" namespace, is an unfortunate + historical accident. */ +typedef struct bufferDesc pm_bufferDesc; + void pm_feed_from_memory(int const pipeToFeedFd, void * const feederParm); diff --git a/lib/util/nstring.c b/lib/util/nstring.c index 711cfca9..5644d3b9 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -226,7 +226,6 @@ pm_vsnprintf(char * const str, } p += n; str_l += n; } else { - const char *starting_p; size_t min_field_width; size_t precision = 0; bool precision_specified; @@ -268,7 +267,6 @@ pm_vsnprintf(char * const str, str_arg = credits; /* just to make compiler happy (defined but not used) */ str_arg = NULL; - starting_p = p; ++p; /* skip '%' */ /* parse flags */ diff --git a/lib/util/shhopt.h b/lib/util/shhopt.h index 9a446290..6b56bfd4 100644 --- a/lib/util/shhopt.h +++ b/lib/util/shhopt.h @@ -217,7 +217,10 @@ typedef struct { OPTENTRY(shortvalue, longvalue, typevalue, outputvalue, flagvalue) \ } -#define OPTENTINIT OPTION_DEF[0].type = OPT_END +#define OPTENTINIT \ + do {OPTION_DEF_INDEX=0; \ + OPTION_DEF[OPTION_DEF_INDEX].type = OPT_END; \ + } while (0) struct optNameValue { diff --git a/other/pamlookup.c b/other/pamlookup.c index 4ceb047f..d57546d9 100644 --- a/other/pamlookup.c +++ b/other/pamlookup.c @@ -99,7 +99,8 @@ fitLookup(tuple ** const inputLookup, /*---------------------------------------------------------------------------- Scale the lookup table image so that it has dimensions 'cols' x 'rows'. -----------------------------------------------------------------------------*/ - const char * pamscaleCommand; + const char * widthArg; + const char * heightArg; struct pamtuples inPamtuples; struct pamtuples outPamtuples; @@ -107,18 +108,21 @@ fitLookup(tuple ** const inputLookup, fitLookuppamP->width = cols; fitLookuppamP->height = rows; - pm_asprintf(&pamscaleCommand, "pamscale -width=%u -height=%u", cols, rows); + pm_asprintf(&widthArg, "-width=%u", cols); + pm_asprintf(&heightArg, "-height=%u", rows); inPamtuples.pamP = (struct pam *) &inputLookuppam; inPamtuples.tuplesP = (tuple ***) &inputLookup; outPamtuples.pamP = fitLookuppamP; outPamtuples.tuplesP = fitLookupP; - pm_system(&pm_feed_from_pamtuples, &inPamtuples, - &pm_accept_to_pamtuples, &outPamtuples, - pamscaleCommand); + pm_system_lp("pamscale", + &pm_feed_from_pamtuples, &inPamtuples, + &pm_accept_to_pamtuples, &outPamtuples, + "pamscale", widthArg, heightArg, NULL); - pm_strfree(pamscaleCommand); + pm_strfree(heightArg); + pm_strfree(widthArg); } diff --git a/other/pamx/send.c b/other/pamx/send.c index fd50d5e9..3c3852e2 100644 --- a/other/pamx/send.c +++ b/other/pamx/send.c @@ -22,9 +22,10 @@ #include "send.h" #define TRUE_TO_15BIT(PIXEL) \ + ((unsigned short) \ ((((PIXEL) & 0xf80000) >> 9) | \ (((PIXEL) & 0x00f800) >> 6) | \ - (((PIXEL) & 0x0000f8) >> 3)) + (((PIXEL) & 0x0000f8) >> 3))) #define RED_INTENSITY(P) (((P) & 0x7c00) >> 10) #define GREEN_INTENSITY(P) (((P) & 0x03e0) >> 5) @@ -116,63 +117,97 @@ bitsPerPixelAtDepth(Display * const disp, -static Image * -itrueToRGB(Image * const imageP, - unsigned int const ddepth) { - - int y, x, num_pixels, colors; - unsigned long pixel_counts[32786]; - unsigned long pixel_array[32786]; - Pixel pixval; +static void +findColors(const Image * const imageP, + unsigned int * const pixelCt) { +/*---------------------------------------------------------------------------- + Find the colors in the Itrue raster 'raster'; return the histogram of + those colors as 'pixelCt'. +-----------------------------------------------------------------------------*/ + unsigned short color; unsigned char * pixel; - unsigned char * dpixel; - Image * newImageP; - - newImageP = newRGBImage(imageP->width, imageP->height, ddepth); + unsigned int y; - colors = 1 << ddepth; - - memset(pixel_counts, 0, 32768 * sizeof(unsigned long)); + for (color = 0; color < 32768; ++color) + pixelCt[color] = 0; /* initial value */ - pixel= imageP->data; - for (y= 0; y < imageP->height; y++) { + for (y = 0, pixel = imageP->data; y < imageP->height; ++y) { unsigned int x; - for (x= 0; x < imageP->width; x++) { - unsigned int const z = TRUE_TO_15BIT(memToVal(pixel, 3)); - pixel_counts[z]++; + for (x = 0; x < imageP->width; ++x) { + unsigned int const color = TRUE_TO_15BIT(memToVal(pixel, 3)); + ++pixelCt[color]; pixel += 3; } } - num_pixels = 0; - for (x = 0; x < 32768; ++x) { - if (pixel_counts[x] > 0) { - unsigned long const red = RED_INTENSITY(x); - unsigned long const grn = GREEN_INTENSITY(x); - unsigned long const blu = BLUE_INTENSITY(x); - pixel_counts[x] = num_pixels; - *(newImageP->rgb.red + num_pixels) = red<<11; - *(newImageP->rgb.grn + num_pixels) = grn<<11; - *(newImageP->rgb.blu + num_pixels) = blu<<11; - pixel_array[num_pixels++] = (short)x; - if (num_pixels > colors) - break; +} + + + +static Image * +pseudoColorImageFromItrue(Image * const imageP, + unsigned int const ddepth) { +/*---------------------------------------------------------------------------- + A pseudoColor image from the RGB image *imageP. + + We compute the index -- i.e. assign each color in *imageP a number. +-----------------------------------------------------------------------------*/ + unsigned int const maxColorCt = (1 << ddepth); + + unsigned int y; + unsigned int colorCt; + /* Number of colors we've indexed so far */ + unsigned int pixelCt[32768]; + /* colorCt[x] is the number of pixels of color 'x' in the image, + where 'x' is the 15 bit RGB representation of the color. + */ + unsigned int colorIndex[32768]; + /* colorIndex[x] is the color index we assigned to the color 'x', + where 'x' is the 15 bit RGB representation of the color. + */ + Pixel pixval; + unsigned char * dpixel; + Image * newImageP; + unsigned short color; /* A color, in 15 bit RGB */ + unsigned char * pixel; + + newImageP = newRGBImage(imageP->width, imageP->height, ddepth); + + findColors(imageP, pixelCt); + + for (color = 0, colorCt = 0; + color < 32768 && colorCt <= maxColorCt; + ++color) { + if (pixelCt[color] > 0) { + unsigned long const red = RED_INTENSITY(color); + unsigned long const grn = GREEN_INTENSITY(color); + unsigned long const blu = BLUE_INTENSITY(color); + + /* Put the color in the color map */ + newImageP->rgb.red[colorCt] = red<<11; + newImageP->rgb.grn[colorCt] = grn<<11; + newImageP->rgb.blu[colorCt] = blu<<11; + + /* Reverse-index it */ + colorIndex[color] = colorCt; + + ++colorCt; } } - - pixel = imageP->data; - dpixel = newImageP->data; + newImageP->rgb.used = colorCt; - for (y = 0; y < imageP->height; ++y) { + for (y = 0, pixel = imageP->data, dpixel = newImageP->data; + y < imageP->height; + ++y) { + unsigned int x; for (x = 0; x < imageP->width; ++x) { - unsigned int const z = TRUE_TO_15BIT(memToVal(pixel, 3)); - pixval = pixel_counts[z]; + unsigned short const color = TRUE_TO_15BIT(memToVal(pixel, 3)); + pixval = colorIndex[color]; valToMem(pixval, dpixel, newImageP->pixlen); pixel += 3; dpixel += newImageP->pixlen; } } - newImageP->rgb.used = num_pixels; newImageP->rgb.compressed = 1; return newImageP; @@ -197,7 +232,7 @@ makeUsableVisual(Image * const origImageP, *newImagePP = origImageP; break; case PseudoColor: - *newImagePP = itrueToRGB(origImageP, ddepth); + *newImagePP = pseudoColorImageFromItrue(origImageP, ddepth); if (*newImagePP == NULL) pm_error("Unable to convert for Pseudocolor."); break; diff --git a/test/Test-Order b/test/Test-Order index 92efca05..38873bd4 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -62,6 +62,7 @@ pambackground.test pbmpscale.test pnmremap1.test pnmremap2.test +pnmquantall.test pnmtile.test ppmbrighten.test ppmdither.test @@ -103,6 +104,7 @@ ppmchange-roundtrip.test pamdice-roundtrip.test pamslice-roundtrip.test lookup-roundtrip.test +enlarge-reduce-roundtrip.test # Round-trip tests : lossless converters @@ -150,6 +152,7 @@ xpm-roundtrip.test xv-roundtrip.test xwd-roundtrip.test -# Round-trip tests : lossy converter +# Round-trip tests : lossy converters +fiasco-roundtrip.test yuv-roundtrip.test diff --git a/test/all-in-place.ok b/test/all-in-place.ok index 6ba75993..2fe1ed52 100644 --- a/test/all-in-place.ok +++ b/test/all-in-place.ok @@ -11,6 +11,7 @@ cmuwmtopbm: ok ddbugtopbm: ok escp2topbm: ok eyuvtoppm: ok +fiascotopnm: ok fitstopnm: ok fstopgm: ok g3topbm: ok @@ -78,6 +79,7 @@ pamsplit: ok pamstack: ok pamstereogram: ok pamstretch: ok +pamstretch-gen: ok pamsumm: ok pamsummcol: ok pamthreshold: ok @@ -195,6 +197,7 @@ pnmhisteq: ok pnmhistmap: ok pnmindex: ok pnminvert: ok +pnmmargin: ok pnmmercator: ok pnmmontage: ok pnmnlfilt: ok @@ -202,6 +205,8 @@ pnmnorm: ok pnmpad: ok pnmpaste: ok pnmpsnr: ok +pnmquant: ok +pnmquantall: ok pnmremap: ok pnmrotate: ok pnmscalefixed: ok @@ -236,6 +241,7 @@ ppmdist: ok ppmdither: ok ppmdmkfont: ok ppmdraw: ok +ppmfade: ok ppmflash: ok ppmforge: ok ppmglobe: ok @@ -245,8 +251,10 @@ ppmmake: ok ppmmix: ok ppmntsc: ok ppmpat: ok +ppmrainbow: ok ppmrelief: ok ppmrough: ok +ppmshadow: ok ppmshift: ok ppmspread: ok ppmtoacad: ok @@ -315,15 +323,5 @@ yuvsplittoppm: ok yuvtoppm: ok yuy2topam: ok zeisstopnm: ok -fiascotopnm: ok -manweb: ok -pnmmargin: ok anytopnm: ok -ppmtomap: ok -ppmshadow: ok -pnmquant: ok -pnmquantall: ok -ppmrainbow: ok -ppmfade: ok -pamstretch-gen: ok -pcdovtoppm: ok +manweb: ok diff --git a/test/all-in-place.test b/test/all-in-place.test index 4c8af56b..e372d373 100755 --- a/test/all-in-place.test +++ b/test/all-in-place.test @@ -4,9 +4,12 @@ # We test by actually running all the executables. # Failure message -# See Netpbm Library Prerequisites -# http://netpbm.sourceforge.net/prereq.html -# if make succeeds but this test fails. +## See Netpbm Library Prerequisites +## http://netpbm.sourceforge.net/prereq.html +## if make succeeds but this test fails +## +## If you run the "make test-install" on an older version, some executables +## may be reported as missing because of missing features. function testExitStatus () { @@ -50,6 +53,7 @@ ordinary_testprogs="\ ddbugtopbm \ escp2topbm \ eyuvtoppm \ + fiascotopnm \ fitstopnm \ fstopgm \ g3topbm \ @@ -117,6 +121,7 @@ ordinary_testprogs="\ pamstack \ pamstereogram \ pamstretch \ + pamstretch-gen \ pamsumm \ pamsummcol \ pamthreshold \ @@ -234,6 +239,7 @@ ordinary_testprogs="\ pnmhistmap \ pnmindex \ pnminvert \ + pnmmargin \ pnmmercator \ pnmmontage \ pnmnlfilt \ @@ -241,6 +247,8 @@ ordinary_testprogs="\ pnmpad \ pnmpaste \ pnmpsnr \ + pnmquant \ + pnmquantall \ pnmremap \ pnmrotate \ pnmscalefixed \ @@ -275,6 +283,7 @@ ordinary_testprogs="\ ppmdither \ ppmdmkfont \ ppmdraw \ + ppmfade \ ppmflash \ ppmforge \ ppmglobe \ @@ -284,8 +293,10 @@ ordinary_testprogs="\ ppmmix \ ppmntsc \ ppmpat \ + ppmrainbow \ ppmrelief \ ppmrough \ + ppmshadow \ ppmshift \ ppmspread \ ppmtoacad \ @@ -356,74 +367,28 @@ ordinary_testprogs="\ zeisstopnm \ " +# The string "fiascotopnm" has to be filtered out by egrep for fiascotopnm +# has a slightly different version report format. + for i in $ordinary_testprogs do $i --version 2>&1 | \ - egrep -v \ + egrep -v -e fiascotopnm -e \ "(Using libnetpbm|Compiled|(BSD|SYSV|MSDOS|AMIGA) defined|RGB_?ENV=)" \ 1>&2; testExitStatus $i 0 ${PIPESTATUS[0]} done -# Test fiascotopnm, which has a unique -v flag. -fiascotopnm -v 2> /dev/null - testExitStatus fiascotopnm 2 $? - - -# Test manweb and pnmmargin, which have --help. -manweb --help > /dev/null - testExitStatus manweb 0 $? - -pnmmargin --help 2> /dev/null - testExitStatus pnmmargin 1 $? - - -# Test anytopnm, pnmnoraw, pnmquant, pnmquantall -# ppmrainbow, ppmshadow, ppmtomap -# with trivial input. - -$i ${tmpdir}/test.pbm > /dev/null 2> /dev/null; -tmpdir=${tmpdir:-/tmp} -test_pbm=${tmpdir}/test.pbm - -cat > ${test_pbm} <<EOF -P1 -1 1 -1 -EOF - -for i in anytopnm ppmtomap ppmshadow - do - $i ${tmpdir}/test.pbm > /dev/null 2> /dev/null; - testExitStatus $i 0 $? - done - -for i in pnmquant pnmquantall - do - $i 2 ${tmpdir}/test.pbm > /dev/null 2> /dev/null; - testExitStatus $i 0 $? - done - -rm ${test_pbm} - ppmrainbow rgb:00/00/00 rgb:ff/ff/ff \ - -tmpdir=${tmpdir} -width=2 -height=2 > /dev/null - testExitStatus ppmrainbow 0 $? +# Anytopnm now supports --version but it delegates the report to pamtopnm. +# It fails if pamtopnm is absent. +# We consider anytopnm too important to test in an indirect manner. +anytopnm testgrid.pbm > /dev/null 2> /dev/null; +testExitStatus anytopnm 0 $? -# Test ppmfade with corrupt input. -# Prevent the creation of output files by setting base to /dev/null. -# Exit status should be 50. - ppmfade -f /dev/zero -base /dev/null > /dev/null 2> /dev/null - testExitStatus ppmfade 50 $? +# Test manweb which has --help. -# Test pamstretch-gen and pcdovtoppm with no input. -# These two programs write a usage message on standout in this case. -# Exit status should be 1. - -for i in pamstretch-gen pcdovtoppm - do - $i > /dev/null - testExitStatus $i 1 $? - done +manweb --help > /dev/null + testExitStatus manweb 0 $? diff --git a/test/enlarge-reduce-roundtrip.ok b/test/enlarge-reduce-roundtrip.ok new file mode 100644 index 00000000..8ee8118a --- /dev/null +++ b/test/enlarge-reduce-roundtrip.ok @@ -0,0 +1,17 @@ +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 +2364818683 590 diff --git a/test/enlarge-reduce-roundtrip.test b/test/enlarge-reduce-roundtrip.test new file mode 100755 index 00000000..54b52c60 --- /dev/null +++ b/test/enlarge-reduce-roundtrip.test @@ -0,0 +1,34 @@ +#! /bin/bash +# This script tests: pamenlarge pbmpscale pbmreduce +# Also requires: pbmtext + +tmpdir=${tmpdir:-/tmp} +xanadu_pbm=${tmpdir}/xanadu.pbm + +echo "In Xanadu did Kubla khan" | pbmtext > ${xanadu_pbm} + +# Should print 2364818683 590 + +cat ${xanadu_pbm} | cksum + +# Should print 2364818683 590 eight times + +for scale in 2 4 6 7 + do + for flag in "-fs -randomseed=0" "-threshold -v 0.4" + do + pamenlarge ${scale} ${xanadu_pbm} | pbmreduce ${flag} ${scale} | cksum + done + done + +# Should print 2364818683 590 eight times + +for scale in 5 7 9 11 + do + for flag in "-fs -randomseed=0" "-threshold" + do + pbmpscale ${scale} ${xanadu_pbm} | pbmreduce ${flag} ${scale} | cksum + done + done + +rm ${xanadu_pbm} diff --git a/test/fiasco-roundtrip.ok b/test/fiasco-roundtrip.ok new file mode 100644 index 00000000..e26677f4 --- /dev/null +++ b/test/fiasco-roundtrip.ok @@ -0,0 +1 @@ +215556145 102615 diff --git a/test/fiasco-roundtrip.test b/test/fiasco-roundtrip.test new file mode 100755 index 00000000..f733c04a --- /dev/null +++ b/test/fiasco-roundtrip.test @@ -0,0 +1,8 @@ +#! /bin/bash +# This script tests: pnmtofiasco fiascotopnm +# Also requires: pnmpad + +# Should print 215556145 102615 + +pnmpad --black --bottom 1 --left 1 testimg.ppm | \ + pnmtofiasco --progress-meter 0 | fiascotopnm | cksum diff --git a/test/legacy-names.ok b/test/legacy-names.ok index 9676639b..94ef875f 100644 --- a/test/legacy-names.ok +++ b/test/legacy-names.ok @@ -4,6 +4,8 @@ icontopbm: ok pamfixtrunc: ok pamrgbatopng: ok pbmtoicon: ok +pbmtox10bm: ok +pgmcrater: ok pgmedge: ok pgmnorm: ok pgmoil: ok @@ -17,21 +19,21 @@ pnmenlarge: ok pnmfile: ok pnmflip: ok pnminterp: ok +pnmnoraw: ok pnmscale: ok pnmsplit: ok pnmtofits: ok +pnmtoplainpnm: ok pnmtopnm: ok pnmtotiff: ok ppmnorm: ok +ppmquant: ok +ppmquantall: ok ppmtogif: ok ppmtojpeg: ok +ppmtomap: ok ppmtompeg: ok ppmtotga: ok ppmtouil: ok -pgmcrater: ok -pbmtox10bm: ok -pnmnoraw: ok -pnmtoplainpnm: ok -ppmquant: ok -ppmquantall: ok hpcdtoppm: ok +pcdovtoppm: ok diff --git a/test/legacy-names.test b/test/legacy-names.test index df40e62d..30509d20 100755 --- a/test/legacy-names.test +++ b/test/legacy-names.test @@ -10,6 +10,12 @@ ## ## Important: This test checks obsoleted names. ## Programs here do not appear in other tests. +## +## Programs here are wrapper scripts provided for backward compatibility. +## The newer replacement program may be the cause of any failure reported. +## +## If you run the "make test-install" on an older version, some executables +## may be reported as missing because of missing features. # Skip this test if CHECK_TYPE = tree @@ -55,6 +61,8 @@ ordinary_testprogs="\ pamfixtrunc \ pamrgbatopng \ pbmtoicon \ + pbmtox10bm \ + pgmcrater \ pgmedge \ pgmnorm \ pgmoil \ @@ -68,14 +76,19 @@ ordinary_testprogs="\ pnmfile \ pnmflip \ pnminterp \ + pnmnoraw \ pnmscale \ pnmsplit \ pnmtofits \ + pnmtoplainpnm \ pnmtopnm \ pnmtotiff \ ppmnorm \ + ppmquant \ + ppmquantall \ ppmtogif \ ppmtojpeg \ + ppmtomap \ ppmtompeg \ ppmtotga \ ppmtouil \ @@ -91,42 +104,11 @@ for i in $ordinary_testprogs done -# Test pgmcrater - -pgmcrater -number 1 -xsize 15 -ysize 15 -randomseed 1 > /dev/null -testExitStatus pgmcrater 0 $? - - -# Test pbmtox10bm, pnmnoraw, pnmtoplainpnm, ppmquantall, ppmrainbow -# with trivial input. -$i ${tmpdir}/test.pbm > /dev/null 2> /dev/null; -tmpdir=${tmpdir:-/tmp} -test_pbm=${tmpdir}/test.pbm - -cat > ${test_pbm} <<EOF -P1 -1 1 -1 -EOF - -for i in pbmtox10bm pnmnoraw pnmtoplainpnm - do - $i ${tmpdir}/test.pbm > /dev/null 2> /dev/null; - testExitStatus $i 0 $? - done - -for i in ppmquant ppmquantall - do - $i 2 ${tmpdir}/test.pbm > /dev/null 2> /dev/null; - testExitStatus $i 0 $? - done - - -rm ${test_pbm} - - -# Test hpcdtoppm. Simply confirm its existence. +# Test hpcdtoppm and pcdovtoppm. Simply confirm their existence. type -p hpcdtoppm > /dev/null testExitStatus hpcdtoppm 0 $? + +type -p pcdovtoppm > /dev/null +testExitStatus pcdovtoppm 0 $? diff --git a/test/pbmtext.ok b/test/pbmtext.ok index f19df9aa..bd12fb94 100644 --- a/test/pbmtext.ok +++ b/test/pbmtext.ok @@ -11,3 +11,14 @@ 1305436978 1018 1647614653 2027 1647614653 2027 +1647614653 2027 +3233136020 4535 +1216262214 5711 +386826492 35 +1 +1 +1 +1 +1 +1 +1 diff --git a/test/pbmtext.test b/test/pbmtext.test index 0a177270..20c9b285 100755 --- a/test/pbmtext.test +++ b/test/pbmtext.test @@ -19,9 +19,9 @@ text="The quick brown fog jumps over the lazy docs." # Test 2: -for flags in "" "-nom" "-builtin fixed" +for flags in "" "-nomargins" "-builtin fixed" do -echo $text | pbmtext $flags | cksum +echo ${text} | pbmtext ${flags} | cksum done temp_pbm=${tmpdir}/temp.pbm @@ -33,13 +33,19 @@ temp_pbm=${tmpdir}/temp.pbm for flags in "" "-builtin fixed" do pbmtext ${flags} ${text} | tee ${temp_pbm} | cksum -width=`pamfile ${temp_pbm} | awk '$2=="PBM" && NR==1 { w=$4}; END {print w}' ` -pbmtext ${flags} -width=$width $text | cksum +width1=`pamfile ${temp_pbm} | awk '$2=="PBM" && NR==1 {w=$4}; END {print w}' ` +width2=`pbmtext ${flags} ${text} --dry-run | awk '{print $1}' ` + +if [ ${width1} -eq ${width2} ]; then + pbmtext ${flags} -width=${width1} ${text} | cksum +else + echo ${width1} ${width2} +fi rm ${temp_pbm} done -# Test 3: Should print 1647614653 2027 twice +# Test 4: Should print 1647614653 2027 three times # Note: backslashes inserted in 3 locations in the rectange to make # possible input as a here document. @@ -61,8 +67,111 @@ _ PQRSTUVWXYZ[ _ M ",/^_[\`jpqy| M EOF -cat ${fontRectangle_txt} | pbmtext -nom -builtin fixed | tee ${font_pbm} | \ -cksum +pbmtext -dump-sheet -builtin fixed | tee ${font_pbm} | cksum +cat ${fontRectangle_txt} | pbmtext -nom -builtin fixed | cksum cat ${fontRectangle_txt} | pbmtext -nom -font ${font_pbm} | cksum - rm ${fontRectangle_txt} ${font_pbm} + + +# Test 5: Print all characters defined in the built-in bdf font + +# One long row +# Should print +awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); + for (i=160;i<=255;++i) printf("%c",i); }' | \ + pbmtext -builtin bdf | cksum + +# One tall column +# Should print +awk 'BEGIN { for (i=32; i<=125;++i) printf("%c\n",i); + for (i=160;i<=255;++i) printf("%c\n",i); }' | \ + pbmtext -nomargins -builtin bdf | cksum + + +# Test 6: +# Test corruptions in BDF font file. + +font_bdf=${tmpdir}/font.bdf +font_corrupt_bdf=${tmpdir}/fontcorrupt.bdf + +# Though this is BDF font file defines only three letters, it is valid. + +cat > ${font_bdf} << EOF +STARTFONT 2.1 +COMMENT $XFree86: xc/fonts/bdf/misc/micro.bdf,v 1.1 1999/09/25 14:36:34 dawes Exp $ - Modified for test +FONT micro +SIZE 4 75 75 +FONTBOUNDINGBOX 4 5 0 0 +STARTPROPERTIES 3 +FONT_DESCENT 0 +FONT_ASCENT 5 +CHARSET_REGISTRY "ISO88591" +CHARSET_ENCODING "1" +COPYRIGHT "Public domain font. Share and enjoy." +ENDPROPERTIES +CHARS 3 +STARTCHAR A +ENCODING 65 +SWIDTH 1000 0 +DWIDTH 4 0 +BBX 4 5 0 0 +BITMAP +e0 +a0 +e0 +a0 +a0 +ENDCHAR +STARTCHAR B +ENCODING 66 +SWIDTH 1000 0 +DWIDTH 4 0 +BBX 4 5 0 0 +BITMAP +e0 +a0 +c0 +a0 +e0 +ENDCHAR +STARTCHAR C +ENCODING 67 +SWIDTH 1000 0 +DWIDTH 4 0 +BBX 4 5 0 0 +BITMAP +e0 +80 +80 +80 +e0 +ENDCHAR +ENDFONT +EOF + +# This should succeed and produce 386826492 35 +pbmtext -font ${font_bdf} ABC | cksum + +# The rest should all fail. Writes 1 seven times. +pbmtext -font ${font_bdf} BCD +echo $? + +sed 's/FONTBOUNDINGBOX 4 5 0 0/FONTBOUNDINGBOX 4 4 0 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + +sed 's/BBX 4 5 0 0/BBX 4 6 0 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + +for delete_line in 14 16 18 20 + do + sed "${delete_line}"d ${font_bdf} > ${font_corrupt_bdf} + pbmtext -font ${font_corrupt_bdf} ABC > /dev/null + echo $? + rm ${font_corrupt_bdf} + done diff --git a/test/pnmquantall.ok b/test/pnmquantall.ok new file mode 100644 index 00000000..bd5bbc05 --- /dev/null +++ b/test/pnmquantall.ok @@ -0,0 +1,5 @@ +got color map +2373957371 33838 testimg.red +3892560659 33838 testimg.grn +1383839923 33838 testimg.blu +1 diff --git a/test/pnmquantall.test b/test/pnmquantall.test new file mode 100755 index 00000000..f0f18ab0 --- /dev/null +++ b/test/pnmquantall.test @@ -0,0 +1,17 @@ +#! /bin/bash +# This script tests: pnmquantall +# Also requires: ppmtorgb3 pgmhist + +ppmtorgb3 testimg.ppm + +pnmquantall 20 testimg.red testimg.grn testimg.blu + +for i in testimg.red testimg.grn testimg.blu +do +cksum $i +done + +# Should print 1 + +pnmcat testimg.red testimg.grn testimg.blu -tb | \ + pgmhist -m | awk '$2>0 {s++}; END { print s<=20 }' diff --git a/test/ppmchange.test b/test/ppmchange.test index d29a699f..397b290f 100755 --- a/test/ppmchange.test +++ b/test/ppmchange.test @@ -5,7 +5,7 @@ # Failure message ## If this test fails and ppmchange-roundtrip.test succeeds, -## the probably cause is a problem with one of the options of +## the probable cause is a problem with one of the options of ## ppmchange: -closeness or -remainder. tmpdir=${tmpdir:-/tmp} diff --git a/version.mk b/version.mk index 26e9c884..319622cd 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 -NETPBM_MINOR_RELEASE = 74 -NETPBM_POINT_RELEASE = 5 +NETPBM_MINOR_RELEASE = 75 +NETPBM_POINT_RELEASE = 0 |