etlegacy-libs/jpegturbo/cdjpeg.h

146 lines
5 KiB
C
Raw Normal View History

2014-11-21 20:32:31 +00:00
/*
* cdjpeg.h
*
2015-01-24 20:09:39 +00:00
* This file was part of the Independent JPEG Group's software:
2014-11-21 20:32:31 +00:00
* Copyright (C) 1994-1997, Thomas G. Lane.
2015-01-24 20:09:39 +00:00
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
2017-07-01 14:55:13 +00:00
* For conditions of distribution and use, see the accompanying README.ijg
* file.
2014-11-21 20:32:31 +00:00
*
* This file contains common declarations for the sample applications
* cjpeg and djpeg. It is NOT used by the core JPEG library.
*/
2015-01-24 20:09:39 +00:00
#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
2014-11-21 20:32:31 +00:00
#include "jinclude.h"
#include "jpeglib.h"
2015-01-24 20:09:39 +00:00
#include "jerror.h" /* get library error codes too */
#include "cderror.h" /* get application-specific error codes */
2014-11-21 20:32:31 +00:00
/*
* Object interface for cjpeg's source file decoding modules
*/
2017-07-01 14:55:13 +00:00
typedef struct cjpeg_source_struct *cjpeg_source_ptr;
2014-11-21 20:32:31 +00:00
struct cjpeg_source_struct {
2015-01-24 20:09:39 +00:00
void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
void (*finish_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
2014-11-21 20:32:31 +00:00
FILE *input_file;
JSAMPARRAY buffer;
JDIMENSION buffer_height;
};
/*
* Object interface for djpeg's output file encoding modules
*/
2017-07-01 14:55:13 +00:00
typedef struct djpeg_dest_struct *djpeg_dest_ptr;
2014-11-21 20:32:31 +00:00
struct djpeg_dest_struct {
/* start_output is called after jpeg_start_decompress finishes.
* The color map will be ready at this time, if one is needed.
*/
2015-01-24 20:09:39 +00:00
void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
2014-11-21 20:32:31 +00:00
/* Emit the specified number of pixel rows from the buffer. */
2015-01-24 20:09:39 +00:00
void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
JDIMENSION rows_supplied);
2014-11-21 20:32:31 +00:00
/* Finish up at the end of the image. */
2015-01-24 20:09:39 +00:00
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
2014-11-21 20:32:31 +00:00
/* Target file spec; filled in by djpeg.c after object is created. */
2017-07-01 14:55:13 +00:00
FILE *output_file;
2014-11-21 20:32:31 +00:00
/* Output pixel-row buffer. Created by module init or start_output.
* Width is cinfo->output_width * cinfo->output_components;
* height is buffer_height.
*/
JSAMPARRAY buffer;
JDIMENSION buffer_height;
};
/*
* cjpeg/djpeg may need to perform extra passes to convert to or from
* the source/destination file format. The JPEG library does not know
* about these passes, but we'd like them to be counted by the progress
* monitor. We use an expanded progress monitor object to hold the
* additional pass count.
*/
struct cdjpeg_progress_mgr {
2015-01-24 20:09:39 +00:00
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
int completed_extra_passes; /* extra passes completed */
int total_extra_passes; /* total extra */
2014-11-21 20:32:31 +00:00
/* last printed percentage stored here to avoid multiple printouts */
int percent_done;
};
2017-07-01 14:55:13 +00:00
typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
2014-11-21 20:32:31 +00:00
/* Module selection routines for I/O modules. */
2015-01-24 20:09:39 +00:00
EXTERN(cjpeg_source_ptr) jinit_read_bmp (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_bmp (j_decompress_ptr cinfo,
boolean is_os2);
EXTERN(cjpeg_source_ptr) jinit_read_gif (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_gif (j_decompress_ptr cinfo);
EXTERN(cjpeg_source_ptr) jinit_read_ppm (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_ppm (j_decompress_ptr cinfo);
EXTERN(cjpeg_source_ptr) jinit_read_rle (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_rle (j_decompress_ptr cinfo);
EXTERN(cjpeg_source_ptr) jinit_read_targa (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_targa (j_decompress_ptr cinfo);
2014-11-21 20:32:31 +00:00
/* cjpeg support routines (in rdswitch.c) */
2017-07-01 14:55:13 +00:00
EXTERN(boolean) read_quant_tables (j_compress_ptr cinfo, char *filename,
2015-01-24 20:09:39 +00:00
boolean force_baseline);
2017-07-01 14:55:13 +00:00
EXTERN(boolean) read_scan_script (j_compress_ptr cinfo, char *filename);
2015-01-24 20:09:39 +00:00
EXTERN(boolean) set_quality_ratings (j_compress_ptr cinfo, char *arg,
boolean force_baseline);
EXTERN(boolean) set_quant_slots (j_compress_ptr cinfo, char *arg);
EXTERN(boolean) set_sample_factors (j_compress_ptr cinfo, char *arg);
2014-11-21 20:32:31 +00:00
/* djpeg support routines (in rdcolmap.c) */
2017-07-01 14:55:13 +00:00
EXTERN(void) read_color_map (j_decompress_ptr cinfo, FILE *infile);
2014-11-21 20:32:31 +00:00
/* common support routines (in cdjpeg.c) */
2015-01-24 20:09:39 +00:00
EXTERN(void) enable_signal_catcher (j_common_ptr cinfo);
EXTERN(void) start_progress_monitor (j_common_ptr cinfo,
cd_progress_ptr progress);
EXTERN(void) end_progress_monitor (j_common_ptr cinfo);
2017-07-01 14:55:13 +00:00
EXTERN(boolean) keymatch (char *arg, const char *keyword, int minchars);
2015-01-24 20:09:39 +00:00
EXTERN(FILE *) read_stdin (void);
EXTERN(FILE *) write_stdout (void);
2014-11-21 20:32:31 +00:00
/* miscellaneous useful macros */
2015-01-24 20:09:39 +00:00
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
#define READ_BINARY "r"
#define WRITE_BINARY "w"
2014-11-21 20:32:31 +00:00
#else
2015-01-24 20:09:39 +00:00
#define READ_BINARY "rb"
#define WRITE_BINARY "wb"
2014-11-21 20:32:31 +00:00
#endif
2015-01-24 20:09:39 +00:00
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
2014-11-21 20:32:31 +00:00
#define EXIT_FAILURE 1
#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_WARNING
#define EXIT_WARNING 2
#endif