cdjpeg.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * cdjpeg.h
  3. *
  4. * Copyright (C) 1994-1997, Thomas G. Lane.
  5. * This file is part of the Independent JPEG Group's software.
  6. * For conditions of distribution and use, see the accompanying README file.
  7. *
  8. * This file contains common declarations for the sample applications
  9. * cjpeg and djpeg. It is NOT used by the core JPEG library.
  10. */
  11. #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
  12. #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
  13. #include "jinclude.h"
  14. #include "jpeglib.h"
  15. #include "jerror.h" /* get library error codes too */
  16. #include "cderror.h" /* get application-specific error codes */
  17. /*
  18. * Object interface for cjpeg's source file decoding modules
  19. */
  20. typedef struct cjpeg_source_struct * cjpeg_source_ptr;
  21. struct cjpeg_source_struct {
  22. JMETHOD(void, start_input, (j_compress_ptr cinfo,
  23. cjpeg_source_ptr sinfo));
  24. JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
  25. cjpeg_source_ptr sinfo));
  26. JMETHOD(void, finish_input, (j_compress_ptr cinfo,
  27. cjpeg_source_ptr sinfo));
  28. FILE *input_file;
  29. JSAMPARRAY buffer;
  30. JDIMENSION buffer_height;
  31. };
  32. /*
  33. * Object interface for djpeg's output file encoding modules
  34. */
  35. typedef struct djpeg_dest_struct * djpeg_dest_ptr;
  36. struct djpeg_dest_struct {
  37. /* start_output is called after jpeg_start_decompress finishes.
  38. * The color map will be ready at this time, if one is needed.
  39. */
  40. JMETHOD(void, start_output, (j_decompress_ptr cinfo,
  41. djpeg_dest_ptr dinfo));
  42. /* Emit the specified number of pixel rows from the buffer. */
  43. JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo,
  44. djpeg_dest_ptr dinfo,
  45. JDIMENSION rows_supplied));
  46. /* Finish up at the end of the image. */
  47. JMETHOD(void, finish_output, (j_decompress_ptr cinfo,
  48. djpeg_dest_ptr dinfo));
  49. /* Target file spec; filled in by djpeg.c after object is created. */
  50. FILE * output_file;
  51. /* Output pixel-row buffer. Created by module init or start_output.
  52. * Width is cinfo->output_width * cinfo->output_components;
  53. * height is buffer_height.
  54. */
  55. JSAMPARRAY buffer;
  56. JDIMENSION buffer_height;
  57. };
  58. /*
  59. * cjpeg/djpeg may need to perform extra passes to convert to or from
  60. * the source/destination file format. The JPEG library does not know
  61. * about these passes, but we'd like them to be counted by the progress
  62. * monitor. We use an expanded progress monitor object to hold the
  63. * additional pass count.
  64. */
  65. struct cdjpeg_progress_mgr {
  66. struct jpeg_progress_mgr pub; /* fields known to JPEG library */
  67. int completed_extra_passes; /* extra passes completed */
  68. int total_extra_passes; /* total extra */
  69. /* last printed percentage stored here to avoid multiple printouts */
  70. int percent_done;
  71. };
  72. typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
  73. /* Short forms of external names for systems with brain-damaged linkers. */
  74. #ifdef NEED_SHORT_EXTERNAL_NAMES
  75. #define jinit_read_bmp jIRdBMP
  76. #define jinit_write_bmp jIWrBMP
  77. #define jinit_read_gif jIRdGIF
  78. #define jinit_write_gif jIWrGIF
  79. #define jinit_read_ppm jIRdPPM
  80. #define jinit_write_ppm jIWrPPM
  81. #define jinit_read_rle jIRdRLE
  82. #define jinit_write_rle jIWrRLE
  83. #define jinit_read_targa jIRdTarga
  84. #define jinit_write_targa jIWrTarga
  85. #define read_quant_tables RdQTables
  86. #define read_scan_script RdScnScript
  87. #define set_quant_slots SetQSlots
  88. #define set_sample_factors SetSFacts
  89. #define read_color_map RdCMap
  90. #define enable_signal_catcher EnSigCatcher
  91. #define start_progress_monitor StProgMon
  92. #define end_progress_monitor EnProgMon
  93. #define read_stdin RdStdin
  94. #define write_stdout WrStdout
  95. #endif /* NEED_SHORT_EXTERNAL_NAMES */
  96. /* Module selection routines for I/O modules. */
  97. EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
  98. EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
  99. boolean is_os2));
  100. EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
  101. EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
  102. EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
  103. EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
  104. EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
  105. EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
  106. EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
  107. EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
  108. /* cjpeg support routines (in rdswitch.c) */
  109. EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
  110. int scale_factor, boolean force_baseline));
  111. EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
  112. EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
  113. EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
  114. /* djpeg support routines (in rdcolmap.c) */
  115. EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
  116. /* common support routines (in cdjpeg.c) */
  117. EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
  118. EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
  119. cd_progress_ptr progress));
  120. EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
  121. EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
  122. EXTERN(FILE *) read_stdin JPP((void));
  123. EXTERN(FILE *) write_stdout JPP((void));
  124. /* miscellaneous useful macros */
  125. #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
  126. #define READ_BINARY "r"
  127. #define WRITE_BINARY "w"
  128. #else
  129. #ifdef VMS /* VMS is very nonstandard */
  130. #define READ_BINARY "rb", "ctx=stm"
  131. #define WRITE_BINARY "wb", "ctx=stm"
  132. #else /* standard ANSI-compliant case */
  133. #define READ_BINARY "rb"
  134. #define WRITE_BINARY "wb"
  135. #endif
  136. #endif
  137. #ifndef EXIT_FAILURE /* define exit() codes if not provided */
  138. #define EXIT_FAILURE 1
  139. #endif
  140. #ifndef EXIT_SUCCESS
  141. #ifdef VMS
  142. #define EXIT_SUCCESS 1 /* VMS is very nonstandard */
  143. #else
  144. #define EXIT_SUCCESS 0
  145. #endif
  146. #endif
  147. #ifndef EXIT_WARNING
  148. #ifdef VMS
  149. #define EXIT_WARNING 1 /* VMS is very nonstandard */
  150. #else
  151. #define EXIT_WARNING 2
  152. #endif
  153. #endif