From aff951c3594a4949b58ab47c2036ac79040a1071 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 29 Dec 2019 20:12:09 +0000 Subject: Fix typos in comments and messages, whitespace git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3726 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- editor/pamdice.c | 87 +++++++++++++++--------------- editor/pamperspective.c | 2 +- editor/pamthreshold.c | 31 ++++++----- editor/pamundice.c | 59 ++++++++++---------- editor/pgmmedian.c | 26 ++++----- editor/pnmcat.c | 33 ++++++------ editor/pnmconvol.c | 6 +-- editor/pnmgamma.c | 2 +- editor/pnmnlfilt.c | 113 ++++++++++++++++++++------------------- editor/pnmstitch.c | 6 +-- editor/specialty/pampaintspill.c | 4 +- editor/specialty/pgmabel.c | 18 ++++--- 12 files changed, 203 insertions(+), 184 deletions(-) (limited to 'editor') diff --git a/editor/pamdice.c b/editor/pamdice.c index 2c53a110..b21d8bbd 100644 --- a/editor/pamdice.c +++ b/editor/pamdice.c @@ -25,15 +25,15 @@ struct cmdlineInfo { in a form easy for the program to use. */ const char * inputFileName; /* '-' if stdin */ - const char * outstem; + const char * outstem; /* null-terminated string, max MAXFILENAMELEN-10 characters */ unsigned int sliceVertically; /* boolean */ unsigned int sliceHorizontally; /* boolean */ unsigned int width; /* Meaningless if !sliceVertically */ unsigned int height; /* Meaningless if !sliceHorizontally */ - unsigned int hoverlap; + unsigned int hoverlap; /* Meaningless if !sliceVertically. Guaranteed < width */ - unsigned int voverlap; + unsigned int voverlap; /* Meaningless if !sliceHorizontally. Guaranteed < height */ unsigned int verbose; }; @@ -44,7 +44,7 @@ parseCommandLine(int argc, char ** argv, struct cmdlineInfo * const cmdlineP ) { /*---------------------------------------------------------------------------- parse program command line described in Unix standard form by argc - and argv. Return the information in the options as *cmdlineP. + and argv. Return the information in the options as *cmdlineP. If command line is internally inconsistent (invalid options, etc.), issue error message to stderr and abort program. @@ -56,14 +56,14 @@ parseCommandLine(int argc, char ** argv, /* Instructions to pm_optParseOptions3 on how to parse our options. */ optStruct3 opt; - + unsigned int outstemSpec, hoverlapSpec, voverlapSpec; unsigned int option_def_index; MALLOCARRAY_NOFAIL(option_def, 100); option_def_index = 0; /* incremented by OPTENT3 */ - OPTENT3(0, "width", OPT_UINT, &cmdlineP->width, + OPTENT3(0, "width", OPT_UINT, &cmdlineP->width, &cmdlineP->sliceVertically, 0); OPTENT3(0, "height", OPT_UINT, &cmdlineP->height, &cmdlineP->sliceHorizontally, 0); @@ -110,8 +110,8 @@ parseCommandLine(int argc, char ** argv, cmdlineP->inputFileName = "-"; else if (argc-1 == 1) cmdlineP->inputFileName = argv[1]; - else - pm_error("Progam takes at most 1 parameter: the file specification. " + else + pm_error("Program takes at most 1 parameter: the file specification. " "You specified %u", argc-1); } @@ -147,7 +147,7 @@ computeSliceGeometry(struct cmdlineInfo const cmdline, if (cmdline.height >= inpam.height) *nHorizSliceP = 1; else - *nHorizSliceP = 1 + divup(inpam.height - cmdline.height, + *nHorizSliceP = 1 + divup(inpam.height - cmdline.height, cmdline.height - cmdline.voverlap); *sliceHeightP = cmdline.height; } else { @@ -155,14 +155,14 @@ computeSliceGeometry(struct cmdlineInfo const cmdline, *sliceHeightP = inpam.height; } - *bottomSliceHeightP = + *bottomSliceHeightP = inpam.height - (*nHorizSliceP-1) * (cmdline.height - cmdline.voverlap); if (cmdline.sliceVertically) { if (cmdline.width >= inpam.width) *nVertSliceP = 1; else - *nVertSliceP = 1 + divup(inpam.width - cmdline.width, + *nVertSliceP = 1 + divup(inpam.width - cmdline.width, cmdline.width - cmdline.hoverlap); *sliceWidthP = cmdline.width; } else { @@ -170,7 +170,7 @@ computeSliceGeometry(struct cmdlineInfo const cmdline, *sliceWidthP = inpam.width; } - *rightSliceWidthP = + *rightSliceWidthP = inpam.width - (*nVertSliceP-1) * (cmdline.width - cmdline.hoverlap); if (verbose) { @@ -180,7 +180,7 @@ computeSliceGeometry(struct cmdlineInfo const cmdline, *nVertSliceP, *nHorizSliceP, *sliceWidthP, *sliceHeightP); if (*rightSliceWidthP != *sliceWidthP) - pm_message("Right vertical slice is only %u wide", + pm_message("Right vertical slice is only %u wide", *rightSliceWidthP); if (*bottomSliceHeightP != *sliceHeightP) pm_message("Bottom horizontal slice is only %u high", @@ -207,7 +207,7 @@ ndigits(unsigned int const arg) { static void -computeOutputFilenameFormat(int const format, +computeOutputFilenameFormat(int const format, char const outstem[], unsigned int const nHorizSlice, unsigned int const nVertSlice, @@ -222,7 +222,7 @@ computeOutputFilenameFormat(int const format, case PAM_TYPE: filenameSuffix = "pam"; break; default: filenameSuffix = ""; break; } - + pm_asprintf(filenameFormatP, "%s_%%0%uu_%%0%uu.%s", outstem, ndigits(nHorizSlice), ndigits(nVertSlice), filenameSuffix); @@ -234,12 +234,12 @@ computeOutputFilenameFormat(int const format, static void -openOutStreams(struct pam const inpam, +openOutStreams(struct pam const inpam, struct pam outpam[], - unsigned int const horizSlice, + unsigned int const horizSlice, unsigned int const nHorizSlice, unsigned int const nVertSlice, - unsigned int const sliceHeight, + unsigned int const sliceHeight, unsigned int const sliceWidth, unsigned int const rightSliceWidth, unsigned int const hOverlap, @@ -265,17 +265,17 @@ openOutStreams(struct pam const inpam, else { outpam[vertSlice] = inpam; outpam[vertSlice].file = pm_openw(filename); - - outpam[vertSlice].width = + + outpam[vertSlice].width = vertSlice < nVertSlice-1 ? sliceWidth : rightSliceWidth; - + outpam[vertSlice].height = sliceHeight; - + pnm_writepaminit(&outpam[vertSlice]); pm_strfree(filename); } - } + } pm_strfree(filenameFormat); } @@ -285,14 +285,14 @@ static void closeOutFiles(struct pam pam[], unsigned int const nVertSlice) { unsigned int vertSlice; - + for (vertSlice = 0; vertSlice < nVertSlice; ++vertSlice) pm_close(pam[vertSlice].file); } static void -sliceRow(tuple inputRow[], - struct pam outpam[], +sliceRow(tuple inputRow[], + struct pam outpam[], unsigned int const nVertSlice, unsigned int const hOverlap) { /*---------------------------------------------------------------------------- @@ -306,11 +306,11 @@ sliceRow(tuple inputRow[], tuple * outputRow; unsigned int vertSlice; unsigned int const sliceWidth = outpam[0].width; - unsigned int const stride = + unsigned int const stride = nVertSlice > 1 ? sliceWidth - hOverlap : sliceWidth; - for (vertSlice = 0, outputRow = inputRow; - vertSlice < nVertSlice; + for (vertSlice = 0, outputRow = inputRow; + vertSlice < nVertSlice; outputRow += stride, ++vertSlice) { pnm_writepamrow(&outpam[vertSlice], outputRow); } @@ -336,7 +336,7 @@ static void initInput(struct inputWindow * const inputWindowP, struct pam * const pamP, unsigned int const windowSize) { - + struct pam allocPam; /* Just for allocating the window array */ unsigned int i; @@ -345,7 +345,7 @@ initInput(struct inputWindow * const inputWindowP, allocPam = *pamP; allocPam.height = windowSize; - + inputWindowP->rows = pnm_allocpamarray(&allocPam); inputWindowP->firstRowInWindow = 0; @@ -388,7 +388,7 @@ getInputRow(struct inputWindow * const inputWindowP, /* Read in the new last row in the window */ inputWindowP->rows[i] = oldRow0; /* Reuse the memory */ pnm_readpamrow(&inputWindowP->pam, inputWindowP->rows[i]); - } + } return inputWindowP->rows[row - inputWindowP->firstRowInWindow]; } @@ -428,7 +428,7 @@ main(int argc, char ** argv) { /* Width in pam columns of each vertical slice, except the rightmost slice, which may be narrower. If we aren't slicing vertically, that means one slice, i.e. the slice width - is the image width. + is the image width. */ unsigned int rightSliceWidth; /* Width in pam columns of the rightmost vertical slice. */ @@ -436,23 +436,23 @@ main(int argc, char ** argv) { /* Height in pam rows of each horizontal slice, except the bottom slice, which may be shorter. If we aren't slicing horizontally, that means one slice, i.e. the slice height - is the image height. + is the image height. */ unsigned int bottomSliceHeight; /* Height in pam rows of the bottom horizontal slice. */ unsigned int nHorizSlice; unsigned int nVertSlice; struct inputWindow inputWindow; - + struct pam * outpam; /* malloc'ed. outpam[x] is the pam structure that controls the current horizontal slice of vertical slice x. */ pnm_init(&argc, argv); - + parseCommandLine(argc, argv, &cmdline); - + ifP = pm_openr(cmdline.inputFileName); pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); @@ -462,19 +462,19 @@ main(int argc, char ** argv) { &nVertSlice, &sliceWidth, &rightSliceWidth); allocOutpam(nVertSlice, &outpam); - - initInput(&inputWindow, &inpam, + + initInput(&inputWindow, &inpam, nHorizSlice > 1 ? cmdline.voverlap + 1 : 1); for (horizSlice = 0; horizSlice < nHorizSlice; ++horizSlice) { - unsigned int const thisSliceFirstRow = + unsigned int const thisSliceFirstRow = horizSlice * (sliceHeight - cmdline.voverlap); - unsigned int const thisSliceHeight = + unsigned int const thisSliceHeight = horizSlice < nHorizSlice-1 ? sliceHeight : bottomSliceHeight; unsigned int row; - openOutStreams(inpam, outpam, horizSlice, nHorizSlice, nVertSlice, + openOutStreams(inpam, outpam, horizSlice, nHorizSlice, nVertSlice, thisSliceHeight, sliceWidth, rightSliceWidth, cmdline.hoverlap, cmdline.outstem); @@ -494,3 +494,6 @@ main(int argc, char ** argv) { return 0; } + + + diff --git a/editor/pamperspective.c b/editor/pamperspective.c index a206b57f..a8b1cf8f 100644 --- a/editor/pamperspective.c +++ b/editor/pamperspective.c @@ -804,7 +804,7 @@ static void determine_world_parallelogram (world_data *const world, yw_lr = world->yi_lr * zw_lr; /* Now we introduce the margin. There are several ways the margin can be - defined. margin_spec keeps track of wether one of them has yet been + defined. margin_spec keeps track of whether one of them has yet been used. As long as margin_spec==FALSE, the variables top_margin to bottom_margin are not initialized! */ diff --git a/editor/pamthreshold.c b/editor/pamthreshold.c index 8d28bc4a..809d76d9 100644 --- a/editor/pamthreshold.c +++ b/editor/pamthreshold.c @@ -73,7 +73,7 @@ initRange(struct range * const rangeP) { rangeP->max = 0.0; } - + static void addToRange(struct range * const rangeP, @@ -89,7 +89,7 @@ static float spread(struct range const range) { assert(range.max >= range.min); - + return range.max - range.min; } @@ -120,12 +120,12 @@ parseGeometry(const char * const wxl, static void -parseCommandLine(int argc, +parseCommandLine(int argc, char ** argv, struct cmdlineInfo *cmdlineP ) { /*---------------------------------------------------------------------------- Parse program command line described in Unix standard form by argc - and argv. Return the information in the options as *cmdlineP. + and argv. Return the information in the options as *cmdlineP. If command line is internally inconsistent (invalid options, etc.), issue error message to stderr and abort program. @@ -145,7 +145,7 @@ parseCommandLine(int argc, MALLOCARRAY_NOFAIL(option_def, 100); /* define the options */ - OPTENT3(0, "simple", OPT_FLAG, NULL, + OPTENT3(0, "simple", OPT_FLAG, NULL, &cmdlineP->simple, 0); OPTENT3(0, "local", OPT_STRING, &localOpt, &localSpec, 0); @@ -155,7 +155,7 @@ parseCommandLine(int argc, &thresholdSpec, 0); OPTENT3(0, "contrast", OPT_FLOAT, &cmdlineP->contrast, &contrastSpec, 0); - OPTENT3(0, "verbose", OPT_FLAG, NULL, + OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); /* set the defaults */ @@ -216,8 +216,8 @@ parseCommandLine(int argc, cmdlineP->inputFileName = "-"; else if (argc-1 == 1) cmdlineP->inputFileName = argv[1]; - else - pm_error("Progam takes at most 1 parameter: the file name. " + else + pm_error("Program takes at most 1 parameter: the file name. " "You specified %d", argc-1); } @@ -389,7 +389,7 @@ computeGlobalThreshold(struct pam * const inpamP, of the "k-means clustering algorithm." The article claims it's proven to converge, by the way. - We have an interation limit just as a safety net. + We have an iteration limit just as a safety net. This code originally implemented a rather different algorithm, while nonetheless carrying the comment that it implemented the @@ -524,7 +524,7 @@ thresholdLocalRow(struct pam * const inpamP, getLocalThreshold(inrows, inpamP->width, col, localWidth, windowHeight, cmdline.threshold, minSpread, globalThreshold, &threshold); - + thresholdPixel(outpamP, inrow[col], outrow[col], threshold); } } @@ -569,12 +569,12 @@ thresholdLocal(struct pam * const inpamP, unsigned int oddLocalWidth; unsigned int oddLocalHeight; unsigned int i; - + /* use a subimage with odd width and height to have a middle pixel */ if (cmdline.width % 2 == 0) oddLocalWidth = cmdline.width + 1; - else + else oddLocalWidth = cmdline.width; if (cmdline.height % 2 == 0) oddLocalHeight = cmdline.height + 1; @@ -616,7 +616,7 @@ thresholdLocal(struct pam * const inpamP, outpamP, outrow); pnm_writepamrow(outpamP, outrow); - + /* read next image line if available and necessary */ if (row + windowHeight / 2 >= nextRowToRead && nextRowToRead < inpamP->height) @@ -655,7 +655,7 @@ thresholdIterative(struct pam * const inpamP, int main(int argc, char **argv) { - FILE * ifP; + FILE * ifP; struct cmdlineInfo cmdline; struct pam inpam, outpam; int eof; /* No more images in input stream */ @@ -711,3 +711,6 @@ main(int argc, char **argv) { return 0; } + + + diff --git a/editor/pamundice.c b/editor/pamundice.c index dbe0a8df..aae3d65b 100644 --- a/editor/pamundice.c +++ b/editor/pamundice.c @@ -29,8 +29,8 @@ struct cmdlineInfo { /* null-terminated string, max MAXFILENAMELEN-10 characters */ unsigned int across; unsigned int down; - unsigned int hoverlap; - unsigned int voverlap; + unsigned int hoverlap; + unsigned int voverlap; unsigned int verbose; }; @@ -41,7 +41,7 @@ parseCommandLine(int argc, char ** argv, struct cmdlineInfo * const cmdlineP ) { /*---------------------------------------------------------------------------- parse program command line described in Unix standard form by argc - and argv. Return the information in the options as *cmdlineP. + and argv. Return the information in the options as *cmdlineP. If command line is internally inconsistent (invalid options, etc.), issue error message to stderr and abort program. @@ -53,7 +53,7 @@ parseCommandLine(int argc, char ** argv, /* Instructions to pm_optParseOptions3 on how to parse our options. */ optStruct3 opt; - + unsigned int acrossSpec, downSpec; unsigned int hoverlapSpec, voverlapSpec; unsigned int option_def_index; @@ -81,7 +81,7 @@ parseCommandLine(int argc, char ** argv, if (!acrossSpec) cmdlineP->across = 1; - + if (!downSpec) cmdlineP->down = 1; @@ -98,7 +98,7 @@ parseCommandLine(int argc, char ** argv, cmdlineP->inputFilePattern = argv[1]; if (argc-1 > 1) - pm_error("Progam takes at most one parameter: input file name. " + pm_error("Program takes at most one parameter: input file name. " "You specified %u", argc-1); } } @@ -128,7 +128,7 @@ buffer_init(struct buffer * const bufferP) { static void buffer_term(struct buffer * const bufferP) { - + free(bufferP->string); } @@ -184,7 +184,7 @@ getPrecision(const char * const pattern, inCursor = startInCursor; /* Start right after the '%' */ precision = 0; - + while (isdigit(pattern[inCursor])) { precision = 10 * precision + digitValue(pattern[inCursor]); ++inCursor; @@ -219,7 +219,7 @@ doSubstitution(const char * const pattern, ++inCursor; } else { unsigned int precision; - + getPrecision(pattern, inCursor, &precision, &inCursor); if (pattern[inCursor] == '\0') @@ -252,7 +252,7 @@ doSubstitution(const char * const pattern, desc, (unsigned)strlen(substString), precision); else buffer_addString(bufferP, substString); - + pm_strfree(desc); pm_strfree(substString); @@ -338,17 +338,17 @@ openInputImage(const char * const inputFilePattern, FILE * retval; const char * fileName; - + computeInputFileName(inputFilePattern, rank, file, &fileName); retval = pm_openr(fileName); - + pm_strfree(fileName); return retval; } - + static void getImageInfo(const char * const inputFilePattern, @@ -422,9 +422,9 @@ getOutputHeight(const char * const inputFilePattern, pm_error("Rank %u, file 0 image has height %u, " "which is less than the vertical overlap of %u pixels", rank, inpam.height, voverlap); - + totalHeight += inpam.height; - + if (rank < nRank-1) totalHeight -= voverlap; } @@ -466,7 +466,7 @@ initOutpam(const char * const inputFilePattern, outpamP->len = PAM_STRUCT_SIZE(tuple_type); outpamP->file = ofP; outpamP->plainformat = 0; - + getCommonInfo(inputFilePattern, &outpamP->format, &outpamP->depth, &outpamP->maxval, outpamP->tuple_type); @@ -503,7 +503,7 @@ openInStreams(struct pam inpam[], FILE * const ifP = openInputImage(inputFilePattern, rank, file); pnm_readpaminit(ifP, &inpam[file], PAM_STRUCT_SIZE(tuple_type)); - } + } } @@ -515,7 +515,7 @@ closeInFiles(struct pam pam[], Close the 'fileCount' input file streams represented by pam[]. -----------------------------------------------------------------------------*/ unsigned int file; - + for (file = 0; file < fileCount; ++file) pm_close(pam[file].file); } @@ -523,8 +523,8 @@ closeInFiles(struct pam pam[], static void -assembleRow(tuple outputRow[], - struct pam inpam[], +assembleRow(tuple outputRow[], + struct pam inpam[], unsigned int const fileCount, unsigned int const hOverlap) { /*---------------------------------------------------------------------------- @@ -541,8 +541,8 @@ assembleRow(tuple outputRow[], tuple * inputRow; unsigned int file; - for (file = 0, inputRow = &outputRow[0]; - file < fileCount; + for (file = 0, inputRow = &outputRow[0]; + file < fileCount; ++file) { unsigned int const overlap = file == fileCount - 1 ? 0 : hOverlap; @@ -622,7 +622,7 @@ verifyRankFileAttributes(struct pam * const inpam, rank, file, inpamP->height, inpam[0].height); else { totalWidth += inpamP->width; - + if (file < nFile-1) totalWidth -= hoverlap; } @@ -649,7 +649,7 @@ assembleTiles(struct pam * const outpamP, /* Number of the current rank (horizontal slice). Ranks are numbered sequentially starting at 0. */ - + for (rank = 0; rank < nRank; ++rank) { unsigned int row; unsigned int rankHeight; @@ -678,20 +678,20 @@ main(int argc, char ** argv) { struct pam outpam; struct pam * inpam; /* malloc'ed. inpam[x] is the pam structure that controls the - current rank of file x. + current rank of file x. */ tuple * tuplerow; pnm_init(&argc, argv); - + parseCommandLine(argc, argv, &cmdline); - + allocInpam(cmdline.across, &inpam); initOutpam(cmdline.inputFilePattern, cmdline.across, cmdline.down, cmdline.hoverlap, cmdline.voverlap, stdout, cmdline.verbose, &outpam); - + tuplerow = pnm_allocpamrow(&outpam); pnm_writepaminit(&outpam); @@ -706,3 +706,6 @@ main(int argc, char ** argv) { return 0; } + + + diff --git a/editor/pgmmedian.c b/editor/pgmmedian.c index 4648af68..cdd94629 100644 --- a/editor/pgmmedian.c +++ b/editor/pgmmedian.c @@ -1,4 +1,4 @@ -/* +/* ** Version 1.0 September 28, 1996 ** ** Copyright (C) 1996 by Mike Burns @@ -15,11 +15,11 @@ /* References ** ---------- -** The select k'th value implementation is based on Algorithm 489 by +** The select k'th value implementation is based on Algorithm 489 by ** Robert W. Floyd from the "Collected Algorithms from ACM" Volume II. ** ** The histogram sort is based is described in the paper "A Fast Two- -** Dimensional Median Filtering Algorithm" in "IEEE Transactions on +** Dimensional Median Filtering Algorithm" in "IEEE Transactions on ** Acoustics, Speech, and Signal Processing" Vol. ASSP-27, No. 1, February ** 1979. The algorithm I more closely followed is found in "Digital ** Image Processing Algorithms" by Ioannis Pitas. @@ -189,12 +189,11 @@ selectMedian(FILE * const ifP, unsigned int const numValues = crows * ccols; unsigned int col; - gray * garray; - /* Array of the currenty gray values */ + gray * garray; /* Array of the currently gray values */ int * parray; int * subcol; gray ** rowptr; - + garray = pgm_allocrow(numValues); MALLOCARRAY(rowptr, crows); @@ -212,7 +211,7 @@ selectMedian(FILE * const ifP, int crow; int rownum, irow, temprow; unsigned int col; - + pgm_readpgmrow(ifP, grays[row % crows], cols, maxval, format); /* Rotate pointers to rows, so rows can be accessed in order. */ @@ -334,7 +333,7 @@ histogramSortMedian(FILE * const ifP, for (mdn = 0; ltmdn <= median; ++mdn) ltmdn += hist[mdn]; --mdn; - if (ltmdn > median) + if (ltmdn > median) ltmdn -= hist[mdn]; grayrow[col] = mdn; @@ -374,7 +373,7 @@ histogramSortMedian(FILE * const ifP, ++mdn; } --mdn; - if (ltmdn > median) + if (ltmdn > median) ltmdn -= hist[mdn]; } grayrow[col] = mdn; @@ -410,7 +409,7 @@ main(int argc, pgm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); - + ifP = pm_openr(cmdline.inputFileName); ccolso2 = cmdline.width / 2; @@ -446,7 +445,7 @@ main(int argc, case SELECT_MEDIAN: selectMedian(ifP, cmdline.width, cmdline.height, cols, rows, median); break; - + case HISTOGRAM_SORT_MEDIAN: histogramSortMedian(ifP, cmdline.width, cmdline.height, cols, rows, median); @@ -454,7 +453,7 @@ main(int argc, case MEDIAN_UNSPECIFIED: pm_error("INTERNAL ERROR: median unspecified"); } - + pm_close(ifP); pm_close(stdout); @@ -463,3 +462,6 @@ main(int argc, return 0; } + + + diff --git a/editor/pnmcat.c b/editor/pnmcat.c index a26dcf3e..565ecceb 100644 --- a/editor/pnmcat.c +++ b/editor/pnmcat.c @@ -358,9 +358,9 @@ getPbmImageInfo(struct imgInfo const img[], case JUST_MAX: img2[i].padtop = newrows - img[i].rows; break; case JUST_CENTER: img2[i].padtop = (newrows - img[i].rows) / 2; break; } - + img2[i].offset = (i == 0) ? 0 : img2[i-1].offset + img[i-1].cols; - + if (img[i].rows == newrows) /* no padding */ img2[i].proberow = NULL; else { /* determine pad color for image i */ @@ -414,13 +414,13 @@ concatenateLeftRightPbm(FILE * const ofP, unsigned int const newcols, unsigned int const newrows, enum justification const justification, - struct imgInfo const img[], + struct imgInfo const img[], enum backcolor const backcolor) { unsigned char * const outrow = pbm_allocrow_packed(newcols); /* We use just one outrow. All padding and image data (with the - exeption of following img2.proberow) goes directly into this - packed PBM row. + exception of following img2.proberow) goes directly into this + packed PBM row. */ struct imgInfoPbm2 * img2; @@ -496,7 +496,7 @@ concatenateTopBottomPbm(FILE * const ofP, unsigned int i; unsigned int row, startRow; - + outrow[pbm_packed_bytes(newcols)-1] = 0x00; switch (backcolor){ @@ -525,7 +525,7 @@ concatenateTopBottomPbm(FILE * const ofP, bit bgBit; startRow = 1; - + pbm_readpbmrow_bitoffset(img[i].ifP, outrow, img[i].cols, img[i].format, padleft); @@ -544,23 +544,23 @@ concatenateTopBottomPbm(FILE * const ofP, if (backChange || (i > 0 && img[i-1].cols > img[i].cols)) { unsigned int const padright = newcols - padleft - img[i].cols; - + if (padleft > 0) padFillBitrow(outrow, background, padleft, 0); - - if (padright > 0) + + if (padright > 0) padFillBitrow(outrow, background, padright, padleft + img[i].cols); - + } } - + if (startRow == 1) /* Top row already read for auto background color determination. Write it out. */ pbm_writepbmrow_packed(ofP, outrow, newcols, 0); - + for (row = startRow; row < img[i].rows; ++row) { pbm_readpbmrow_bitoffset(img[i].ifP, outrow, img[i].cols, img[i].format, padleft); @@ -685,7 +685,7 @@ concatenateLeftRightGen(FILE * const ofP, unsigned int col; for (col = 0; col < img[i].cols; ++col) img2[i].inrow[col] = img2[i].xelrow[col]; - + free(img2[i].xelrow); } else if (row >= img2[i].padtop && row < img2[i].padtop + img[i].rows) { @@ -745,7 +745,7 @@ concatenateTopBottomGen(FILE * const ofP, startRow = 0; backChange = FALSE; inrow = newxelrow; - } else { /* Calculate left padding amount */ + } else { /* Calculate left padding amount */ switch (justification) { case JUST_MIN: padleft = 0; break; case JUST_MAX: padleft = newcols - img[i].cols; break; @@ -869,3 +869,6 @@ main(int argc, return 0; } + + + diff --git a/editor/pnmconvol.c b/editor/pnmconvol.c index b1d8e025..fcd52bea 100644 --- a/editor/pnmconvol.c +++ b/editor/pnmconvol.c @@ -1314,7 +1314,7 @@ computeInitialColumnSums(struct pam * const pamP, sample ** const convColumnSum) { /*---------------------------------------------------------------------------- Add up the sum of each column of window[][], whose rows are described - by *inpamP. The window's height is that of tthe convolution kernel + by *inpamP. The window's height is that of the convolution kernel *convKernelP. Return it as convColumnSum[][]. @@ -1854,7 +1854,7 @@ convolveHorizontalRowPlane(struct pam * const pamP, pamP->maxval); } else if (col == ccolso2) { unsigned int const leftcol = 0; - /* Window is up againt left edge of image */ + /* Window is up against left edge of image */ { unsigned int ccol; @@ -2019,7 +2019,7 @@ convolveVerticalRowPlane(struct pam * const pamP, if (col == ccolso2) { unsigned int const leftcol = 0; - /* Convolution window is againt left edge of image */ + /* Convolution window is against left edge of image */ unsigned int ccol; diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c index b357b0d8..1fdf20eb 100644 --- a/editor/pnmgamma.c +++ b/editor/pnmgamma.c @@ -602,7 +602,7 @@ createGammaTables(enum transferFunction const transferFunction, if (*rtableP == NULL || *gtableP == NULL || *btableP == NULL) pm_error("Can't get memory to make gamma transfer tables"); - /* Build the gamma corection tables. */ + /* Build the gamma correction tables. */ switch (transferFunction) { case XF_BT709RAMP: { buildBt709Gamma(*rtableP, maxval, newMaxval, rgamma); diff --git a/editor/pnmnlfilt.c b/editor/pnmnlfilt.c index f55a67bd..bcb3680d 100644 --- a/editor/pnmnlfilt.c +++ b/editor/pnmnlfilt.c @@ -59,9 +59,9 @@ struct cmdlineInfo { }; -static void -parseCommandLine(int argc, - char ** argv, +static void +parseCommandLine(int argc, + char ** argv, struct cmdlineInfo * const cmdlineP) { if (argc-1 < 2) @@ -75,9 +75,9 @@ parseCommandLine(int argc, if (sscanf( argv[2], "%lf", &cmdlineP->radius ) != 1) pm_error("Invalid radius (2nd) argument '%s'. " - "Must be a decimal number", + "Must be a decimal number", argv[2]); - + if ((cmdlineP->alpha > -0.1 && cmdlineP->alpha < 0.0) || (cmdlineP->alpha > 0.5 && cmdlineP->alpha < 1.0)) pm_error( "Alpha must be in range 0.0 <= alpha <= 0.5 " @@ -118,11 +118,11 @@ parseCommandLine(int argc, this value. */ -#define MXIVAL PPM_MAXMAXVAL +#define MXIVAL PPM_MAXMAXVAL -xelval omaxval; +xelval omaxval; /* global so that pixel processing code can get at it quickly */ -int noisevariance; +int noisevariance; /* global so that pixel processing code can get at it quickly */ /* @@ -157,7 +157,7 @@ static xelval maxval; /* round and scale floating point to scaled integer */ #define ROUNDSCALE(x) ((int)(((x) * (double)SCALE) + 0.5)) /* round and un-scale scaled integer value */ -#define RUNSCALE(x) (((x) + (1 << (SCALEB-1))) >> SCALEB) +#define RUNSCALE(x) (((x) + (1 << (SCALEB-1))) >> SCALEB) /* rounded un-scale */ #define UNSCALE(x) ((x) >> SCALEB) @@ -194,9 +194,9 @@ int AVEDIV[7 * NOCSVAL]; /* divide by 7 to give average value */ int SQUARE[2 * NOCSVAL]; /* scaled square lookup table */ /* ************************************************** * - Hexagon intersecting square area functions - Compute the area of the intersection of a triangle - and a rectangle + Hexagon intersecting square area functions + Compute the area of the intersection of a triangle + and a rectangle ************************************************** */ /* Triangle orientation is per geometric axes (not graphical axies) */ @@ -210,7 +210,7 @@ int SQUARE[2 * NOCSVAL]; /* scaled square lookup table */ #define SWAPI(a,b) (t = a, a = -b, b = -t) -static double +static double triang_area(double rx0, double ry0, double rx1, double ry1, double tx0, double ty0, double tx1, double ty1, int tt) { @@ -250,7 +250,7 @@ triang_area(double rx0, double ry0, double rx1, double ry1, a = tx0 - b * ty0; d = (ty1 - ty0)/(tx1 - tx0); c = ty0 - d * tx0; - + /* compute top or right intersection */ tt = 0; ly1 = ry1; @@ -278,7 +278,7 @@ triang_area(double rx0, double ry0, double rx1, double ry1, return (rx1 - rx0) * (ry1 - ry0); tt |= 2; /* bottom intersection */ } - + if (tt == 0) { /* top and left intersection */ /* rectangle minus triangle */ @@ -293,7 +293,7 @@ triang_area(double rx0, double ry0, double rx1, double ry1, return ((rx1 - lx1) * (ry1 - ry0)) + (0.5 * (lx1 - lx0) * (ry1 - ry0)); } else { - /* tt == 3 */ + /* tt == 3 */ /* right and bottom intersection */ /* triangle */ return (0.5 * (rx1 - lx0) * (ly1 - ry0)); @@ -303,7 +303,7 @@ triang_area(double rx0, double ry0, double rx1, double ry1, static double -rectang_area(double rx0, double ry0, double rx1, double ry1, +rectang_area(double rx0, double ry0, double rx1, double ry1, double tx0, double ty0, double tx1, double ty1) { /* Compute rectangle area */ /* rx0,ry0,rx1,ry1: rectangle boundaries */ @@ -326,7 +326,7 @@ rectang_area(double rx0, double ry0, double rx1, double ry1, -static double +static double hex_area(double sx, double sy, double hx, double hy, double d) { /* compute the area of overlap of a hexagon diameter d, */ /* centered at hx,hy, with a unit square of center sx,sy. */ @@ -384,7 +384,7 @@ setupSquare(void) { for (i=0; i < (2 * NOCSVAL); ++i) { /* compute square and rescale by (val >> (2 * SCALEB + 2)) table */ - int const val = CSCTOSC(i - NOCSVAL); + int const val = CSCTOSC(i - NOCSVAL); /* NOCSVAL offset to cope with -ve input values */ SQUARE[i] = (val * val) >> (2 * SCALEB + 2); } @@ -414,7 +414,7 @@ setup1(double const alpha, *mmeanscaleP = *meanscaleP = maxscale/noinmean; if (alpha == 0.0) { - /* mean filter */ + /* mean filter */ *alpharangeP = 0; *alphafractionP = 0.0; /* not used */ } else if (alpha < (1.0/6.0)) { @@ -438,9 +438,9 @@ setup1(double const alpha, double const noinmean = 7.0; *alpharangeP = 5; /* edge enhancement function */ *mmeanscaleP = *meanscaleP = maxscale; /* compute scaled hex values */ - *alphafractionP = 1.0/noinmean; + *alphafractionP = 1.0/noinmean; /* Set up 1:1 division lookup - not used */ - *noisevarianceP = sqr(alphaNormalized * omaxval) / 8.0; + *noisevarianceP = sqr(alphaNormalized * omaxval) / 8.0; /* estimate of noise variance */ } else if (alpha >= -0.9 && alpha <= -0.1) { /* edge enhancement function */ @@ -449,7 +449,7 @@ setup1(double const alpha, *alpharangeP = 4; /* edge enhancement function */ *meanscaleP = maxscale * (-posAlpha/((1.0 - posAlpha) * 7.0)); /* mean of 7 and scaled by -posAlpha/(1-posAlpha) */ - *mmeanscaleP = maxscale * (1.0/(1.0 - posAlpha) + *meanscaleP); + *mmeanscaleP = maxscale * (1.0/(1.0 - posAlpha) + *meanscaleP); /* middle pixel has 1/(1-posAlpha) as well */ *alphafractionP = 0.0; /* not used */ } else { @@ -481,18 +481,18 @@ setupPixelWeightingTables(double const radius, double const mmeanscale) { /* Setup pixel weighting tables - note we pre-compute mean - division here too. + division here too. */ - double const hexhoff = radius/2; + double const hexhoff = radius/2; /* horizontal offset of vertical hex centers */ - double const hexvoff = 3.0 * radius/sqrt(12.0); + double const hexvoff = 3.0 * radius/sqrt(12.0); /* vertical offset of vertical hex centers */ double const tabscale = meanscale / (radius * hexvoff); double const mtabscale = mmeanscale / (radius * hexvoff); /* scale tables to normalize by hexagon area, and number of - hexes used in mean + hexes used in mean */ double const v0 = hex_area(0.0, 0.0, hexhoff, hexvoff, radius) * tabscale; @@ -538,7 +538,7 @@ setupPixelWeightingTables(double const radius, /* Table initialization function - return alpha range */ -static int +static int atfilt_setup(double const alpha, double const radius, double const maxscale) { @@ -546,7 +546,7 @@ atfilt_setup(double const alpha, int alpharange; /* alpha range value 0 - 5 */ double meanscale; /* scale for finding mean */ double mmeanscale; /* scale for finding mean - midle hex */ - double alphafraction; + double alphafraction; /* fraction of next largest/smallest to subtract from sum */ setup1(alpha, radius, maxscale, @@ -562,7 +562,7 @@ atfilt_setup(double const alpha, -static int +static int atfilt0(int * p) { /* Core pixel processing function - hand it 3x3 pixels and return result. */ /* Mean filter */ @@ -586,7 +586,7 @@ atfilt0(int * p) { else if (xx < small) \ small = xx; } -static int +static int atfilt1(int * p) { /* Mean of 5 - 7 middle values */ /* 'p' is 9 pixel values from 3x3 neighbors */ @@ -635,7 +635,7 @@ atfilt1(int * p) { } -static int +static int atfilt2(int *p) { /* Mean of 3 - 5 middle values */ /* 'p' is 9 pixel values from 3x3 neighbors */ @@ -708,10 +708,10 @@ atfilt2(int *p) { small2 = xx; \ }} -static int +static int atfilt3(int *p) { /* Mean of 1 - 3 middle values. If only 1 value, then this is a median - filter. + filter. */ /* 'p' is pixel values from 3x3 neighbors */ int h0,h1,h2,h3,h4,h5,h6; /* hexagon values 2 3 */ @@ -737,12 +737,12 @@ atfilt3(int *p) { CHECK(h5); CHECK(h6); /* Compute mean of middle 1-3 values */ - return UNSCALE(h0 -big0 -big1 -small0 -small1 + return UNSCALE(h0 -big0 -big1 -small0 -small1 -ALFRAC[(big2 + small2)>>SCALEB]); } #undef CHECK -static int +static int atfilt4(int *p) { /* Edge enhancement */ /* notice we use the global omaxval */ @@ -765,7 +765,7 @@ atfilt4(int *p) { return hav; } -static int +static int atfilt5(int *p) { /* Optimal estimation - do smoothing in inverse proportion */ /* to the local variance. */ @@ -786,19 +786,19 @@ atfilt5(int *p) { h6 = V0[p[0]] + V1[p[7]] + V2[p[8]] + V3[p[1]]; mean = h0 + h1 + h2 + h3 + h4 + h5 + h6; mean = AVEDIV[SCTOCSC(mean)]; /* compute scaled mean by dividing by 7 */ - temp = (h1 - mean); variance = SQUARE[NOCSVAL + SCTOCSC(temp)]; + temp = (h1 - mean); variance = SQUARE[NOCSVAL + SCTOCSC(temp)]; /* compute scaled variance */ - temp = (h2 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; + temp = (h2 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; /* and rescale to keep */ - temp = (h3 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; + temp = (h3 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; /* within 32 bit limits */ temp = (h4 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; temp = (h5 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; temp = (h6 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; - temp = (h0 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; + temp = (h0 - mean); variance += SQUARE[NOCSVAL + SCTOCSC(temp)]; /* (temp = h0 - mean) */ if (variance != 0) /* avoid possible divide by 0 */ - temp = mean + (variance * temp) / (variance + noisevariance); + temp = mean + (variance * temp) / (variance + noisevariance); /* optimal estimate */ else temp = h0; if (temp < 0) @@ -811,17 +811,17 @@ atfilt5(int *p) { -static void +static void do_one_frame(FILE * const ifP) { pnm_writepnminit( stdout, cols, rows, omaxval, oformat, 0 ); - + if ( PNM_FORMAT_TYPE(oformat) == PPM_TYPE ) { int pr[9],pg[9],pb[9]; /* 3x3 neighbor pixel values */ int r,g,b; for ( row = 0; row < rows; row++ ) { - int po,no; /* offsets for left and right colums in 3x3 */ + int po,no; /* offsets for left and right columns in 3x3 */ xel *ip0, *ip1, *ip2, *op; if (row == 0) { @@ -897,14 +897,14 @@ do_one_frame(FILE * const ifP) { promote = ( PNM_FORMAT_TYPE(format) != PNM_FORMAT_TYPE(oformat) ); for ( row = 0; row < rows; row++ ) { - int po,no; /* offsets for left and right colums in 3x3 */ + int po,no; /* offsets for left and right columns in 3x3 */ xel *ip0, *ip1, *ip2, *op; if (row == 0) { irow0 = irow1; pnm_readpnmrow( ifP, irow1, cols, maxval, format ); if ( promote ) - pnm_promoteformatrow( irow1, cols, maxval, + pnm_promoteformatrow( irow1, cols, maxval, format, maxval, oformat ); } if (row == (rows-1)) @@ -912,7 +912,7 @@ do_one_frame(FILE * const ifP) { else { pnm_readpnmrow( ifP, irow2, cols, maxval, format ); if ( promote ) - pnm_promoteformatrow( irow2, cols, maxval, + pnm_promoteformatrow( irow2, cols, maxval, format, maxval, oformat ); } @@ -955,7 +955,7 @@ do_one_frame(FILE * const ifP) { static void -verifySame(unsigned int const imageSeq, +verifySame(unsigned int const imageSeq, int const imageCols, int const imageRows, xelval const imageMaxval, int const imageFormat, int const cols, int const rows, @@ -1000,16 +1000,16 @@ main(int argc, char *argv[]) { ifP = pm_openr(cmdline.inputFileName); pnm_readpnminit(ifP, &cols, &rows, &maxval, &format); - - if (maxval > MXIVAL) + + if (maxval > MXIVAL) pm_error("The maxval of the input image (%d) is too large.\n" - "This program's limit is %d.", + "This program's limit is %d.", maxval, MXIVAL); - + oformat = PNM_FORMAT_TYPE(format); /* force output to max precision without forcing new 2-byte format */ omaxval = MIN(maxval, PPM_MAXMAXVAL); - + atfunc = atfuncs[atfilt_setup(cmdline.alpha, cmdline.radius, (double)omaxval/(double)maxval)]; @@ -1038,7 +1038,7 @@ main(int argc, char *argv[]) { int imageFormat; ++imageSeq; - pnm_readpnminit(ifP, &imageCols, &imageRows, + pnm_readpnminit(ifP, &imageCols, &imageRows, &imageMaxval, &imageFormat); verifySame(imageSeq, imageCols, imageRows, imageMaxval, imageFormat, @@ -1054,3 +1054,6 @@ main(int argc, char *argv[]) { return 0; } + + + diff --git a/editor/pnmstitch.c b/editor/pnmstitch.c index eae5e1b9..4c4c708a 100644 --- a/editor/pnmstitch.c +++ b/editor/pnmstitch.c @@ -20,7 +20,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * Any restrictions or encumberances added to this source code or derivitives, + * Any restrictions or encumberances added to this source code or derivatives, * is prohibited. * * Name: pnmstitch.c @@ -1116,7 +1116,7 @@ OutputAlloc(Output * const me, static void StraightThroughDeAlloc(Output * me) { - /* Trick the proper freeing of resouces on the Output Image */ + /* Trick the proper freeing of resources on the Output Image */ me->image->pam.height = 1; OutputDeAlloc(me); } /* StraightThroughDeAlloc() - end */ @@ -1131,7 +1131,7 @@ StraightThroughAlloc(Output * const me, if (OutputAlloc(me, file, width, height, prototype) == FALSE) { StraightThroughDeAlloc(me); } - /* Trick the proper allocation of resouces on the Output Image */ + /* Trick the proper allocation of resources on the Output Image */ me->image->pam.height = 1; me->image->tuple = pnm_allocpamarray(&me->image->pam); if (me->image->tuple == (tuple **)NULL) { diff --git a/editor/specialty/pampaintspill.c b/editor/specialty/pampaintspill.c index eb1888f7..c7994723 100644 --- a/editor/specialty/pampaintspill.c +++ b/editor/specialty/pampaintspill.c @@ -281,7 +281,7 @@ euclideanDistanceSqr(const struct coords * const p0, unsigned int const width, unsigned int const height) { /*---------------------------------------------------------------------------- - Return the square of the Euclidian distance between p0 and p1. + Return the square of the Euclidean distance between p0 and p1. -----------------------------------------------------------------------------*/ double const deltax = (double) (int) (p1->x - p0->x); double const deltay = (double) (int) (p1->y - p0->y); @@ -299,7 +299,7 @@ euclideanDistanceTorusSqr(const struct coords * const p0, unsigned int const width, unsigned int const height) { /*---------------------------------------------------------------------------- - Return the square of the Euclidian distance between p0 and p1, assuming + Return the square of the Euclidean distance between p0 and p1, assuming it's a toroidal surface on which the top row curves around to meet the bottom and the left column to the right. -----------------------------------------------------------------------------*/ diff --git a/editor/specialty/pgmabel.c b/editor/specialty/pgmabel.c index 1a6e481f..aa748f88 100644 --- a/editor/specialty/pgmabel.c +++ b/editor/specialty/pgmabel.c @@ -44,7 +44,7 @@ static const char* const version="$VER: pgmabel 1.009 (24 Jan 2002)"; #include "pgm.h" #ifndef PID2 /* PI/2 (on AMIGA always defined) */ -#define PID2 1.57079632679489661923 +#define PID2 1.57079632679489661923 #endif @@ -59,7 +59,7 @@ static double *aldl, *ardl; /* pointer for weighting factors */ ** xr <- array of the calculated elements of the row ** adl <- pre-calculated surface coefficient for each segment */ -static double +static double Sum ( int n, double *xr, int N, double *adl) { int k; @@ -79,7 +79,7 @@ Sum ( int n, double *xr, int N, double *adl) ** R, N <- indizes of the coefficient ** r <- radial position of the center of the surface */ -static double +static double dr ( int R, double r, int N) { double a; @@ -95,7 +95,7 @@ dr ( int R, double r, int N) ** N <- width of the array ** adl <- array with pre-calculated weighting factors */ -static void +static void abel ( float *y, int N, double *adl) { register int n; @@ -127,7 +127,7 @@ abel ( float *y, int N, double *adl) /* ---------------------------------------------------------------------------- ** printing a help message if Option -h(elp) is chosen */ -static void +static void help() { pm_message("-----------------------------------------------------------------"); @@ -143,7 +143,7 @@ help() pm_message("| verbose : output of useful data |"); pm_message("| pgmfile : Name of a pgmfile (optional) |"); pm_message("| |"); - pm_message("| for further information please contact the manpage |"); + pm_message("| for further information please contact the manpage |"); pm_message("-----------------------------------------------------------------"); pm_message("%s",version); /* telling the version */ exit(-1); /* retur-code for no result */ @@ -268,11 +268,11 @@ int main( argc, argv ) } for (col = 0; col < (cols-midcol); ++col) /* factors for right side */ { - for (tc = 0; tc < (cols-midcol); ++tc) + for (tc = 0; tc < (cols-midcol); ++tc) ardl[col*(cols-midcol)+tc] = dr(col,tc+0.5,cols-midcol); } - /* abel-transformation for each row splitted in right and left side */ + /* abel-transformation for each row split into right and left side */ for ( row = 0; row < rows ; ++row ) { pgm_readpgmrow( ifp, grayorig, cols, maxval, format ); @@ -309,3 +309,5 @@ int main( argc, argv ) exit( 0 ); /* end of procedure */ } + + -- cgit 1.4.1