⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 djpeg.c

📁 These are all the utilities you need to generate MPEG-I movies on a UNIX box with full motion video
💻 C
📖 第 1 页 / 共 2 页
字号:
      /* GIF output format. */      requested_fmt = FMT_GIF;    } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {      /* Force monochrome output. */      cinfo->out_color_space = JCS_GRAYSCALE;    } else if (keymatch(arg, "maxmemory", 1)) {      /* Maximum memory in Kb (or Mb with 'm'). */      long lval;      char ch = 'x';      if (++argn >= argc)	/* advance to next argument */	usage();      if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)	usage();      if (ch == 'm' || ch == 'M')	lval *= 1000L;      cinfo->mem->max_memory_to_use = lval * 1000L;    } else if (keymatch(arg, "nodither", 3)) {      /* Suppress dithering in color quantization. */      cinfo->use_dithering = FALSE;    } else if (keymatch(arg, "nosmooth", 3)) {      /* Suppress fancy upsampling */      cinfo->do_fancy_upsampling = FALSE;    } else if (keymatch(arg, "onepass", 1)) {      /* Use fast one-pass quantization. */      cinfo->two_pass_quantize = FALSE;    } else if (keymatch(arg, "outfile", 3)) {      /* Set output file name. */      if (++argn >= argc)	/* advance to next argument */	usage();      outfilename = argv[argn];	/* save it away for later use */    } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {      /* PPM/PGM output format. */      requested_fmt = FMT_PPM;    } else if (keymatch(arg, "rle", 1)) {      /* RLE output format. */      requested_fmt = FMT_RLE;    } else if (keymatch(arg, "targa", 1)) {      /* Targa output format. */      requested_fmt = FMT_TARGA;    } else if (keymatch(arg, "raw", 1)) {      /* raw output format. */      requested_fmt = FMT_RAW;    } else {      usage();			/* bogus switch */    }  }  return argn;			/* return index of next arg (file name) */}/* * The main program. */GLOBAL intmain (int argc, char **argv){  struct jpeg_decompress_struct cinfo;  struct jpeg_error_mgr jerr;  int file_index;  djpeg_dest_ptr dest_mgr = NULL;  FILE * input_file;  FILE * output_file;  JDIMENSION num_scanlines;  /* On Mac, fetch a command line. */#ifdef THINK_C  argc = ccommand(&argv);#endif  progname = argv[0];  /* Initialize the JPEG decompression object with default error handling. */  cinfo.err = jpeg_std_error(&jerr);  jpeg_create_decompress(&cinfo);  /* Add some application-specific error messages (from cderror.h) */  jerr.addon_message_table = addon_message_table;  jerr.first_addon_message = JMSG_FIRSTADDONCODE;  jerr.last_addon_message = JMSG_LASTADDONCODE;  /* Now safe to enable signal catcher. */#ifdef NEED_SIGNAL_CATCHER  sig_cinfo = (j_common_ptr) cinfo;  signal(SIGINT, signal_catcher);#ifdef SIGTERM			/* not all systems have SIGTERM */  signal(SIGTERM, signal_catcher);#endif#endif  /* Scan command line to find file names. */  /* It is convenient to use just one switch-parsing routine, but the switch   * values read here are ignored; we will rescan the switches after opening   * the input file.   */  file_index = parse_switches(&cinfo, 0, argc, argv);#ifdef TWO_FILE_COMMANDLINE  /* Must have either -outfile switch or explicit output file name */  if (outfilename == NULL) {    if (file_index != argc-2) {      fprintf(stderr, "%s: must name one input and one output file\n",	      progname);      usage();    }    outfilename = argv[file_index+1];  } else {    if (file_index != argc-1) {      fprintf(stderr, "%s: must name one input and one output file\n",	      progname);      usage();    }  }#else  /* Unix style: expect zero or one file name */  if (file_index < argc-1) {    fprintf(stderr, "%s: only one input file\n", progname);    usage();  }#endif /* TWO_FILE_COMMANDLINE */  /* Open the input file. */  if (file_index < argc) {    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);      exit(EXIT_FAILURE);    }  } else {    /* default input file is stdin */#ifdef USE_SETMODE		/* need to hack file mode? */    setmode(fileno(stdin), O_BINARY);#endif#ifdef USE_FDOPEN		/* need to re-open in binary mode? */    if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open stdin\n", progname);      exit(EXIT_FAILURE);    }#else    input_file = stdin;#endif  }  /* Open the output file. */  if (outfilename != NULL) {    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s\n", progname, outfilename);      exit(EXIT_FAILURE);    }  } else {    /* default output file is stdout */#ifdef USE_SETMODE		/* need to hack file mode? */    setmode(fileno(stdout), O_BINARY);#endif#ifdef USE_FDOPEN		/* need to re-open in binary mode? */    if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open stdout\n", progname);      exit(EXIT_FAILURE);    }#else    output_file = stdout;#endif  }#ifdef PROGRESS_REPORT  /* Enable progress display, unless trace output is on */  if (jerr.trace_level == 0)    dc_methods.progress_monitor = progress_monitor;#endif  /* Specify data source for decompression */  jpeg_stdio_src(&cinfo, input_file);  /* Read file header, set default decompression parameters */  (void) jpeg_read_header(&cinfo, TRUE);  /* Adjust default decompression parameters by re-parsing the options */  file_index = parse_switches(&cinfo, 0, argc, argv);  /* Initialize the output module now to let it override any crucial   * option settings (for instance, GIF wants to force color quantization).   */  switch (requested_fmt) {#ifdef GIF_SUPPORTED  case FMT_GIF:    dest_mgr = jinit_write_gif(&cinfo);    break;#endif#ifdef PPM_SUPPORTED  case FMT_PPM:    dest_mgr = jinit_write_ppm(&cinfo);    break;#endif#ifdef RAW_SUPPORTED  case FMT_RAW:    dest_mgr = jinit_write_raw(&cinfo);    break;#endif#ifdef RLE_SUPPORTED  case FMT_RLE:    dest_mgr = jinit_write_rle(&cinfo);    break;#endif#ifdef TARGA_SUPPORTED  case FMT_TARGA:    dest_mgr = jinit_write_targa(&cinfo);    break;#endif  default:    ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);    break;  }  dest_mgr->output_file = output_file;  /* Start decompressor */  jpeg_start_decompress(&cinfo);  /* Write output file header */  (*dest_mgr->start_output) (&cinfo, dest_mgr);  /* Process data */  while (cinfo.output_scanline < cinfo.output_height) {   if(!cinfo.want_raw_output ){    num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,					dest_mgr->buffer_height);  }else{    num_scanlines = jpeg_read_raw_scanlines(&cinfo, dest_mgr->image_buffer,                                        dest_mgr->buffer_height);  }    (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);  }  /* Finish decompression and release memory */  (*dest_mgr->finish_output) (&cinfo, dest_mgr);  jpeg_finish_decompress(&cinfo);  jpeg_destroy_decompress(&cinfo);#ifdef PROGRESS_REPORT  /* Clear away progress display */  if (jerr.trace_level == 0) {    fprintf(stderr, "\r                \r");    fflush(stderr);  }#endif  /* All done. */  exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);  return 0;			/* suppress no-return-value warnings */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -