kusano 7d535a
/*
kusano 7d535a
 * cdjpeg.h
kusano 7d535a
 *
kusano 7d535a
 * Copyright (C) 1994-1997, Thomas G. Lane.
kusano 7d535a
 * This file is part of the Independent JPEG Group's software.
kusano 7d535a
 * For conditions of distribution and use, see the accompanying README file.
kusano 7d535a
 *
kusano 7d535a
 * This file contains common declarations for the sample applications
kusano 7d535a
 * cjpeg and djpeg.  It is NOT used by the core JPEG library.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#define JPEG_CJPEG_DJPEG	/* define proper options in jconfig.h */
kusano 7d535a
#define JPEG_INTERNAL_OPTIONS	/* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
kusano 7d535a
#include "jinclude.h"
kusano 7d535a
#include "jpeglib.h"
kusano 7d535a
#include "jerror.h"		/* get library error codes too */
kusano 7d535a
#include "cderror.h"		/* get application-specific error codes */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Object interface for cjpeg's source file decoding modules
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
typedef struct cjpeg_source_struct * cjpeg_source_ptr;
kusano 7d535a
kusano 7d535a
struct cjpeg_source_struct {
kusano 7d535a
  JMETHOD(void, start_input, (j_compress_ptr cinfo,
kusano 7d535a
			      cjpeg_source_ptr sinfo));
kusano 7d535a
  JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
kusano 7d535a
				       cjpeg_source_ptr sinfo));
kusano 7d535a
  JMETHOD(void, finish_input, (j_compress_ptr cinfo,
kusano 7d535a
			       cjpeg_source_ptr sinfo));
kusano 7d535a
kusano 7d535a
  FILE *input_file;
kusano 7d535a
kusano 7d535a
  JSAMPARRAY buffer;
kusano 7d535a
  JDIMENSION buffer_height;
kusano 7d535a
};
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Object interface for djpeg's output file encoding modules
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
typedef struct djpeg_dest_struct * djpeg_dest_ptr;
kusano 7d535a
kusano 7d535a
struct djpeg_dest_struct {
kusano 7d535a
  /* start_output is called after jpeg_start_decompress finishes.
kusano 7d535a
   * The color map will be ready at this time, if one is needed.
kusano 7d535a
   */
kusano 7d535a
  JMETHOD(void, start_output, (j_decompress_ptr cinfo,
kusano 7d535a
			       djpeg_dest_ptr dinfo));
kusano 7d535a
  /* Emit the specified number of pixel rows from the buffer. */
kusano 7d535a
  JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo,
kusano 7d535a
				 djpeg_dest_ptr dinfo,
kusano 7d535a
				 JDIMENSION rows_supplied));
kusano 7d535a
  /* Finish up at the end of the image. */
kusano 7d535a
  JMETHOD(void, finish_output, (j_decompress_ptr cinfo,
kusano 7d535a
				djpeg_dest_ptr dinfo));
kusano 7d535a
kusano 7d535a
  /* Target file spec; filled in by djpeg.c after object is created. */
kusano 7d535a
  FILE * output_file;
kusano 7d535a
kusano 7d535a
  /* Output pixel-row buffer.  Created by module init or start_output.
kusano 7d535a
   * Width is cinfo->output_width * cinfo->output_components;
kusano 7d535a
   * height is buffer_height.
kusano 7d535a
   */
kusano 7d535a
  JSAMPARRAY buffer;
kusano 7d535a
  JDIMENSION buffer_height;
kusano 7d535a
};
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * cjpeg/djpeg may need to perform extra passes to convert to or from
kusano 7d535a
 * the source/destination file format.  The JPEG library does not know
kusano 7d535a
 * about these passes, but we'd like them to be counted by the progress
kusano 7d535a
 * monitor.  We use an expanded progress monitor object to hold the
kusano 7d535a
 * additional pass count.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
struct cdjpeg_progress_mgr {
kusano 7d535a
  struct jpeg_progress_mgr pub;	/* fields known to JPEG library */
kusano 7d535a
  int completed_extra_passes;	/* extra passes completed */
kusano 7d535a
  int total_extra_passes;	/* total extra */
kusano 7d535a
  /* last printed percentage stored here to avoid multiple printouts */
kusano 7d535a
  int percent_done;
kusano 7d535a
};
kusano 7d535a
kusano 7d535a
typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Short forms of external names for systems with brain-damaged linkers. */
kusano 7d535a
kusano 7d535a
#ifdef NEED_SHORT_EXTERNAL_NAMES
kusano 7d535a
#define jinit_read_bmp		jIRdBMP
kusano 7d535a
#define jinit_write_bmp		jIWrBMP
kusano 7d535a
#define jinit_read_gif		jIRdGIF
kusano 7d535a
#define jinit_write_gif		jIWrGIF
kusano 7d535a
#define jinit_read_ppm		jIRdPPM
kusano 7d535a
#define jinit_write_ppm		jIWrPPM
kusano 7d535a
#define jinit_read_rle		jIRdRLE
kusano 7d535a
#define jinit_write_rle		jIWrRLE
kusano 7d535a
#define jinit_read_targa	jIRdTarga
kusano 7d535a
#define jinit_write_targa	jIWrTarga
kusano 7d535a
#define read_quant_tables	RdQTables
kusano 7d535a
#define read_scan_script	RdScnScript
kusano 7d535a
#define set_quality_ratings     SetQRates
kusano 7d535a
#define set_quant_slots		SetQSlots
kusano 7d535a
#define set_sample_factors	SetSFacts
kusano 7d535a
#define read_color_map		RdCMap
kusano 7d535a
#define enable_signal_catcher	EnSigCatcher
kusano 7d535a
#define start_progress_monitor	StProgMon
kusano 7d535a
#define end_progress_monitor	EnProgMon
kusano 7d535a
#define read_stdin		RdStdin
kusano 7d535a
#define write_stdout		WrStdout
kusano 7d535a
#endif /* NEED_SHORT_EXTERNAL_NAMES */
kusano 7d535a
kusano 7d535a
/* Module selection routines for I/O modules. */
kusano 7d535a
kusano 7d535a
EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
kusano 7d535a
EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
kusano 7d535a
					    boolean is_os2));
kusano 7d535a
EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
kusano 7d535a
EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
kusano 7d535a
EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
kusano 7d535a
EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
kusano 7d535a
EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
kusano 7d535a
EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
kusano 7d535a
EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
kusano 7d535a
EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
kusano 7d535a
kusano 7d535a
/* cjpeg support routines (in rdswitch.c) */
kusano 7d535a
kusano 7d535a
EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
kusano 7d535a
				       boolean force_baseline));
kusano 7d535a
EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
kusano 7d535a
EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg,
kusano 7d535a
					 boolean force_baseline));
kusano 7d535a
EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
kusano 7d535a
EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
kusano 7d535a
kusano 7d535a
/* djpeg support routines (in rdcolmap.c) */
kusano 7d535a
kusano 7d535a
EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
kusano 7d535a
kusano 7d535a
/* common support routines (in cdjpeg.c) */
kusano 7d535a
kusano 7d535a
EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
kusano 7d535a
EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
kusano 7d535a
					 cd_progress_ptr progress));
kusano 7d535a
EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
kusano 7d535a
EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
kusano 7d535a
EXTERN(FILE *) read_stdin JPP((void));
kusano 7d535a
EXTERN(FILE *) write_stdout JPP((void));
kusano 7d535a
kusano 7d535a
/* miscellaneous useful macros */
kusano 7d535a
kusano 7d535a
#ifdef DONT_USE_B_MODE		/* define mode parameters for fopen() */
kusano 7d535a
#define READ_BINARY	"r"
kusano 7d535a
#define WRITE_BINARY	"w"
kusano 7d535a
#else
kusano 7d535a
#ifdef VMS			/* VMS is very nonstandard */
kusano 7d535a
#define READ_BINARY	"rb", "ctx=stm"
kusano 7d535a
#define WRITE_BINARY	"wb", "ctx=stm"
kusano 7d535a
#else				/* standard ANSI-compliant case */
kusano 7d535a
#define READ_BINARY	"rb"
kusano 7d535a
#define WRITE_BINARY	"wb"
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifndef EXIT_FAILURE		/* define exit() codes if not provided */
kusano 7d535a
#define EXIT_FAILURE  1
kusano 7d535a
#endif
kusano 7d535a
#ifndef EXIT_SUCCESS
kusano 7d535a
#ifdef VMS
kusano 7d535a
#define EXIT_SUCCESS  1		/* VMS is very nonstandard */
kusano 7d535a
#else
kusano 7d535a
#define EXIT_SUCCESS  0
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
#ifndef EXIT_WARNING
kusano 7d535a
#ifdef VMS
kusano 7d535a
#define EXIT_WARNING  1		/* VMS is very nonstandard */
kusano 7d535a
#else
kusano 7d535a
#define EXIT_WARNING  2
kusano 7d535a
#endif
kusano 7d535a
#endif