KVRunListCreator::KVRunListCreator(const TString& dir, const TString& datatype, const TString& fmt) { // Give directory to scan, optional format for runfile names SetRunDir(dir); if (fmt != "") SetFileFormat(fmt); else SetFileFormat(gEnv->GetValue("DataSet.RunFileName.raw", "run_%04d.dat%*")); fRunInfos.SetOwner(); fDataType = datatype; ScanDirectory(); TFile f("runinfos.root", "recreate"); GetRunInfos().Write(); f.Close(); }
// Save() // Save the file referenced within this class. Returns whatever // the GetLastError() function of the file format loader returned. // If a filename is provided, it will replace the filename already // existing in the instance. A new file format can also be passed in, // which will replace the existing file format. int ImageData::Save( const char * _filename, ImageFileFormats _file_format ) { // Check for a valid filename if( filename == NULL ) return IMGSAVER_INVALID_FILENAME; // Make sure there is an image to save if( image == NULL ) return IMGSAVER_INVALID_IMAGE; if( _file_format != IMGFF_UNKNOWN ) SetFileFormat( _file_format ); // Make sure the file format is valid if( (GetFileFormat() < 1) || (GetFileFormat() > IMGFF_NUM_FILE_FORMATS) ) { return IMGSAVER_INVALID_FILE_FORMAT; } // Auto-Add the extension and use the new filename, if applicable char new_filename[ MAX_PATH_LENGTH ]; if( _filename == NULL ) strcpy( new_filename, filename ); // Use the old name else strcpy( new_filename, _filename ); // Use the new name if( auto_extension ) { // Use the first extension, if applicable DirStrings::ChangeExtension( new_filename, GetExtensionList( _file_format )[0] ); SetFilename( new_filename ); } // Figure out which file format to save in // NOTE: If you add a new file format, you MUST insert the file // format's information here. This should consist of copying // one of the existing cases and replacing references to the // original file format to your new on. switch( file_format ) { case IMGFF_BMP: // BMP Image Saver BMP::Save( filename, this ); return BMP::GetLastError(); break; case IMGFF_TARGA: // Targa Image Saver // Targa::Save( file_name ); // return Targa::GetLastError(); break; case IMGFF_CSOURCE: // CSource Image Saver CSource::Save( filename, this ); return CSource::GetLastError(); break; // INSERT NEW FILE FORMAT HERE (SAVER) } // Unrecognized File Format; fail return IMGSAVER_UNRECOGNIZED_FILE_FORMAT; }
BonkEnc::ConfigureFAAC::ConfigureFAAC() { Point pos; Size size; currentConfig = BonkEnc::currentConfig; mpegVersion = currentConfig->faac_mpegversion; aacType = currentConfig->faac_type; bitrate = currentConfig->faac_bitrate; allowjs = currentConfig->faac_allowjs; usetns = currentConfig->faac_usetns; setQuality = currentConfig->faac_set_quality; aacQuality = currentConfig->faac_aac_quality; allowID3 = currentConfig->faac_enable_id3; fileFormat = currentConfig->faac_enable_mp4; mainWnd = new Window(String(BonkEnc::i18n->TranslateString("%1 encoder configuration")).Replace("%1", "FAAC"), currentConfig->wndPos + Point(80, 80), Size(547, 295)); mainWnd->SetRightToLeft(BonkEnc::i18n->IsActiveLanguageRightToLeft()); mainWnd_titlebar = new Titlebar(TB_CLOSEBUTTON); divbar = new Divider(39, OR_HORZ | OR_BOTTOM); pos.x = 175; pos.y = 29; size.cx = 0; size.cy = 0; btn_cancel = new Button(BonkEnc::i18n->TranslateString("Cancel"), NIL, pos, size); btn_cancel->onAction.Connect(&ConfigureFAAC::Cancel, this); btn_cancel->SetOrientation(OR_LOWERRIGHT); pos.x -= 88; btn_ok = new Button(BonkEnc::i18n->TranslateString("OK"), NIL, pos, size); btn_ok->onAction.Connect(&ConfigureFAAC::OK, this); btn_ok->SetOrientation(OR_LOWERRIGHT); pos.x = 7; pos.y = 7; size.cx = 525; size.cy = 208; tabwidget = new TabWidget(pos, size); layer_format = new Layer(BonkEnc::i18n->TranslateString("Format")); pos.x = 135; pos.y = 11; size.cx = 120; size.cy = 65; group_version = new GroupBox(BonkEnc::i18n->TranslateString("MPEG version"), pos, size); pos.x += 10; pos.y += 13; size.cx = 99; size.cy = 0; option_version_mpeg2 = new OptionBox("MPEG 2", pos, size, &mpegVersion, 1); option_version_mpeg2->onAction.Connect(&ConfigureFAAC::SetMPEGVersion, this); pos.y += 25; option_version_mpeg4 = new OptionBox("MPEG 4", pos, size, &mpegVersion, 0); option_version_mpeg4->onAction.Connect(&ConfigureFAAC::SetMPEGVersion, this); pos.x = 7; pos.y = 88; size.cx = 120; size.cy = 90; group_aactype = new GroupBox(BonkEnc::i18n->TranslateString("AAC object type"), pos, size); pos.x += 10; pos.y += 13; size.cx = 99; size.cy = 0; option_aactype_main = new OptionBox("MAIN", pos, size, &aacType, 1); option_aactype_main->onAction.Connect(&ConfigureFAAC::SetObjectType, this); pos.y += 25; option_aactype_low = new OptionBox("LC", pos, size, &aacType, 2); option_aactype_low->onAction.Connect(&ConfigureFAAC::SetObjectType, this); pos.y += 25; option_aactype_ltp = new OptionBox("LTP", pos, size, &aacType, 4); option_aactype_ltp->onAction.Connect(&ConfigureFAAC::SetObjectType, this); pos.x = 7; pos.y = 11; size.cx = 120; size.cy = 65; group_mp4 = new GroupBox(BonkEnc::i18n->TranslateString("File format"), pos, size); pos.x += 10; pos.y += 13; size.cx = 99; size.cy = 0; option_mp4 = new OptionBox("MP4", pos, size, &fileFormat, 1); option_mp4->onAction.Connect(&ConfigureFAAC::SetFileFormat, this); if (!currentConfig->enable_mp4) { option_mp4->Deactivate(); fileFormat = 0; } pos.y += 25; option_aac = new OptionBox("AAC", pos, size, &fileFormat, 0); option_aac->onAction.Connect(&ConfigureFAAC::SetFileFormat, this); pos.x = 135; pos.y = 88; size.cx = 279; size.cy = 90; group_id3v2 = new GroupBox(BonkEnc::i18n->TranslateString("Info tags"), pos, size); pos.x += 10; pos.y += 13; size.cx = 200; size.cy = 0; check_id3v2 = new CheckBox(BonkEnc::i18n->TranslateString("Allow ID3v2 tags in AAC files"), pos, size, &allowID3); check_id3v2->SetWidth(check_id3v2->textSize.cx + 20); pos.y += 25; text_note = new Text(BonkEnc::i18n->TranslateString("Note:"), pos); pos.x += text_note->textSize.cx + 2; text_id3v2 = new Text(BonkEnc::i18n->TranslateString("Some players may have problems playing AAC\nfiles with ID3 tags attached. Please use this option only\nif you are sure that your player can handle these tags."), pos); group_id3v2->SetWidth(text_note->textSize.cx + text_id3v2->textSize.cx + 22); layer_quality = new Layer(BonkEnc::i18n->TranslateString("Quality")); pos.x = 7; pos.y = 11; size.cx = 320; size.cy = 65; group_bitrate = new GroupBox(BonkEnc::i18n->TranslateString("Bitrate / Quality"), pos, size); pos.x += 10; pos.y += 13; size.cx = 150; size.cy = 0; option_bitrate = new OptionBox(BonkEnc::i18n->TranslateString("Bitrate per channel:"), pos, size, &setQuality, 0); option_bitrate->onAction.Connect(&ConfigureFAAC::ToggleBitrateQuality, this); option_bitrate->SetWidth(option_bitrate->textSize.cx + 19); pos.x += (option_bitrate->GetWidth() + 9); size.cx = 227 - option_bitrate->GetWidth(); size.cy = 0; slider_bitrate = new Slider(pos, size, OR_HORZ, &bitrate, 8, 256); slider_bitrate->onValueChange.Connect(&ConfigureFAAC::SetBitrate, this); pos.x += (size.cx + 8); pos.y -= 1; size.cx = 25; edit_bitrate = new EditBox("", pos, size, 3); edit_bitrate->SetFlags(EDB_NUMERIC); edit_bitrate->onInput.Connect(&ConfigureFAAC::SetBitrateByEditBox, this); pos.x += 32; pos.y += 3; text_bitrate_kbps = new Text("kbps", pos); pos.x = 17; pos.y += 23; size.cx = 150; size.cy = 0; option_quality = new OptionBox(BonkEnc::i18n->TranslateString("Set quality:"), pos, size, &setQuality, 1); option_quality->onAction.Connect(&ConfigureFAAC::ToggleBitrateQuality, this); option_quality->SetWidth(option_bitrate->textSize.cx + 19); pos.x += (option_quality->GetWidth() + 9); size.cx = 227 - option_quality->GetWidth(); size.cy = 0; slider_quality = new Slider(pos, size, OR_HORZ, &aacQuality, 10, 500); slider_quality->onValueChange.Connect(&ConfigureFAAC::SetQuality, this); pos.x += (size.cx + 8); pos.y -= 1; size.cx = 25; edit_quality = new EditBox("", pos, size, 3); edit_quality->SetFlags(EDB_NUMERIC); edit_quality->onInput.Connect(&ConfigureFAAC::SetQualityByEditBox, this); pos.x += 32; pos.y += 3; text_quality_percent = new Text("%", pos); pos.x = 335; pos.y = 11; size.cx = 179; size.cy = 42; group_js = new GroupBox(BonkEnc::i18n->TranslateString("Stereo mode"), pos, size); pos.x += 10; pos.y += 13; size.cx = 158; size.cy = 0; check_js = new CheckBox(BonkEnc::i18n->TranslateString("Allow Joint Stereo"), pos, size, &allowjs); pos.x = 335; pos.y = 65; size.cx = 179; size.cy = 42; group_tns = new GroupBox(BonkEnc::i18n->TranslateString("Temporal Noise Shaping"), pos, size); pos.x += 10; pos.y += 13; size.cx = 158; size.cy = 0; check_tns = new CheckBox(BonkEnc::i18n->TranslateString("Use Temporal Noise Shaping"), pos, size, &usetns); pos.x = 7; pos.y = 88; size.cx = 320; size.cy = 43; group_bandwidth = new GroupBox(BonkEnc::i18n->TranslateString("Maximum bandwidth"), pos, size); pos.x += 11; pos.y += 15; text_bandwidth = new Text(BonkEnc::i18n->TranslateString("Maximum AAC frequency bandwidth to use (Hz):"), pos); pos.x += (text_bandwidth->textSize.cx + 8); pos.y -= 3; size.cx = 291 - text_bandwidth->textSize.cx; size.cy = 0; edit_bandwidth = new EditBox(String::FromInt(currentConfig->faac_bandwidth), pos, size, 5); edit_bandwidth->SetFlags(EDB_NUMERIC); SetBitrate(); SetQuality(); SetMPEGVersion(); SetFileFormat(); ToggleBitrateQuality(); Add(mainWnd); mainWnd->Add(btn_ok); mainWnd->Add(btn_cancel); mainWnd->Add(tabwidget); mainWnd->Add(mainWnd_titlebar); mainWnd->Add(divbar); tabwidget->Add(layer_quality); tabwidget->Add(layer_format); layer_format->Add(group_version); layer_format->Add(option_version_mpeg2); layer_format->Add(option_version_mpeg4); layer_format->Add(group_aactype); layer_format->Add(option_aactype_main); layer_format->Add(option_aactype_low); layer_format->Add(option_aactype_ltp); layer_format->Add(group_mp4); layer_format->Add(option_mp4); layer_format->Add(option_aac); layer_format->Add(group_id3v2); layer_format->Add(check_id3v2); layer_format->Add(text_note); layer_format->Add(text_id3v2); layer_quality->Add(group_bitrate); layer_quality->Add(option_bitrate); layer_quality->Add(slider_bitrate); layer_quality->Add(edit_bitrate); layer_quality->Add(text_bitrate_kbps); layer_quality->Add(option_quality); layer_quality->Add(slider_quality); layer_quality->Add(edit_quality); layer_quality->Add(text_quality_percent); layer_quality->Add(group_js); layer_quality->Add(check_js); layer_quality->Add(group_tns); layer_quality->Add(check_tns); layer_quality->Add(group_bandwidth); layer_quality->Add(text_bandwidth); layer_quality->Add(edit_bandwidth); mainWnd->SetFlags(mainWnd->GetFlags() | WF_NOTASKBUTTON); mainWnd->SetIcon(ImageLoader::Load("freac.pci:0")); }
/*===========================================================================* * * 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 * * RETURNS: TRUE if the parameter file was read correctly; FALSE if not * * SIDE EFFECTS: sets parameters accordingly, as well as machine info for * parallel execution and input file names * *===========================================================================*/ boolean ReadParamFile(char *fileName, int function) { numInputFileEntries = 0; // for gmsh FILE *fpointer; char input[256]; char *charPtr; boolean yuvUsed = FALSE; /* static const char *optionText[LAST_OPTION+1] = { "GOP_SIZE", "PATTERN", "PIXEL", "PQSCALE", "OUTPUT", "RANGE", "PSEARCH_ALG", "IQSCALE", "INPUT_DIR", "INPUT_CONVERT", "INPUT", "BQSCALE", "BASE_FILE_FORMAT", "SLICES_PER_FRAME", "BSEARCH_ALG", "REFERENCE_FRAME"}; */ register int index; register int row, col; if ( (fpointer = fopen(fileName, "r")) == NULL ) { fprintf(stderr, "Error: Cannot open parameter file: %s\n", fileName); return FALSE; } /* should set defaults */ numInputFiles = 0; numMachines = 0; sprintf(currentPath, "."); sprintf(currentGOPPath, "."); sprintf(currentFramePath, "."); #ifndef HPUX SetRemoteShell((char*)"rsh"); #else SetRemoteShell("remsh"); #endif switch(function) { case ENCODE_FRAMES: for ( index = FIRST_OPTION; index <= LAST_OPTION; index++ ) { optionSeen[index] = FALSE; } optionSeen[OPTION_IO_CONVERT] = FALSE; optionSeen[OPTION_SLAVE_CONVERT] = FALSE; break; case COMBINE_GOPS: for ( index = FIRST_OPTION; index <= LAST_OPTION; index++ ) { optionSeen[index] = TRUE; } optionSeen[OPTION_OUTPUT] = FALSE; break; case COMBINE_FRAMES: for ( index = FIRST_OPTION; index <= LAST_OPTION; index++ ) { optionSeen[index] = TRUE; } optionSeen[OPTION_GOP] = FALSE; optionSeen[OPTION_OUTPUT] = FALSE; break; } for( index=LAST_OPTION+1; index<= NUM_OPTIONS; index++ ) { optionSeen[index]=FALSE; } 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; case 'F': if ( strncmp(input, "FRAME_INPUT_DIR", 15) == 0 ) { charPtr = SkipSpacesTabs(&input[15]); if ( strncmp(charPtr, "stdin", 5) == 0 || strncmp(charPtr, "STDIN", 5) == 0 ) { stdinUsed = TRUE; numInputFiles = MAXINT; numInputFileEntries = 1; } strcpy(currentFramePath, charPtr); } else if ( strncmp(input, "FRAME_INPUT", 11) == 0 ) { if ( function == COMBINE_FRAMES ) { ReadInputFileNames(fpointer, "FRAME_END_INPUT"); } } else if ( strncmp(input, "FORCE_I_ALIGN", 13) == 0 ) { forceIalign = TRUE; } else if ( strncmp(input, "FORCE_ENCODE_LAST_FRAME", 23) == 0 ) { forceEncodeLast = TRUE; } else if ( strncmp(input, "FRAME_RATE", 10) == 0 ) { charPtr = SkipSpacesTabs(&input[10]); frameRate = GetFrameRate(charPtr); frameRateRounded = (int) VidRateNum[frameRate]; if ( (frameRate % 3) == 1) { frameRateInteger = FALSE; } optionSeen[OPTION_FRAME_RATE] = TRUE; } break; case 'G': if ( strncmp(input, "GOP_SIZE", 8) == 0 ) { charPtr = SkipSpacesTabs(&input[8]); SetGOPSize(atoi(charPtr)); optionSeen[OPTION_GOP] = TRUE; } else if ( strncmp(input, "GOP_INPUT_DIR", 13) == 0 ) { charPtr = SkipSpacesTabs(&input[13]); if ( strncmp(charPtr, "stdin", 5) == 0 || strncmp(charPtr, "STDIN", 5) == 0 ) { stdinUsed = TRUE; numInputFiles = MAXINT; numInputFileEntries = 1; } strcpy(currentGOPPath, charPtr); } else if ( strncmp(input, "GOP_INPUT", 9) == 0 ) { if ( function == COMBINE_GOPS ) { ReadInputFileNames(fpointer, "GOP_END_INPUT"); } } else if ( strncmp(input, "GAMMA", 5) == 0) { charPtr = SkipSpacesTabs(&input[5]); GammaCorrection = TRUE; sscanf(charPtr,"%f",&GammaValue); optionSeen[OPTION_GAMMA] = TRUE; } break; case 'I': if ( strncmp(input, "IQSCALE", 7) == 0 ) { charPtr = SkipSpacesTabs(&input[7]); SetIQScale(atoi(charPtr)); optionSeen[OPTION_IQSCALE] = TRUE; } else if ( strncmp(input, "INPUT_DIR", 9) == 0 ) { charPtr = SkipSpacesTabs(&input[9]); if ( strncmp(charPtr, "stdin", 5) == 0 || strncmp(charPtr, "STDIN", 5) == 0 ) { stdinUsed = TRUE; numInputFiles = MAXINT; numInputFileEntries = 1; } strcpy(currentPath, charPtr); optionSeen[OPTION_INPUT_DIR] = TRUE; } else if ( strncmp(input, "INPUT_CONVERT", 13) == 0 ) { charPtr = SkipSpacesTabs(&input[13]); strcpy(inputConversion, charPtr); optionSeen[OPTION_INPUT_CONVERT] = TRUE; } else if ( strcmp(input, "INPUT") == 0 ) { /* yes, strcmp */ if ( function == ENCODE_FRAMES ) { ReadInputFileNames(fpointer, "END_INPUT"); optionSeen[OPTION_INPUT] = TRUE; } } else if ( strncmp(input, "IO_SERVER_CONVERT", 17) == 0 ) { charPtr = SkipSpacesTabs(&input[17]); strcpy(ioConversion, charPtr); optionSeen[OPTION_IO_CONVERT] = TRUE; } else if ( strncmp(input, "IQTABLE", 7) == 0 ) { for ( row = 0; row < 8; row ++ ) { if(!fgets(input, 256, fpointer)) return FALSE; 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])) { throw "Line of IQTABLE doesn't have 8 elements!"; } for ( col = 0; col < 8; col ++ ) { if ((qtable[row*8+col]<1) || (qtable[row*8+col]>255)) { fprintf(stderr, "Warning: IQTable Element %1d,%1d (%d) corrected to 1-255.\n", row+1, col+1, qtable[row*8+col]); qtable[row*8+col] = (qtable[row*8+col]<1)?1:255; }} } if ( qtable[0] != 8 ) { fprintf(stderr, "Warning: IQTable Element 1,1 reset to 8, since it must be 8.\n"); qtable[0] = 8; } customQtable = qtable; optionSeen[OPTION_IQTABLE] = TRUE; } else if ( strncmp(input, "INPUT", 5) == 0 ) { /* handle spaces after input */ //log(10.0); charPtr = SkipSpacesTabs(&input[5]); if ( function == ENCODE_FRAMES && *charPtr==0) { ReadInputFileNames(fpointer, "END_INPUT"); optionSeen[OPTION_INPUT] = TRUE; } } break; case 'N': if ( strncmp(input, "NIQTABLE", 8) == 0 ) { for ( row = 0; row < 8; row ++ ) { if(!fgets(input, 256, fpointer)) return FALSE; charPtr = input; if (8!=sscanf(charPtr,"%d %d %d %d %d %d %d %d", &niqtable[row*8+0], &niqtable[row*8+1], &niqtable[row*8+2], &niqtable[row*8+3], &niqtable[row*8+4], &niqtable[row*8+5], &niqtable[row*8+6], &niqtable[row*8+7])) { throw "Line of NIQTABLE doesn't have 8 elements!"; } for ( col = 0; col < 8; col++ ) { if ((niqtable[row*8+col]<1) || (niqtable[row*8+col]>255)) { fprintf(stderr, "Warning: NIQTable Element %1d,%1d (%d) corrected to 1-255.\n", row+1, col+1, niqtable[row*8+col]); niqtable[row*8+col]=(niqtable[row*8+col]<1)?1:255; }} } customNIQtable = niqtable; optionSeen[OPTION_NIQTABLE] = TRUE; } break; case 'O': if ( strncmp(input, "OUTPUT", 6) == 0 ) { charPtr = SkipSpacesTabs(&input[6]); if ( whichGOP == -1 ) { strcpy(outputFileName, charPtr); } else { sprintf(outputFileName, "%s.gop.%d", charPtr, whichGOP); } optionSeen[OPTION_OUTPUT] = TRUE; } break; case 'P': if ( strncmp(input, "PATTERN", 7) == 0 ) { charPtr = SkipSpacesTabs(&input[7]); SetFramePattern(charPtr); optionSeen[OPTION_PATTERN] = TRUE; } else if ( strncmp(input, "PIXEL", 5) == 0 ) { charPtr = SkipSpacesTabs(&input[5]); SetPixelSearch(charPtr); optionSeen[OPTION_PIXEL] = TRUE; } else if ( strncmp(input, "PQSCALE", 7) == 0 ) { charPtr = SkipSpacesTabs(&input[7]); SetPQScale(atoi(charPtr)); optionSeen[OPTION_PQSCALE] = TRUE; } else if ( strncmp(input, "PSEARCH_ALG", 11) == 0 ) { charPtr = SkipSpacesTabs(&input[11]); SetPSearchAlg(charPtr); optionSeen[OPTION_PSEARCH_ALG] = TRUE; } else if ( strncmp(input, "PARALLEL_TEST_FRAMES", 20) == 0 ) { SetParallelPerfect(FALSE); charPtr = SkipSpacesTabs(&input[20]); parallelTestFrames = atoi(charPtr); } else if ( strncmp(input, "PARALLEL_TIME_CHUNKS", 20) == 0 ) { SetParallelPerfect(FALSE); charPtr = SkipSpacesTabs(&input[20]); parallelTimeChunks = atoi(charPtr); } else if ( strncmp(input, "PARALLEL_CHUNK_TAPER", 20) == 0 ) { SetParallelPerfect(FALSE); parallelTimeChunks = -1; } else if ( strncmp(input, "PARALLEL_PERFECT", 16) == 0 ) { SetParallelPerfect(TRUE); } else if ( strncmp(input, "PARALLEL", 8) == 0 ) { ReadMachineNames(fpointer); optionSeen[OPTION_PARALLEL] = TRUE; } break; case 'R': if ( strncmp(input, "RANGE", 5) == 0 ) { int num_ranges=0,a,b; charPtr = SkipSpacesTabs(&input[5]); optionSeen[OPTION_RANGE] = TRUE; num_ranges=sscanf(charPtr,"%d %d",&a,&b); if (num_ranges==2) { SetSearchRange(a,b); } else if (sscanf(charPtr,"%d [%d]",&a,&b)==2) { SetSearchRange(a,b); } else SetSearchRange(a,a); } else if ( strncmp(input, "REFERENCE_FRAME", 15) == 0 ) { charPtr = SkipSpacesTabs(&input[15]); SetReferenceFrameType(charPtr); optionSeen[OPTION_REF_FRAME] = TRUE; } else if ( strncmp(input, "RSH", 3) == 0 ) { charPtr = SkipSpacesTabs(&input[3]); SetRemoteShell(charPtr); } else if ( strncmp(input, "RESIZE", 6) == 0 ) { charPtr = SkipSpacesTabs(&input[6]); sscanf(charPtr, "%dx%d", &outputWidth, &outputHeight); outputWidth &= ~(DCTSIZE * 2 - 1); outputHeight &= ~(DCTSIZE * 2 - 1); optionSeen[OPTION_RESIZE] = TRUE; } break; case 'S': if ( strncmp(input, "SLICES_PER_FRAME", 16) == 0 ) { charPtr = SkipSpacesTabs(&input[16]); SetSlicesPerFrame(atoi(charPtr)); optionSeen[OPTION_SPF] = TRUE; } else if ( strncmp(input, "SLAVE_CONVERT", 13) == 0 ) { charPtr = SkipSpacesTabs(&input[13]); strcpy(slaveConversion, charPtr); optionSeen[OPTION_SLAVE_CONVERT] = TRUE; } else if ( strncmp(input, "SPECIFICS_FILE", 14) == 0 ) { charPtr = SkipSpacesTabs(&input[14]); strcpy(specificsFile, charPtr); specificsOn=TRUE; optionSeen[OPTION_SPECIFICS] = TRUE; } else if ( strncmp(input, "SPECIFICS_DEFINES", 16) == 0 ) { charPtr = SkipSpacesTabs(&input[17]); strcpy(specificsDefines, charPtr); optionSeen[OPTION_DEFS_SPECIFICS] = TRUE; } else if (strncmp(input, "SEQUENCE_SIZE", 13) == 0) { charPtr = SkipSpacesTabs(&input[13]); mult_seq_headers = atoi(charPtr); } else if (strncmp(input, "SIZE", 4) == 0 ) { charPtr = SkipSpacesTabs(&input[4]); sscanf(charPtr, "%dx%d", &yuvWidth, &yuvHeight); realWidth = yuvWidth; realHeight = yuvHeight; Fsize_Validate(&yuvWidth, &yuvHeight); optionSeen[OPTION_YUV_SIZE] = TRUE; } break; case 'T': if ( strncmp(input, "TUNE", 4) == 0) { tuneingOn = TRUE; charPtr = SkipSpacesTabs(&input[4]); ParseTuneParam(charPtr); } break; case 'U': if ( strncmp(input, "USER_DATA", 9) == 0 ) { charPtr = SkipSpacesTabs(&input[9]); strcpy((char*)userDataFileName, charPtr); optionSeen[OPTION_USER_DATA] = TRUE; } break; case 'Y': if (strncmp(input, "YUV_SIZE", 8) == 0 ) { charPtr = SkipSpacesTabs(&input[8]); sscanf(charPtr, "%dx%d", &yuvWidth, &yuvHeight); realWidth = yuvWidth; realHeight = yuvHeight; Fsize_Validate(&yuvWidth, &yuvHeight); optionSeen[OPTION_YUV_SIZE] = TRUE; } else if (strncmp(input, "Y_SIZE", 6) == 0 ) { charPtr = SkipSpacesTabs(&input[6]); sscanf(charPtr, "%dx%d", &yuvWidth, &yuvHeight); realWidth = yuvWidth; realHeight = yuvHeight; Fsize_Validate(&yuvWidth, &yuvHeight); optionSeen[OPTION_YUV_SIZE] = TRUE; } else if ( strncmp(input, "YUV_FORMAT", 10) == 0 ) { charPtr = SkipSpacesTabs(&input[10]); strcpy(yuvConversion, charPtr); optionSeen[OPTION_YUV_FORMAT] = TRUE; } break; } } fclose(fpointer); for ( index = FIRST_OPTION; index <= LAST_OPTION; index++ ) { if ( ! optionSeen[index] ) { /* INPUT unnecessary when stdin is used */ if ((index == OPTION_INPUT) && stdinUsed) { continue; } throw "Missing option"; } } /* error checking */ if ( yuvUsed ) { if (! optionSeen[OPTION_YUV_SIZE]) { throw "YUV format used but YUV_SIZE not given"; } if (! optionSeen[OPTION_YUV_FORMAT]) { strcpy (yuvConversion, "EYUV"); fprintf(stderr, "WARNING: YUV format not specified; defaulting to Berkeley YUV (EYUV)\n\n"); } } if ( stdinUsed && optionSeen[OPTION_PARALLEL] ) { throw "stdin reading for parallel execution not enabled yet"; } if ( optionSeen[OPTION_PARALLEL] && !optionSeen[OPTION_YUV_SIZE]) { throw "Specify SIZE WxH for parallel encoding"; } if ( optionSeen[OPTION_IO_CONVERT] != optionSeen[OPTION_SLAVE_CONVERT] ) { throw "must have either both IO_SERVER_CONVERT and SLAVE_CONVERT or neither"; } if ( optionSeen[OPTION_DEFS_SPECIFICS] && !optionSeen[OPTION_SPECIFICS]) { throw "does not make sense to define Specifics file options, but no specifics file"; } SetIOConvert(optionSeen[OPTION_IO_CONVERT]); SetResize(optionSeen[OPTION_RESIZE]); if ( function == ENCODE_FRAMES ) { SetFCode(); if ( psearchAlg == PSEARCH_TWOLEVEL ) SetPixelSearch((char*)"HALF"); } return TRUE; }