Пример #1
0
void SearchEdge() {
	int x = 0;
	int z = 0;
	int tmp;
	int tmp1, tmp2;
	int LorR = 0;
	int buffer[160];
	int F_continueSearch[2] = { 1, 1 };
	int F_maybeCrossRoad[2] = { 0, 0 };
	int F_reborn = 0;

	uchar buffer_startLine[80][2];
	int n_startLine = 1;
	int C_startLine = 0;
	int startLineX[2];

	Pr_SelectFIFO = ~Pr_SelectFIFO;
	al422b_SelectFIFO(Pr_SelectFIFO);
	al422b_Reset();

	// initial parameters --->>>
	F_startLine = 0;

	edgeStartZ[left] = 0;
	edgeStartZ[right] = 0;

	C_activePoint[left] = 0;
	C_activePoint[right] = 0;

	searchRange[right].start = rightSearchRange;
	searchRange[right].end = midSearchRange;
	searchRange[left].start = midSearchRange;
	searchRange[left].end = leftSearchRange;

	SkipLines(skipLines-1);

	SkipPixels(40);
	for (x = 0; x < 80; x++)
		buffer_startLine[x][0] = ReadPixel();
	SkipPixels(40);

	for (z = 0; z < 30; z++) {

		if(z<8)
		{
			SkipLines(((29 - z) / skiplineControl) - 1);
			//ÆðÅÜÏßËÑË÷
			startLineX[left] = 79;
			startLineX[right] = 0;

			tmp1 = n_startLine % 2;
			tmp2 = (n_startLine - 1) % 2;

			SkipPixels(40);
			for(x=0;x<80;x++)buffer_startLine[x][tmp1] = ReadPixel();
			SkipPixels(40);

			C_startLine = 0;
			for(x=0;x<50;x++)
			{

				if((ABS(buffer_startLine[x][tmp1] - buffer_startLine[x][tmp2])) > (thresholdEdge+10))
				{
					C_startLine ++;
				}
				else
				{
					if(C_startLine>5)
					{
						startLineX[right] = x;
						break;
					}
					else C_startLine = 0;
				}
			}
			
			C_startLine = 0;
			for(x=79;x>50;x--)
			{
				if((ABS(buffer_startLine[x][tmp1] - buffer_startLine[x][tmp2])) > (thresholdEdge+10))
				{
					C_startLine ++;
				}
				else
				{
					
					if(C_startLine>5)
					{
						startLineX[left] = x;
						break;
					}
					else C_startLine = 0;
				}

			}

			if((ABS(startLineX[left] - startLineX[right])) < (50))
					F_startLine = 1;
			
			n_startLine ++;
		}
		else
		{
			SkipLines((29 - z) / skiplineControl);
		}

		if(searchRange[right].end > searchRange[left].start)
		{
			searchRange[left].start = (searchRange[right].end + searchRange[left].start) / 2;
			searchRange[right].end = searchRange[left].start;
		}

		tmp = searchRange[right].start;
		SkipPixels(tmp);
		for(x=searchRange[right].start;x<searchRange[right].end;x++)buffer[x] = ReadPixel();
		tmp = searchRange[left].start - searchRange[right].end;
		SkipPixels(tmp);
		for(x=searchRange[left].start;x<searchRange[left].end;x++)buffer[x] = ReadPixel();
		tmp = 160 - searchRange[left].end;
		SkipPixels(tmp);

		//right
		LorR = right;
		if(F_continueSearch[LorR] == 1)
		{
			F_continueSearch[LorR] = 0;
			for(x=(searchRange[LorR].end-1-2);x>=searchRange[LorR].start;x--)
			{
				if(Gradient(buffer[x+2] ,buffer[x]) > thresholdEdge)
				{
					if(F_reborn == 1)
					edgeStartZ[LorR] = 10;
					else
					{
						if(z>1)//ÅжÏÕÛ½Ç
						{
							if((ABS((x - edgePoint[LorR][z-1].x) - (edgePoint[LorR][z-1].x - edgePoint[LorR][z-2].x)))> 5)
							{
								break;
							}
						}
					}
					edgePoint[LorR][z].x = x;
					edgePoint[LorR][z].z = z;
					SetSearchRange(LorR, x, defaultRange);
					F_continueSearch[LorR] = 1;
					C_activePoint[LorR] ++;

					break;
				}
			}
		}

		//left
		LorR = left;
		if(F_continueSearch[LorR] == 1)
		{
			F_continueSearch[LorR] = 0;
			for(x=searchRange[LorR].start+2;x<searchRange[LorR].end;x++)
			{
				if(Gradient(buffer[x-2] ,buffer[x]) > thresholdEdge)
				{
					if(F_reborn == 1)
					edgeStartZ[LorR] = 10;
					else
					{
						if(z>1)//ÅжÏÕÛ½Ç
						{
							if((ABS((x - edgePoint[LorR][z-1].x) - (edgePoint[LorR][z-1].x - edgePoint[LorR][z-2].x)))> 5)
							{
								break;
							}
						}
					}
					edgePoint[LorR][z].x = x;
					edgePoint[LorR][z].z = z;
					SetSearchRange(LorR, x, defaultRange);
					F_continueSearch[LorR] = 1;
					C_activePoint[LorR] ++;
					break;
				}
			}
		}

		switch(z)
		{
			case 2://Í·Á½Ðж¼Ã»ÓÐ×¥µ½±ßÑصÄÇé¿ö Åж¨
			if((C_activePoint[left] + C_activePoint[right]) < 3)
			F_reborn = 1;
			break;

			case 9://¡°¸´»î°É,ÎÒµÄÓÂÊ¿¡±
			if(F_reborn == 1)
			{
				F_continueSearch[left] = 1;
				F_continueSearch[right] = 1;

				C_activePoint[left] = 0;
				C_activePoint[right] = 0;

				searchRange[right].start = 30;
				searchRange[right].end = 79;
				searchRange[left].start = 79;
				searchRange[left].end = 130;

			}
			break;

			case 10:
			if((C_activePoint[left]+ C_activePoint[right]) < 2)goto myEnd;
			break;
		}

	}

	myEnd:

	if ((C_activePoint[left] + C_activePoint[right]) < 8) {
		F_crossRoad = 1;
	}
	if ((C_activePoint[left] + C_activePoint[right]) > 20) {
		F_crossRoad = 0;
	}
	for (LorR = 0; LorR < 2; LorR++) {
		if(C_activePoint[LorR] == 0)C_activePoint[LorR] = 1;
		crctr_BTX[LorR].tail = edgePoint[LorR][(C_activePoint[LorR]-1) + edgeStartZ[LorR]];
		crctr_BTX[LorR].head = edgePoint[LorR][edgeStartZ[LorR]];
		crctr_BTX[LorR].inflection = GetInflectionPoint(LorR);

		crctr_BTX[LorR].k_hi =KPP(crctr_BTX[LorR].inflection,crctr_BTX[LorR].head);
		crctr_BTX[LorR].k_it =KPP(crctr_BTX[LorR].tail,crctr_BTX[LorR].inflection);
		crctr_BTX[LorR].k_ht =KPP(crctr_BTX[LorR].tail,crctr_BTX[LorR].head);

		crctr_BTX[LorR].R_hit = crctr_BTX[LorR].k_it- crctr_BTX[LorR].k_hi;
	}

}
Пример #2
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;
}