aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcapistd.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcapistd.c')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcapistd.c322
1 files changed, 161 insertions, 161 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcapistd.c b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcapistd.c
index fed66ca..c0320b1 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcapistd.c
+++ b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcapistd.c
@@ -1,161 +1,161 @@
1/* 1/*
2 * jcapistd.c 2 * jcapistd.c
3 * 3 *
4 * Copyright (C) 1994-1996, Thomas G. Lane. 4 * Copyright (C) 1994-1996, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software. 5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file. 6 * For conditions of distribution and use, see the accompanying README file.
7 * 7 *
8 * This file contains application interface code for the compression half 8 * This file contains application interface code for the compression half
9 * of the JPEG library. These are the "standard" API routines that are 9 * of the JPEG library. These are the "standard" API routines that are
10 * used in the normal full-compression case. They are not used by a 10 * used in the normal full-compression case. They are not used by a
11 * transcoding-only application. Note that if an application links in 11 * transcoding-only application. Note that if an application links in
12 * jpeg_start_compress, it will end up linking in the entire compressor. 12 * jpeg_start_compress, it will end up linking in the entire compressor.
13 * We thus must separate this file from jcapimin.c to avoid linking the 13 * We thus must separate this file from jcapimin.c to avoid linking the
14 * whole compression library into a transcoder. 14 * whole compression library into a transcoder.
15 */ 15 */
16 16
17#define JPEG_INTERNALS 17#define JPEG_INTERNALS
18#include "jinclude.h" 18#include "jinclude.h"
19#include "jpeglib.h" 19#include "jpeglib.h"
20 20
21 21
22/* 22/*
23 * Compression initialization. 23 * Compression initialization.
24 * Before calling this, all parameters and a data destination must be set up. 24 * Before calling this, all parameters and a data destination must be set up.
25 * 25 *
26 * We require a write_all_tables parameter as a failsafe check when writing 26 * We require a write_all_tables parameter as a failsafe check when writing
27 * multiple datastreams from the same compression object. Since prior runs 27 * multiple datastreams from the same compression object. Since prior runs
28 * will have left all the tables marked sent_table=TRUE, a subsequent run 28 * will have left all the tables marked sent_table=TRUE, a subsequent run
29 * would emit an abbreviated stream (no tables) by default. This may be what 29 * would emit an abbreviated stream (no tables) by default. This may be what
30 * is wanted, but for safety's sake it should not be the default behavior: 30 * is wanted, but for safety's sake it should not be the default behavior:
31 * programmers should have to make a deliberate choice to emit abbreviated 31 * programmers should have to make a deliberate choice to emit abbreviated
32 * images. Therefore the documentation and examples should encourage people 32 * images. Therefore the documentation and examples should encourage people
33 * to pass write_all_tables=TRUE; then it will take active thought to do the 33 * to pass write_all_tables=TRUE; then it will take active thought to do the
34 * wrong thing. 34 * wrong thing.
35 */ 35 */
36 36
37GLOBAL(void) 37GLOBAL(void)
38jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) 38jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
39{ 39{
40 if (cinfo->global_state != CSTATE_START) 40 if (cinfo->global_state != CSTATE_START)
41 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 41 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
42 42
43 if (write_all_tables) 43 if (write_all_tables)
44 jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ 44 jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
45 45
46 /* (Re)initialize error mgr and destination modules */ 46 /* (Re)initialize error mgr and destination modules */
47 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); 47 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
48 (*cinfo->dest->init_destination) (cinfo); 48 (*cinfo->dest->init_destination) (cinfo);
49 /* Perform master selection of active modules */ 49 /* Perform master selection of active modules */
50 jinit_compress_master(cinfo); 50 jinit_compress_master(cinfo);
51 /* Set up for the first pass */ 51 /* Set up for the first pass */
52 (*cinfo->master->prepare_for_pass) (cinfo); 52 (*cinfo->master->prepare_for_pass) (cinfo);
53 /* Ready for application to drive first pass through jpeg_write_scanlines 53 /* Ready for application to drive first pass through jpeg_write_scanlines
54 * or jpeg_write_raw_data. 54 * or jpeg_write_raw_data.
55 */ 55 */
56 cinfo->next_scanline = 0; 56 cinfo->next_scanline = 0;
57 cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); 57 cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);
58} 58}
59 59
60 60
61/* 61/*
62 * Write some scanlines of data to the JPEG compressor. 62 * Write some scanlines of data to the JPEG compressor.
63 * 63 *
64 * The return value will be the number of lines actually written. 64 * The return value will be the number of lines actually written.
65 * This should be less than the supplied num_lines only in case that 65 * This should be less than the supplied num_lines only in case that
66 * the data destination module has requested suspension of the compressor, 66 * the data destination module has requested suspension of the compressor,
67 * or if more than image_height scanlines are passed in. 67 * or if more than image_height scanlines are passed in.
68 * 68 *
69 * Note: we warn about excess calls to jpeg_write_scanlines() since 69 * Note: we warn about excess calls to jpeg_write_scanlines() since
70 * this likely signals an application programmer error. However, 70 * this likely signals an application programmer error. However,
71 * excess scanlines passed in the last valid call are *silently* ignored, 71 * excess scanlines passed in the last valid call are *silently* ignored,
72 * so that the application need not adjust num_lines for end-of-image 72 * so that the application need not adjust num_lines for end-of-image
73 * when using a multiple-scanline buffer. 73 * when using a multiple-scanline buffer.
74 */ 74 */
75 75
76GLOBAL(JDIMENSION) 76GLOBAL(JDIMENSION)
77jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, 77jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
78 JDIMENSION num_lines) 78 JDIMENSION num_lines)
79{ 79{
80 JDIMENSION row_ctr, rows_left; 80 JDIMENSION row_ctr, rows_left;
81 81
82 if (cinfo->global_state != CSTATE_SCANNING) 82 if (cinfo->global_state != CSTATE_SCANNING)
83 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 83 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
84 if (cinfo->next_scanline >= cinfo->image_height) 84 if (cinfo->next_scanline >= cinfo->image_height)
85 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); 85 WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
86 86
87 /* Call progress monitor hook if present */ 87 /* Call progress monitor hook if present */
88 if (cinfo->progress != NULL) { 88 if (cinfo->progress != NULL) {
89 cinfo->progress->pass_counter = (long) cinfo->next_scanline; 89 cinfo->progress->pass_counter = (long) cinfo->next_scanline;
90 cinfo->progress->pass_limit = (long) cinfo->image_height; 90 cinfo->progress->pass_limit = (long) cinfo->image_height;
91 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); 91 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
92 } 92 }
93 93
94 /* Give master control module another chance if this is first call to 94 /* Give master control module another chance if this is first call to
95 * jpeg_write_scanlines. This lets output of the frame/scan headers be 95 * jpeg_write_scanlines. This lets output of the frame/scan headers be
96 * delayed so that application can write COM, etc, markers between 96 * delayed so that application can write COM, etc, markers between
97 * jpeg_start_compress and jpeg_write_scanlines. 97 * jpeg_start_compress and jpeg_write_scanlines.
98 */ 98 */
99 if (cinfo->master->call_pass_startup) 99 if (cinfo->master->call_pass_startup)
100 (*cinfo->master->pass_startup) (cinfo); 100 (*cinfo->master->pass_startup) (cinfo);
101 101
102 /* Ignore any extra scanlines at bottom of image. */ 102 /* Ignore any extra scanlines at bottom of image. */
103 rows_left = cinfo->image_height - cinfo->next_scanline; 103 rows_left = cinfo->image_height - cinfo->next_scanline;
104 if (num_lines > rows_left) 104 if (num_lines > rows_left)
105 num_lines = rows_left; 105 num_lines = rows_left;
106 106
107 row_ctr = 0; 107 row_ctr = 0;
108 (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); 108 (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines);
109 cinfo->next_scanline += row_ctr; 109 cinfo->next_scanline += row_ctr;
110 return row_ctr; 110 return row_ctr;
111} 111}
112 112
113 113
114/* 114/*
115 * Alternate entry point to write raw data. 115 * Alternate entry point to write raw data.
116 * Processes exactly one iMCU row per call, unless suspended. 116 * Processes exactly one iMCU row per call, unless suspended.
117 */ 117 */
118 118
119GLOBAL(JDIMENSION) 119GLOBAL(JDIMENSION)
120jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, 120jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
121 JDIMENSION num_lines) 121 JDIMENSION num_lines)
122{ 122{
123 JDIMENSION lines_per_iMCU_row; 123 JDIMENSION lines_per_iMCU_row;
124 124
125 if (cinfo->global_state != CSTATE_RAW_OK) 125 if (cinfo->global_state != CSTATE_RAW_OK)
126 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 126 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
127 if (cinfo->next_scanline >= cinfo->image_height) { 127 if (cinfo->next_scanline >= cinfo->image_height) {
128 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); 128 WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
129 return 0; 129 return 0;
130 } 130 }
131 131
132 /* Call progress monitor hook if present */ 132 /* Call progress monitor hook if present */
133 if (cinfo->progress != NULL) { 133 if (cinfo->progress != NULL) {
134 cinfo->progress->pass_counter = (long) cinfo->next_scanline; 134 cinfo->progress->pass_counter = (long) cinfo->next_scanline;
135 cinfo->progress->pass_limit = (long) cinfo->image_height; 135 cinfo->progress->pass_limit = (long) cinfo->image_height;
136 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); 136 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
137 } 137 }
138 138
139 /* Give master control module another chance if this is first call to 139 /* Give master control module another chance if this is first call to
140 * jpeg_write_raw_data. This lets output of the frame/scan headers be 140 * jpeg_write_raw_data. This lets output of the frame/scan headers be
141 * delayed so that application can write COM, etc, markers between 141 * delayed so that application can write COM, etc, markers between
142 * jpeg_start_compress and jpeg_write_raw_data. 142 * jpeg_start_compress and jpeg_write_raw_data.
143 */ 143 */
144 if (cinfo->master->call_pass_startup) 144 if (cinfo->master->call_pass_startup)
145 (*cinfo->master->pass_startup) (cinfo); 145 (*cinfo->master->pass_startup) (cinfo);
146 146
147 /* Verify that at least one iMCU row has been passed. */ 147 /* Verify that at least one iMCU row has been passed. */
148 lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; 148 lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE;
149 if (num_lines < lines_per_iMCU_row) 149 if (num_lines < lines_per_iMCU_row)
150 ERREXIT(cinfo, JERR_BUFFER_SIZE); 150 ERREXIT(cinfo, JERR_BUFFER_SIZE);
151 151
152 /* Directly compress the row. */ 152 /* Directly compress the row. */
153 if (! (*cinfo->coef->compress_data) (cinfo, data)) { 153 if (! (*cinfo->coef->compress_data) (cinfo, data)) {
154 /* If compressor did not consume the whole row, suspend processing. */ 154 /* If compressor did not consume the whole row, suspend processing. */
155 return 0; 155 return 0;
156 } 156 }
157 157
158 /* OK, we processed one iMCU row. */ 158 /* OK, we processed one iMCU row. */
159 cinfo->next_scanline += lines_per_iMCU_row; 159 cinfo->next_scanline += lines_per_iMCU_row;
160 return lines_per_iMCU_row; 160 return lines_per_iMCU_row;
161} 161}