Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define JPEG_INTERNALS
00018 #include "jinclude.h"
00019 #include "jpeglib.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 GLOBAL(void)
00038 jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
00039 {
00040 if (cinfo->global_state != CSTATE_START)
00041 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00042
00043 if (write_all_tables)
00044 jpeg_suppress_tables(cinfo, FALSE);
00045
00046
00047 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
00048 (*cinfo->dest->init_destination) (cinfo);
00049
00050 jinit_compress_master(cinfo);
00051
00052 (*cinfo->master->prepare_for_pass) (cinfo);
00053
00054
00055
00056 cinfo->next_scanline = 0;
00057 cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 GLOBAL(JDIMENSION)
00077 jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
00078 JDIMENSION num_lines)
00079 {
00080 JDIMENSION row_ctr, rows_left;
00081
00082 if (cinfo->global_state != CSTATE_SCANNING)
00083 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00084 if (cinfo->next_scanline >= cinfo->image_height)
00085 WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
00086
00087
00088 if (cinfo->progress != NULL) {
00089 cinfo->progress->pass_counter = (long) cinfo->next_scanline;
00090 cinfo->progress->pass_limit = (long) cinfo->image_height;
00091 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
00092 }
00093
00094
00095
00096
00097
00098
00099 if (cinfo->master->call_pass_startup)
00100 (*cinfo->master->pass_startup) (cinfo);
00101
00102
00103 rows_left = cinfo->image_height - cinfo->next_scanline;
00104 if (num_lines > rows_left)
00105 num_lines = rows_left;
00106
00107 row_ctr = 0;
00108 (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines);
00109 cinfo->next_scanline += row_ctr;
00110 return row_ctr;
00111 }
00112
00113
00114
00115
00116
00117
00118
00119 GLOBAL(JDIMENSION)
00120 jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
00121 JDIMENSION num_lines)
00122 {
00123 JDIMENSION lines_per_iMCU_row;
00124
00125 if (cinfo->global_state != CSTATE_RAW_OK)
00126 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00127 if (cinfo->next_scanline >= cinfo->image_height) {
00128 WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
00129 return 0;
00130 }
00131
00132
00133 if (cinfo->progress != NULL) {
00134 cinfo->progress->pass_counter = (long) cinfo->next_scanline;
00135 cinfo->progress->pass_limit = (long) cinfo->image_height;
00136 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
00137 }
00138
00139
00140
00141
00142
00143
00144 if (cinfo->master->call_pass_startup)
00145 (*cinfo->master->pass_startup) (cinfo);
00146
00147
00148 lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE;
00149 if (num_lines < lines_per_iMCU_row)
00150 ERREXIT(cinfo, JERR_BUFFER_SIZE);
00151
00152
00153 if (! (*cinfo->coef->compress_data) (cinfo, data)) {
00154
00155 return 0;
00156 }
00157
00158
00159 cinfo->next_scanline += lines_per_iMCU_row;
00160 return lines_per_iMCU_row;
00161 }