diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-12-29 20:12:09 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-12-29 20:12:09 +0000 |
commit | aff951c3594a4949b58ab47c2036ac79040a1071 (patch) | |
tree | 6e5cd5a0930b8b7137770387eac863726867c7c4 /converter/ppm | |
parent | fd1ea104fcd58b15d3db5d47a4cc5f56a3c05026 (diff) | |
download | netpbm-mirror-aff951c3594a4949b58ab47c2036ac79040a1071.tar.gz netpbm-mirror-aff951c3594a4949b58ab47c2036ac79040a1071.tar.xz netpbm-mirror-aff951c3594a4949b58ab47c2036ac79040a1071.zip |
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
Diffstat (limited to 'converter/ppm')
29 files changed, 806 insertions, 790 deletions
diff --git a/converter/ppm/ilbm.h b/converter/ppm/ilbm.h index dbe47758..c0fac7d2 100644 --- a/converter/ppm/ilbm.h +++ b/converter/ppm/ilbm.h @@ -25,8 +25,8 @@ typedef struct { #define mskHasTransparentColor 2 #define mskLasso 3 /* can't handle this */ #define mskMAXKNOWN mskLasso -static const char * mskNAME[] = { - "none", "mask plane", "transparent color", "lasso" +static const char * mskNAME[] = { + "none", "mask plane", "transparent color", "lasso" }; #define cmpNone 0 @@ -147,98 +147,98 @@ typedef unsigned long IFF_ID; #define MAKE_ID(a, b, c, d) \ ((IFF_ID)(a)<<24 | (IFF_ID)(b)<<16 | (IFF_ID)(c)<<8 | (IFF_ID)(d)) -#define ID_FORM MAKE_ID('F', 'O', 'R', 'M') +#define ID_FORM MAKE_ID('F', 'O', 'R', 'M') /* EA IFF 85 group identifier */ -#define ID_CAT MAKE_ID('C', 'A', 'T', ' ') +#define ID_CAT MAKE_ID('C', 'A', 'T', ' ') /* EA IFF 85 group identifier */ -#define ID_LIST MAKE_ID('L', 'I', 'S', 'T') +#define ID_LIST MAKE_ID('L', 'I', 'S', 'T') /* EA IFF 85 group identifier */ -#define ID_PROP MAKE_ID('P', 'R', 'O', 'P') +#define ID_PROP MAKE_ID('P', 'R', 'O', 'P') /* EA IFF 85 group identifier */ -#define ID_END MAKE_ID('E', 'N', 'D', ' ') +#define ID_END MAKE_ID('E', 'N', 'D', ' ') /* unofficial END-of-FORM identifier (see Amiga RKM Devices Ed.3 page 376) */ -#define ID_ILBM MAKE_ID('I', 'L', 'B', 'M') +#define ID_ILBM MAKE_ID('I', 'L', 'B', 'M') /* EA IFF 85 raster bitmap form */ -#define ID_DEEP MAKE_ID('D', 'E', 'E', 'P') +#define ID_DEEP MAKE_ID('D', 'E', 'E', 'P') /* Chunky pixel image files (Used in TV Paint) */ -#define ID_RGB8 MAKE_ID('R', 'G', 'B', '8') +#define ID_RGB8 MAKE_ID('R', 'G', 'B', '8') /* RGB image forms, Turbo Silver (Impulse) */ -#define ID_RGBN MAKE_ID('R', 'G', 'B', 'N') +#define ID_RGBN MAKE_ID('R', 'G', 'B', 'N') /* RGB image forms, Turbo Silver (Impulse) */ -#define ID_PBM MAKE_ID('P', 'B', 'M', ' ') +#define ID_PBM MAKE_ID('P', 'B', 'M', ' ') /* 256-color chunky format (DPaint 2 ?) */ -#define ID_ACBM MAKE_ID('A', 'C', 'B', 'M') +#define ID_ACBM MAKE_ID('A', 'C', 'B', 'M') /* Amiga Contiguous Bitmap (AmigaBasic) */ /* generic */ -#define ID_FVER MAKE_ID('F', 'V', 'E', 'R') +#define ID_FVER MAKE_ID('F', 'V', 'E', 'R') /* AmigaOS version string */ -#define ID_JUNK MAKE_ID('J', 'U', 'N', 'K') +#define ID_JUNK MAKE_ID('J', 'U', 'N', 'K') /* always ignore this chunk */ -#define ID_ANNO MAKE_ID('A', 'N', 'N', 'O') +#define ID_ANNO MAKE_ID('A', 'N', 'N', 'O') /* EA IFF 85 Generic Annotation chunk */ -#define ID_AUTH MAKE_ID('A', 'U', 'T', 'H') +#define ID_AUTH MAKE_ID('A', 'U', 'T', 'H') /* EA IFF 85 Generic Author chunk */ -#define ID_CHRS MAKE_ID('C', 'H', 'R', 'S') +#define ID_CHRS MAKE_ID('C', 'H', 'R', 'S') /* EA IFF 85 Generic character string chunk */ -#define ID_NAME MAKE_ID('N', 'A', 'M', 'E') +#define ID_NAME MAKE_ID('N', 'A', 'M', 'E') /* EA IFF 85 Generic Name of art, music, etc. chunk */ -#define ID_TEXT MAKE_ID('T', 'E', 'X', 'T') +#define ID_TEXT MAKE_ID('T', 'E', 'X', 'T') /* EA IFF 85 Generic unformatted ASCII text chunk */ -#define ID_copy MAKE_ID('(', 'c', ')', ' ') +#define ID_copy MAKE_ID('(', 'c', ')', ' ') /* EA IFF 85 Generic Copyright text chunk */ /* ILBM chunks */ -#define ID_BMHD MAKE_ID('B', 'M', 'H', 'D') +#define ID_BMHD MAKE_ID('B', 'M', 'H', 'D') /* ILBM BitmapHeader */ -#define ID_CMAP MAKE_ID('C', 'M', 'A', 'P') +#define ID_CMAP MAKE_ID('C', 'M', 'A', 'P') /* ILBM 8bit RGB colormap */ -#define ID_GRAB MAKE_ID('G', 'R', 'A', 'B') - /* ILBM "hotspot" coordiantes */ -#define ID_DEST MAKE_ID('D', 'E', 'S', 'T') +#define ID_GRAB MAKE_ID('G', 'R', 'A', 'B') + /* ILBM "hotspot" coordinates */ +#define ID_DEST MAKE_ID('D', 'E', 'S', 'T') /* ILBM destination image info */ -#define ID_SPRT MAKE_ID('S', 'P', 'R', 'T') +#define ID_SPRT MAKE_ID('S', 'P', 'R', 'T') /* ILBM sprite identifier */ -#define ID_CAMG MAKE_ID('C', 'A', 'M', 'G') +#define ID_CAMG MAKE_ID('C', 'A', 'M', 'G') /* Amiga viewportmodes */ -#define ID_BODY MAKE_ID('B', 'O', 'D', 'Y') +#define ID_BODY MAKE_ID('B', 'O', 'D', 'Y') /* ILBM image data */ -#define ID_CRNG MAKE_ID('C', 'R', 'N', 'G') +#define ID_CRNG MAKE_ID('C', 'R', 'N', 'G') /* color cycling */ -#define ID_CCRT MAKE_ID('C', 'C', 'R', 'T') +#define ID_CCRT MAKE_ID('C', 'C', 'R', 'T') /* color cycling */ -#define ID_CLUT MAKE_ID('C', 'L', 'U', 'T') +#define ID_CLUT MAKE_ID('C', 'L', 'U', 'T') /* Color Lookup Table chunk */ -#define ID_DPI MAKE_ID('D', 'P', 'I', ' ') +#define ID_DPI MAKE_ID('D', 'P', 'I', ' ') /* Dots per inch chunk */ -#define ID_DPPV MAKE_ID('D', 'P', 'P', 'V') +#define ID_DPPV MAKE_ID('D', 'P', 'P', 'V') /* DPaint perspective chunk (EA) */ -#define ID_DRNG MAKE_ID('D', 'R', 'N', 'G') +#define ID_DRNG MAKE_ID('D', 'R', 'N', 'G') /* DPaint IV enhanced color cycle chunk (EA) */ -#define ID_EPSF MAKE_ID('E', 'P', 'S', 'F') +#define ID_EPSF MAKE_ID('E', 'P', 'S', 'F') /* Encapsulated Postscript chunk */ -#define ID_CMYK MAKE_ID('C', 'M', 'Y', 'K') +#define ID_CMYK MAKE_ID('C', 'M', 'Y', 'K') /* Cyan, Magenta, Yellow, & Black color map (Soft-Logik) */ -#define ID_CNAM MAKE_ID('C', 'N', 'A', 'M') +#define ID_CNAM MAKE_ID('C', 'N', 'A', 'M') /* Color naming chunk (Soft-Logik) */ -#define ID_PCHG MAKE_ID('P', 'C', 'H', 'G') +#define ID_PCHG MAKE_ID('P', 'C', 'H', 'G') /* Line by line palette control information (Sebastiano Vigna) */ -#define ID_PRVW MAKE_ID('P', 'R', 'V', 'W') +#define ID_PRVW MAKE_ID('P', 'R', 'V', 'W') /* A mini duplicate ILBM used for preview (Gary Bonham) */ -#define ID_XBMI MAKE_ID('X', 'B', 'M', 'I') +#define ID_XBMI MAKE_ID('X', 'B', 'M', 'I') /* eXtended BitMap Information (Soft-Logik) */ -#define ID_CTBL MAKE_ID('C', 'T', 'B', 'L') +#define ID_CTBL MAKE_ID('C', 'T', 'B', 'L') /* Newtek Dynamic Ham color chunk */ -#define ID_DYCP MAKE_ID('D', 'Y', 'C', 'P') +#define ID_DYCP MAKE_ID('D', 'Y', 'C', 'P') /* Newtek Dynamic Ham chunk */ -#define ID_SHAM MAKE_ID('S', 'H', 'A', 'M') +#define ID_SHAM MAKE_ID('S', 'H', 'A', 'M') /* Sliced HAM color chunk */ -#define ID_ABIT MAKE_ID('A', 'B', 'I', 'T') +#define ID_ABIT MAKE_ID('A', 'B', 'I', 'T') /* ACBM body chunk */ -#define ID_DCOL MAKE_ID('D', 'C', 'O', 'L') +#define ID_DCOL MAKE_ID('D', 'C', 'O', 'L') /* unofficial direct color */ #define ID_DPPS MAKE_ID('D', 'P', 'P', 'S') /* ? */ diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c index 92d4d6f2..b9b89862 100644 --- a/converter/ppm/ilbmtoppm.c +++ b/converter/ppm/ilbmtoppm.c @@ -1597,8 +1597,8 @@ rgbn_to_ppm(FILE * const ifP, Multipalette chunk reader Currently there are three multipalette formats: - SHAM - sliced HAM (obselete) - CTBL - dynamic HAM/Hires (obselete) + SHAM - sliced HAM (obsolete) + CTBL - dynamic HAM/Hires (obsolete) PCHG - palette change There is no official documentation available for SHAM and CTBL, so this is mostly guesswork from other sources and hexdumps of pictures... diff --git a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c index b8b94f74..ffb01d0c 100644 --- a/converter/ppm/pjtoppm.c +++ b/converter/ppm/pjtoppm.c @@ -143,7 +143,7 @@ main(int argc, const char ** argv) { switch (c) { case 'M': /* transmission mode */ if (val != 0 && val != 1) - pm_error("unimplemented trasmission mode %d", val); + pm_error("unimplemented transmission mode %d", val); mode = val; break; case 'V': /* send plane */ diff --git a/converter/ppm/ppmtoarbtxt.c b/converter/ppm/ppmtoarbtxt.c index 6d4ed04e..6d4c6eac 100644 --- a/converter/ppm/ppmtoarbtxt.c +++ b/converter/ppm/ppmtoarbtxt.c @@ -1079,7 +1079,7 @@ readSkeletonFile(const char * const filename, int rc; rc = getc(sklfileP); if (rc == EOF) { - /* Not a replacement sequence, just an escape caharacter + /* Not a replacement sequence, just an escape character at the end of the file. */ Buffer_add(&buffer, escape); diff --git a/converter/ppm/ppmtobmp.c b/converter/ppm/ppmtobmp.c index f89cec8d..41cee482 100644 --- a/converter/ppm/ppmtobmp.c +++ b/converter/ppm/ppmtobmp.c @@ -138,7 +138,7 @@ parseCommandLine(int argc, const char ** argv, cmdlineP->inputFilename = pm_strdup(argv[1]); else pm_error("Too many arguments. The only argument accepted " - "is the input file specificaton"); + "is the input file specification"); free(option_def); } diff --git a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c index 5b0b3245..50b790d6 100644 --- a/converter/ppm/ppmtomitsu.c +++ b/converter/ppm/ppmtomitsu.c @@ -705,7 +705,7 @@ main(int argc, char * argv[]) { for (row = 0; row < rows; ++row) ppm_readppmrow(ifP, pixels[row], cols, maxval, format); - /* first check wether we can use the lut transfer */ + /* first check whether we can use the lut transfer */ table = ppm_computecolorhist(pixels, cols, rows, MAXLUTCOL+1, &nColor); diff --git a/converter/ppm/ppmtompeg/LOGIC b/converter/ppm/ppmtompeg/LOGIC index 8c19dc8d..b346d597 100644 --- a/converter/ppm/ppmtompeg/LOGIC +++ b/converter/ppm/ppmtompeg/LOGIC @@ -45,7 +45,7 @@ is ready. When an encoder server finishes an assignment, it connects to the master server TCP listen port and tells the master it is done, and receives over -the same connetion its next assignment. If there is no more work to do, +the same connection its next assignment. If there is no more work to do, the master server instead tells the encoder server just to terminate. When the master server has told every encoder server to terminate, it diff --git a/converter/ppm/ppmtompeg/Makefile b/converter/ppm/ppmtompeg/Makefile index eeab9727..9ad09c77 100644 --- a/converter/ppm/ppmtompeg/Makefile +++ b/converter/ppm/ppmtompeg/Makefile @@ -124,7 +124,7 @@ profile: LDFLAGS_TARGET = \ PERL = perl # The following stuff is for the Huffman encoding tables. It's commented-out -# because you probably don't want to change this. If you do, then uncommment +# because you probably don't want to change this. If you do, then uncomment # it. # # huff.h: huff.c diff --git a/converter/ppm/ppmtompeg/bsearch.c b/converter/ppm/ppmtompeg/bsearch.c index c618bbd4..b825ef72 100644 --- a/converter/ppm/ppmtompeg/bsearch.c +++ b/converter/ppm/ppmtompeg/bsearch.c @@ -26,7 +26,7 @@ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -/* +/* * $Header: /n/picasso/project/mpeg/mpeg_dist/mpeg_encode/RCS/bsearch.c,v 1.10 1995/08/07 21:49:01 smoot Exp $ * $Log: bsearch.c,v $ * Revision 1.10 1995/08/07 21:49:01 smoot @@ -37,7 +37,7 @@ * (B frames which are backward P's at the start of a sequence) * * Revision 1.8 1995/03/27 19:17:43 smoot - * killed useless type error messge (int32 defiend as int) + * killed useless type error message (int32 defined as int) * * Revision 1.7 1995/01/19 23:07:20 eyhung * Changed copyrights @@ -194,7 +194,7 @@ FindBestMatchExhaust(const LumBlock * const blockP, /* maybe should try spiral pattern centered around prev motion vector? */ - /* try a spiral pattern */ + /* try a spiral pattern */ for (distance = stepSize; distance <= searchRange; distance += stepSize) { @@ -212,7 +212,7 @@ FindBestMatchExhaust(const LumBlock * const blockP, m.y = my; m.x = mx; diff = LumAddMotionError(currentBlockP, blockP, prev, by, bx, m, bestDiff); - + if (diff < bestDiff) { *motionP = m; bestDiff = diff; @@ -237,7 +237,7 @@ FindBestMatchExhaust(const LumBlock * const blockP, diff = LumAddMotionError(currentBlockP, blockP, prev, by, bx, m, bestDiff); - + if (diff < bestDiff) { *motionP = m; bestDiff = diff; @@ -310,7 +310,7 @@ FindBestMatchTwoLevel(const LumBlock * const blockP, if (VALID_MOTION(*motionP)) { bestDiff = LumAddMotionError(currentBlockP, blockP, prev, by, bx, *motionP, bestSoFar); - + if (bestSoFar < bestDiff) bestDiff = bestSoFar; } else { @@ -323,7 +323,7 @@ FindBestMatchTwoLevel(const LumBlock * const blockP, /* maybe should try spiral pattern centered around prev motion vector? */ - /* try a spiral pattern */ + /* try a spiral pattern */ for ( distance = 2; distance <= searchRange; distance += 2 ) { tempRightMY = MIN(distance, rightMY); tempRightMX = MIN(distance, rightMX); @@ -339,7 +339,7 @@ FindBestMatchTwoLevel(const LumBlock * const blockP, m.y = my; m.x = mx; diff = LumAddMotionError(currentBlockP, blockP, prev, by, bx, m, bestDiff); - + if (diff < bestDiff) { *motionP = m; bestDiff = diff; @@ -361,7 +361,7 @@ FindBestMatchTwoLevel(const LumBlock * const blockP, m.y = my; m.x = mx; diff = LumAddMotionError(currentBlockP, blockP, prev, by, bx, m, bestDiff); - + if (diff < bestDiff) { *motionP = m; bestDiff = diff; @@ -423,7 +423,7 @@ trySpacing(int const spacing, MpegFrame * const prev, int const by, int const bx) { - + int tempRightMY, tempRightMX; int my; int bestDiff; @@ -435,7 +435,7 @@ trySpacing(int const spacing, tempRightMY = MIN(rightMY, center.y + spacing + 1); tempRightMX = MIN(rightMX, center.x + spacing + 1); - + for (my = center.y - spacing; my < tempRightMY; my += spacing) { if (my >= leftMY) { int mx; @@ -446,7 +446,7 @@ trySpacing(int const spacing, m.y = my; m.x = mx; diff = LumAddMotionError(currentBlockP, blockP, prev, by, bx, m, bestDiff); - + if (diff < bestDiff) { /* We have a new best */ newCenter = m; @@ -466,7 +466,7 @@ static void chooseNewSpacing(int const oldSpacing, int const stepSize, int * const newSpacingP) { - + if (stepSize == 2) { /* make sure spacing is even */ if (oldSpacing == 2) *newSpacingP = 0; @@ -530,7 +530,7 @@ FindBestMatchLogarithmic(const LumBlock * const blockP, /* Start at (0,0) */ center.y = center.x = 0; - + while (spacing >= stepSize) { trySpacing(spacing, center, bestDiff, ¢er, &bestDiff, @@ -580,7 +580,7 @@ FindBestMatchSubSample(const LumBlock * const blockP, int const searchRange) { /* too lazy to write the code for this... */ - + return FindBestMatchExhaust(blockP, currentBlockP, prev, by, bx, motionP, bestSoFar, searchRange); @@ -671,9 +671,9 @@ BMotionSearchNoInterp(const LumBlock * const currentBlockP, /* CALL SEARCH PROCEDURE */ switch(psearchAlg) { case PSEARCH_SUBSAMPLE: - *forwardErrP = PSubSampleSearch(currentBlockP, prev, by, bx, + *forwardErrP = PSubSampleSearch(currentBlockP, prev, by, bx, &motionP->fwd,searchRangeB); - *backErrP = PSubSampleSearch(currentBlockP, next, by, bx, + *backErrP = PSubSampleSearch(currentBlockP, next, by, bx, &motionP->bwd, searchRangeB); break; case PSEARCH_EXHAUSTIVE: @@ -690,9 +690,9 @@ BMotionSearchNoInterp(const LumBlock * const currentBlockP, *forwardErrP, searchRangeB); break; case PSEARCH_LOGARITHMIC: - *forwardErrP = PLogarithmicSearch(currentBlockP, prev, by, bx, + *forwardErrP = PLogarithmicSearch(currentBlockP, prev, by, bx, &motionP->fwd, searchRangeB); - *backErrP = PLogarithmicSearch(currentBlockP, next, by, bx, + *backErrP = PLogarithmicSearch(currentBlockP, next, by, bx, &motionP->bwd, searchRangeB); break; case PSEARCH_TWOLEVEL: @@ -731,7 +731,7 @@ BMotionSearchNoInterp(const LumBlock * const currentBlockP, * *fmyP,fmxP,bmyP,bmxP are inputs as well as outputs. We do not update * them if it would make the error worse than the existing values. Otherwise, * we update them to the vectors we find to be best. - * + * *===========================================================================*/ static int BMotionSearchSimple(const LumBlock * const currentBlockP, @@ -750,7 +750,7 @@ BMotionSearchSimple(const LumBlock * const currentBlockP, /* STEP 1 */ BMotionSearchNoInterp(currentBlockP, prev, next, by, bx, motionP, &forwardErr, &backErr, TRUE); - + /* STEP 2 */ ComputeBMotionLumBlock(prev, next, by, bx, MOTION_INTERPOLATE, @@ -799,7 +799,7 @@ BMotionSearchCross2(const LumBlock * const currentBlockP, int const bx, motion * const motionP, int const oldMode) { - + int retval; LumBlock forwardBlock, backBlock; int32 forwardErr, backErr; @@ -816,19 +816,19 @@ BMotionSearchCross2(const LumBlock * const currentBlockP, { /* STEP 2 */ - + struct motion motion; motion.fwd = motionP->fwd; motion.bwd.y = motion.bwd.x = 0; ComputeBMotionLumBlock(prev, next, by, bx, MOTION_FORWARD, motion, &forwardBlock); - + motion.fwd.y = motion.fwd.x = 0; motion.bwd = motionP->bwd; ComputeBMotionLumBlock(prev, next, by, bx, MOTION_BACKWARD, motion, &backBlock); } - /* try a cross-search; total of 4 local searches */ + /* try a cross-search; total of 4 local searches */ newMotion = *motionP; interpErrF = FindBestMatch(&forwardBlock, currentBlockP, @@ -934,11 +934,11 @@ BMotionSearchExhaust(const LumBlock * const currentBlockP, motion, &forwardBlock); newMotion = motion.fwd; - + diff = FindBestMatch(&forwardBlock, currentBlockP, next, by, bx, &newMotion, bestDiff, searchRangeB); - + if (diff < bestDiff) { motionP->fwd = motion.fwd; motionP->bwd = newMotion; @@ -968,7 +968,7 @@ BMotionSearchExhaust(const LumBlock * const currentBlockP, * * PRECONDITIONS: The relevant block in 'current' is valid (it has not * been dct'd). Thus, the data in 'current' can be - * accesed through y_blocks, cr_blocks, and cb_blocks. + * accessed through y_blocks, cr_blocks, and cb_blocks. * This is not the case for the blocks in 'prev' and * 'next.' Therefore, references into 'prev' and 'next' * should be done @@ -1001,7 +1001,7 @@ BMotionSearch(const LumBlock * const currentBlockP, PMotionSearch(currentBlockP, next, by, bx, &motionP->bwd); return MOTION_BACKWARD; } - + /* otherwise simply call the appropriate algorithm, based on user preference */ diff --git a/converter/ppm/ppmtompeg/examples/payam.param b/converter/ppm/ppmtompeg/examples/payam.param index ce886914..e9287a89 100644 --- a/converter/ppm/ppmtompeg/examples/payam.param +++ b/converter/ppm/ppmtompeg/examples/payam.param @@ -16,7 +16,7 @@ kh*.pnm [1-3] END_INPUT -# motion vector search paramters +# motion vector search parameters # MAD or MSE -- must be upper case ERROR MAD diff --git a/converter/ppm/ppmtompeg/examples/payam18.param b/converter/ppm/ppmtompeg/examples/payam18.param index 7f7b767e..95839e83 100644 --- a/converter/ppm/ppmtompeg/examples/payam18.param +++ b/converter/ppm/ppmtompeg/examples/payam18.param @@ -15,7 +15,7 @@ kh*.pnm [1-39] END_INPUT -# motion vector search paramters +# motion vector search parameters # FULL or HALF -- must be upper case PIXEL HALF diff --git a/converter/ppm/ppmtompeg/examples/template.param b/converter/ppm/ppmtompeg/examples/template.param index 78ad5300..fb837428 100644 --- a/converter/ppm/ppmtompeg/examples/template.param +++ b/converter/ppm/ppmtompeg/examples/template.param @@ -138,7 +138,7 @@ BQSCALE 25 # this must be ORIGINAL or DECODED REFERENCE_FRAME ORIGINAL -# for parallel parameters see parallel.param in the exmaples subdirectory +# for parallel parameters see parallel.param in the examples subdirectory # if you want constant bit-rate mode, specify it as follows (number is bits/sec): BIT_RATE 1000000 diff --git a/converter/ppm/ppmtompeg/frametype.c b/converter/ppm/ppmtompeg/frametype.c index 09afa403..debefcdc 100644 --- a/converter/ppm/ppmtompeg/frametype.c +++ b/converter/ppm/ppmtompeg/frametype.c @@ -13,7 +13,7 @@ * FType_FutureRef returns the number of the future reference frame * * FType_PastRef returns the number of the past reference frame * * * - * 00.12.07 change malloc from frameTable to calloc to fix bug + * 00.12.07 change malloc from frameTable to calloc to fix bug *===========================================================================*/ /* @@ -86,24 +86,24 @@ FType_Type(unsigned int const frameNum) { char retval; - if (use_cache) + if (use_cache) return frameTable[frameNum].typ; - + if (frameNum+1 == numFrames) { /* It's the last frame in the sequence. If the pattern says it's a B, we convert it to I because a B frame makes no sense as the last frame of a sequence. */ - if (patternedType == 'b') + if (patternedType == 'b') retval = 'i'; - else + else retval = patternedType; } else { if (specificsOn) { static int lastI = -1; int newtype; - - if (lastI > frameNum) + + if (lastI > frameNum) lastI = -1; newtype = SpecTypeLookup(frameNum); switch (newtype) { @@ -119,13 +119,13 @@ FType_Type(unsigned int const frameNum) { break; default: if (lastI != -1) { - unsigned int const pretendFrameNumber = + unsigned int const pretendFrameNumber = (frameNum - lastI + firstI) % framePatternLen; retval = framePattern[pretendFrameNumber]; - } else + } else retval = patternedType; } - } else + } else retval = patternedType; } return retval; @@ -180,7 +180,7 @@ FType_PastRef(currFrameNum) } else { index = currFrameNum % framePatternLen; pastIndex = frameTable[index].prev->number; - + return currFrameNum - (((index-pastIndex)+framePatternLen) % framePatternLen); } @@ -227,14 +227,14 @@ SetFramePattern(const char * const pattern) { firstI = -1; for (index = 0; index < len; index++) { switch( SIMPLE_ASCII_UPPER(pattern[index]) ) { - case 'I': + case 'I': buf[index] = 'i'; if (firstI == -1) firstI = index; break; - case 'P': - buf[index] = 'p'; + case 'P': + buf[index] = 'p'; break; - case 'B': + case 'B': buf[index] = 'b'; break; default: @@ -248,7 +248,7 @@ SetFramePattern(const char * const pattern) { framePattern = buf; framePatternLen = len; - + /* Used to ComputeFrameTable(), but now must wait until param parsed. (STDIN or not) */ @@ -259,7 +259,7 @@ SetFramePattern(const char * const pattern) { void ComputeFrameTable(unsigned int const numFramesArg) { /*---------------------------------------------------------------------------- - Compute a table of I, P, B frames to help in determining dependencie + Compute a table of I, P, B frames to help in determining dependency 'numFrames' == 0 means number of frames is not known at this time. -----------------------------------------------------------------------------*/ @@ -339,7 +339,7 @@ ComputeFrameTable(unsigned int const numFramesArg) { break; } } - + /* why? SRS */ frameTable[table_size].number = framePatternLen; ptr = firstB; @@ -362,3 +362,6 @@ ComputeFrameTable(unsigned int const numFramesArg) { if (numFrames) use_cache = TRUE; } + + + diff --git a/converter/ppm/ppmtompeg/jpeg.c b/converter/ppm/ppmtompeg/jpeg.c index 24c9ae2d..4540f6f0 100644 --- a/converter/ppm/ppmtompeg/jpeg.c +++ b/converter/ppm/ppmtompeg/jpeg.c @@ -1,12 +1,12 @@ /*===========================================================================* - * jpeg.c - * - * procedures to deal with JPEG files - * - * EXPORTED PROCEDURES: - * JMovie2JPEG - * ReadJPEG - * + * jpeg.c + * + * procedures to deal with JPEG files + * + * EXPORTED PROCEDURES: + * JMovie2JPEG + * ReadJPEG + * *===========================================================================*/ /* COPYRIGHT INFORMATION IS AT THE END OF THIS FILE */ @@ -20,7 +20,7 @@ /* With the lossless jpeg patch applied to the Jpeg library (ftp://ftp.wizards.dupont.com/pub/ImageMagick/delegates/ljpeg-6b.tar.gz), the name of min_DCT_scaled_size changes to min_codec_data_unit, - for some reason. With this macro, we change it back. + for some reason. With this macro, we change it back. */ #define min_codec_data_unit min_DCT_scaled_size #include <jpeglib.h> @@ -40,7 +40,7 @@ /* make it happier.... */ #undef DCTSIZE2 -/* jcopy_sample_rows() is an internal routine in the JPEG library, not +/* jcopy_sample_rows() is an internal routine in the JPEG library, not meant for use by us. We should figure out what the official interface for this is and use it. The following is copied out of jpegint.h, which is part of the JPEG library source code. @@ -88,7 +88,7 @@ void JMovie2JPEG(const char * const infilename, /* input filename string */ const char * const obase, - /* output filename base string=>obase##.jpg */ + /* output filename base string=>obase##.jpg */ int const start, /* first frame to be extracted */ int const end @@ -126,154 +126,154 @@ JMovie2JPEG(const char * const infilename, for the appending of the jpeg bitstream. It can be made smaller if you have a better idea of its expected size */ - static unsigned char inbuffer[300000] = { - 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, + static unsigned char inbuffer[300000] = { + 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x01, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x11, + 0x00, 0x01, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0xF0, 0x01, 0x40, 0x03, 0x01, 0x21, - 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xFF, + 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xFF, 0xDB, 0x00, 0x84, 0x00, 0x10, 0x0B, 0x0C, 0x0E, - 0x0C, 0x0A, 0x10, 0x0E, 0x0D, 0x0E, 0x12, + 0x0C, 0x0A, 0x10, 0x0E, 0x0D, 0x0E, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 0x1A, 0x18, 0x16, - 0x16, 0x18, 0x31, 0x23, 0x25, 0x1D, 0x28, 0x3A, + 0x16, 0x18, 0x31, 0x23, 0x25, 0x1D, 0x28, 0x3A, 0x33, 0x3D, 0x3C, 0x39, 0x33, 0x38, 0x37, 0x40, - 0x48, 0x5C, 0x4E, 0x40, 0x44, 0x57, 0x45, 0x37, + 0x48, 0x5C, 0x4E, 0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6D, 0x51, 0x57, 0x5F, 0x62, 0x67, - 0x68, 0x67, 0x3E, 0x4D, 0x71, 0x79, 0x70, 0x64, + 0x68, 0x67, 0x3E, 0x4D, 0x71, 0x79, 0x70, 0x64, 0x78, 0x5C, 0x65, 0x67, 0x63, 0x01, 0x11, 0x12, - 0x12, 0x18, 0x15, 0x18, 0x2F, 0x1A, 0x1A, 0x2F, + 0x12, 0x18, 0x15, 0x18, 0x2F, 0x1A, 0x1A, 0x2F, 0x63, 0x42, 0x38, 0x42, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, + 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, + 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, + 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, + 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, + 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0xFF, 0xC4, - 0x01, 0xA2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, + 0x01, 0xA2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, - 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, + 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, - 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, + 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, - 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, + 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15, 0x52, 0xD1, - 0xF0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, + 0xF0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, + 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, - 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, + 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, - 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, + 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, - 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, + 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, - 0xF7, 0xF8, 0xF9, 0xFA, 0x01, 0x00, 0x03, 0x01, + 0xF7, 0xF8, 0xF9, 0xFA, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, - 0x0A, 0x0B, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x0A, 0x0B, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, - 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, + 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, - 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, + 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1, 0xC1, 0x09, 0x23, - 0x33, 0x52, 0xF0, 0x15, 0x62, 0x72, 0xD1, + 0x33, 0x52, 0xF0, 0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25, 0xF1, 0x17, - 0x18, 0x19, 0x1A, 0x26, 0x27, 0x28, 0x29, 0x2A, + 0x18, 0x19, 0x1A, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, - 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, + 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x82, 0x83, - 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, + 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, - 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, + 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, - 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, - 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, 0xE3, 0xE4, 0xE5, + 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2, 0xF3, 0xF4, - 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFF, 0xDA, + 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFF, 0xDA, 0x00, 0x0C, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, - 0x11, 0x00, 0x3F, 0x00 + 0x11, 0x00, 0x3F, 0x00 }; - + if (start > end) { fprintf(stderr,"bad frame numbers\n"); exit(1); } - + /* open J_Movie */ inFile = fopen(infilename, "rb"); if (inFile == NULL) { perror (infilename); exit(1); } - - /* get file descriptor */ + + /* get file descriptor */ fd = fileno(inFile); - + /* The following lines parse the jpeg_movie header and recover the */ - /* relavant information */ + /* relevant information */ fseek(inFile, 8 * sizeof(char), 0); - + if (fread(&ver_no, sizeof(int), 1, inFile) != 1) { perror("Error in reading version"); exit(1); - } + } if (ver_no != 2) { perror("Unrecognized version - Quantization tables may be wrong\n"); } if (fread(&fps, sizeof(int), 1, inFile) != 1) { perror("Error in reading fps"); exit(1); - } + } if (fread (&no_frames, sizeof(int), 1, inFile) != 1) { perror("Error in reading no_frames"); exit(1); - } + } MALLOCARRAY(inoffsets, no_frames); - + if (fread(&width, sizeof(int), 1, inFile) != 1) { perror("Error in reading width"); exit(1); - } + } /* set image width in JFIF header */ inbuffer[27] = (char)(0xFF & (width >> 8)); inbuffer[28] = (char)(0xFF & width); - + if (fread(&height, sizeof(int), 1, inFile) != 1) { perror("Error in reading height"); exit(1); - } + } /* set image height in JFIF header */ inbuffer[25] = (char)(0xFF & (height >> 8)); inbuffer[26] = (char)(0xFF & height); - + if (fread(&bandwidth, sizeof(int), 1, inFile) != 1) { perror("Error in reading bandwidth"); exit(1); - } - + } + if (fread(&qfactor, sizeof(int), 1, inFile) != 1) { perror("Error in reading qfactor"); exit(1); - } + } /* The default quality factor = 100, therefore, if our quality factor does not equal 100 we must scale the quantization matrices in the JFIF header - */ + */ /* Note values are clipped to a max of 255 */ if (qfactor != 100) { for (Temp = 44; Temp < 108; ++Temp) { @@ -283,13 +283,13 @@ JMovie2JPEG(const char * const infilename, for (Temp = 109; Temp < 173; ++Temp) { temp = (inbuffer[Temp]*qfactor)/100; inbuffer[Temp] = (char)((temp<255) ? temp : 255); - } + } } - + if (fread(&mapsize, sizeof(int), 1, inFile) != 1) { perror("Error in reading mapsize"); exit(1); - } + } if (fread (&image_offset, sizeof(int), 1, inFile) != 1) { perror("Error in reading image offset"); exit(1); @@ -298,32 +298,32 @@ JMovie2JPEG(const char * const infilename, perror("Error in reading audio tracks"); exit(1); } - + fread(junk,sizeof(int),1,inFile); - + if (fread (&audiosize, sizeof(int), 1, inFile) != 1) { perror("Error in reading audiosize"); exit(1); } - + fseek (inFile, image_offset, 0); - + last = MIN(end, no_frames-1); for (i = 0; i < no_frames; ++i) { fread(&(inoffsets[i]), sizeof(int), 1, inFile); } /* Reads in the frame sizes into the array */ - + rewind(inFile); - /* Extract JFIF files from J_Movie */ + /* Extract JFIF files from J_Movie */ for (i = start; i <= last; ++i) { size = inoffsets[i] - inoffsets[i-1]- 5; - lseek(fd, inoffsets[i-1], 0); + lseek(fd, inoffsets[i-1], 0); read(fd, &(op_code), 1); while (op_code != 0xffffffec) { read(fd,junk,audiosize); - read(fd, &(op_code), 1); + read(fd, &(op_code), 1); size = size - audiosize ; } /* To skip the audio bytes in each frame */ read(fd, jpeg_size, 4); @@ -331,7 +331,7 @@ JMovie2JPEG(const char * const infilename, sprintf(ofname, "%s%d.jpg", obase, i); outFile = fopen(ofname, "wb"); fwrite(inbuffer, (size+607), sizeof(char), outFile); - fclose(outFile); + fclose(outFile); } free(inoffsets); fclose(inFile); @@ -413,50 +413,50 @@ ReadJPEG(MpegFrame * const mf, jpeg_stdio_src(&cinfo, fp); } } - + /* specify data source (eg, a file) */ - + jpeg_stdio_src(&cinfo, fp); - + /* read file parameters with jpeg_read_header() */ - - + + (void) jpeg_read_header(&cinfo, TRUE); /* We can ignore the return value from jpeg_read_header since * (a) suspension is not possible with the stdio data source, and * (b) we passed TRUE to reject a tables-only JPEG file as an error. */ - + /* set parameters for decompression */ cinfo.raw_data_out = TRUE; cinfo.out_color_space = JCS_YCbCr; - + /* calculate image output dimensions */ jpeg_calc_output_dimensions(&cinfo); /* the above calculation will set these soon */ /* for now we'll set them ourselves */ - + /* tell mpeg_encode the size of the JPEG Image*/ Fsize_Note(mf->id,(int)(cinfo.image_width),(int)(cinfo.image_height)); - + /* Allocate memory for the raw YCbCr data to occupy*/ Frame_AllocYCC(mf); /*allocate space for mpeg frame*/ - + /* copy pointers to array structure- this make the following code more compact */ orig[0] = mf->orig_y; orig[1] = mf->orig_cb; orig[2] = mf->orig_cr; - + /* Note that we can use the info obtained from jpeg_read_header. */ - + /* Start decompressor */ - + jpeg_start_decompress(&cinfo); - - + + /* JSAMPLEs per row in output buffer */ /* collect component subsample values*/ for (cp=0, compptr = cinfo.comp_info; @@ -470,28 +470,28 @@ ReadJPEG(MpegFrame * const mf, max_h_samp = (temp_h<h_samp[2]) ? h_samp[2]:temp_h; temp_v = (v_samp[0]<v_samp[1]) ? v_samp[1] : v_samp[0]; max_v_samp = (temp_v<v_samp[2]) ? v_samp[2]:temp_v; - + /* Make an 8-row-high sample array that will go away when done with image */ buffer_height = cinfo.max_v_samp_factor * minDctVScaledSize(cinfo); - + for(cp=0,compptr = cinfo.comp_info;cp<cinfo.num_components; cp++,compptr++) { ncols[cp] = (JDIMENSION)((cinfo.image_width*compptr->h_samp_factor)/ max_h_samp); - + nrows[cp] = (JDIMENSION)((buffer_height*compptr->v_samp_factor)/ max_v_samp); - + scanarray[cp] = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, ncols[cp], nrows[cp]); } - + /* while (scan lines remain to be read) jpeg_read_scanlines(...); */ - + /* Here we use the library's state variable cinfo.output_scanline as the * loop counter, so that we don't have to keep track ourselves. */ @@ -525,29 +525,29 @@ ReadJPEG(MpegFrame * const mf, } } else pm_error("Invalid subsampling ratio"); - + /* transfer data from jpeg buffer to MPEG frame */ /* calculate the row we wish to output into */ for (ci = 0, compptr = cinfo.comp_info; ci < cinfo.num_components; ++ci, ++compptr) { current_row[ci] =((cinfo.output_scanline - buffer_height)* - (v_samp[ci])/max_v_samp); - + (v_samp[ci])/max_v_samp); + jcopy_sample_rows(scanarray[ci],0,(JSAMPARRAY)(orig[ci]), current_row[ci],nrows[ci],ncols[ci]); } - } - + } + /* Step 7: Finish decompression */ - + (void) jpeg_finish_decompress(&cinfo); /* We can ignore the return value since suspension is not possible * with the stdio data source. */ - + /* Step 8: Release JPEG decompression object */ - + /* ** DO NOT release the cinfo struct if we are reading from stdin, this ** is because the cinfo struct contains the read buffer, and the read @@ -572,7 +572,7 @@ ReadJPEG(MpegFrame * const mf, think that jpeg_destroy can do an error exit, but why assume anything...) */ - + /* At this point you may want to check to see whether any corrupt-data * warnings occurred (test whether jerr.pub.num_warnings is nonzero). * If you prefer to treat corrupt data as a fatal error, override the diff --git a/converter/ppm/ppmtompeg/mheaders.c b/converter/ppm/ppmtompeg/mheaders.c index 4cfe49ac..98e1b063 100644 --- a/converter/ppm/ppmtompeg/mheaders.c +++ b/converter/ppm/ppmtompeg/mheaders.c @@ -39,7 +39,7 @@ * $Header: /n/picasso/project/mpeg/mpeg_dist/mpeg_encode/RCS/mheaders.c,v 1.15 1995/08/07 21:45:19 smoot Exp $ * $Log: mheaders.c,v $ * Revision 1.15 1995/08/07 21:45:19 smoot - * check for illegal MVs (shouldnt ever be called, but....) + * check for illegal MVs (shouldn't ever be called, but....) * fix bug which made us not weite Iframe Qscale changes * warns if writing a size=0 mpeg * @@ -746,7 +746,7 @@ Mhead_GenSequenceHeader(BitBucket * const bbPtr, } Bitio_Write(bbPtr, pratio, 4); - /* Wrtie picture rate, negative values default to 30 fps. */ + /* Write picture rate, negative values default to 30 fps. */ if (pict_rate < 0) { fprintf(stderr, "PROGRAMMER ERROR: pict_rate = %d\n", pict_rate); diff --git a/converter/ppm/ppmtompeg/mpeg.c b/converter/ppm/ppmtompeg/mpeg.c index 33e1a9f9..cb014b32 100644 --- a/converter/ppm/ppmtompeg/mpeg.c +++ b/converter/ppm/ppmtompeg/mpeg.c @@ -91,7 +91,7 @@ static boolean frameCountsUnknown; /*==================* - * GLOBAL VARIABLES * + * GLOBAL VARIABLES * *==================*/ /* important -- don't initialize anything here */ @@ -142,14 +142,14 @@ ShowRemainingTime(boolean const childProcess) { /* nothing */; } else if ( numI + numP + numB == 0 ) { /* no time left */ - } else if ( timeMask != 0 ) { + } else if ( timeMask != 0 ) { /* haven't encoded all types yet */ } else { static int lastTime = 0; float total; time_t nowTime; float secondsPerFrame; - + time(&nowTime); secondsPerFrame = (nowTime-timeStart)/(float)framesOutput; total = secondsPerFrame*(float)(numI+numP+numB); @@ -174,7 +174,7 @@ static void initTCTime(unsigned int const firstFrameNumber) { unsigned int frameNumber; - + tc_hrs = 0; tc_min = 0; tc_sec = 0; tc_pict = 0; tc_extra = 0; for (frameNumber = 0; frameNumber < firstFrameNumber; ++frameNumber) IncrementTCTime(); @@ -201,13 +201,13 @@ IncrementTCTime() { otherwise, it is the number of extra 1/1001 frames we've passed by so far; for example, if fps = 24000/1001, then 24 frames = 24024/24000 - seconds = 1 second + 24/24000 seconds = 1 + 1/1000 seconds; similary, + seconds = 1 second + 24/24000 seconds = 1 + 1/1000 seconds; similarly, if fps = 30000/1001, then 30 frames = 30030/30000 = 1 + 1/1000 seconds and if fps = 60000/1001, then 60 frames = 1 + 1/1000 seconds if fps = 24000/1001, then 1/1000 seconds = 24/1001 frames if fps = 30000/1001, then 1/1000 seconds = 30/1001 frames - if fps = 60000/1001, then 1/1000 seconds = 60/1001 frames + if fps = 60000/1001, then 1/1000 seconds = 60/1001 frames */ totalFramesSent++; @@ -250,7 +250,7 @@ initializeRateControl(bool const wantUnderflowWarning, */ } } - + /*===========================================================================* @@ -294,16 +294,16 @@ finishFrameOutput(MpegFrame * const frameP, boolean const childProcess, boolean const remoteIO) { - if ((referenceFrame == DECODED_FRAME) && + if ((referenceFrame == DECODED_FRAME) && childProcess && NonLocalRefFrame(frameP->id)) { if (remoteIO) SendDecodedFrame(frameP); else WriteDecodedFrame(frameP); - + NotifyDecodeServerReady(frameP->id); } - + if (separateFiles) { if (remoteIO) SendRemoteFrame(frameP->id, bbP); @@ -314,7 +314,7 @@ finishFrameOutput(MpegFrame * const frameP, } } - + static void @@ -324,41 +324,41 @@ outputIFrame(MpegFrame * const frameP, int const realEnd, MpegFrame * const pastRefFrameP, boolean const separateFiles) { - + /* only start a new GOP with I */ /* don't start GOP if only doing frames */ if (!separateFiles && currentGOP >= gopSize) { - boolean const closed = + boolean const closed = (totalFramesSent == frameP->id || pastRefFrameP == NULL); static int num_gop = 0; - + /* first, check to see if closed GOP */ - + /* new GOP */ - if (num_gop != 0 && mult_seq_headers && + if (num_gop != 0 && mult_seq_headers && num_gop % mult_seq_headers == 0) { if (!realQuiet) { - fprintf(stdout, + fprintf(stdout, "Creating new Sequence before GOP %d\n", num_gop); fflush(stdout); } - + Mhead_GenSequenceHeader( bbP, Fsize_x, Fsize_y, /* pratio */ aspectRatio, /* pict_rate */ frameRate, /* bit_rate */ bit_rate, /* buf_size */ buf_size, /* c_param_flag */ 1, - /* iq_matrix */ customQtable, + /* iq_matrix */ customQtable, /* niq_matrix */ customNIQtable, /* ext_data */ NULL, /* ext_data_size */ 0, /* user_data */ NULL, /* user_data_size */ 0); } - + if (!realQuiet) pm_message("Creating new GOP (closed = %s) before frame %d\n", closed ? "YES" : "NO", frameP->id); - + ++num_gop; Mhead_GenGOPHeader(bbP, /* drop_frame_flag */ 0, tc_hrs, tc_min, tc_sec, tc_pict, @@ -371,13 +371,13 @@ outputIFrame(MpegFrame * const frameP, else SetGOPStartTime(pastRefFrameP->id + 1); } - + if (frameP->id >= realStart && frameP->id <= realEnd) GenIFrame(bbP, frameP); - + --numI; timeMask &= 0x6; - + ++currentGOP; IncrementTCTime(); } @@ -396,7 +396,7 @@ outputPFrame(MpegFrame * const frameP, --numP; timeMask &= 0x5; - + ++currentGOP; IncrementTCTime(); } @@ -464,7 +464,7 @@ getBFrame(int const frameNum, *bFramePP = bFrameP; } else { /* As the frame input is serial, we can't read the B frame now. - Rather, Caller has already read it and chained it to + Rather, Caller has already read it and chained it to the previous reference frame. So we get that copy now. */ *bFramePP = pastRefFrameP->next; @@ -510,15 +510,15 @@ processBFrames(MpegFrame * const pastRefFrameP, assert(pastRefFrameP != NULL); assert(futureRefFrameP != NULL); - - for (frameNum = MAX(realStart, firstBFrameNum); - frameNum < MIN(realEnd, futureRefFrameP->id); + + for (frameNum = MAX(realStart, firstBFrameNum); + frameNum < MIN(realEnd, futureRefFrameP->id); ++frameNum) { MpegFrame * bFrame; BitBucket * bbP; - getBFrame(frameNum, inputSourceP, pastRefFrameP, childProcess, + getBFrame(frameNum, inputSourceP, pastRefFrameP, childProcess, remoteIO, &bFrame, IOtimeP, framesReadP); @@ -554,7 +554,7 @@ processBFrames(MpegFrame * const pastRefFrameP, static void -processRefFrame(MpegFrame * const frameP, +processRefFrame(MpegFrame * const frameP, BitBucket * const wholeStreamBbP, int const realStart, int const realEnd, @@ -574,18 +574,18 @@ processRefFrame(MpegFrame * const frameP, -----------------------------------------------------------------------------*/ if (frameP->id >= realStart && frameP->id <= realEnd) { bool const separateFiles = (wholeStreamBbP == NULL); - + BitBucket * bbP; - + if (separateFiles) bbP = bitioNew(outputFileName, frameP->id, remoteIO); else bbP = wholeStreamBbP; - + /* first, output this reference frame */ switch (frameP->type) { case TYPE_IFRAME: - outputIFrame(frameP, bbP, realStart, realEnd, pastRefFrameP, + outputIFrame(frameP, bbP, realStart, realEnd, pastRefFrameP, separateFiles); break; case TYPE_PFRAME: @@ -595,10 +595,10 @@ processRefFrame(MpegFrame * const frameP, default: pm_error("INTERNAL ERROR: non-reference frame passed to " "ProcessRefFrame()"); - } - + } + ++(*framesOutputP); - + finishFrameOutput(frameP, bbP, separateFiles, referenceFrame, childProcess, remoteIO); } @@ -620,7 +620,7 @@ countFrames(unsigned int const firstFrame, -----------------------------------------------------------------------------*/ unsigned int numI, numP, numB; unsigned int timeMask; - + numI = 0; numP = 0; numB = 0; timeMask = 0; if (stdinUsed) { @@ -663,7 +663,7 @@ readAndSaveFrame(struct inputSource * const inputSourceP, type 'frameType'. Increment *framesReadP. - + Add the time it took to read it, in seconds, to *iotimeP. Iff we can't read because we hit end of file, return @@ -672,11 +672,11 @@ readAndSaveFrame(struct inputSource * const inputSourceP, /* This really should be part of ReadNthFrame. The frame should be chained to the input object, not the past reference frame. */ - + MpegFrame * p; MpegFrame * frameP; time_t ioTimeStart, ioTimeEnd; - + time(&ioTimeStart); frameP = Frame_New(frameNumber, frameType); @@ -687,15 +687,15 @@ readAndSaveFrame(struct inputSource * const inputSourceP, Frame_Free(frameP); else { ++(*framesReadP); - + time(&ioTimeEnd); *ioTimeP += (ioTimeEnd - ioTimeStart); - /* Add the B frame to the end of the queue of B-frames + /* Add the B frame to the end of the queue of B-frames for later encoding. */ assert(pastRefFrameP != NULL); - + p = pastRefFrameP; while (p->next != NULL) p = p->next; @@ -726,7 +726,7 @@ doFirstFrameStuff(enum frameContext const context, -----------------------------------------------------------------------------*/ *inputFrameBitsP = 24 * Fsize_x * Fsize_y; SetBlocksPerSlice(); - + if (context == CONTEXT_WHOLESTREAM) { int32 const bitstreamMode = getRateMode(); char * userData; @@ -742,11 +742,11 @@ doFirstFrameStuff(enum frameContext const context, bit_rate = -1; buf_size = -1; } - + if (strlen(userDataFileName) != 0) { struct stat statbuf; FILE *fp; - + stat(userDataFileName,&statbuf); userDataSize = statbuf.st_size; userData = malloc(userDataSize); @@ -771,7 +771,7 @@ doFirstFrameStuff(enum frameContext const context, } else { /* Put in our UserData Header */ const char * userDataString; time_t now; - + time(&now); pm_asprintf(&userDataString,"MPEG stream encoded by UCB Encoder " "(mpeg_encode) v%s on %s.", @@ -782,11 +782,11 @@ doFirstFrameStuff(enum frameContext const context, } Mhead_GenSequenceHeader(bbP, Fsize_x, Fsize_y, /* pratio */ aspectRatio, - /* pict_rate */ frameRate, + /* pict_rate */ frameRate, /* bit_rate */ bit_rate, /* buf_size */ buf_size, /*c_param_flag */ 1, - /* iq_matrix */ qtable, + /* iq_matrix */ qtable, /* niq_matrix */ niqtable, /* ext_data */ NULL, /* ext_data_size */ 0, @@ -844,9 +844,9 @@ getPreviousFrame(unsigned int const frameStart, separateConversion, slaveConversion, inputConversion, frameP, &endOfStream); assert(!endOfStream); /* Because Stdin causes failure above */ - } + } ++(*framesReadP); - + time(&ioTimeEnd); *ioTimeP += (ioTimeEnd-ioTimeStart); @@ -858,7 +858,7 @@ getPreviousFrame(unsigned int const frameStart, static void computeFrameRange(unsigned int const frameStart, unsigned int const frameEnd, - enum frameContext const context, + enum frameContext const context, struct inputSource * const inputSourceP, unsigned int * const firstFrameP, unsigned int * const lastFrameP) { @@ -881,13 +881,13 @@ computeFrameRange(unsigned int const frameStart, *firstFrameP = frameStart; /* if last frame is B, need to read in P or I frame after it */ - if ((FType_Type(frameEnd) == 'b') && + if ((FType_Type(frameEnd) == 'b') && (frameEnd != inputSourceP->numInputFiles-1)) { /* can't find the next reference frame interactively */ if (inputSourceP->stdinUsed) pm_error("Cannot encode frames from Standard Input " "when last frame is a B-frame."); - + *lastFrameP = FType_FutureRef(frameEnd); } else *lastFrameP = frameEnd; @@ -930,11 +930,11 @@ getFrame(MpegFrame ** const framePP, time_t ioTimeStart, ioTimeEnd; MpegFrame * frameP; bool endOfStream; - + time(&ioTimeStart); frameP = Frame_New(frameNumber, frameType); - + if ((referenceFrame == DECODED_FRAME) && ((frameNumber < realStart) || (frameNumber > realEnd)) ) { WaitForDecodedFrame(frameNumber); @@ -952,13 +952,13 @@ getFrame(MpegFrame ** const framePP, ReadNthFrame(inputSourceP, frameNumber, remoteIO, childProcess, separateConversion, slaveConversion, inputConversion, frameP, &endOfStream); - + if (endOfStream) { Frame_Free(frameP); *framePP = NULL; } else { ++(*framesReadP); - + time(&ioTimeEnd); *ioTimeP += (ioTimeEnd - ioTimeStart); @@ -988,9 +988,9 @@ handleBitRate(unsigned int const realEnd, static void doAFrame(unsigned int const frameNumber, struct inputSource * const inputSourceP, - enum frameContext const context, - unsigned int const frameStart, - unsigned int const frameEnd, + enum frameContext const context, + unsigned int const frameStart, + unsigned int const frameEnd, unsigned int const realStart, unsigned int const realEnd, bool const childProcess, @@ -1017,7 +1017,7 @@ doAFrame(unsigned int const frameNumber, output each frame to its own individual file instead. -----------------------------------------------------------------------------*/ char const frameType = FType_Type(frameNumber); - + *endOfStreamP = FALSE; /* initial assumption */ if (frameType == 'b') { @@ -1026,44 +1026,44 @@ doAFrame(unsigned int const frameNumber, just read it later. */ *newPastRefFramePP = pastRefFrameP; - if (inputSourceP->stdinUsed) + if (inputSourceP->stdinUsed) readAndSaveFrame(inputSourceP, frameNumber, frameType, inputConversion, pastRefFrameP, framesReadP, &IOtime, endOfStreamP); } else { MpegFrame * frameP; - + getFrame(&frameP, inputSourceP, frameNumber, frameType, realStart, realEnd, referenceFrame, childProcess, remoteIO, separateConversion, slaveConversion, inputConversion, framesReadP, &IOtime); - + if (frameP) { *endOfStreamP = FALSE; if (!*firstFrameDoneP) { doFirstFrameStuff(context, userDataFileName, wholeStreamBbP, Fsize_x, Fsize_y, aspectRatio, - frameRate, qtable, niqtable, + frameRate, qtable, niqtable, inputFrameBitsP); - + *firstFrameDoneP = TRUE; } processRefFrame(frameP, wholeStreamBbP, frameStart, frameEnd, - pastRefFrameP, childProcess, outputFileName, + pastRefFrameP, childProcess, outputFileName, framesReadP, framesOutputP); - + if (pastRefFrameP) { processBFrames(pastRefFrameP, frameP, realStart, realEnd, - inputSourceP, remoteIO, childProcess, + inputSourceP, remoteIO, childProcess, &IOtime, wholeStreamBbP, outputFileName, framesReadP, framesOutputP, ¤tGOP); } if (pastRefFrameP != NULL) Frame_Free(pastRefFrameP); - + *newPastRefFramePP = frameP; } else *endOfStreamP = TRUE; @@ -1074,13 +1074,13 @@ doAFrame(unsigned int const frameNumber, void GenMPEGStream(struct inputSource * const inputSourceP, - enum frameContext const context, - unsigned int const frameStart, - unsigned int const frameEnd, - int32 const qtable[], - int32 const niqtable[], + enum frameContext const context, + unsigned int const frameStart, + unsigned int const frameEnd, + int32 const qtable[], + int32 const niqtable[], bool const childProcess, - FILE * const ofP, + FILE * const ofP, const char * const outputFileName, bool const wantVbvUnderflowWarning, bool const wantVbvOverflowWarning, @@ -1129,7 +1129,7 @@ GenMPEGStream(struct inputSource * const inputSourceP, "(%u frames)", frameEnd, inputSourceP->numInputFiles); if (context == CONTEXT_WHOLESTREAM && - !inputSourceP->stdinUsed && + !inputSourceP->stdinUsed && FType_Type(inputSourceP->numInputFiles-1) == 'b') pm_message("WARNING: " "One or more B-frames at end will not be encoded. " @@ -1188,27 +1188,27 @@ GenMPEGStream(struct inputSource * const inputSourceP, frameNumber <= lastFrame && !endOfStream; ++frameNumber) { - doAFrame(frameNumber, inputSourceP, context, + doAFrame(frameNumber, inputSourceP, context, frameStart, frameEnd, realStart, realEnd, childProcess, outputFileName, pastRefFrameP, &pastRefFrameP, &framesRead, &framesOutput, &firstFrameDone, streamBbP, inputFrameBitsP, &endOfStream); } - + if (pastRefFrameP != NULL) Frame_Free(pastRefFrameP); - + /* SEQUENCE END CODE */ if (context == CONTEXT_WHOLESTREAM) Mhead_GenSequenceEnder(streamBbP); - + if (streamBbP) numBits = streamBbP->cumulativeBits; else { /* What should the correct value be? Most likely 1. "numBits" is - used below, so we need to make sure it's properly initialized - to somthing (anything). + used below, so we need to make sure it's properly initialized + to something (anything). */ numBits = 1; } @@ -1272,9 +1272,9 @@ SetGOPSize(size) * *===========================================================================*/ void -PrintStartStats(time_t const startTime, +PrintStartStats(time_t const startTime, bool const specificFrames, - unsigned int const firstFrame, + unsigned int const firstFrame, unsigned int const lastFrame, struct inputSource * const inputSourceP) { @@ -1296,7 +1296,7 @@ PrintStartStats(time_t const startTime, fprintf(stdout, "\n\n"); } } - + for (i = 0; i < 2; ++i) { if ( ( i == 0 ) && (! realQuiet) ) { fpointer = stdout; @@ -1322,15 +1322,15 @@ PrintStartStats(time_t const startTime, fprintf(fpointer, "INPUT FROM FILES:\n"); GetNthInputFileName(inputSourceP, 0, &inputFileName); - fprintf(fpointer, "FIRST FILE: %s/%s\n", + fprintf(fpointer, "FIRST FILE: %s/%s\n", currentPath, inputFileName); pm_strfree(inputFileName); - GetNthInputFileName(inputSourceP, inputSourceP->numInputFiles-1, + GetNthInputFileName(inputSourceP, inputSourceP->numInputFiles-1, &inputFileName); - fprintf(fpointer, "LAST FILE: %s/%s\n", + fprintf(fpointer, "LAST FILE: %s/%s\n", currentPath, inputFileName); pm_strfree(inputFileName); - } + } fprintf(fpointer, "OUTPUT: %s\n", outputFileName); if (resizeFrame) @@ -1341,15 +1341,15 @@ PrintStartStats(time_t const startTime, fprintf(fpointer, "SLICES PER FRAME: %d\n", slicesPerFrame); if (searchRangeP==searchRangeB) fprintf(fpointer, "RANGE: +/-%d\n", searchRangeP/2); - else fprintf(fpointer, "RANGES: +/-%d %d\n", + else fprintf(fpointer, "RANGES: +/-%d %d\n", searchRangeP/2,searchRangeB/2); - fprintf(fpointer, "PIXEL SEARCH: %s\n", + fprintf(fpointer, "PIXEL SEARCH: %s\n", pixelFullSearch ? "FULL" : "HALF"); fprintf(fpointer, "PSEARCH: %s\n", PSearchName()); fprintf(fpointer, "BSEARCH: %s\n", BSearchName()); - fprintf(fpointer, "QSCALE: %d %d %d\n", qscaleI, + fprintf(fpointer, "QSCALE: %d %d %d\n", qscaleI, GetPQScale(), GetBQScale()); - if (specificsOn) + if (specificsOn) fprintf(fpointer, "(Except as modified by Specifics file)\n"); if ( referenceFrame == DECODED_FRAME ) { fprintf(fpointer, "REFERENCE FRAME: DECODED\n"); @@ -1386,22 +1386,22 @@ NonLocalRefFrame(int const id) { boolean retval; int const lastIPid = FType_PastRef(id); - + /* might be accessed by B-frame */ - + if (lastIPid+1 < realStart) retval = TRUE; else { unsigned int const nextIPid = FType_FutureRef(id); - + /* if B-frame is out of range, then current frame can be - ref'd by it + ref'd by it */ - + /* might be accessed by B-frame */ if (nextIPid > realEnd+1) retval = TRUE; - + /* might be accessed by P-frame */ if ((nextIPid > realEnd) && (FType_Type(nextIPid) == 'p')) retval = TRUE; @@ -1410,7 +1410,7 @@ NonLocalRefFrame(int const id) { } - + /*===========================================================================* * * SetFrameRate @@ -1508,9 +1508,9 @@ ComputeDHMSTime(someTime, timeText) void -ComputeGOPFrames(int const whichGOP, - unsigned int * const firstFrameP, - unsigned int * const lastFrameP, +ComputeGOPFrames(int const whichGOP, + unsigned int * const firstFrameP, + unsigned int * const lastFrameP, unsigned int const numFrames) { /*---------------------------------------------------------------------------- Figure out which frames are in GOP number 'whichGOP'. @@ -1537,7 +1537,7 @@ ComputeGOPFrames(int const whichGOP, if (gopNum == whichGOP) { foundGop = TRUE; firstFrame = frameNum; - } + } /* go past one gop */ /* must go past at least one frame */ @@ -1551,7 +1551,7 @@ ComputeGOPFrames(int const whichGOP, ++frameNum; ++passedB; } - } while ((frameNum < numFrames) && + } while ((frameNum < numFrames) && ((FType_Type(frameNum) != 'i') || (currGOP < gopSize))); currGOP -= gopSize; @@ -1583,7 +1583,7 @@ doEndStats(FILE * const fpointer, fprintf(fpointer, "TIME COMPLETED: %s", ctime(&endTime)); fprintf(fpointer, "%s\n\n", timeText); - + ShowIFrameSummary(inputFrameBits, totalBits, fpointer); ShowPFrameSummary(inputFrameBits, totalBits, fpointer); ShowBFrameSummary(inputFrameBits, totalBits, fpointer); @@ -1595,7 +1595,7 @@ doEndStats(FILE * const fpointer, if (diffTime > 0) { fprintf(fpointer, "Total Frames Per Sec Elapsed: %f (%ld mps)\n", (float)framesOutput/(float)diffTime, - (long)((float)framesOutput * + (long)((float)framesOutput * (float)inputFrameBits / (256.0*24.0*(float)diffTime))); } else { @@ -1613,7 +1613,7 @@ doEndStats(FILE * const fpointer, frameRateRounded, frameRateRounded*totalBits/framesOutput); fprintf(fpointer, "MPEG file created in : %s\n", outputFileName); fprintf(fpointer, "\n\n"); - + if ( computeMVHist ) { ShowPMVHistogram(fpointer); ShowBBMVHistogram(fpointer); @@ -1637,7 +1637,7 @@ doEndStats(FILE * const fpointer, void PrintEndStats(time_t const startTime, time_t const endTime, - unsigned int const inputFrameBits, + unsigned int const inputFrameBits, unsigned int const totalBits) { float totalCPU; @@ -1652,7 +1652,7 @@ PrintEndStats(time_t const startTime, doEndStats(stdout, startTime, endTime, inputFrameBits, totalBits, totalCPU); } - + if (statFile) { doEndStats(statFile, startTime, endTime, inputFrameBits, totalBits, totalCPU); @@ -1664,7 +1664,7 @@ PrintEndStats(time_t const startTime, void -ReadDecodedRefFrame(MpegFrame * const frameP, +ReadDecodedRefFrame(MpegFrame * const frameP, unsigned int const frameNumber) { FILE *fpointer; @@ -1689,7 +1689,7 @@ ReadDecodedRefFrame(MpegFrame * const frameP, }} Frame_AllocDecoded(frameP, TRUE); - + for ( y = 0; y < height; y++ ) { size_t bytesRead; @@ -1697,7 +1697,7 @@ ReadDecodedRefFrame(MpegFrame * const frameP, if (bytesRead != width) pm_error("Could not read enough bytes from '%s;", fileName); } - + for (y = 0; y < (height >> 1); y++) { /* U */ size_t const bytesToRead = width/2; size_t bytesRead; @@ -1706,7 +1706,7 @@ ReadDecodedRefFrame(MpegFrame * const frameP, if (bytesRead != bytesToRead) pm_message("Could not read enough bytes from '%s'", fileName); } - + for (y = 0; y < (height >> 1); y++) { /* V */ size_t const bytesToRead = width/2; size_t bytesRead; @@ -1723,7 +1723,7 @@ static void OpenBitRateFile() { bitRateFile = fopen(bitRateFileName, "w"); if ( bitRateFile == NULL ) { - pm_message("ERROR: Could not open bit rate file: '%s'", + pm_message("ERROR: Could not open bit rate file: '%s'", bitRateFileName); showBitRatePerFrame = FALSE; } @@ -1735,3 +1735,6 @@ static void CloseBitRateFile() { fclose(bitRateFile); } + + + diff --git a/converter/ppm/ppmtompeg/opts.c b/converter/ppm/ppmtompeg/opts.c index 841efdab..c9c94cd6 100644 --- a/converter/ppm/ppmtompeg/opts.c +++ b/converter/ppm/ppmtompeg/opts.c @@ -13,17 +13,17 @@ /* * Copyright (c) 1995 The Regents of the University of California. * All rights reserved. - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. - * + * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS @@ -122,7 +122,7 @@ SkipSpacesTabs(const char * const start) { * SIDE EFFECTS: sets collect_quant and collect_quant_fp * *===========================================================================*/ -static void +static void SetupCollectQuantStats(const char * const charPtr) { char fname[256]; @@ -166,17 +166,17 @@ SetupCollectQuantStats(const char * const charPtr) * SIDE EFFECTS: sets kill_dim, kill_dim_break, kill_dim_end * *===========================================================================*/ -static void +static void SetupKillDimAreas(const char * const charPtr) { int items_scanned; kill_dim = TRUE; - items_scanned = sscanf(charPtr, "%d %d %f", + items_scanned = sscanf(charPtr, "%d %d %f", &kill_dim_break, &kill_dim_end, &kill_dim_slope); if (items_scanned != 3) { kill_dim_slope = 0.25; - items_scanned = sscanf(charPtr, "%d %d", + items_scanned = sscanf(charPtr, "%d %d", &kill_dim_break, &kill_dim_end); if (items_scanned != 2) { /* Use defaults */ @@ -205,10 +205,10 @@ SetupKillDimAreas(const char * const charPtr) * * RETURNS: nothing * - * SIDE EFFECTS: sets squash_max_differences SquashMaxLum SquashMaxChr + * SIDE EFFECTS: sets squash_max_differences SquashMaxLum SquashMaxChr * *===========================================================================*/ -static void +static void SetupSquashSmall(const char * const charPtr) { squash_small_differences = TRUE; @@ -232,7 +232,7 @@ SetupSquashSmall(const char * const charPtr) * can change LocalDCTRateScale, LocalDCTDistortScale * *===========================================================================*/ -static void +static void SetupLocalDCT(const char * const charPtr) { int num_scales=0; @@ -262,7 +262,7 @@ SetupLocalDCT(const char * const charPtr) * SIDE EFFECTS: sets DoLaplace, L1, L2, and Lambdas * *===========================================================================*/ -static void +static void SetupLaplace() { int i; @@ -328,18 +328,18 @@ SetupWriteDistortions(const char * const charPtr) default: fprintf(stderr, "Unknown TUNE parameter setting format %s\n", cp); }} -} +} /*=====================* * EXPORTED PROCEDURES * *=====================*/ -void +void CalcLambdas(void) { int i,j,n; double var; - + n = LaplaceNum; for (i = 0; i < 3; i++) { for (j = 0; j < 64; j++) { @@ -378,11 +378,11 @@ Mpost_UnQuantZigBlockLaplace(in, out, qscale, iblock) /* qtable[0] must be 8 */ out[0][0] = (int16)(in[0] * 8); - + for ( index = 1; index < DCTSIZE_SQ; index++ ) { position = ZAG[index]; level = in[index]; - + if (level == 0) { ((int16 *)out)[position] = 0; continue; @@ -413,7 +413,7 @@ Mpost_UnQuantZigBlockLaplace(in, out, qscale, iblock) } } -int +int mse(Block blk1, Block blk2) { register int index, error, tmp; @@ -447,7 +447,7 @@ void Tune_Init() { int i; - /* Just check for each, and do whats needed */ + /* Just check for each, and do what's needed */ if (collect_quant) { if (!pureDCT) { pureDCT = TRUE; @@ -456,14 +456,14 @@ void Tune_Init() } fprintf(collect_quant_fp, "# %s\n", outputFileName); fprintf(collect_quant_fp, "#"); - for (i=0; i<64; i++) + for (i=0; i<64; i++) fprintf(collect_quant_fp, " %d", qtable[i]); fprintf(collect_quant_fp, "\n#"); - for (i=0; i<64; i++) + for (i=0; i<64; i++) fprintf(collect_quant_fp, " %d", niqtable[i]); - fprintf(collect_quant_fp, "\n# %d %d %d\n\n", + fprintf(collect_quant_fp, "\n# %d %d %d\n\n", GetIQScale(), GetPQScale(), GetBQScale()); - + } if (DoLaplace) { @@ -475,7 +475,7 @@ void Tune_Init() decodeRefFrames = TRUE; printSNR = TRUE; } - + } /*===========================================================================* @@ -492,7 +492,7 @@ void Tune_Init() void ParseTuneParam(const char * const charPtr) { switch (ASCII_TOUPPER(*charPtr)) { - case 'B': + case 'B': if (1 != sscanf(charPtr+2, "%d", &block_bound)) { fprintf(stderr, "Invalid tuning parameter (b) in parameter file.\n"); } diff --git a/converter/ppm/ppmtompeg/parallel.c b/converter/ppm/ppmtompeg/parallel.c index e3bcec1a..0fe635ed 100644 --- a/converter/ppm/ppmtompeg/parallel.c +++ b/converter/ppm/ppmtompeg/parallel.c @@ -1,8 +1,8 @@ /*===========================================================================* - * parallel.c - * - * Procedures to make encoder run in parallel - * + * parallel.c + * + * Procedures to make encoder run in parallel + * *===========================================================================*/ /* COPYRIGHT INFORMATION IS AT THE END OF THIS FILE */ @@ -13,8 +13,8 @@ *==============*/ #define _XOPEN_SOURCE 500 /* Make sure stdio.h contains pclose() */ -/* _ALL_SOURCE is needed on AIX to make the C library include the - socket services (e.g. define struct sockaddr) +/* _ALL_SOURCE is needed on AIX to make the C library include the + socket services (e.g. define struct sockaddr) Note that AIX standards.h actually sets feature declaration macros such as _XOPEN_SOURCE, unless they are already set. @@ -93,7 +93,8 @@ struct scheduler { * CONSTANTS * *==================*/ -#define TERMINATE_PID_SIGNAL SIGTERM /* signal used to terminate forked childs */ +#define TERMINATE_PID_SIGNAL SIGTERM + /* signal used to terminate forked children */ #ifndef MAXARGS #define MAXARGS 1024 /* Max Number of arguments in safe_fork command */ #endif @@ -187,8 +188,8 @@ errorExit(const char format[], ...) { static void -TransmitPortNum(const char * const hostName, - int const portNum, +TransmitPortNum(const char * const hostName, + int const portNum, int const newPortNum) { /*---------------------------------------------------------------------------- Transmit the port number 'newPortNum' to the master on port 'portNum' @@ -196,15 +197,15 @@ TransmitPortNum(const char * const hostName, -----------------------------------------------------------------------------*/ int clientSocket; const char * error; - + ConnectToSocket(hostName, portNum, &hostEntry, &clientSocket, &error); - + if (error) errorExit("Can't connect in order to transmit port number. %s", error); WriteInt(clientSocket, newPortNum); - + close(clientSocket); } @@ -215,19 +216,19 @@ readYUVDecoded(int const socketFd, unsigned int const Fsize_x, unsigned int const Fsize_y, MpegFrame * const frameP) { - + unsigned int y; - + for (y = 0; y < Fsize_y; ++y) /* Y */ - ReadBytes(socketFd, + ReadBytes(socketFd, (unsigned char *)frameP->decoded_y[y], Fsize_x); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* U */ - ReadBytes(socketFd, + ReadBytes(socketFd, (unsigned char *)frameP->decoded_cb[y], (Fsize_x >> 1)); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* V */ - ReadBytes(socketFd, + ReadBytes(socketFd, (unsigned char *)frameP->decoded_cr[y], (Fsize_x >> 1)); } @@ -238,19 +239,19 @@ writeYUVDecoded(int const socketFd, unsigned int const Fsize_x, unsigned int const Fsize_y, MpegFrame * const frameP) { - + unsigned int y; - + for (y = 0; y < Fsize_y; ++y) /* Y */ - WriteBytes(socketFd, + WriteBytes(socketFd, (unsigned char *)frameP->decoded_y[y], Fsize_x); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* U */ - WriteBytes(socketFd, + WriteBytes(socketFd, (unsigned char *)frameP->decoded_cb[y], (Fsize_x >> 1)); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* V */ - WriteBytes(socketFd, + WriteBytes(socketFd, (unsigned char *)frameP->decoded_cr[y], (Fsize_x >> 1)); } @@ -261,19 +262,19 @@ writeYUVOrig(int const socketFd, unsigned int const Fsize_x, unsigned int const Fsize_y, MpegFrame * const frameP) { - + unsigned int y; - + for (y = 0; y < Fsize_y; ++y) /* Y */ - WriteBytes(socketFd, + WriteBytes(socketFd, (unsigned char *)frameP->orig_y[y], Fsize_x); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* U */ - WriteBytes(socketFd, + WriteBytes(socketFd, (unsigned char *)frameP->orig_cb[y], (Fsize_x >> 1)); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* V */ - WriteBytes(socketFd, + WriteBytes(socketFd, (unsigned char *)frameP->orig_cr[y], (Fsize_x >> 1)); } @@ -284,19 +285,19 @@ readYUVOrig(int const socketFd, unsigned int const Fsize_x, unsigned int const Fsize_y, MpegFrame * const frameP) { - + unsigned int y; - + for (y = 0; y < Fsize_y; ++y) /* Y */ - ReadBytes(socketFd, + ReadBytes(socketFd, (unsigned char *)frameP->orig_y[y], Fsize_x); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* U */ - ReadBytes(socketFd, + ReadBytes(socketFd, (unsigned char *)frameP->orig_cb[y], (Fsize_x >> 1)); - + for (y = 0; y < (Fsize_y >> 1); ++y) /* V */ - ReadBytes(socketFd, + ReadBytes(socketFd, (unsigned char *)frameP->orig_cr[y], (Fsize_x >> 1)); } @@ -340,20 +341,20 @@ NotifyDecodeServerReady(int const id) { int clientSocket; time_t tempTimeStart, tempTimeEnd; const char * error; - + time(&tempTimeStart); - + ConnectToSocket(IOhostName, decodePortNumber, &hostEntry, &clientSocket, &error); - + if (error) errorExit("CHILD: Can't connect to decode server to tell it a frame " "is ready. %s", error); - + WriteInt(clientSocket, id); - + close(clientSocket); - + time(&tempTimeEnd); IOtime += (tempTimeEnd-tempTimeStart); } @@ -461,23 +462,23 @@ SendDecodedFrame(MpegFrame * const frameP) { Send frame *frameP to the decode server. -----------------------------------------------------------------------------*/ int const negativeTwo = -2; - + int clientSocket; const char * error; - + /* send to IOServer */ ConnectToSocket(IOhostName, ioPortNumber, &hostEntry, &clientSocket, &error); if (error) errorExit("CHILD: Can't connect to decode server to " "give it a decoded frame. %s", error); - + WriteInt(clientSocket, negativeTwo); - + WriteInt(clientSocket, frameP->id); writeYUVDecoded(clientSocket, Fsize_x, Fsize_y, frameP); - + close(clientSocket); } @@ -490,11 +491,11 @@ SendDecodedFrame(MpegFrame * const frameP) { * * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * *===========================================================================*/ void -GetRemoteDecodedRefFrame(MpegFrame * const frameP, +GetRemoteDecodedRefFrame(MpegFrame * const frameP, int const frameNumber) { /*---------------------------------------------------------------------------- Get decoded frame number 'frameNumber' *frameP from the decode server. @@ -551,7 +552,7 @@ static void cleanup_fork( dummy ) /* try to kill all child processes */ #endif if (kill(ClientPid[i], TERMINATE_PID_SIGNAL)) { - fprintf(stderr, "cleanup_fork: killed PID=%d failed (errno %d)\n", + fprintf(stderr, "cleanup_fork: killed PID=%d failed (errno %d)\n", ClientPid[i], errno); } } @@ -574,24 +575,24 @@ static int safe_fork(command) /* fork child process and remember its PID * static int init=0; char *argis[MAXARGS]; register int i=1; - + if (!(argis[0] = strtok(command, " \t"))) return(0); /* tokenize */ while ((argis[i] = strtok(NULL, " \t")) && i < MAXARGS) ++i; argis[i] = NULL; - + #ifdef DEBUG_FORK - {register int i=0; + {register int i=0; fprintf(stderr, "Command %s becomes:\n", command); while(argis[i]) {fprintf(stderr, "--%s--\n", argis[i]); ++i;} } #endif - + if (!init) { /* register clean-up routine */ signal (SIGQUIT, cleanup_fork); signal (SIGTERM, cleanup_fork); signal (SIGINT , cleanup_fork); init=1; } - + if (-1 == (ClientPid[current_max_forked_pid] = fork()) ) { perror("safe_fork: fork failed "); return(-1); @@ -682,25 +683,25 @@ decodedFrameToDisk(int const otherSock) { MpegFrame * frameP; ReadInt(otherSock, &frameNumber); - + if (debugSockets) { - fprintf(stdout, "INPUT SERVER: GETTING DECODED FRAME %d\n", + fprintf(stdout, "INPUT SERVER: GETTING DECODED FRAME %d\n", frameNumber); fflush(stdout); } /* should read frame from socket, then write to disk */ frameP = Frame_New(frameNumber, 'i'); - + Frame_AllocDecoded(frameP, TRUE); - + readYUVDecoded(otherSock, Fsize_x, Fsize_y, frameP); /* now output to disk */ WriteDecodedFrame(frameP); Frame_Free(frameP); -} +} @@ -708,12 +709,12 @@ static void decodedFrameFromDisk(int const otherSock) { /* request for decoded frame from disk */ - + int frameNumber; MpegFrame * frameP; ReadInt(otherSock, &frameNumber); - + if (debugSockets) { fprintf(stdout, "INPUT SERVER: READING DECODED FRAME %d " "from DISK\n", frameNumber); @@ -722,15 +723,15 @@ decodedFrameFromDisk(int const otherSock) { /* should read frame from disk, then write to socket */ frameP = Frame_New(frameNumber, 'i'); - + Frame_AllocDecoded(frameP, TRUE); - + ReadDecodedRefFrame(frameP, frameNumber); - + writeYUVDecoded(otherSock, Fsize_x, Fsize_y, frameP); - + Frame_Free(frameP); -} +} @@ -762,10 +763,10 @@ routeFromSocketToDisk(int const otherSock, MALLOCARRAY_NOFAIL(bigBuffer, bigBufferSize); } - + /* now read in the bytes */ ReadBytes(otherSock, bigBuffer, numBytes); - + /* open file to output this stuff to */ pm_asprintf(&fileName, "%s.frame.%d", outputFileName, frameNumber); filePtr = fopen(fileName, "wb"); @@ -777,9 +778,9 @@ routeFromSocketToDisk(int const otherSock, /* now write the bytes here */ fwrite(bigBuffer, sizeof(char), numBytes, filePtr); - + fclose(filePtr); - + if (debugSockets) { fprintf(stdout, "====I/O SERVER: WROTE FRAME %d to disk\n", frameNumber); @@ -788,7 +789,7 @@ routeFromSocketToDisk(int const otherSock, *bigBufferP = bigBuffer; *bigBufferSizeP = bigBufferSize; -} +} @@ -803,7 +804,7 @@ readConvertWriteToSocket(struct inputSource * const inputSourceP, the "base format" result to socket 'otherSock'. -----------------------------------------------------------------------------*/ FILE * convertedFileP; - + convertedFileP = ReadIOConvert(inputSourceP, frameNumber); if (convertedFileP) { bool eof; @@ -811,21 +812,21 @@ readConvertWriteToSocket(struct inputSource * const inputSourceP, while (!eof) { unsigned char buffer[1024]; unsigned int numBytes; - + numBytes = fread(buffer, 1, sizeof(buffer), convertedFileP); - + if (numBytes > 0) { WriteInt(otherSock, numBytes); WriteBytes(otherSock, buffer, numBytes); } else eof = TRUE; } - + if (strcmp(ioConversion, "*") == 0 ) fclose(convertedFileP); else pclose(convertedFileP); - + *endOfStreamP = FALSE; } else *endOfStreamP = TRUE; @@ -848,13 +849,13 @@ readWriteYuvToSocket(struct inputSource * const inputSourceP, MpegFrame * frameP; frameP = Frame_New(frameNumber, 'i'); - + ReadFrame(frameP, inputSourceP, frameNumber, inputConversion, endOfStreamP); - + if (!*endOfStreamP) { writeYUVOrig(otherSock, Fsize_x, Fsize_y, frameP); - + { /* Make sure we don't leave until other processor read everything @@ -907,7 +908,7 @@ processNextConnection(int const serverSocket, int otherSock; int command; const char * error; - + AcceptConnection(serverSocket, &otherSock, &error); if (error) errorExit("I/O SERVER: Failed to accept next connection. %s", error); @@ -948,12 +949,12 @@ processNextConnection(int const serverSocket, } close(otherSock); } - + void IoServer(struct inputSource * const inputSourceP, - const char * const parallelHostName, + const char * const parallelHostName, int const portNum) { /*---------------------------------------------------------------------------- Execute an I/O server. @@ -979,7 +980,7 @@ IoServer(struct inputSource * const inputSourceP, bigBufferSize = 0; /* Start with no buffer */ bigBuffer = NULL; - + /* once we get IO port num, should transmit it to parallel server */ CreateListeningSocket(&serverSocket, &ioPortNum, &error); @@ -1043,12 +1044,12 @@ SendRemoteFrame(int const frameNumber, BitBucket * const bb) { WriteInt(clientSocket, negativeFour); WriteInt(clientSocket, frameNumber); - + if (frameNumber != -1) { /* send number of bytes */ - + WriteInt(clientSocket, (bb->totalbits+7)>>3); - + /* now send the bytes themselves */ Bitio_WriteToSocket(bb, clientSocket); } @@ -1062,11 +1063,11 @@ SendRemoteFrame(int const frameNumber, BitBucket * const bb) { void -GetRemoteFrame(MpegFrame * const frameP, +GetRemoteFrame(MpegFrame * const frameP, int const frameNumber) { /*---------------------------------------------------------------------------- Get a frame from the I/O server. - + This is intended for use by a child. -----------------------------------------------------------------------------*/ int clientSocket; @@ -1084,7 +1085,7 @@ GetRemoteFrame(MpegFrame * const frameP, &clientSocket, &error); if (error) - errorExit("CHILD: Can't connect to I/O server to get a frame. %s", + errorExit("CHILD: Can't connect to I/O server to get a frame. %s", error); WriteInt(clientSocket, frameNumber); @@ -1104,7 +1105,7 @@ GetRemoteFrame(MpegFrame * const frameP, if (numBytes > sizeof(buffer)) errorExit("Invalid message received: numBytes = %d, " - "which is greater than %u", + "which is greater than %u", numBytes, (unsigned)sizeof(numBytes)); ReadBytes(clientSocket, buffer, numBytes); @@ -1162,9 +1163,9 @@ getAndProcessACombineConnection(int const outputServerSocket) { if (error) errorExit("COMBINE SERVER: " "Failed to accept next connection. %s", error); - + ReadInt(otherSock, &command); - + if (command == -2) { /* this is notification from non-remote process that a frame is done. @@ -1173,7 +1174,7 @@ getAndProcessACombineConnection(int const outputServerSocket) { ReadInt(otherSock, &frameStart); ReadInt(otherSock, &frameEnd); - + machineDebug("COMBINE_SERVER: Frames %d - %d done", frameStart, frameEnd); { @@ -1199,7 +1200,7 @@ openInputFile(const char * const fileName, FILE * inputFileP; unsigned int attempts; - + inputFileP = NULL; attempts = 0; @@ -1207,14 +1208,14 @@ openInputFile(const char * const fileName, inputFileP = fopen(fileName, "rb"); if (inputFileP == NULL) { pm_message("ERROR Couldn't read frame file '%s' errno = %d (%s)" - "attempt %d", + "attempt %d", fileName, errno, strerror(errno), attempts); pm_sleep(1000); } ++attempts; } if (inputFileP == NULL) - pm_error("Unable to open file '%s' after %d attempts.", + pm_error("Unable to open file '%s' after %d attempts.", fileName, attempts); *inputFilePP = inputFileP; @@ -1239,7 +1240,7 @@ waitForOutputFile(void * const inputHandle, const char * fileName; while (!frameDone[frameNumber]) { - machineDebug("COMBINE_SERVER: Waiting for frame %u done", + machineDebug("COMBINE_SERVER: Waiting for frame %u done", frameNumber); getAndProcessACombineConnection(outputServerSocket); @@ -1274,8 +1275,8 @@ unlinkFile(void * const inputHandle, void -CombineServer(int const numFrames, - const char * const masterHostName, +CombineServer(int const numFrames, + const char * const masterHostName, int const masterPortNum, const char * const outputFileName) { /*---------------------------------------------------------------------------- @@ -1287,17 +1288,17 @@ CombineServer(int const numFrames, FILE * ofP; const char * error; struct combineControl combineControl; - + /* once we get Combine port num, should transmit it to parallel server */ - + CreateListeningSocket(&outputServerSocket, &combinePortNum, &error); if (error) errorExit("Unable to create socket on which to listen. %s", error); machineDebug("COMBINE SERVER: LISTENING ON PORT %d", combinePortNum); - + TransmitPortNum(masterHostName, masterPortNum, combinePortNum); - + MALLOCARRAY_NOFAIL(frameDone, numFrames); { unsigned int i; @@ -1305,16 +1306,16 @@ CombineServer(int const numFrames, frameDone[i] = FALSE; } ofP = pm_openw(outputFileName); - + combineControl.numFrames = numFrames; FramesToMPEG(ofP, &combineControl, &waitForOutputFile, &unlinkFile); machineDebug("COMBINE SERVER: Shutting down"); - + /* tell Master server we are done */ TransmitPortNum(masterHostName, masterPortNum, combinePortNum); - + close(outputServerSocket); fclose(ofP); @@ -1340,18 +1341,18 @@ startCombineServer(const char * const encoderName, int otherSock; const char * error; - pm_snprintf(command, sizeof(command), + pm_snprintf(command, sizeof(command), "%s %s -max_machines %d -output_server %s %d %d %s", - encoderName, + encoderName, debugMachines ? "-debug_machines" : "", - numMachines, masterHostName, masterPortNum, + numMachines, masterHostName, masterPortNum, numInputFiles, paramFileName); - + machineDebug("MASTER: Starting combine server with shell command '%s'", command); safe_fork(command); - + machineDebug("MASTER: Listening for connection back from " "new Combine server"); @@ -1382,9 +1383,9 @@ startDecodeServer(const char * const encoderName, int otherSock; const char * error; - pm_snprintf(command, sizeof(command), + pm_snprintf(command, sizeof(command), "%s %s -max_machines %d -decode_server %s %d %d %s", - encoder_name, + encoder_name, debugMachines ? "-debug_machines" : "", numMachines, masterHostName, masterPortNum, numInputFiles, paramFileName); @@ -1404,9 +1405,9 @@ startDecodeServer(const char * const encoderName, "decode server. %s", error); ReadInt(otherSock, decodePortNumP); - + close(otherSock); - + machineDebug("MASTER: Decode port number = %d", *decodePortNumP); } @@ -1420,11 +1421,11 @@ startIoServer(const char * const encoderName, int const masterSocket, const char * const paramFileName, int * const ioPortNumP) { - + char command[1024]; int otherSock; const char * error; - + sprintf(command, "%s -max_machines %d -io_server %s %d %s", encoderName, numChildren, masterHostName, masterPortNum, paramFileName); @@ -1433,7 +1434,7 @@ startIoServer(const char * const encoderName, command); safe_fork(command); - + machineDebug("MASTER: Listening for connection back from " "new I/O server"); @@ -1442,14 +1443,14 @@ startIoServer(const char * const encoderName, errorExit("MASTER SERVER: " "Failed to accept connection back from the new " "I/O server. %s", error); - + ReadInt(otherSock, ioPortNumP); close(otherSock); - + machineDebug("MASTER: I/O port number = %d", *ioPortNumP); -} - - +} + + static void extendToEndOfPattern(unsigned int * const nFramesP, @@ -1458,7 +1459,7 @@ extendToEndOfPattern(unsigned int * const nFramesP, unsigned int const numFramesInStream) { assert(framePatternLen >= 1); - + while (startFrame + *nFramesP < numFramesInStream && (startFrame + *nFramesP) % framePatternLen != 0) ++(*nFramesP); @@ -1478,7 +1479,7 @@ allocateInitialFrames(struct scheduler * const schedulerP, /*---------------------------------------------------------------------------- Choose which frames, to hand out to the new child numbered 'childNum'. -----------------------------------------------------------------------------*/ - unsigned int const framesPerChild = + unsigned int const framesPerChild = MAX(1, ((schedulerP->numFramesInJob - schedulerP->nextFrame) / (schedulerP->numMachines - childNum))); @@ -1507,7 +1508,7 @@ allocateInitialFrames(struct scheduler * const schedulerP, static float taperedGoalTime(struct childState const childState[], unsigned int const remainingFrameCount) { - + float goalTime; float allChildrenFPS; float remainingJobTime; @@ -1515,9 +1516,9 @@ taperedGoalTime(struct childState const childState[], float sum; int numMachinesToEstimate; unsigned int childNum; - + /* frames left = lastFrameInStream - startFrame + 1 */ - for (childNum = 0, sum = 0.0, numMachinesToEstimate = 0; + for (childNum = 0, sum = 0.0, numMachinesToEstimate = 0; childNum < numMachines; ++childNum) { if (!childState[childNum].finished) { if (childState[childNum].fps < 0.0 ) @@ -1526,12 +1527,12 @@ taperedGoalTime(struct childState const childState[], sum += childState[childNum].fps; } } - + allChildrenFPS = (float)numMachines * (sum/(float)(numMachines-numMachinesToEstimate)); - + remainingJobTime = (float)remainingFrameCount/allChildrenFPS; - + goalTime = MAX(5.0, remainingJobTime/2); return goalTime; @@ -1575,23 +1576,23 @@ allocateMoreFrames(struct scheduler * const schedulerP, if (!goalTimeSpecified) { goalTime = taperedGoalTime(childState, - schedulerP->numFramesInJob - + schedulerP->numFramesInJob - schedulerP->nextFrame); - + pm_message("MASTER: ASSIGNING %s %.2f seconds of work", machineName[childNum], goalTime); } else goalTime = goalTimeArg; - + if (childState[childNum].numSeconds != 0) - avgFps = (float)childState[childNum].numFrames / + avgFps = (float)childState[childNum].numFrames / childState[childNum].numSeconds; else avgFps = 0.1; /* arbitrary small value */ nFrames = MAX(1u, (unsigned int)(goalTime * avgFps + 0.5)); - - nFrames = MIN(nFrames, + + nFrames = MIN(nFrames, schedulerP->numFramesInJob - schedulerP->nextFrame); if (forceIalign) @@ -1648,7 +1649,7 @@ startChildren(struct scheduler * const schedulerP, MALLOCARRAY_NOFAIL(childState, schedulerP->numMachines); childrenLeftCurrentIoServer = 0; /* No current I/O server yet */ - + numIoServers = 0; /* None created yet */ for (childNum = 0; childNum < schedulerP->numMachines; ++childNum) { @@ -1669,17 +1670,17 @@ startChildren(struct scheduler * const schedulerP, machineName[childNum]); } else { childState[childNum].finished = FALSE; - + if (remote[childNum]) { if (childrenLeftCurrentIoServer == 0) { - startIoServer(encoderName, schedulerP->numMachines, + startIoServer(encoderName, schedulerP->numMachines, masterHostName, masterPortNum, masterSocket, paramFileName, &ioPortNum[numIoServers++]); - + childrenLeftCurrentIoServer = SOMAXCONN; } --childrenLeftCurrentIoServer; - } + } pm_snprintf(command, sizeof(command), "%s %s -l %s %s " "%s %s -child %s %d %d %d %d %d %d " @@ -1689,22 +1690,22 @@ startChildren(struct scheduler * const schedulerP, beNice ? "nice" : "", executable[childNum], debugMachines ? "-debug_machines" : "", - masterHostName, masterPortNum, + masterHostName, masterPortNum, remote[childNum] ? ioPortNum[numIoServers-1] : 0, combinePortNum, decodePortNum, childNum, remote[childNum] ? 1 : 0, startFrame, startFrame + nFrames - 1, - remote[childNum] ? + remote[childNum] ? remoteParamFile[childNum] : paramFileName ); - + machineDebug("MASTER: Starting child server " "with shell command '%s'", command); safe_fork(command); machineDebug("MASTER: Frames %d-%d assigned to new child %s", - startFrame, startFrame + nFrames - 1, + startFrame, startFrame + nFrames - 1, machineName[childNum]); } childState[childNum].startFrame = startFrame; @@ -1720,7 +1721,7 @@ startChildren(struct scheduler * const schedulerP, static void noteFrameDone(const char * const combineHostName, int const combinePortNum, - unsigned int const frameStart, + unsigned int const frameStart, unsigned int const frameEnd) { /*---------------------------------------------------------------------------- Tell the Combine server that frames 'frameStart' through 'frameEnd' @@ -1738,7 +1739,7 @@ noteFrameDone(const char * const combineHostName, ConnectToSocket(combineHostName, combinePortNum, &hostEntP, &clientSocket, &error); - + if (error) errorExit("MASTER: Can't connect to Combine server to tell it frames " "are done. %s", error); @@ -1775,7 +1776,7 @@ feedTheChildren(struct scheduler * const schedulerP, As children finish assignments, inform the combine server at 'combineHostName':'combinePortNum' of such. - Note that the children got initial assigments when they were created. + Note that the children got initial assignments when they were created. So the first thing we do is wait for them to finish those. -----------------------------------------------------------------------------*/ unsigned int numFinished; @@ -1808,7 +1809,7 @@ feedTheChildren(struct scheduler * const schedulerP, ReadInt(otherSock, &seconds); csP = &childState[childNum]; - + csP->numSeconds += seconds; csP->fps = (float)csP->numFrames / (float)csP->numSeconds; @@ -1818,7 +1819,7 @@ feedTheChildren(struct scheduler * const schedulerP, framesPerSecond = (float)csP->lastNumFrames * 2.0; machineDebug("MASTER: Child %s FINISHED ASSIGNMENT. " - "%f frames per second", + "%f frames per second", machineName[childNum], framesPerSecond); noteFrameDone(combineHostName, combinePortNum, csP->startFrame, @@ -1855,7 +1856,7 @@ feedTheChildren(struct scheduler * const schedulerP, close(otherSock); machineDebug("MASTER: %d/%d DONE; %d ARE ASSIGNED", - framesDone, schedulerP->numFramesInJob, + framesDone, schedulerP->numFramesInJob, schedulerP->nextFrame - framesDone); } } @@ -1898,7 +1899,7 @@ waitForCombineServerToTerminate(int const masterSocket) { } close(otherSock); } - + static void @@ -1932,46 +1933,46 @@ printFinalStats(FILE * const statfileP, (unsigned int)(startUpEnd - startUpBegin)); fprintf(fileP, "SHUT DOWN TIME: %u seconds\n", (unsigned int)(shutDownEnd - shutDownBegin)); - - fprintf(fileP, + + fprintf(fileP, "%14.14s %8.8s %8.8s %12.12s %9.9s\n", "MACHINE", "Frames", "Seconds", "Frames/Sec", "Self Time"); - fprintf(fileP, + fprintf(fileP, "%14.14s %8.8s %8.8s %12.12s %9.9s\n", "--------------", "--------", "--------", "------------", "---------"); totalFPS = 0.0; for (childNum = 0; childNum < numChildren; ++childNum) { - float const localFPS = + float const localFPS = (float)childState[childNum].numFrames / childState[childNum].numSeconds; fprintf(fileP, "%14.14s %8u %8u %12.4f %8u\n", - machineName[childNum], - childState[childNum].numFrames, + machineName[childNum], + childState[childNum].numFrames, childState[childNum].numSeconds, - localFPS, + localFPS, (unsigned int)((float)numFrames/localFPS)); totalFPS += localFPS; } - fprintf(fileP, + fprintf(fileP, "%14.14s %8.8s %8.8s %12.12s %9.9s\n", "--------------", "--------", "--------", "------------", "---------"); - fprintf(fileP, "%14s %8.8s %8u %12.4f\n", - "OPTIMAL", "", + fprintf(fileP, "%14s %8.8s %8u %12.4f\n", + "OPTIMAL", "", (unsigned int)((float)numFrames/totalFPS), totalFPS); - + { unsigned int const diffTime = shutDownEnd - startUpBegin; - - fprintf(fileP, "%14s %8.8s %8u %12.4f\n", - "ACTUAL", "", diffTime, + + fprintf(fileP, "%14s %8.8s %8u %12.4f\n", + "ACTUAL", "", diffTime, (float)numFrames / diffTime); } fprintf(fileP, "\n\n"); @@ -1983,7 +1984,7 @@ printFinalStats(FILE * const statfileP, void MasterServer(struct inputSource * const inputSourceP, - const char * const paramFileName, + const char * const paramFileName, const char * const outputFileName) { /*---------------------------------------------------------------------------- Execute the master server function. @@ -2025,21 +2026,21 @@ MasterServer(struct inputSource * const inputSourceP, fprintf(stdout, "---MASTER USING PORT %d\n", portNum); startCombineServer(encoder_name, numMachines, hostName, portNum, - inputSourceP->numInputFiles, - paramFileName, masterSocket, + inputSourceP->numInputFiles, + paramFileName, masterSocket, &combinePortNum); if (referenceFrame == DECODED_FRAME) startDecodeServer(encoder_name, numMachines, hostName, portNum, - inputSourceP->numInputFiles, + inputSourceP->numInputFiles, paramFileName, masterSocket, &decodePortNum); startChildren(&scheduler, encoder_name, hostName, portNum, paramFileName, parallelPerfect, forceIalign, - framePatternLen, parallelTestFrames, + framePatternLen, parallelTestFrames, niceProcesses, - masterSocket, combinePortNum, decodePortNum, + masterSocket, combinePortNum, decodePortNum, ioPortNum, &numIoServers, &childState); @@ -2076,10 +2077,10 @@ MasterServer(struct inputSource * const inputSourceP, void -NotifyMasterDone(const char * const masterHostName, - int const masterPortNum, +NotifyMasterDone(const char * const masterHostName, + int const masterPortNum, int const childNum, - unsigned int const seconds, + unsigned int const seconds, boolean * const moreWorkToDoP, int * const nextFrameStartP, int * const nextFrameEndP) { @@ -2098,11 +2099,11 @@ NotifyMasterDone(const char * const masterHostName, time_t tempTimeStart, tempTimeEnd; const char * error; - machineDebug("CHILD: NOTIFYING MASTER Machine %d assignment complete", + machineDebug("CHILD: NOTIFYING MASTER Machine %d assignment complete", childNum); time(&tempTimeStart); - + ConnectToSocket(masterHostName, masterPortNum, &hostEntry, &clientSocket, &error); if (error) @@ -2132,9 +2133,9 @@ NotifyMasterDone(const char * const masterHostName, void -DecodeServer(int const numInputFiles, - const char * const decodeFileName, - const char * const masterHostName, +DecodeServer(int const numInputFiles, + const char * const decodeFileName, + const char * const masterHostName, int const masterPortNum) { /*---------------------------------------------------------------------------- Execute the decode server. @@ -2220,7 +2221,7 @@ DecodeServer(int const numInputFiles, } } else { frameDone[frameReady] = TRUE; - + machineDebug("DECODE SERVER: FRAME %d READY", frameReady); if ( waitMachine[frameReady] ) { @@ -2233,7 +2234,7 @@ DecodeServer(int const numInputFiles, &clientSocket, &error); if (error) errorExit("DECODE SERVER: " - "Can't connect to child machine. %s", + "Can't connect to child machine. %s", error); close(clientSocket); waitPtr = waitList[waitPtr]-1; @@ -2243,7 +2244,7 @@ DecodeServer(int const numInputFiles, close(otherSock); } - + machineDebug("DECODE SERVER: Shutting down"); /* tell Master server we are done */ diff --git a/converter/ppm/ppmtompeg/parse_huff.pl b/converter/ppm/ppmtompeg/parse_huff.pl index 1fc6466c..633e5877 100644 --- a/converter/ppm/ppmtompeg/parse_huff.pl +++ b/converter/ppm/ppmtompeg/parse_huff.pl @@ -51,7 +51,7 @@ # composed of 1, 0, space, and 's'. Spaces are ignored, and # s corresponds to the sign bit. In the output of this program, # We'll completely right-shift the data, with a 0 for the sign -# bit. The encoder will make appropriate changes before outputing. +# bit. The encoder will make appropriate changes before outputting. open(HUFFC, "> huff.c") || die "Can't write huff.c: $!\n"; diff --git a/converter/ppm/ppmtompeg/psearch.c b/converter/ppm/ppmtompeg/psearch.c index 3cca1241..e350137e 100644 --- a/converter/ppm/ppmtompeg/psearch.c +++ b/converter/ppm/ppmtompeg/psearch.c @@ -58,7 +58,7 @@ int psearchAlg; * * PRECONDITIONS: The relevant block in 'current' is valid (it has not * been dct'd). Thus, the data in 'current' can be - * accesed through y_blocks, cr_blocks, and cb_blocks. + * accessed through y_blocks, cr_blocks, and cb_blocks. * This is not the case for the blocks in 'prev.' * Therefore, references into 'prev' should be done * through the struct items ref_y, ref_cr, ref_cb diff --git a/converter/ppm/ppmtompeg/psocket.c b/converter/ppm/ppmtompeg/psocket.c index 6a50dc27..aac61022 100644 --- a/converter/ppm/ppmtompeg/psocket.c +++ b/converter/ppm/ppmtompeg/psocket.c @@ -10,15 +10,15 @@ ============================================================================*/ #define _XOPEN_SOURCE 500 /* Make sure stdio.h contains pclose() */ -/* _ALL_SOURCE is needed on AIX to make the C library include the - socket services (e.g. define struct sockaddr) +/* _ALL_SOURCE is needed on AIX to make the C library include the + socket services (e.g. define struct sockaddr) Note that AIX standards.h actually sets feature declaration macros such as _XOPEN_SOURCE, unless they are already set. */ #define _ALL_SOURCE #define __EXTENSIONS__ - /* __EXTENSIONS__ is for a broken Sun C library (uname SunOS kosh 5.8 + /* __EXTENSIONS__ is for a broken Sun C library (uname SunOS kosh 5.8 generic_108528-16 sun4u sparc). When you define _XOPEN_SOURCE, it's vnode.h and resource.h fail to define some data types that they need (e.g. timestruct_t). But with __EXTENSIONS__, they declare the @@ -126,8 +126,8 @@ unmarshallInt(unsigned char const buffer[], static void -safeRead(int const fd, - unsigned char * const buf, +safeRead(int const fd, + unsigned char * const buf, unsigned int const nbyte) { /*---------------------------------------------------------------------------- Safely read from file 'fd'. Keep reading until we get @@ -144,7 +144,7 @@ safeRead(int const fd, errorExit("read (of %u bytes (total %u) ) returned " "errno %d (%s)", nbyte-numRead, nbyte, errno, strerror(errno)); - else + else numRead += result; } } @@ -203,8 +203,8 @@ marshallInt(int const value, static void -safeWrite(int const fd, - unsigned char * const buf, +safeWrite(int const fd, + unsigned char * const buf, unsigned int const nbyte) { /*---------------------------------------------------------------------------- Safely write to file 'fd'. Keep writing until we write 'nbyte' @@ -217,7 +217,7 @@ safeWrite(int const fd, while (numWritten < nbyte) { int const result = write(fd, &buf[numWritten], nbyte-numWritten); - if (result == -1) + if (result == -1) errorExit("write (of %u bytes (total %u) ) returned " "errno %d (%s)", nbyte-numWritten, nbyte, errno, strerror(errno)); @@ -251,8 +251,8 @@ WriteInt(int const socketFd, void -ConnectToSocket(const char * const machineName, - int const portNum, +ConnectToSocket(const char * const machineName, + int const portNum, struct hostent ** const hostEnt, int * const socketFdP, const char ** const errorP) { @@ -266,7 +266,7 @@ ConnectToSocket(const char * const machineName, **hostEnt. -----------------------------------------------------------------------------*/ int rc; - + *errorP = NULL; /* initial value */ if ((*hostEnt) == NULL) { @@ -277,15 +277,15 @@ ConnectToSocket(const char * const machineName, if (!*errorP) { rc = socket(AF_INET, SOCK_STREAM, 0); if (rc < 0) - pm_asprintf(errorP, "socket() failed with errno %d (%s)", + pm_asprintf(errorP, "socket() failed with errno %d (%s)", errno, strerror(errno)); else { int const socketFd = rc; - + int rc; unsigned short tempShort; struct sockaddr_in nameEntry; - + nameEntry.sin_family = AF_INET; memset((void *) nameEntry.sin_zero, 0, 8); memcpy((void *) &(nameEntry.sin_addr.s_addr), @@ -293,12 +293,12 @@ ConnectToSocket(const char * const machineName, (size_t) (*hostEnt)->h_length); tempShort = portNum; nameEntry.sin_port = htons(tempShort); - + rc = connect(socketFd, (struct sockaddr *) &nameEntry, sizeof(struct sockaddr)); - + if (rc != 0) - pm_asprintf(errorP, + pm_asprintf(errorP, "connect() to host '%s', port %d failed with " "errno %d (%s)", machineName, portNum, errno, strerror(errno)); @@ -317,7 +317,7 @@ ConnectToSocket(const char * const machineName, static bool portInUseErrno(int const testErrno) { /*---------------------------------------------------------------------------- - Return TRUE iff 'testErrno' is what a bind() would return if one requestd + Return TRUE iff 'testErrno' is what a bind() would return if one requested a port number that is unavailable (but other port numbers might be). -----------------------------------------------------------------------------*/ bool retval; @@ -340,19 +340,19 @@ static void bindToUnusedPort(int const socketFd, unsigned short * const portNumP, const char ** const errorP) { - + bool foundPort; unsigned short trialPortNum; *errorP = NULL; /* initial value */ - for (foundPort = FALSE, trialPortNum = 2048; - !foundPort && trialPortNum < 16384 && !*errorP; + for (foundPort = FALSE, trialPortNum = 2048; + !foundPort && trialPortNum < 16384 && !*errorP; ++trialPortNum) { - + struct sockaddr_in nameEntry; int rc; - + memset((char *) &nameEntry, 0, sizeof(nameEntry)); nameEntry.sin_family = AF_INET; nameEntry.sin_port = htons(trialPortNum); @@ -365,10 +365,10 @@ bindToUnusedPort(int const socketFd, *portNumP = trialPortNum; } else if (!portInUseErrno(errno)) pm_asprintf(errorP, "bind() of TCP port number %hu failed " - "with errno %d (%s)", + "with errno %d (%s)", trialPortNum, errno, strerror(errno)); } - + if (!*errorP && !foundPort) pm_asprintf(errorP, "Unable to find a free port. Every TCP port " "in the range 2048-16383 is in use"); @@ -389,7 +389,7 @@ CreateListeningSocket(int * const socketP, partner can connect). -----------------------------------------------------------------------------*/ int rc; - + rc = socket(AF_INET, SOCK_STREAM, 0); if (rc < 0) pm_asprintf(errorP, @@ -415,7 +415,7 @@ CreateListeningSocket(int * const socketP, rc = listen(socketFd, SOMAXCONN); if (rc != 0) pm_asprintf(errorP, "Unable to listen on TCP socket. " - "listen() fails with errno %d (%s)", + "listen() fails with errno %d (%s)", errno, strerror(errno)); } if (*errorP) @@ -433,11 +433,11 @@ AcceptConnection(int const listenSocketFd, struct sockaddr otherSocket; socklenx_t otherSize; /* This is an ugly dual-meaning variable. As input to accept(), - it is the storage size of 'otherSocket'. As output, it is the + it is the storage size of 'otherSocket'. As output, it is the data length of 'otherSocket'. */ int rc; - + otherSize = sizeof(otherSocket); rc = accept(listenSocketFd, &otherSocket, &otherSize); @@ -450,3 +450,6 @@ AcceptConnection(int const listenSocketFd, *errorP = NULL; } } + + + diff --git a/converter/ppm/ppmtompeg/rate.c b/converter/ppm/ppmtompeg/rate.c index 6ec330cf..45511ca1 100644 --- a/converter/ppm/ppmtompeg/rate.c +++ b/converter/ppm/ppmtompeg/rate.c @@ -1,6 +1,6 @@ /*============================================================================* * rate.c * - * * + * * * Procedures concerned with rate control * * * * EXPORTED PROCEDURES: * @@ -75,7 +75,7 @@ #define MAX_BIT_RATE 104857600 /* 18 digit number in units of 400 */ #define MAX_BUFFER_SIZE 16760832 /* 10 digit number in units of 16k */ -#define DEFAULT_BUFFER_SIZE 327680 /* maximun for "constrained" bitstream */ +#define DEFAULT_BUFFER_SIZE 327680 /* maximum for "constrained" bitstream */ #define DEFAULT_VBV_FULLNESS 3 /* wait till 1/3 full */ #define DEFAULT_PICT_RATE_CODE 5 /* code for 30 Frames/sec */ #define DEFAULT_PICT_RATE 30 /* 30 frames per second */ @@ -92,7 +92,7 @@ static bool wantVbvUnderflowWarning; static bool wantVbvOverflowWarning; /* Variables for the VBV buffer defined in MPEG specs */ -static unsigned int VBV_remainingDelay; +static unsigned int VBV_remainingDelay; /* delay in units of 1/90000 seconds */ static int32 VBV_buffer = 0; /* fullness of the theoretical VBV buffer */ static int32 bufferFillRate = 0; /* constant rate at which buffer filled */ @@ -104,7 +104,7 @@ static int Xi, Xp, Xb; /* Global complexity measure */ static int Si, Sp, Sb; /* Total # bits for last pict of type (Overhead?) */ static float Qi, Qp, Qb; /* avg quantizaton for last picture of type */ - + /* Target bit allocations for each type of picture*/ int Ti, Tp, Tb; @@ -175,22 +175,22 @@ static int Qscale; /* Clipped, truncated quantization value */ static FILE *RC_FILE; #endif -static const char * const Frame_header1 = +static const char * const Frame_header1 = " Fm # Bit GOP V "; -static const char * const Frame_header2 = +static const char * const Frame_header2 = " # type MBs Alloc left Ni Np Nb N_act buff Q_rc Qscale"; -static const char * const Frame_header3 = +static const char * const Frame_header3 = "---- - ---- ------ ------- -- -- -- ----- ------ ---- ----"; -static const char * const Frame_trailer1 = +static const char * const Frame_trailer1 = " avg virt % GOP % VBV"; -static const char * const Frame_trailer2 = +static const char * const Frame_trailer2 = " Sx Qx Xx act N_act buffer alloc left left buf delay"; -static const char * const Frame_trailer3 = +static const char * const Frame_trailer3 = "------ --.-- ------- --- --.-- ------- --- ------- --- ------- ------"; -static const char * const MB_header1 = +static const char * const MB_header1 = "MB# #bits Q mqt Dj Q_j actj N_act totbits b/MB %alloc %done"; -static const char * const MB_header2 = +static const char * const MB_header2 = "--- ----- -- --- ------ --- ----- --.-- ------ ---- --- ---"; static char rc_buffer[101]; @@ -211,8 +211,8 @@ void checkSpatialActivity (Block blk0, Block blk1, Block blk2, Block blk3); void incNumBlocks (int num); void calculateVBVDelay (int num); int BlockExperiments (int16 *OrigBlock, int16 *NewBlock, int control); - - + + static void analyzePattern(const char * const framePattern, @@ -226,10 +226,10 @@ analyzePattern(const char * const framePattern, unsigned int i; /* Initialize Pattern info */ - *gop_xP = framePatternLen; + *gop_xP = framePatternLen; for (i = 0, *gop_iP = 0, *gop_pP = 0, *gop_bP = 0, *errorP = NULL; - i < framePatternLen && !*errorP; + i < framePatternLen && !*errorP; ++i) { switch(framePattern[i]) { case 'i': ++*gop_iP; break; @@ -241,7 +241,7 @@ analyzePattern(const char * const framePattern, } assert(*gop_xP == *gop_iP + *gop_pP + *gop_bP); } - + /*===========================================================================* @@ -252,7 +252,7 @@ analyzePattern(const char * const framePattern, * * RETURNS: nothing * - * SIDE EFFECTS: many global variables + * SIDE EFFECTS: many global variables * * NOTES: Get rid of the redundant pattern stuff!! *===========================================================================*/ @@ -266,7 +266,7 @@ initRateControl(bool const wantUnderflowWarning, wantVbvOverflowWarning = wantOverflowWarning; DBG_PRINT(("Initializing Allocation Data\n")); - + #ifdef RC_STATS_FILE RC_FILE = fopen("RC_STATS_FILE", "w"); if ( RC_FILE == NULL) { @@ -278,7 +278,7 @@ initRateControl(bool const wantUnderflowWarning, #endif VBV_remainingDelay = 0; - + analyzePattern(framePattern, framePatternLen, &GOP_X, &GOP_I, &GOP_P, &GOP_B, &error); @@ -291,46 +291,46 @@ initRateControl(bool const wantUnderflowWarning, } - /* Initializing GOP bit allocation */ + /* Initializing GOP bit allocation */ rc_R = 0; rc_G = (bit_rate * GOP_X/frameRateRounded); - + /* Initialize the "global complexity measures" */ Xi = (160 * bit_rate/115); Xp = (60 * bit_rate/115); Xb = (42 * bit_rate/115); - + /* Initialize MB counters */ rc_totalMBBits= rc_bitsThisMB= rc_totalFrameBits=rc_totalOverheadBits = 0; rc_numBlocks = rc_totalQuant = 0; - + /* init virtual buffers */ reactionParameter = (2 * bit_rate / frameRateRounded); d0_i = (10 * reactionParameter / 31); d0_p = (Kp * d0_i); d0_b = (Kb * d0_i); - + lastFrameVirtBuf = d0_i; /* start with I Frame */ rc_Q = lastFrameVirtBuf * 31 / reactionParameter; - + /* init spatial activity measures */ avg_act = 400; /* Suggested initial value */ N_act = 1; - + mquant = rc_Q * N_act; - + frameDelayIncrement = (90000 / frameRateRounded); /* num of "delay" units per frame */ - bufferFillRate = bit_rate / frameRateRounded; + bufferFillRate = bit_rate / frameRateRounded; /* VBV buf fills at constant rate */ VBV_buffer = buffer_size; DBG_PRINT(("VBV- delay: %d, fill rate: %d, delay/Frame: %d units, " "buffer size: %d\n", - VBV_remainginDelay, bufferFillRate, frameDelayIncrement, + VBV_remainginDelay, bufferFillRate, frameDelayIncrement, buffer_size)); - + result = initGOPRateControl(); - + return result; } @@ -343,21 +343,21 @@ initRateControl(bool const wantUnderflowWarning, * * RETURNS: nothing * - * SIDE EFFECTS: many global variables + * SIDE EFFECTS: many global variables * *===========================================================================*/ int initGOPRateControl() { DBG_PRINT(("Initializing new GOP\n")); - + Nx = GOP_X; Ni = GOP_I; Np = GOP_P; Nb = GOP_B; - + rc_R += rc_G; - + DBG_PRINT(("bufsize: %d, bitrate: %d, pictrate: %d, GOP bits: %d\n", buffer_size, bit_rate, frameRateRounded, rc_R)); DBG_PRINT(("Xi: %d, Xp: %d, Xb: %d Nx: %d, Ni: %d, Np: %d, Nb: %d\n", @@ -389,20 +389,20 @@ targetRateControl(MpegFrame * const frame) { float tempX, tempY, tempZ; int result; int frameType; - + minimumBits = (bit_rate / (8 * frameRateRounded)); - + /* Check if new GOP */ if (Nx == 0) { initGOPRateControl(); } - + if (MB_cnt < 0) {MB_cnt = determineMBCount();} - + switch (frame->type) { case TYPE_IFRAME: frameType = 'I'; - + tempX = ( (Np * Ki * Xp) / (Xi * Kp) ); tempY = ( (Nb * Ki * Xb) / (Xi*Kb) ); tempZ = Ni + tempX + tempY; @@ -411,7 +411,7 @@ targetRateControl(MpegFrame * const frame) { current_Tx = Ti = result; lastFrameVirtBuf = d0_i; break; - + case TYPE_PFRAME: frameType = 'P'; tempX = ( (Ni * Kp * Xi) / (Ki * Xp) ); @@ -422,7 +422,7 @@ targetRateControl(MpegFrame * const frame) { current_Tx = Tp = result; lastFrameVirtBuf = d0_p; break; - + case TYPE_BFRAME: frameType = 'B'; tempX = ( (Ni * Kb * Xi) / (Ki * Xb) ); @@ -433,17 +433,17 @@ targetRateControl(MpegFrame * const frame) { current_Tx = Tb = result; lastFrameVirtBuf = d0_b; break; - + default: frameType = 'X'; } - + N_act = 1; rc_Q = lastFrameVirtBuf * 31 / reactionParameter; mquant = rc_Q * N_act; Qscale = (mquant > 31 ? 31 : mquant); Qscale = (Qscale < 1 ? 1 : Qscale); - + #ifdef HEINOUS_DEBUG_MODE { const char * strPtr; @@ -459,15 +459,15 @@ targetRateControl(MpegFrame * const frame) { /* Print Frame info */ sprintf(rc_buffer, "%4d %1c %4d %6d %7d " "%2d %2d %2d %2.2f %6d %4d %3d", - frame->id,frameType,MB_cnt,current_Tx,rc_R,Ni,Np,Nb, + frame->id,frameType,MB_cnt,current_Tx,rc_R,Ni,Np,Nb, N_act, lastFrameVirtBuf, rc_Q, Qscale); - + #ifdef RC_STATS_FILE fprintf(RC_FILE,"%s\n", rc_buffer); fflush(RC_FILE); #endif DBG_PRINT(("%s\n",rc_buffer)); - + /* Print headers for Macroblock info */ if (RC_MB_SAMPLE_RATE) { #ifdef HEINOUS_DEBUG_MODE @@ -483,7 +483,7 @@ targetRateControl(MpegFrame * const frame) { -static void +static void updateVBVBuffer(int const frameBits) { /*---------------------------------------------------------------------------- Update the VBV buffer after each frame. This theoretical buffer is @@ -532,11 +532,11 @@ updateRateControl(int const type) { pctAllocUsed = (totalBits *100 / current_Tx); rc_R -= totalBits; pctGOPUsed = (rc_R *100/ rc_G); - + avg_act = (total_act_j / MB_cnt); - + updateVBVBuffer(totalBits); - + switch (type) { case TYPE_IFRAME: Ti = current_Tx; @@ -563,9 +563,9 @@ updateRateControl(int const type) { Xb = frameComplexity; break; } - + #ifdef HEINOUS_DEBUG_MODE - { + { /* Print Frame info */ const char * strPtr; strPtr = Frame_trailer1; @@ -575,26 +575,26 @@ updateRateControl(int const type) { strPtr = Frame_trailer3; DBG_PRINT(("%s\n",strPtr)); } -#endif +#endif sprintf(rc_buffer, "%6d %2.2f %6d %3d %2.2f %7d " "%3d %7d %3d %6d %6d", - totalBits, avgQuant, frameComplexity, avg_act, N_act, - currentVirtBuf, pctAllocUsed, rc_R, pctGOPUsed, + totalBits, avgQuant, frameComplexity, avg_act, N_act, + currentVirtBuf, pctAllocUsed, rc_R, pctGOPUsed, VBV_buffer, VBV_remainingDelay); #ifdef RC_STATS_FILE fprintf(RC_FILE,"%s\n", rc_buffer); fflush(RC_FILE); #endif DBG_PRINT(("%s\n",rc_buffer)); - + Nx--; rc_totalMBBits= rc_bitsThisMB= rc_totalFrameBits=rc_totalOverheadBits = 0; rc_numBlocks = rc_totalQuant = total_act_j = currentVirtBuf = 0; - + DBG_PRINT(("GOP now has %d bits remaining (%3d%%) for %d frames .. , " - "Ni= %d, Np= %d, Nb= %d\n", + "Ni= %d, Np= %d, Nb= %d\n", rc_R, (rc_R*100/rc_G), (Ni+Np+Nb), Ni, Np, Nb)); - + } @@ -622,21 +622,21 @@ int type; int pctUsed, pctDone; int bitsThisMB; int bitsPerMB; - + bitsThisMB = rc_bitsThisMB; totalBits = rc_totalFrameBits; - bitsPerMB = (totalBits / rc_numBlocks); - pctDone = (rc_numBlocks * 100/ MB_cnt); + bitsPerMB = (totalBits / rc_numBlocks); + pctDone = (rc_numBlocks * 100/ MB_cnt); pctUsed = (totalBits *100/current_Tx); - + sprintf(rc_buffer, "%3d %5d %2d %3d %6d %3d %6d %2.2f %6d %4d %3d %3d\n", - (rc_numBlocks - 1), bitsThisMB, Qscale, mquant, currentVirtBuf, + (rc_numBlocks - 1), bitsThisMB, Qscale, mquant, currentVirtBuf, rc_Q, act_j, N_act, totalBits, bitsPerMB, pctUsed, pctDone); #ifdef RC_STATS_FILE fprintf(RC_FILE, "%s", rc_buffer); fflush(RC_FILE); #endif - + if ( (RC_MB_SAMPLE_RATE) && ((rc_numBlocks -1) % RC_MB_SAMPLE_RATE)) { DBG_PRINT(("%s\n", rc_buffer)); } else { @@ -695,7 +695,7 @@ void incMacroBlockBits(num) * * RETURNS: new Qscale * - * SIDE EFFECTS: + * SIDE EFFECTS: * *===========================================================================*/ int needQScaleChange(oldQScale, blk0, blk1, blk2, blk3) @@ -705,19 +705,19 @@ int needQScaleChange(oldQScale, blk0, blk1, blk2, blk3) Block blk2; Block blk3; { - + /* One more MacroBlock seen */ rc_numBlocks++; /* this notes each block num in MB */ - + checkBufferFullness(oldQScale); - + checkSpatialActivity(blk0, blk1, blk2, blk3); - + mquant = rc_Q * N_act; Qscale = (mquant > 31 ? 31 : mquant); Qscale = (Qscale < 1 ? 1 : Qscale); rc_totalQuant += Qscale; - + if (oldQScale == Qscale) return -1; else @@ -727,7 +727,7 @@ int needQScaleChange(oldQScale, blk0, blk1, blk2, blk3) /*===========================================================================* * - * determineMBCount() + * determineMBCount() * * Determines number of Macro Blocks in frame from the frame sizes * passed. @@ -741,7 +741,7 @@ int determineMBCount () { int y,x; - + x = (Fsize_x +15)/16; y = (Fsize_y +15)/16; return (x * y); @@ -769,11 +769,11 @@ void checkBufferFullness (oldQScale) int oldQScale; { int temp; - + temp = lastFrameVirtBuf + rc_totalFrameBits; temp -= (current_Tx * rc_numBlocks / MB_cnt); currentVirtBuf = temp; - + rc_Q = (currentVirtBuf * 31 / reactionParameter); return; } @@ -783,8 +783,8 @@ void checkBufferFullness (oldQScale) * * void checkSpatialActivity() * - * Calcualtes the spatial activity for the four luminance blocks of the - * macroblock. Along with the normalized reference quantization parameter + * Calculates the spatial activity for the four luminance blocks of the + * macroblock. Along with the normalized reference quantization parameter * (rc_Q) , it determines the quantization factor for the next macroblock. * * RETURNS: nothing @@ -801,19 +801,19 @@ void checkSpatialActivity(blk0, blk1, blk2, blk3) Block blk3; { int temp; - int16 *blkArray[4]; + int16 *blkArray[4]; int16 *curBlock; int16 *blk_ptr; int var[4]; int i, j; - - + + blkArray[0] = (int16 *) blk0; blkArray[1] = (int16 *) blk1; blkArray[2] = (int16 *) blk2; blkArray[3] = (int16 *) blk3; - - + + for (i =0; i < 4; i++) { /* Compute the activity in each block */ curBlock = blkArray[i]; blk_ptr = curBlock; @@ -821,14 +821,14 @@ void checkSpatialActivity(blk0, blk1, blk2, blk3) /* Find the mean pixel value */ for (j=0; j < DCTSIZE_SQ; j ++) { P_mean += *(blk_ptr++); - /* P_mean += curBlock[j]; + /* P_mean += curBlock[j]; if (curBlock[j] != *(blk_ptr++)) { printf("ARRAY ERROR: block %d\n", j); } */ } P_mean /= DCTSIZE_SQ; - + /* Now find the variance */ curBlock = blkArray[i]; blk_ptr = curBlock; @@ -839,25 +839,25 @@ void checkSpatialActivity(blk0, blk1, blk2, blk3) printf("ARRAY ERROR: block %d\n", j); } temp = curBlock[j] - P_mean; -#endif +#endif temp = *(blk_ptr++) - P_mean; var[i] += (temp * temp); } var[i] /= DCTSIZE_SQ; } - + /* Choose the minimum variance from the 4 blocks and use as the activity */ var_sblk = var[0]; for (i=1; i < 4; i++) { var_sblk = (var_sblk < var[i] ? var_sblk : var[i]); } - - + + act_j = 1 + var_sblk; total_act_j += act_j; temp = (2 * act_j + avg_act); N_act = ( (float) temp / (float) (act_j + 2*avg_act) ); - + return; } @@ -900,7 +900,7 @@ int getRateMode() void setBitRate (const char * const charPtr) { int rate, rnd; - + rate = atoi(charPtr); if (rate > 0) { RateControlMode = FIXED_RATE; @@ -915,7 +915,7 @@ void setBitRate (const char * const charPtr) rate = (rate > MAX_BIT_RATE ? MAX_BIT_RATE : rate); bit_rate = rate; DBG_PRINT(("Bit rate is: %d\n", bit_rate)); -} +} @@ -957,7 +957,7 @@ int getBitRate () void setBufferSize (const char * const charPtr) { int size; - + size = atoi(charPtr); size = (size > MAX_BUFFER_SIZE ? MAX_BUFFER_SIZE : size); if (size > 0) { diff --git a/converter/ppm/ppmtopcx.c b/converter/ppm/ppmtopcx.c index fa68edc5..973470a3 100644 --- a/converter/ppm/ppmtopcx.c +++ b/converter/ppm/ppmtopcx.c @@ -12,7 +12,7 @@ ** ** 11/Dec/94: first version ** 12/Dec/94: added handling of "packed" format (16 colors or less) -** +** ** ZSoft PCX File Format Technical Reference Manual ** http://bespin.org/~qz/pc-gpe/pcx.txt ** http://web.archive.org/web/20100206055706/http://www.qzx.com/pc-gpe/pcx.txt @@ -74,7 +74,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. @@ -94,15 +94,15 @@ parseCommandLine(int argc, char ** argv, MALLOCARRAY(option_def, 100); option_def_index = 0; /* incremented by OPTENT3 */ - OPTENT3(0, "24bit", OPT_FLAG, NULL, + OPTENT3(0, "24bit", OPT_FLAG, NULL, &cmdlineP->truecolor, 0); - OPTENT3(0, "8bit", OPT_FLAG, NULL, + OPTENT3(0, "8bit", OPT_FLAG, NULL, &cmdlineP->use_8_bit, 0); - OPTENT3(0, "planes", OPT_UINT, &cmdlineP->planes, + OPTENT3(0, "planes", OPT_UINT, &cmdlineP->planes, &planesSpec, 0); - OPTENT3(0, "packed", OPT_FLAG, NULL, + OPTENT3(0, "packed", OPT_FLAG, NULL, &cmdlineP->packed, 0); - OPTENT3(0, "verbose", OPT_FLAG, NULL, + OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); OPTENT3(0, "stdpalette", OPT_FLAG, NULL, &cmdlineP->stdpalette, 0); @@ -144,14 +144,14 @@ parseCommandLine(int argc, char ** argv, if (cmdlineP->use_8_bit) pm_error("-planes is meaningless with -8bit"); } - + if (paletteSpec && cmdlineP->stdpalette) pm_error("You can't specify both -palette and -stdpalette"); if (!paletteSpec) cmdlineP->palette = NULL; - if (cmdlineP->use_8_bit && cmdlineP->truecolor) + if (cmdlineP->use_8_bit && cmdlineP->truecolor) pm_error("You cannot specify both -8bit and -truecolor"); if (argc-1 < 1) @@ -172,11 +172,11 @@ parseCommandLine(int argc, char ** argv, * Write out a two-byte little-endian word to the PCX file */ static void -Putword(int const w, +Putword(int const w, FILE * const fp) { int rc; - + rc = pm_writelittleshort(fp, w); if (rc != 0) @@ -189,7 +189,7 @@ Putword(int const w, * Write out a byte to the PCX file */ static void -Putbyte(int const b, +Putbyte(int const b, FILE * const fp) { int rc; @@ -205,9 +205,9 @@ static const unsigned char bitmask[] = {1, 2, 4, 8, 16, 32, 64, 128}; static void -extractPlane(unsigned char * const rawrow, - int const cols, - unsigned char * const buf, +extractPlane(unsigned char * const rawrow, + int const cols, + unsigned char * const buf, int const plane) { /*---------------------------------------------------------------------------- From the image row 'rawrow', which is an array of 'cols' palette indices @@ -223,7 +223,7 @@ extractPlane(unsigned char * const rawrow, int cbit; /* Significance of bit representing current column in output */ unsigned char *cp; /* Ptr to next output byte to fill */ unsigned char byteUnderConstruction; - + cp = buf; /* initial value */ cbit = 7; @@ -250,9 +250,9 @@ extractPlane(unsigned char * const rawrow, static void -PackBits(unsigned char * const rawrow, - int const width, - unsigned char * const buf, +PackBits(unsigned char * const rawrow, + int const width, + unsigned char * const buf, int const bits) { int x, i, shift; @@ -273,13 +273,13 @@ PackBits(unsigned char * const rawrow, static void -write_header(FILE * const fp, - int const cols, - int const rows, - int const BitsPerPixel, - int const Planes, +write_header(FILE * const fp, + int const cols, + int const rows, + int const BitsPerPixel, + int const Planes, struct pcxCmapEntry const cmap16[], - unsigned int const xPos, + unsigned int const xPos, unsigned int const yPos) { int i, BytesPerLine; @@ -288,7 +288,7 @@ write_header(FILE * const fp, Putbyte(0x05, fp); /* PC Paintbrush version */ Putbyte(0x01, fp); /* .PCX run length encoding */ Putbyte(BitsPerPixel, fp); /* bits per pixel */ - + Putword(xPos, fp); /* x1 - image left */ Putword(yPos, fp); /* y1 - image top */ Putword(xPos+cols-1, fp); /* x2 - image right */ @@ -330,8 +330,8 @@ write_header(FILE * const fp, static void -PCXEncode(FILE * const fp, - const unsigned char * const buf, +PCXEncode(FILE * const fp, + const unsigned char * const buf, int const Size) { const unsigned char * const end = buf + Size; @@ -377,10 +377,10 @@ indexOfColor(colorhash_table const cht, -----------------------------------------------------------------------------*/ int const rc = ppm_lookupcolor(cht, &color); - + if (rc < 0) pm_error("Image contains color which is not " - "in the palette: %u/%u/%u", + "in the palette: %u/%u/%u", PPM_GETR(color), PPM_GETG(color), PPM_GETB(color)); return rc; @@ -389,12 +389,12 @@ indexOfColor(colorhash_table const cht, static void -ppmTo16ColorPcx(pixel ** const pixels, - int const cols, - int const rows, - struct pcxCmapEntry const pcxcmap[], - int const colors, - colorhash_table const cht, +ppmTo16ColorPcx(pixel ** const pixels, + int const cols, + int const rows, + struct pcxCmapEntry const pcxcmap[], + int const colors, + colorhash_table const cht, bool const packbits, unsigned int const planesRequested, unsigned int const xPos, @@ -429,7 +429,7 @@ ppmTo16ColorPcx(pixel ** const pixels, MALLOCARRAY_NOFAIL(indexRow, cols); MALLOCARRAY_NOFAIL(planesrow, BytesPerLine); - write_header(stdout, cols, rows, BitsPerPixel, Planes, pcxcmap, + write_header(stdout, cols, rows, BitsPerPixel, Planes, pcxcmap, xPos, yPos); for (row = 0; row < rows; ++row) { int col; @@ -454,13 +454,13 @@ ppmTo16ColorPcx(pixel ** const pixels, static void -ppmTo256ColorPcx(pixel ** const pixels, - int const cols, - int const rows, - struct pcxCmapEntry const pcxcmap[], - int const colors, +ppmTo256ColorPcx(pixel ** const pixels, + int const cols, + int const rows, + struct pcxCmapEntry const pcxcmap[], + int const colors, colorhash_table const cht, - unsigned int const xPos, + unsigned int const xPos, unsigned int const yPos) { int row; @@ -489,11 +489,11 @@ ppmTo256ColorPcx(pixel ** const pixels, static void -ppmToTruecolorPcx(pixel ** const pixels, - int const cols, - int const rows, +ppmToTruecolorPcx(pixel ** const pixels, + int const cols, + int const rows, pixval const maxval, - unsigned int const xPos, + unsigned int const xPos, unsigned int const yPos) { unsigned char *redrow, *greenrow, *bluerow; @@ -530,7 +530,7 @@ ppmToTruecolorPcx(pixel ** const pixels, -static const struct pcxCmapEntry +static const struct pcxCmapEntry stdPalette[] = { { 0, 0, 0 }, { 0, 0, 170 }, @@ -565,7 +565,7 @@ putPcxColorInHash(colorhash_table const cht, int rc; PPM_DEPTH(ppmColor, newPcxColor, PCX_MAXVAL, maxval); - + rc = ppm_lookupcolor(cht, &ppmColor); if (rc == -1) @@ -577,8 +577,8 @@ putPcxColorInHash(colorhash_table const cht, 'maxval' is less than PCX_MAXVAL), and two distinct colors in the standard palette are indistinguishable at subject image color resolution. - - So we have to figure out wether color 'newPcxColor' or + + So we have to figure out whether color 'newPcxColor' or 'existingPcxColor' is a better match for 'ppmColor'. */ @@ -588,8 +588,8 @@ putPcxColorInHash(colorhash_table const cht, pixel existingPcxColor; PPM_DEPTH(idealPcxColor, ppmColor, maxval, PCX_MAXVAL); - - PPM_ASSIGN(existingPcxColor, + + PPM_ASSIGN(existingPcxColor, stdPalette[existingColorIndex].r, stdPalette[existingColorIndex].g, stdPalette[existingColorIndex].b); @@ -619,7 +619,7 @@ generateStandardPalette(struct pcxCmapEntry ** const pcxcmapP, colorhash_table cht; MALLOCARRAY_NOFAIL(pcxcmap, MAXCOLORS); - + *pcxcmapP = pcxcmap; cht = ppm_alloccolorhash(); @@ -629,8 +629,8 @@ generateStandardPalette(struct pcxCmapEntry ** const pcxcmapP, /* The color of this colormap entry, in PCX resolution */ pcxcmap[colorIndex] = stdPalette[colorIndex]; - - PPM_ASSIGN(pcxColor, + + PPM_ASSIGN(pcxColor, stdPalette[colorIndex].r, stdPalette[colorIndex].g, stdPalette[colorIndex].b); @@ -651,27 +651,27 @@ generateStandardPalette(struct pcxCmapEntry ** const pcxcmapP, *chtP = cht; *colorsP = stdPaletteSize; } - + static void readPpmPalette(const char * const paletteFileName, - pixel (* const ppmPaletteP)[], + pixel (* const ppmPaletteP)[], unsigned int * const paletteSizeP) { FILE * pfP; pixel ** pixels; int cols, rows; pixval maxval; - + pfP = pm_openr(paletteFileName); pixels = ppm_readppm(pfP, &cols, &rows, &maxval); pm_close(pfP); - + *paletteSizeP = rows * cols; - if (*paletteSizeP > MAXCOLORS) + if (*paletteSizeP > MAXCOLORS) pm_error("ordered palette image contains %d pixels. Maximum is %d", *paletteSizeP, MAXCOLORS); @@ -681,12 +681,12 @@ readPpmPalette(const char * const paletteFileName, j = 0; /* initial value */ for (row = 0; row < rows; ++row) { int col; - for (col = 0; col < cols; ++col) + for (col = 0; col < cols; ++col) (*ppmPaletteP)[j++] = pixels[row][col]; } } ppm_freearray(pixels, rows); -} +} @@ -706,7 +706,7 @@ readPaletteFromFile(struct pcxCmapEntry ** const pcxcmapP, readPpmPalette(paletteFileName, &ppmPalette, &paletteSize); MALLOCARRAY_NOFAIL(pcxcmap, MAXCOLORS); - + *pcxcmapP = pcxcmap; cht = ppm_alloccolorhash(); @@ -716,8 +716,8 @@ readPaletteFromFile(struct pcxCmapEntry ** const pcxcmapP, /* The color of this colormap entry, in PCX resolution */ pcxcmap[colorIndex] = pcxCmapEntryFromPixel(ppmPalette[colorIndex]); - - PPM_ASSIGN(pcxColor, + + PPM_ASSIGN(pcxColor, ppmPalette[colorIndex].r, ppmPalette[colorIndex].g, ppmPalette[colorIndex].b); @@ -728,7 +728,7 @@ readPaletteFromFile(struct pcxCmapEntry ** const pcxcmapP, *chtP = cht; *colorsP = paletteSize; } - + static void @@ -748,7 +748,7 @@ moveBlackToIndex0(colorhist_vector const chv, for (i = 0; i < colors; ++i) if (PPM_EQUAL(chv[i].color, blackPixel)) blackPresent = TRUE; - + if (blackPresent) { /* We use a trick here. ppm_addtocolorhist() always adds to the beginning of the table and if the color is already elsewhere in @@ -780,10 +780,10 @@ makePcxColormapFromImage(pixel ** const pixels, *pcxcmapP. Also return a lookup hash to relate a color in the image to the - appropriate index in *pcxcmapP. Return that in newly malloc'ed + appropriate index in *pcxcmapP. Return that in newly malloc'ed storage as *chtP. - Iff there are too many colors to do that (i.e. more than 256), + Iff there are too many colors to do that (i.e. more than 256), return *tooManyColorsP == TRUE. -----------------------------------------------------------------------------*/ int colors; @@ -801,7 +801,7 @@ makePcxColormapFromImage(pixel ** const pixels, *tooManyColorsP = FALSE; pm_message("%d colors found", colors); - + moveBlackToIndex0(chv, colors); MALLOCARRAY_NOFAIL(pcxcmap, MAXCOLORS); @@ -835,12 +835,12 @@ makePcxColormapFromImage(pixel ** const pixels, -static void -ppmToPalettePcx(pixel ** const pixels, - int const cols, +static void +ppmToPalettePcx(pixel ** const pixels, + int const cols, int const rows, pixval const maxval, - unsigned int const xPos, + unsigned int const xPos, unsigned int const yPos, struct pcxCmapEntry const pcxcmap[], colorhash_table const cht, @@ -848,10 +848,10 @@ ppmToPalettePcx(pixel ** const pixels, bool const packbits, unsigned int const planes, bool const use_8_bit) { - + /* convert image */ if( colors <= 16 && !use_8_bit ) - ppmTo16ColorPcx(pixels, cols, rows, pcxcmap, colors, cht, + ppmTo16ColorPcx(pixels, cols, rows, pcxcmap, colors, cht, packbits, planes, xPos, yPos); else ppmTo256ColorPcx(pixels, cols, rows, pcxcmap, colors, cht, @@ -889,14 +889,14 @@ main(int argc, char *argv[]) { generateStandardPalette(&pcxcmap, maxval, &cht, &colors); } else if (cmdline.palette) { truecolor = FALSE; - readPaletteFromFile(&pcxcmap, cmdline.palette, maxval, + readPaletteFromFile(&pcxcmap, cmdline.palette, maxval, &cht, &colors); } else { bool tooManyColors; makePcxColormapFromImage(pixels, cols, rows, maxval, &pcxcmap, &cht, &colors, &tooManyColors); - + if (tooManyColors) { pm_message("too many colors - writing a 24bit PCX file"); pm_message("if you want a non-24bit file, " @@ -908,16 +908,19 @@ main(int argc, char *argv[]) { } if (truecolor) - ppmToTruecolorPcx(pixels, cols, rows, maxval, + ppmToTruecolorPcx(pixels, cols, rows, maxval, cmdline.xpos, cmdline.ypos); else { - ppmToPalettePcx(pixels, cols, rows, maxval, + ppmToPalettePcx(pixels, cols, rows, maxval, cmdline.xpos, cmdline.ypos, - pcxcmap, cht, colors, cmdline.packed, + pcxcmap, cht, colors, cmdline.packed, cmdline.planes, cmdline.use_8_bit); - + ppm_freecolorhash(cht); free(pcxcmap); } return 0; } + + + diff --git a/converter/ppm/ppmtospu.c b/converter/ppm/ppmtospu.c index b558c1fe..a6acbaa0 100644 --- a/converter/ppm/ppmtospu.c +++ b/converter/ppm/ppmtospu.c @@ -292,7 +292,7 @@ computePalette(struct PixelType * const pixelType) { /* Uses popularity algorithm */ - /* Count the occurences of each color */ + /* Count the occurrences of each color */ for (i = 0; i < 512; ++i) hist[i] = 0; diff --git a/converter/ppm/sldtoppm.c b/converter/ppm/sldtoppm.c index 2dc049f8..2fef0233 100644 --- a/converter/ppm/sldtoppm.c +++ b/converter/ppm/sldtoppm.c @@ -600,7 +600,7 @@ slider(slvecfn slvec, curcolor = cw & 0xFF; break; - default: /* Co-ordinates */ + default: /* Coordinates */ lx = vec.f.x = cw; ly = vec.f.y = sli(); vec.t.x = sli(); diff --git a/converter/ppm/xim.h b/converter/ppm/xim.h index 27556b30..2e6a6dc1 100644 --- a/converter/ppm/xim.h +++ b/converter/ppm/xim.h @@ -24,7 +24,7 @@ typedef struct ImageHeader { char file_version[8]; /* header version */ char header_size[8]; /* Size of file header in bytes */ char image_width[8]; /* Width of the raster image */ - char image_height[8]; /* Height of the raster imgage */ + char image_height[8]; /* Height of the raster image */ char num_colors[8]; /* Actual number of entries in c_map */ char num_channels[3]; /* 0 or 1 = pixmap, 3 = RG&B buffers */ char bytes_per_line[5]; /* bytes per scanline */ @@ -111,7 +111,7 @@ typedef struct XimAsciiHeader { /* Note: * - All data is in char's in order to maintain easily portability -* across machines, and some human readibility. +* across machines, and some human readability. * - Images may be stored as pixmaps (8 bits/pixel) or as separate * red, green, blue channel data (24+ bits/pixel). * - An alpha channel is optional and is found after every num_channels diff --git a/converter/ppm/ximtoppm.c b/converter/ppm/ximtoppm.c index 75faac69..96209425 100644 --- a/converter/ppm/ximtoppm.c +++ b/converter/ppm/ximtoppm.c @@ -50,7 +50,7 @@ parseCommandLine(int argc, char ** argv, unsigned int alphaoutSpec; option_def_index = 0; /* incremented by OPTENT3 */ - OPTENT3(0, "alphaout", OPT_STRING, + OPTENT3(0, "alphaout", OPT_STRING, &cmdlineP->alpha_filename, &alphaoutSpec, 0); opt.opt_table = option_def; @@ -67,21 +67,21 @@ parseCommandLine(int argc, char ** argv, cmdlineP->input_filename = "-"; /* he wants stdin */ else if (argc - 1 == 1) cmdlineP->input_filename = strdup(argv[1]); - else + else pm_error("Too many arguments. The only argument accepted " "is the input file specification"); - if (cmdlineP->alpha_filename && + if (cmdlineP->alpha_filename && streq(cmdlineP->alpha_filename, "-")) cmdlineP->alpha_stdout = TRUE; - else + else cmdlineP->alpha_stdout = FALSE; } /* The subroutines are excerpted and slightly modified from the - X.V11R4 version of xim_io.c. + X.V11R4 version of xim_io.c. */ static int @@ -143,7 +143,7 @@ ReadXimHeader(FILE * const in_fp, header->width = atoi(a_head.image_width); strncpy(header->program, a_head.program,strlen(a_head.program)); } - /* Do double checking for bakwards compatibility */ + /* Do double checking for backwards compatibility */ if (header->npics == 0) header->npics = 1; if (header->bits_channel == 0) @@ -153,7 +153,7 @@ ReadXimHeader(FILE * const in_fp, header->bits_channel = 8; } if ((int)header->bytes_per_line == 0) - header->bytes_per_line = + header->bytes_per_line = (header->bits_channel == 1 && header->nchannels == 1) ? (header->width + 7) / 8 : header->width; @@ -209,7 +209,7 @@ ReadImageChannel(FILE * const infp, } marker += i; } - /* return to the beginning of the next image's bufffer */ + /* return to the beginning of the next image's buffer */ if (fseek(infp, marker, 0) == -1) { pm_message("ReadImageChannel: can't fseek to location in image buffer" ); return(0); @@ -294,7 +294,7 @@ ReadXimImage(FILE * const in_fp, * Author: Philip Thompson * $Date: 89/11/01 10:14:23 $ * $Revision: 1.14 $ -* Purpose: General xim libray of utililities +* Purpose: General xim library of utililities * Copyright (c) 1988 Philip R. Thompson * Computer Resource Laboratory (CRL) * Dept. of Architecture and Planning @@ -356,21 +356,21 @@ main(int argc, ppm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); - + ifP = pm_openr(cmdline.input_filename); - + if (cmdline.alpha_stdout) alpha_file = stdout; - else if (cmdline.alpha_filename == NULL) + else if (cmdline.alpha_filename == NULL) alpha_file = NULL; else alpha_file = pm_openw(cmdline.alpha_filename); - - if (cmdline.alpha_stdout) + + if (cmdline.alpha_stdout) imageout_file = NULL; else imageout_file = stdout; - + success = ReadXim(ifP, &xim); if (!success) pm_error("can't read Xim file"); @@ -397,7 +397,7 @@ main(int argc, "unknown Xim file type, nchannels == %d, bits_channel == %d", xim.nchannels, xim.bits_channel); - if (imageout_file) + if (imageout_file) ppm_writeppminit(imageout_file, cols, rows, maxval, 0); if (alpha_file) pgm_writepgminit(alpha_file, cols, rows, maxval, 0); @@ -409,8 +409,8 @@ main(int argc, if (mapped) { byte * const ximrow = xim.data + row * xim.bytes_per_line; unsigned int col; - - for (col = 0; col < cols; ++col) + + for (col = 0; col < cols; ++col) pixelrow[col] = colormap[ximrow[col]]; alpharow[col] = 0; } else { @@ -426,11 +426,11 @@ main(int argc, redrow[col], grnrow[col], blurow[col]); if (xim.nchannels > 3) alpharow[col] = othrow[col]; - else + else alpharow[col] = 0; } } - if (imageout_file) + if (imageout_file) ppm_writeppmrow(imageout_file, pixelrow, cols, maxval, 0); if (alpha_file) pgm_writepgmrow(alpha_file, alpharow, cols, maxval, 0); @@ -443,3 +443,6 @@ main(int argc, return 0; } + + + diff --git a/converter/ppm/xpmtoppm.README b/converter/ppm/xpmtoppm.README index b5e254fa..0a32113c 100644 --- a/converter/ppm/xpmtoppm.README +++ b/converter/ppm/xpmtoppm.README @@ -49,7 +49,7 @@ xpmtoppm.c: - Now understands multword X11 color names - Now reads multiple color keys. Takes the color - of the hightest available key. Lines no longer need + of the highest available key. Lines no longer need to begin with key 'c'. - expanded line buffer to from 500 to 2048 for bigger files diff --git a/converter/ppm/xpmtoppm.c b/converter/ppm/xpmtoppm.c index 46101a09..0c9abcc0 100644 --- a/converter/ppm/xpmtoppm.c +++ b/converter/ppm/xpmtoppm.c @@ -544,7 +544,7 @@ interpretXpm3ColorTableLine(char const line[], addToColorMap(hashP, colorName, curbuf, isTransparent); highkey = curkey; } - /* intialize state to process this new key */ + /* initialize state to process this new key */ curkey = key; curbuf[0] = '\0'; isTransparent = FALSE; @@ -1074,7 +1074,7 @@ main(int argc, char *argv[]) { ** - Now understands multiword X11 color names ** ** - Now reads multiple color keys. Takes the color -** of the hightest available key. Lines no longer need +** of the highest available key. Lines no longer need ** to begin with key 'c'. ** ** - expanded line buffer to from 500 to 2048 for bigger files |