📄 param.c
字号:
pm_error("Unable to resolve backtick entry in input file list. " "Could not open piped command: '%s'", cmd); } else { struct inputSource subInputSource; ReadInputFileNames(fp, "HOPE-THIS_ISNT_A_FILENAME.xyz5555", &subInputSource); mergeInputSource(inputSourceP, &subInputSource); }}static voidReadInputFileNames(FILE * const fpointer, const char * const endInput, struct inputSource * const inputSourceP) {/*---------------------------------------------------------------------------- Read a list of input file names from the parameter file. Add the information to *inputSourceP. If inputSourceP == NULL, read off the list, but ignore it.-----------------------------------------------------------------------------*/ char input[256]; bool endStatementRead; /* read param file up through endInput statement. Each line until endInput is a file specification. */ endStatementRead = FALSE; while (!endStatementRead) { char * rc; rc = fgets(input, sizeof(input), fpointer); if (feof(fpointer)) pm_error("End of file before section end statement '%s'", endInput); else if (rc == NULL) pm_error("Error reading file names from parameter file."); else { if (strncmp(input, endInput, strlen(endInput)) == 0) endStatementRead = TRUE; else if ((input[0] == '#') || (input[0] == '\n')) { /* It's a comment or blank line. Ignore it */ } else if (input[0] == '`' ) { expandBackTickLine(input, inputSourceP); } else { /* get rid of trailing whitespace including newline */ while (ISSPACE(input[strlen(input)-1])) input[strlen(input)-1] = '\0'; if (inputSourceP) AddInputFiles(inputSourceP, input); } } }}static voidinitOptionSeen(void) { unsigned int index; for (index = FIRST_OPTION; index < NUM_OPTIONS; ++index) optionSeen[index] = FALSE;}static voidverifyNoMissingEncodeFramesOption(void) { if (!optionSeen[OPTION_GOP]) pm_error("GOP_SIZE option missing"); if (!optionSeen[OPTION_PATTERN]) pm_error("PATTERN option missing"); if (!optionSeen[OPTION_PIXEL]) pm_error("PIXEL option missing"); if (!optionSeen[OPTION_PQSCALE]) pm_error("PQSCALE option missing"); if (!optionSeen[OPTION_OUTPUT]) pm_error("OUTPUT option missing"); if (!optionSeen[OPTION_RANGE]) pm_error("RANGE option missing"); if (!optionSeen[OPTION_PSEARCH_ALG]) pm_error("PSEARCH_ALG option missing"); if (!optionSeen[OPTION_IQSCALE]) pm_error("IQSCALE option missing"); if (!optionSeen[OPTION_INPUT_DIR]) pm_error("INPUT_DIR option missing"); if (!optionSeen[OPTION_INPUT_CONVERT]) pm_error("INPUT_CONVERT option missing"); if (!optionSeen[OPTION_BQSCALE]) pm_error("BQSCALE option missing"); if (!optionSeen[OPTION_BASE_FORMAT]) pm_error("BASE_FILE_FORMAT option missing"); if (!optionSeen[OPTION_SPF]) pm_error("SLICES_PER_FRAME option missing"); if (!optionSeen[OPTION_BSEARCH_ALG]) pm_error("BSEARCH_ALG option missing"); if (!optionSeen[OPTION_REF_FRAME]) pm_error("REFERENCE_FRAME option missing");}static voidverifyNoMissingCombineGopsOption(void) { if (!optionSeen[OPTION_GOP_INPUT]) pm_error("GOP_INPUT option missing"); if (!optionSeen[OPTION_YUV_SIZE]) pm_error("YUV_SIZE option missing"); if (!optionSeen[OPTION_OUTPUT]) pm_error("OUTPUT option missing");}static voidverifyNoMissingCombineFramesOption(void) { if (!optionSeen[OPTION_GOP]) pm_error("GOP_SIZE option missing"); if (!optionSeen[OPTION_YUV_SIZE]) pm_error("YUV_SIZE option missing"); if (!optionSeen[OPTION_OUTPUT]) pm_error("OUTPUT option missing");}static voidverifyNoMissingOption(int const function) {/*---------------------------------------------------------------------------- Verify that the parameter file contains every option it is supposed to. Abort program if not.-----------------------------------------------------------------------------*/ switch(function) { case ENCODE_FRAMES: verifyNoMissingEncodeFramesOption(); break; case COMBINE_GOPS: verifyNoMissingCombineGopsOption(); break; case COMBINE_FRAMES: verifyNoMissingCombineFramesOption(); break; default: pm_error("Internal error - impossible value for 'function': %d", function); }}static voidprocessIqtable(FILE * const fpointer) { unsigned int row; unsigned int col; char input[256]; for (row = 0; row < 8; ++row) { const char * charPtr; fgets(input, 256, fpointer); charPtr = input; if (8 != sscanf(charPtr,"%d %d %d %d %d %d %d %d", &qtable[row*8+0], &qtable[row*8+1], &qtable[row*8+2], &qtable[row*8+3], &qtable[row*8+4], &qtable[row*8+5], &qtable[row*8+6], &qtable[row*8+7])) { pm_error("Line %d of IQTABLE doesn't have 8 elements!", row); } for (col = 0; col < 8; ++col) { if ((qtable[row*8+col]<1) || (qtable[row*8+col]>255)) { pm_message( "Warning: IQTable Element %1d,%1d (%d) " "corrected to 1-255.", row+1, col+1, qtable[row*8+col]); qtable[row*8+col] = (qtable[row*8+col]<1)?1:255; } } } if (qtable[0] != 8) { pm_message("Warning: IQTable Element 1,1 reset to 8, " "since it must be 8."); qtable[0] = 8; } customQtable = qtable;}static voidsetInputSource(int const function, struct inputSource ** const inputSourcePP, struct inputSource * const inputSourceP, struct inputSource * const gopInputSourceP, struct inputSource * const frameInputSourceP) { switch (function) { case ENCODE_FRAMES: *inputSourcePP = inputSourceP; DestroyInputSource(gopInputSourceP); DestroyInputSource(frameInputSourceP); break; case COMBINE_GOPS: *inputSourcePP = gopInputSourceP; DestroyInputSource(inputSourceP); DestroyInputSource(frameInputSourceP); break; case COMBINE_FRAMES: *inputSourcePP = frameInputSourceP; DestroyInputSource(inputSourceP); DestroyInputSource(gopInputSourceP); break; default: pm_error("INTERNAL ERROR: invalid 'function' %d", function); }}/*=====================* * EXPORTED PROCEDURES * *=====================*//*===========================================================================* * * ReadParamFile * * read the parameter file * function is ENCODE_FRAMES, COMBINE_GOPS, or COMBINE_FRAMES, and * will slightly modify the procedure's behavior as to what it * is looking for in the parameter file * * SIDE EFFECTS: sets parameters accordingly, as well as machine info for * parallel execution and input file names * *===========================================================================*/voidReadParamFile(const char * const fileName, int const function, struct params * const paramP) { FILE *fpointer; char input[256]; const char *charPtr; boolean yuvUsed = FALSE; int row, col; struct inputSource * inputSourceP; /* Contents of INPUT section */ struct inputSource * frameInputSourceP; /* Contents of FRAME_INPUT section */ struct inputSource * gopInputSourceP; /* Contents of GOP_INPUT section */ fpointer = fopen(fileName, "r"); if (fpointer == NULL) pm_error("Error: Cannot open parameter file: %s", fileName); CreateInputSource(&inputSourceP); CreateInputSource(&frameInputSourceP); CreateInputSource(&gopInputSourceP); /* should set defaults */ numMachines = 0; sprintf(currentPath, "."); sprintf(currentGOPPath, "."); sprintf(currentFramePath, ".");#ifndef HPUX SetRemoteShell("rsh");#else SetRemoteShell("remsh");#endif keepTempFiles = FALSE; paramP->warnOverflow = FALSE; paramP->warnUnderflow = FALSE; initOptionSeen(); while ( fgets(input, 256, fpointer) != NULL ) { /* skip comments */ if ( input[0] == '#' ) { continue; } { int len = strlen(input); if (input[len-1] == '\n') { len--; input[len] = '\0'; /* get rid of newline */ /* Junk whitespace */ while ((len >= 0) && ((input[len-1] == ' ') || (input[len-1] == '\t'))) { input[--len] = '\0'; } } } if (strlen(SkipSpacesTabs(input)) == 0) continue; switch(input[0]) { case 'A': if ( strncmp(input, "ASPECT_RATIO", 12) == 0 ) { charPtr = SkipSpacesTabs(&input[12]); aspectRatio = GetAspectRatio(charPtr); optionSeen[OPTION_ASPECT_RATIO] = TRUE; } break; case 'B': if ( strncmp(input, "BQSCALE", 7) == 0 ) { charPtr = SkipSpacesTabs(&input[7]); SetBQScale(atoi(charPtr)); optionSeen[OPTION_BQSCALE] = TRUE; } else if ( strncmp(input, "BASE_FILE_FORMAT", 16) == 0 ) { charPtr = SkipSpacesTabs(&input[16]); SetFileFormat(charPtr); if ( (strncmp(charPtr,"YUV",3) == 0) || (strcmp(charPtr,"Y") == 0) ) { yuvUsed = TRUE; } optionSeen[OPTION_BASE_FORMAT] = TRUE; } else if ( strncmp(input, "BSEARCH_ALG", 11) == 0 ) { charPtr = SkipSpacesTabs(&input[11]); SetBSearchAlg(charPtr); optionSeen[OPTION_BSEARCH_ALG] = TRUE; } else if ( strncmp(input, "BIT_RATE", 8) == 0 ) { charPtr = SkipSpacesTabs(&input[8]); setBitRate(charPtr); optionSeen[OPTION_BIT_RATE] = TRUE; } else if ( strncmp(input, "BUFFER_SIZE", 11) == 0 ) { charPtr = SkipSpacesTabs(&input[11]); setBufferSize(charPtr); optionSeen[OPTION_BUFFER_SIZE] = TRUE; } break; case 'C': if ( strncmp(input, "CDL_FILE", 8) == 0 ) { charPtr = SkipSpacesTabs(&input[8]); strcpy(specificsFile, charPtr); specificsOn=TRUE; optionSeen[OPTION_SPECIFICS] = TRUE; } else if ( strncmp(input, "CDL_DEFINES", 11) == 0 ) { charPtr = SkipSpacesTabs(&input[11]); strcpy(specificsDefines, charPtr); optionSeen[OPTION_DEFS_SPECIFICS] = TRUE; } break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -