diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 23:45:11 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 23:45:11 +0000 |
commit | cdf6e0151411d887fef61245cb303ef190b29335 (patch) | |
tree | 678c2212e125e66e0a868773e2b4ec460794da4e /converter/ppm/ppmtompeg | |
parent | de1311e820dc892f1a3c5c9ae70dbc56868030d8 (diff) | |
download | netpbm-mirror-cdf6e0151411d887fef61245cb303ef190b29335.tar.gz netpbm-mirror-cdf6e0151411d887fef61245cb303ef190b29335.tar.xz netpbm-mirror-cdf6e0151411d887fef61245cb303ef190b29335.zip |
Promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@3641 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/ppm/ppmtompeg')
-rw-r--r-- | converter/ppm/ppmtompeg/HISTORY | 2 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/frame.c | 18 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/frametype.c | 3 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/gethostname.c | 1 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/jrevdct.c | 44 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/mfwddct.c | 31 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/mpeg.c | 1 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/parallel.c | 2 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/param.c | 2 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/ppmtompeg.c | 16 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/rate.c | 46 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/readframe.c | 1 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/specifics.c | 242 |
13 files changed, 225 insertions, 184 deletions
diff --git a/converter/ppm/ppmtompeg/HISTORY b/converter/ppm/ppmtompeg/HISTORY index c9f4932a..e6fb86d3 100644 --- a/converter/ppm/ppmtompeg/HISTORY +++ b/converter/ppm/ppmtompeg/HISTORY @@ -1,4 +1,4 @@ -The entire ppmtojpeg directory was adapted by Bryan from the package +The entire ppmtompeg directory was adapted by Bryan from the package mpeg_encode-1.5b-src (subdirectory mpeg_encode) on March 30, 1999. The program was called mpeg_encode in that package. It was dated August 16, 1995 and came from ftp://mm-ftp.cs.berkeley.edu/pub/multimedia/mpeg/ diff --git a/converter/ppm/ppmtompeg/frame.c b/converter/ppm/ppmtompeg/frame.c index 75b209f8..f91f2cc6 100644 --- a/converter/ppm/ppmtompeg/frame.c +++ b/converter/ppm/ppmtompeg/frame.c @@ -82,8 +82,10 @@ Resize_Array_Width(uint8 ** const inarray, int out_total; uint8 *inptr; uint8 *outptr; +#ifdef DOING_INTERPOLATION uint8 pointA,pointB; - /* double slope,diff; */ + double slope,diff; +#endif for (i = 0; i < in_y; ++i) { /* For each row */ unsigned int j; @@ -105,11 +107,15 @@ Resize_Array_Width(uint8 ** const inarray, --inptr; } } else { +#ifdef DOING_INTERPOLATION pointA = *inptr; +#endif ++inptr; +#ifdef DOING_INTERPOLATION pointB = *inptr; +#endif --inptr; -#if 0 +#ifdef DOING_INTERPOLATION /*Interpolative solution */ slope = ((double)(pointB -pointA))/((double)(out_x)); diff = (((double)(out_total - in_total))); @@ -159,8 +165,10 @@ Resize_Array_Height(uint8 ** const inarray, for(i=0; i < in_x; ++i){ /* for each column */ int in_total; int out_total; +#ifdef DOING_INTERPOLATION uint8 pointA, pointB; double slope, diff; +#endif unsigned int j; int k; @@ -180,15 +188,17 @@ Resize_Array_Height(uint8 ** const inarray, --k; } } else { +#ifdef DOING_INTERPOLATION pointA = inarray[k][i]; - if (k != (in_y -1)) { + if (k != (in_y - 1)) { pointB = inarray[k+1][i]; } else pointB = pointA; /* Interpolative case */ slope = ((double)(pointB -pointA))/(double)(out_y); diff = (double)(out_total - in_total); - /* outarray[j][i] = (inarray[k][i] + (uint8)(slope*diff)); */ + outarray[j][i] = (inarray[k][i] + (uint8)(slope*diff)); +#endif /* Non-Interpolative case */ outarray[j][i] = inarray[k][i]; out_total = out_total + in_y; diff --git a/converter/ppm/ppmtompeg/frametype.c b/converter/ppm/ppmtompeg/frametype.c index b7daacc9..09afa403 100644 --- a/converter/ppm/ppmtompeg/frametype.c +++ b/converter/ppm/ppmtompeg/frametype.c @@ -264,7 +264,7 @@ ComputeFrameTable(unsigned int const numFramesArg) { 'numFrames' == 0 means number of frames is not known at this time. -----------------------------------------------------------------------------*/ int index; - FrameTable *lastI, *lastIP, *firstB, *secondIP; + FrameTable *lastIP, *firstB, *secondIP; FrameTable *ptr; char typ; int table_size; @@ -278,7 +278,6 @@ ComputeFrameTable(unsigned int const numFramesArg) { MALLOCARRAY_NOFAIL(frameTable, 1 + table_size); - lastI = NULL; lastIP = NULL; firstB = NULL; secondIP = NULL; diff --git a/converter/ppm/ppmtompeg/gethostname.c b/converter/ppm/ppmtompeg/gethostname.c index d20af17c..649fff91 100644 --- a/converter/ppm/ppmtompeg/gethostname.c +++ b/converter/ppm/ppmtompeg/gethostname.c @@ -1,3 +1,4 @@ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ #define _BSD_SOURCE /* Make sure strdup() is in string.h */ diff --git a/converter/ppm/ppmtompeg/jrevdct.c b/converter/ppm/ppmtompeg/jrevdct.c index bf9196c4..dd1f9fff 100644 --- a/converter/ppm/ppmtompeg/jrevdct.c +++ b/converter/ppm/ppmtompeg/jrevdct.c @@ -26,7 +26,11 @@ * matrix, perhaps with the difference cases encoded. */ +#define _XOPEN_SOURCE 500 /* get M_PI in math.h */ + #include <memory.h> +#include <math.h> + #include "all.h" #include "dct.h" @@ -1211,35 +1215,29 @@ mpeg_jrevdct_quick(data) */ -/* Here we use math.h to generate constants. Compiler results may - vary a little */ - -#ifndef PI -#ifdef M_PI -#define PI M_PI -#else -#define PI 3.14159265358979323846 -#endif -#endif - /* cosine transform matrix for 8x1 IDCT */ static double itrans_coef[8][8]; -/* initialize DCT coefficient matrix */ -void init_idctref() -{ - int freq, time; - double scale; - - for (freq=0; freq < 8; freq++) - { - scale = (freq == 0) ? sqrt(0.125) : 0.5; - for (time=0; time<8; time++) - itrans_coef[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5)); - } + +void init_idctref() { +/*---------------------------------------------------------------------------- + initialize DCT coefficient matrix +-----------------------------------------------------------------------------*/ + unsigned int freq; + + for (freq=0; freq < 8; ++freq) { + double const scale = (freq == 0) ? sqrt(0.125) : 0.5; + + unsigned int time; + + for (time = 0; time < 8; ++time) + itrans_coef[freq][time] = scale*cos((M_PI/8.0)*freq*(time + 0.5)); + } } + + /* perform IDCT matrix multiply for 8x8 coefficient block */ void reference_rev_dct(block) diff --git a/converter/ppm/ppmtompeg/mfwddct.c b/converter/ppm/ppmtompeg/mfwddct.c index 75c3a718..9381e51c 100644 --- a/converter/ppm/ppmtompeg/mfwddct.c +++ b/converter/ppm/ppmtompeg/mfwddct.c @@ -15,6 +15,10 @@ * instead of floating point. */ +#define _XOPEN_SOURCE 500 /* get M_PI in math.h */ + +#include <math.h> + #include "all.h" #include "dct.h" @@ -375,26 +379,19 @@ mp_fwd_dct_block2(data, dest) * */ -#ifndef PI -#ifdef M_PI -#define PI M_PI -#else -#define PI 3.14159265358979323846 -#endif -#endif -void init_fdct() -{ - int i, j; - double s; +void init_fdct() { - for (i=0; i<8; i++) - { - s = (i==0) ? sqrt(0.125) : 0.5; + unsigned int i; - for (j=0; j<8; j++) - trans_coef[i][j] = s * cos((PI/8.0)*i*(j+0.5)); - } + for (i = 0; i < 8; ++i) { + double const s = i == 0 ? sqrt(0.125) : 0.5; + + unsigned int j; + + for (j = 0; j < 8; ++j) + trans_coef[i][j] = s * cos((M_PI/8.0) * i * (j+0.5)); + } } diff --git a/converter/ppm/ppmtompeg/mpeg.c b/converter/ppm/ppmtompeg/mpeg.c index 24d337ed..33e1a9f9 100644 --- a/converter/ppm/ppmtompeg/mpeg.c +++ b/converter/ppm/ppmtompeg/mpeg.c @@ -30,6 +30,7 @@ * HEADER FILES * *==============*/ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ #define _BSD_SOURCE /* Make sure strdup() is in string.h */ diff --git a/converter/ppm/ppmtompeg/parallel.c b/converter/ppm/ppmtompeg/parallel.c index 2835c67c..e3bcec1a 100644 --- a/converter/ppm/ppmtompeg/parallel.c +++ b/converter/ppm/ppmtompeg/parallel.c @@ -2149,7 +2149,6 @@ DecodeServer(int const numInputFiles, int otherSock; int decodePortNum; int frameReady; - boolean *ready; int *waitMachine; int *waitPort; int *waitList; @@ -2162,7 +2161,6 @@ DecodeServer(int const numInputFiles, /* should keep list of port numbers to notify when frames become ready */ - ready = (boolean *) calloc(numInputFiles, sizeof(boolean)); waitMachine = (int *) calloc(numInputFiles, sizeof(int)); waitPort = (int *) malloc(numMachines*sizeof(int)); waitList = (int *) calloc(numMachines, sizeof(int)); diff --git a/converter/ppm/ppmtompeg/param.c b/converter/ppm/ppmtompeg/param.c index 45605981..87fdfa6b 100644 --- a/converter/ppm/ppmtompeg/param.c +++ b/converter/ppm/ppmtompeg/param.c @@ -7,6 +7,8 @@ /* COPYRIGHT INFORMATION IS AT THE END OF THIS FILE */ +#define _DEFAULT_SOURCE 1 + /* New name for SVID & BSD source defines */ #define _XOPEN_SOURCE 500 /* This makes sure popen() is in stdio.h. In GNU libc 2.1.3, _POSIX_C_SOURCE = 2 is sufficient, but on AIX 4.3, the higher level diff --git a/converter/ppm/ppmtompeg/ppmtompeg.c b/converter/ppm/ppmtompeg/ppmtompeg.c index cd94db39..837b1b9d 100644 --- a/converter/ppm/ppmtompeg/ppmtompeg.c +++ b/converter/ppm/ppmtompeg/ppmtompeg.c @@ -30,6 +30,7 @@ * HEADER FILES * *==============*/ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ #define _BSD_SOURCE /* Make sure strdup() is in string.h */ @@ -190,16 +191,17 @@ parseArgs(int const argc, ++idx; } else if (streq(argv[idx], "-child")) { if (idx+7 < argc-1) { - int combinePortNumber; - /* This used to be important information, when the child - notified the combine server. Now the master notifies - the combine server after the child notifies the master - it is done. So this value is unused. - */ cmdlineP->masterHostname = argv[idx+1]; cmdlineP->masterPortNumber = atoi(argv[idx+2]); ioPortNumber = atoi(argv[idx+3]); - combinePortNumber = atoi(argv[idx+4]); + /* + combinePortNumber = atoi(argv[idx+4]); + + This used to be important information, when the child + notified the combine server. Now the master notifies + the combine server after the child notifies the master + it is done. So this value is unused. + */ decodePortNumber = atoi(argv[idx+5]); machineNumber = atoi(argv[idx+6]); remoteIO = atoi(argv[idx+7]); diff --git a/converter/ppm/ppmtompeg/rate.c b/converter/ppm/ppmtompeg/rate.c index c775e055..6ec330cf 100644 --- a/converter/ppm/ppmtompeg/rate.c +++ b/converter/ppm/ppmtompeg/rate.c @@ -389,7 +389,6 @@ targetRateControl(MpegFrame * const frame) { float tempX, tempY, tempZ; int result; int frameType; - const char *strPtr; minimumBits = (bit_rate / (8 * frameRateRounded)); @@ -445,14 +444,18 @@ targetRateControl(MpegFrame * const frame) { Qscale = (mquant > 31 ? 31 : mquant); Qscale = (Qscale < 1 ? 1 : Qscale); - /* Print headers for Frame info */ - strPtr = Frame_header1; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_header2; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_header3; - DBG_PRINT(("%s\n",strPtr)); - +#ifdef HEINOUS_DEBUG_MODE + { + const char * strPtr; + /* Print headers for Frame info */ + strPtr = Frame_header1; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_header2; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_header3; + DBG_PRINT(("%s\n",strPtr)); + } +#endif /* Print Frame info */ sprintf(rc_buffer, "%4d %1c %4d %6d %7d " "%2d %2d %2d %2.2f %6d %4d %3d", @@ -467,10 +470,13 @@ targetRateControl(MpegFrame * const frame) { /* Print headers for Macroblock info */ if (RC_MB_SAMPLE_RATE) { +#ifdef HEINOUS_DEBUG_MODE + const char * strPtr; strPtr = MB_header1; DBG_PRINT(("%s\n",strPtr)); strPtr = MB_header2; DBG_PRINT(("%s\n",strPtr)); +#endif } } @@ -519,7 +525,6 @@ void updateRateControl(int const type) { int totalBits, frameComplexity, pctAllocUsed, pctGOPUsed; float avgQuant; - const char *strPtr; totalBits = rc_totalFrameBits; avgQuant = ((float) rc_totalQuant / (float) rc_numBlocks); @@ -559,15 +564,18 @@ updateRateControl(int const type) { break; } - - /* Print Frame info */ - strPtr = Frame_trailer1; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_trailer2; - DBG_PRINT(("%s\n",strPtr)); - strPtr = Frame_trailer3; - DBG_PRINT(("%s\n",strPtr)); - +#ifdef HEINOUS_DEBUG_MODE + { + /* Print Frame info */ + const char * strPtr; + strPtr = Frame_trailer1; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_trailer2; + DBG_PRINT(("%s\n",strPtr)); + strPtr = Frame_trailer3; + DBG_PRINT(("%s\n",strPtr)); + } +#endif sprintf(rc_buffer, "%6d %2.2f %6d %3d %2.2f %7d " "%3d %7d %3d %6d %6d", totalBits, avgQuant, frameComplexity, avg_act, N_act, diff --git a/converter/ppm/ppmtompeg/readframe.c b/converter/ppm/ppmtompeg/readframe.c index 23752706..2a359b2f 100644 --- a/converter/ppm/ppmtompeg/readframe.c +++ b/converter/ppm/ppmtompeg/readframe.c @@ -17,6 +17,7 @@ * HEADER FILES * *==============*/ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _BSD_SOURCE /* Make sure popen() is in stdio.h */ #include "all.h" #include <time.h> diff --git a/converter/ppm/ppmtompeg/specifics.c b/converter/ppm/ppmtompeg/specifics.c index fb5e3649..1a1fda44 100644 --- a/converter/ppm/ppmtompeg/specifics.c +++ b/converter/ppm/ppmtompeg/specifics.c @@ -36,6 +36,7 @@ * HEADER FILES * *==============*/ +#include "netpbm/mallocvar.h" #include "all.h" #include "mtypes.h" #include "frames.h" @@ -239,7 +240,6 @@ FILE *fp; FrameSpecList *current, *new; char typ; int fnum,snum, bnum, qs, newqs; - int num_scanned; fsl = MakeFslEntry(); current = fsl; @@ -274,7 +274,7 @@ FILE *fp; break; case 'B': lp += 6; - num_scanned = sscanf(lp, "%d %d", &bnum, &newqs); + sscanf(lp, "%d %d", &bnum, &newqs); if (qs == newqs) break; qs = newqs; AddBs(current, bnum, FALSE, qs); @@ -289,116 +289,140 @@ FILE *fp; } -/* Version 2 */ -void Parse_Specifics_File_v2(fp) -FILE *fp; -{ - char line[1024], *lp; - FrameSpecList *current, *new; - char typ; - int fnum, snum, bnum, qs, newqs; - int num_scanned, fx=0, fy=0, sx=0, sy=0; - char kind[100]; - Block_Specifics *new_blk; - boolean relative; - fsl = MakeFslEntry(); - current = fsl; - while ((fgets(line,1023,fp))!=NULL) { - lp = &line[0]; - while ((*lp == ' ') || (*lp == '\t')) lp++; - if (( *lp == '#' ) || (*lp=='\n')) { - continue; +void +Parse_Specifics_File_v2(FILE * const fP) { +/*---------------------------------------------------------------------------- + Parse Version 2 specific file. +-----------------------------------------------------------------------------*/ + char line[1024]; + FrameSpecList * current; + int qs; + int numScanned; + int fx, fy, sx, sy; + char kind[100]; + Block_Specifics *new_blk; + boolean relative; + + fx = fy = sx = sy = 0; /* initial value */ + + fsl = MakeFslEntry(); + current = fsl; + + while ((fgets(line,1023, fP))!=NULL) { + const char * lp; + + lp = &line[0]; /* initial value */ + + while ((*lp == ' ') || (*lp == '\t')) + ++lp; + if (*lp == '#' || *lp == '\n') { + /* comment or blank line */ + } else { + switch (my_upper(*lp)) { + case 'F': { + char typ; + FrameSpecList * new; + int fnum; + + lp += 6; + sscanf(lp,"%d %c %d", &fnum, &typ, &qs); + new = MakeFslEntry(); + if (current->framenum != -1) { + current->next = new; + current = new; + } + current->framenum = fnum; + current->frametype = CvtType(typ); + if (qs <= 0) + qs = -1; + current->qscale = qs; + } break; + case 'S': { + int snum; + int newqs; + lp += 6; + sscanf(lp,"%d %d", &snum, &newqs); + if (qs == newqs) + break; + qs = newqs; + AddSlc(current, snum, qs); + } break; + case 'B': { + int bnum; + int newqs; + lp += 6; + numScanned = 0; + bnum = atoi(lp); + SkipToSpace(lp); + while ((*lp != '-') && (*lp != '+') && + ((*lp < '0') || (*lp > '9'))) + ++lp; + relative = (*lp == '-' || *lp == '+'); + newqs = atoi(lp); + SkipToSpace(lp); + if (EndString(lp)) { + numScanned = 2; + } else { + numScanned = + 2 + sscanf(lp, "%s %d %d %d %d", + kind, &fx, &fy, &sx, &sy); + } + + qs = newqs; + new_blk = AddBs(current, bnum, relative, qs); + if (numScanned > 2) { + BlockMV * tmp; + + MALLOCVAR(tmp); + + switch (numScanned) { + case 7: + tmp->typ = TYP_BOTH; + tmp->fx = fx; + tmp->fy = fy; + tmp->bx = sx; + tmp->by = sy; + new_blk->mv = tmp; + break; + case 3: + tmp->typ = TYP_SKIP; + new_blk->mv = tmp; + break; + case 5: + if (my_upper(kind[0]) == 'B') { + tmp->typ = TYP_BACK; + tmp->bx = fx; + tmp->by = fy; + } else { + tmp->typ = TYP_FORW; + tmp->fx = fx; + tmp->fy = fy; + } + new_blk->mv = tmp; + break; + default: + fprintf(stderr, + "Bug in specifics file! " + "Skipping short/long entry: %s\n",line); + break; + } + } else + new_blk->mv = NULL; + + } break; + case 'V': + fprintf(stderr, + "Cannot specify version twice! Taking first (%d).\n", + version); + break; + default: + printf("What? *%s*\n",line); + break; + } + } } - - switch (my_upper(*lp)) { - case 'F': - lp += 6; - sscanf(lp,"%d %c %d", &fnum, &typ, &qs); - new = MakeFslEntry(); - if (current->framenum != -1) { - current->next = new; - current = new; - } - current->framenum = fnum; - current->frametype = CvtType(typ); - if (qs <= 0) qs = -1; - current->qscale = qs; - break; - case 'S': - lp += 6; - sscanf(lp,"%d %d", &snum, &newqs); - if (qs == newqs) break; - qs = newqs; - AddSlc(current, snum, qs); - break; - case 'B': - lp += 6; - num_scanned = 0; - bnum = atoi(lp); - SkipToSpace(lp); - while ((*lp != '-') && (*lp != '+') && - ((*lp < '0') || (*lp > '9'))) lp++; - relative = ((*lp == '-') || (*lp == '+')); - newqs = atoi(lp); - SkipToSpace(lp); - if (EndString(lp)) { - num_scanned = 2; - } else { - num_scanned = 2+sscanf(lp, "%s %d %d %d %d", kind, &fx, &fy, &sx, &sy); - } - - qs = newqs; - new_blk = AddBs(current, bnum, relative, qs); - if (num_scanned > 2) { - BlockMV *tmp; - tmp = (BlockMV *) malloc(sizeof(BlockMV)); - switch (num_scanned) { - case 7: - tmp->typ = TYP_BOTH; - tmp->fx = fx; - tmp->fy = fy; - tmp->bx = sx; - tmp->by = sy; - new_blk->mv = tmp; - break; - case 3: - tmp->typ = TYP_SKIP; - new_blk->mv = tmp; - break; - case 5: - if (my_upper(kind[0]) == 'B') { - tmp->typ = TYP_BACK; - tmp->bx = fx; - tmp->by = fy; - } else { - tmp->typ = TYP_FORW; - tmp->fx = fx; - tmp->fy = fy; - } - new_blk->mv = tmp; - break; - default: - fprintf(stderr, - "Bug in specifics file! Skipping short/long entry: %s\n",line); - break; - } - } else { - new_blk->mv = (BlockMV *) NULL; - } - - break; - case 'V': - fprintf(stderr, - "Cannot specify version twice! Taking first (%d).\n", - version); - break; - default: - printf("What? *%s*\n",line); - break; - }} - } |