Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
6.1 KiB

  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_quality_ratings SetQRates
  88. #define set_quant_slots SetQSlots
  89. #define set_sample_factors SetSFacts
  90. #define read_color_map RdCMap
  91. #define enable_signal_catcher EnSigCatcher
  92. #define start_progress_monitor StProgMon
  93. #define end_progress_monitor EnProgMon
  94. #define read_stdin RdStdin
  95. #define write_stdout WrStdout
  96. #endif /* NEED_SHORT_EXTERNAL_NAMES */
  97. /* Module selection routines for I/O modules. */
  98. EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
  99. EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
  100. boolean is_os2));
  101. EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
  102. EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
  103. EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
  104. EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
  105. EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
  106. EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
  107. EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
  108. EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
  109. /* cjpeg support routines (in rdswitch.c) */
  110. EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
  111. boolean force_baseline));
  112. EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
  113. EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg,
  114. boolean force_baseline));
  115. EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
  116. EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
  117. /* djpeg support routines (in rdcolmap.c) */
  118. EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
  119. /* common support routines (in cdjpeg.c) */
  120. EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
  121. EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
  122. cd_progress_ptr progress));
  123. EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
  124. EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
  125. EXTERN(FILE *) read_stdin JPP((void));
  126. EXTERN(FILE *) write_stdout JPP((void));
  127. /* miscellaneous useful macros */
  128. #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
  129. #define READ_BINARY "r"
  130. #define WRITE_BINARY "w"
  131. #else
  132. #ifdef VMS /* VMS is very nonstandard */
  133. #define READ_BINARY "rb", "ctx=stm"
  134. #define WRITE_BINARY "wb", "ctx=stm"
  135. #else /* standard ANSI-compliant case */
  136. #define READ_BINARY "rb"
  137. #define WRITE_BINARY "wb"
  138. #endif
  139. #endif
  140. #ifndef EXIT_FAILURE /* define exit() codes if not provided */
  141. #define EXIT_FAILURE 1
  142. #endif
  143. #ifndef EXIT_SUCCESS
  144. #ifdef VMS
  145. #define EXIT_SUCCESS 1 /* VMS is very nonstandard */
  146. #else
  147. #define EXIT_SUCCESS 0
  148. #endif
  149. #endif
  150. #ifndef EXIT_WARNING
  151. #ifdef VMS
  152. #define EXIT_WARNING 1 /* VMS is very nonstandard */
  153. #else
  154. #define EXIT_WARNING 2
  155. #endif
  156. #endif