cdjpeg.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * cdjpeg.h
  3. *
  4. * This file was part of the Independent JPEG Group's software:
  5. * Copyright (C) 1994-1997, Thomas G. Lane.
  6. * It was modified by The libjpeg-turbo Project to include only code relevant
  7. * to libjpeg-turbo.
  8. * For conditions of distribution and use, see the accompanying README.ijg
  9. * file.
  10. *
  11. * This file contains common declarations for the sample applications
  12. * cjpeg and djpeg. It is NOT used by the core JPEG library.
  13. */
  14. #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
  15. #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
  16. #include "jinclude.h"
  17. #include "jpeglib.h"
  18. #include "jerror.h" /* get library error codes too */
  19. #include "cderror.h" /* get application-specific error codes */
  20. /*
  21. * Object interface for cjpeg's source file decoding modules
  22. */
  23. typedef struct cjpeg_source_struct *cjpeg_source_ptr;
  24. struct cjpeg_source_struct {
  25. void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
  26. JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
  27. void (*finish_input) (j_compress_ptr cinfo, 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. void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
  41. /* Emit the specified number of pixel rows from the buffer. */
  42. void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
  43. JDIMENSION rows_supplied);
  44. /* Finish up at the end of the image. */
  45. void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
  46. /* Target file spec; filled in by djpeg.c after object is created. */
  47. FILE *output_file;
  48. /* Output pixel-row buffer. Created by module init or start_output.
  49. * Width is cinfo->output_width * cinfo->output_components;
  50. * height is buffer_height.
  51. */
  52. JSAMPARRAY buffer;
  53. JDIMENSION buffer_height;
  54. };
  55. /*
  56. * cjpeg/djpeg may need to perform extra passes to convert to or from
  57. * the source/destination file format. The JPEG library does not know
  58. * about these passes, but we'd like them to be counted by the progress
  59. * monitor. We use an expanded progress monitor object to hold the
  60. * additional pass count.
  61. */
  62. struct cdjpeg_progress_mgr {
  63. struct jpeg_progress_mgr pub; /* fields known to JPEG library */
  64. int completed_extra_passes; /* extra passes completed */
  65. int total_extra_passes; /* total extra */
  66. /* last printed percentage stored here to avoid multiple printouts */
  67. int percent_done;
  68. };
  69. typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
  70. /* Module selection routines for I/O modules. */
  71. EXTERN(cjpeg_source_ptr) jinit_read_bmp (j_compress_ptr cinfo);
  72. EXTERN(djpeg_dest_ptr) jinit_write_bmp (j_decompress_ptr cinfo,
  73. boolean is_os2);
  74. EXTERN(cjpeg_source_ptr) jinit_read_gif (j_compress_ptr cinfo);
  75. EXTERN(djpeg_dest_ptr) jinit_write_gif (j_decompress_ptr cinfo);
  76. EXTERN(cjpeg_source_ptr) jinit_read_ppm (j_compress_ptr cinfo);
  77. EXTERN(djpeg_dest_ptr) jinit_write_ppm (j_decompress_ptr cinfo);
  78. EXTERN(cjpeg_source_ptr) jinit_read_rle (j_compress_ptr cinfo);
  79. EXTERN(djpeg_dest_ptr) jinit_write_rle (j_decompress_ptr cinfo);
  80. EXTERN(cjpeg_source_ptr) jinit_read_targa (j_compress_ptr cinfo);
  81. EXTERN(djpeg_dest_ptr) jinit_write_targa (j_decompress_ptr cinfo);
  82. /* cjpeg support routines (in rdswitch.c) */
  83. EXTERN(boolean) read_quant_tables (j_compress_ptr cinfo, char *filename,
  84. boolean force_baseline);
  85. EXTERN(boolean) read_scan_script (j_compress_ptr cinfo, char *filename);
  86. EXTERN(boolean) set_quality_ratings (j_compress_ptr cinfo, char *arg,
  87. boolean force_baseline);
  88. EXTERN(boolean) set_quant_slots (j_compress_ptr cinfo, char *arg);
  89. EXTERN(boolean) set_sample_factors (j_compress_ptr cinfo, char *arg);
  90. /* djpeg support routines (in rdcolmap.c) */
  91. EXTERN(void) read_color_map (j_decompress_ptr cinfo, FILE *infile);
  92. /* common support routines (in cdjpeg.c) */
  93. EXTERN(void) enable_signal_catcher (j_common_ptr cinfo);
  94. EXTERN(void) start_progress_monitor (j_common_ptr cinfo,
  95. cd_progress_ptr progress);
  96. EXTERN(void) end_progress_monitor (j_common_ptr cinfo);
  97. EXTERN(boolean) keymatch (char *arg, const char *keyword, int minchars);
  98. EXTERN(FILE *) read_stdin (void);
  99. EXTERN(FILE *) write_stdout (void);
  100. /* miscellaneous useful macros */
  101. #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
  102. #define READ_BINARY "r"
  103. #define WRITE_BINARY "w"
  104. #else
  105. #define READ_BINARY "rb"
  106. #define WRITE_BINARY "wb"
  107. #endif
  108. #ifndef EXIT_FAILURE /* define exit() codes if not provided */
  109. #define EXIT_FAILURE 1
  110. #endif
  111. #ifndef EXIT_SUCCESS
  112. #define EXIT_SUCCESS 0
  113. #endif
  114. #ifndef EXIT_WARNING
  115. #define EXIT_WARNING 2
  116. #endif