ReactOS 0.4.15-dev-7924-g5949c20
jdapistd.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jdapistd.c:

Go to the source code of this file.

Macros

#define JPEG_INTERNALS
 

Functions

 LOCAL (boolean)
 
 output_pass_setup (j_decompress_ptr cinfo)
 
 jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
 
 jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, JDIMENSION max_lines)
 

Macro Definition Documentation

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 18 of file jdapistd.c.

Function Documentation

◆ jpeg_read_raw_data()

jpeg_read_raw_data ( j_decompress_ptr  cinfo,
JSAMPIMAGE  data,
JDIMENSION  max_lines 
)

Definition at line 186 of file jdapistd.c.

188{
189 JDIMENSION lines_per_iMCU_row;
190
191 if (cinfo->global_state != DSTATE_RAW_OK)
192 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
193 if (cinfo->output_scanline >= cinfo->output_height) {
194 WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
195 return 0;
196 }
197
198 /* Call progress monitor hook if present */
199 if (cinfo->progress != NULL) {
200 cinfo->progress->pass_counter = (long) cinfo->output_scanline;
201 cinfo->progress->pass_limit = (long) cinfo->output_height;
202 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
203 }
204
205 /* Verify that at least one iMCU row can be returned. */
206 lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size;
207 if (max_lines < lines_per_iMCU_row)
208 ERREXIT(cinfo, JERR_BUFFER_SIZE);
209
210 /* Decompress directly into user's buffer. */
211 if (! (*cinfo->coef->decompress_data) (cinfo, data))
212 return 0; /* suspension forced, can do nothing more */
213
214 /* OK, we processed one iMCU row. */
215 cinfo->output_scanline += lines_per_iMCU_row;
216 return lines_per_iMCU_row;
217}
#define NULL
Definition: types.h:112
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:212
#define WARNMS(cinfo, code)
Definition: jerror.h:251
unsigned int JDIMENSION
Definition: jmorecfg.h:229
#define DSTATE_RAW_OK
Definition: jpegint.h:36
JSAMPARRAY JDIMENSION max_lines
Definition: jpeglib.h:1058
#define long
Definition: qsort.c:33
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
JDIMENSION output_height
Definition: jpeglib.h:508
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:680
JDIMENSION output_scanline
Definition: jpeglib.h:537

◆ jpeg_read_scanlines()

jpeg_read_scanlines ( j_decompress_ptr  cinfo,
JSAMPARRAY  scanlines,
JDIMENSION  max_lines 
)

Definition at line 153 of file jdapistd.c.

155{
156 JDIMENSION row_ctr;
157
158 if (cinfo->global_state != DSTATE_SCANNING)
159 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
160 if (cinfo->output_scanline >= cinfo->output_height) {
161 WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
162 return 0;
163 }
164
165 /* Call progress monitor hook if present */
166 if (cinfo->progress != NULL) {
167 cinfo->progress->pass_counter = (long) cinfo->output_scanline;
168 cinfo->progress->pass_limit = (long) cinfo->output_height;
169 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
170 }
171
172 /* Process some data */
173 row_ctr = 0;
174 (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);
175 cinfo->output_scanline += row_ctr;
176 return row_ctr;
177}
#define DSTATE_SCANNING
Definition: jpegint.h:35
JSAMPARRAY scanlines
Definition: jpeglib.h:1016
struct jpeg_d_main_controller * main
Definition: jpeglib.h:679

Referenced by main(), and read_JPEG_file().

◆ LOCAL()

LOCAL ( boolean  )

Definition at line 24 of file jdapistd.c.

40{
41 if (cinfo->global_state == DSTATE_READY) {
42 /* First call: initialize master control, select active modules */
44 if (cinfo->buffered_image) {
45 /* No more work here; expecting jpeg_start_output next */
46 cinfo->global_state = DSTATE_BUFIMAGE;
47 return TRUE;
48 }
49 cinfo->global_state = DSTATE_PRELOAD;
50 }
51 if (cinfo->global_state == DSTATE_PRELOAD) {
52 /* If file has multiple scans, absorb them all into the coef buffer */
53 if (cinfo->inputctl->has_multiple_scans) {
54#ifdef D_MULTISCAN_FILES_SUPPORTED
55 for (;;) {
56 int retcode;
57 /* Call progress monitor hook if present */
58 if (cinfo->progress != NULL)
59 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
60 /* Absorb some more input */
61 retcode = (*cinfo->inputctl->consume_input) (cinfo);
62 if (retcode == JPEG_SUSPENDED)
63 return FALSE;
64 if (retcode == JPEG_REACHED_EOI)
65 break;
66 /* Advance progress counter if appropriate */
67 if (cinfo->progress != NULL &&
68 (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
69 if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
70 /* jdmaster underestimated number of scans; ratchet up one scan */
71 cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
72 }
73 }
74 }
75#else
76 ERREXIT(cinfo, JERR_NOT_COMPILED);
77#endif /* D_MULTISCAN_FILES_SUPPORTED */
78 }
79 cinfo->output_scan_number = cinfo->input_scan_number;
80 } else if (cinfo->global_state != DSTATE_PRESCAN)
81 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
82 /* Perform any dummy output passes, and set up for the final pass */
83 return output_pass_setup(cinfo);
84}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
output_pass_setup(j_decompress_ptr cinfo)
Definition: jdapistd.c:96
jinit_master_decompress(j_decompress_ptr cinfo)
Definition: jdmaster.c:526
#define DSTATE_BUFIMAGE
Definition: jpegint.h:37
#define DSTATE_READY
Definition: jpegint.h:32
#define DSTATE_PRELOAD
Definition: jpegint.h:33
#define DSTATE_PRESCAN
Definition: jpegint.h:34
#define JPEG_REACHED_SOS
Definition: jpeglib.h:1076
#define JPEG_REACHED_EOI
Definition: jpeglib.h:1077
#define JPEG_ROW_COMPLETED
Definition: jpeglib.h:1078
#define JPEG_SUSPENDED
Definition: jpeglib.h:1045

◆ output_pass_setup()

output_pass_setup ( j_decompress_ptr  cinfo)

Definition at line 96 of file jdapistd.c.

97{
98 if (cinfo->global_state != DSTATE_PRESCAN) {
99 /* First call: do pass setup */
100 (*cinfo->master->prepare_for_output_pass) (cinfo);
101 cinfo->output_scanline = 0;
102 cinfo->global_state = DSTATE_PRESCAN;
103 }
104 /* Loop over any required dummy passes */
105 while (cinfo->master->is_dummy_pass) {
106#ifdef QUANT_2PASS_SUPPORTED
107 /* Crank through the dummy pass */
108 while (cinfo->output_scanline < cinfo->output_height) {
109 JDIMENSION last_scanline;
110 /* Call progress monitor hook if present */
111 if (cinfo->progress != NULL) {
112 cinfo->progress->pass_counter = (long) cinfo->output_scanline;
113 cinfo->progress->pass_limit = (long) cinfo->output_height;
114 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
115 }
116 /* Process some data */
117 last_scanline = cinfo->output_scanline;
118 (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
119 &cinfo->output_scanline, (JDIMENSION) 0);
120 if (cinfo->output_scanline == last_scanline)
121 return FALSE; /* No progress made, must suspend */
122 }
123 /* Finish up dummy pass, and set up for another one */
124 (*cinfo->master->finish_output_pass) (cinfo);
125 (*cinfo->master->prepare_for_output_pass) (cinfo);
126 cinfo->output_scanline = 0;
127#else
128 ERREXIT(cinfo, JERR_NOT_COMPILED);
129#endif /* QUANT_2PASS_SUPPORTED */
130 }
131 /* Ready for application to drive output pass through
132 * jpeg_read_scanlines or jpeg_read_raw_data.
133 */
134 cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
135 return TRUE;
136}
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:76
struct jpeg_decomp_master * master
Definition: jpeglib.h:678