Final 350 project
Dependencies: uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed
includes/jdapistd.c@0:791a779d6220, 2017-07-31 (annotated)
- Committer:
- shoaib_ahmed
- Date:
- Mon Jul 31 09:16:35 2017 +0000
- Revision:
- 0:791a779d6220
final project;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shoaib_ahmed | 0:791a779d6220 | 1 | /* |
shoaib_ahmed | 0:791a779d6220 | 2 | * jdapistd.c |
shoaib_ahmed | 0:791a779d6220 | 3 | * |
shoaib_ahmed | 0:791a779d6220 | 4 | * Copyright (C) 1994-1996, Thomas G. Lane. |
shoaib_ahmed | 0:791a779d6220 | 5 | * Modified 2002-2013 by Guido Vollbeding. |
shoaib_ahmed | 0:791a779d6220 | 6 | * This file is part of the Independent JPEG Group's software. |
shoaib_ahmed | 0:791a779d6220 | 7 | * For conditions of distribution and use, see the accompanying README file. |
shoaib_ahmed | 0:791a779d6220 | 8 | * |
shoaib_ahmed | 0:791a779d6220 | 9 | * This file contains application interface code for the decompression half |
shoaib_ahmed | 0:791a779d6220 | 10 | * of the JPEG library. These are the "standard" API routines that are |
shoaib_ahmed | 0:791a779d6220 | 11 | * used in the normal full-decompression case. They are not used by a |
shoaib_ahmed | 0:791a779d6220 | 12 | * transcoding-only application. Note that if an application links in |
shoaib_ahmed | 0:791a779d6220 | 13 | * jpeg_start_decompress, it will end up linking in the entire decompressor. |
shoaib_ahmed | 0:791a779d6220 | 14 | * We thus must separate this file from jdapimin.c to avoid linking the |
shoaib_ahmed | 0:791a779d6220 | 15 | * whole decompression library into a transcoder. |
shoaib_ahmed | 0:791a779d6220 | 16 | */ |
shoaib_ahmed | 0:791a779d6220 | 17 | |
shoaib_ahmed | 0:791a779d6220 | 18 | #define JPEG_INTERNALS |
shoaib_ahmed | 0:791a779d6220 | 19 | #include "jinclude.h" |
shoaib_ahmed | 0:791a779d6220 | 20 | #include "jpeglib.h" |
shoaib_ahmed | 0:791a779d6220 | 21 | |
shoaib_ahmed | 0:791a779d6220 | 22 | |
shoaib_ahmed | 0:791a779d6220 | 23 | /* Forward declarations */ |
shoaib_ahmed | 0:791a779d6220 | 24 | LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); |
shoaib_ahmed | 0:791a779d6220 | 25 | |
shoaib_ahmed | 0:791a779d6220 | 26 | |
shoaib_ahmed | 0:791a779d6220 | 27 | /* |
shoaib_ahmed | 0:791a779d6220 | 28 | * Decompression initialization. |
shoaib_ahmed | 0:791a779d6220 | 29 | * jpeg_read_header must be completed before calling this. |
shoaib_ahmed | 0:791a779d6220 | 30 | * |
shoaib_ahmed | 0:791a779d6220 | 31 | * If a multipass operating mode was selected, this will do all but the |
shoaib_ahmed | 0:791a779d6220 | 32 | * last pass, and thus may take a great deal of time. |
shoaib_ahmed | 0:791a779d6220 | 33 | * |
shoaib_ahmed | 0:791a779d6220 | 34 | * Returns FALSE if suspended. The return value need be inspected only if |
shoaib_ahmed | 0:791a779d6220 | 35 | * a suspending data source is used. |
shoaib_ahmed | 0:791a779d6220 | 36 | */ |
shoaib_ahmed | 0:791a779d6220 | 37 | |
shoaib_ahmed | 0:791a779d6220 | 38 | GLOBAL(boolean) |
shoaib_ahmed | 0:791a779d6220 | 39 | jpeg_start_decompress (j_decompress_ptr cinfo) |
shoaib_ahmed | 0:791a779d6220 | 40 | { |
shoaib_ahmed | 0:791a779d6220 | 41 | if (cinfo->global_state == DSTATE_READY) { |
shoaib_ahmed | 0:791a779d6220 | 42 | /* First call: initialize master control, select active modules */ |
shoaib_ahmed | 0:791a779d6220 | 43 | jinit_master_decompress(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 44 | if (cinfo->buffered_image) { |
shoaib_ahmed | 0:791a779d6220 | 45 | /* No more work here; expecting jpeg_start_output next */ |
shoaib_ahmed | 0:791a779d6220 | 46 | cinfo->global_state = DSTATE_BUFIMAGE; |
shoaib_ahmed | 0:791a779d6220 | 47 | return TRUE; |
shoaib_ahmed | 0:791a779d6220 | 48 | } |
shoaib_ahmed | 0:791a779d6220 | 49 | cinfo->global_state = DSTATE_PRELOAD; |
shoaib_ahmed | 0:791a779d6220 | 50 | } |
shoaib_ahmed | 0:791a779d6220 | 51 | if (cinfo->global_state == DSTATE_PRELOAD) { |
shoaib_ahmed | 0:791a779d6220 | 52 | /* If file has multiple scans, absorb them all into the coef buffer */ |
shoaib_ahmed | 0:791a779d6220 | 53 | if (cinfo->inputctl->has_multiple_scans) { |
shoaib_ahmed | 0:791a779d6220 | 54 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
shoaib_ahmed | 0:791a779d6220 | 55 | for (;;) { |
shoaib_ahmed | 0:791a779d6220 | 56 | int retcode; |
shoaib_ahmed | 0:791a779d6220 | 57 | /* Call progress monitor hook if present */ |
shoaib_ahmed | 0:791a779d6220 | 58 | if (cinfo->progress != NULL) |
shoaib_ahmed | 0:791a779d6220 | 59 | (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
shoaib_ahmed | 0:791a779d6220 | 60 | /* Absorb some more input */ |
shoaib_ahmed | 0:791a779d6220 | 61 | retcode = (*cinfo->inputctl->consume_input) (cinfo); |
shoaib_ahmed | 0:791a779d6220 | 62 | if (retcode == JPEG_SUSPENDED) |
shoaib_ahmed | 0:791a779d6220 | 63 | return FALSE; |
shoaib_ahmed | 0:791a779d6220 | 64 | if (retcode == JPEG_REACHED_EOI) |
shoaib_ahmed | 0:791a779d6220 | 65 | break; |
shoaib_ahmed | 0:791a779d6220 | 66 | /* Advance progress counter if appropriate */ |
shoaib_ahmed | 0:791a779d6220 | 67 | if (cinfo->progress != NULL && |
shoaib_ahmed | 0:791a779d6220 | 68 | (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { |
shoaib_ahmed | 0:791a779d6220 | 69 | if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { |
shoaib_ahmed | 0:791a779d6220 | 70 | /* jdmaster underestimated number of scans; ratchet up one scan */ |
shoaib_ahmed | 0:791a779d6220 | 71 | cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; |
shoaib_ahmed | 0:791a779d6220 | 72 | } |
shoaib_ahmed | 0:791a779d6220 | 73 | } |
shoaib_ahmed | 0:791a779d6220 | 74 | } |
shoaib_ahmed | 0:791a779d6220 | 75 | #else |
shoaib_ahmed | 0:791a779d6220 | 76 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
shoaib_ahmed | 0:791a779d6220 | 77 | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
shoaib_ahmed | 0:791a779d6220 | 78 | } |
shoaib_ahmed | 0:791a779d6220 | 79 | cinfo->output_scan_number = cinfo->input_scan_number; |
shoaib_ahmed | 0:791a779d6220 | 80 | } else if (cinfo->global_state != DSTATE_PRESCAN) |
shoaib_ahmed | 0:791a779d6220 | 81 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
shoaib_ahmed | 0:791a779d6220 | 82 | /* Perform any dummy output passes, and set up for the final pass */ |
shoaib_ahmed | 0:791a779d6220 | 83 | return output_pass_setup(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 84 | } |
shoaib_ahmed | 0:791a779d6220 | 85 | |
shoaib_ahmed | 0:791a779d6220 | 86 | |
shoaib_ahmed | 0:791a779d6220 | 87 | /* |
shoaib_ahmed | 0:791a779d6220 | 88 | * Set up for an output pass, and perform any dummy pass(es) needed. |
shoaib_ahmed | 0:791a779d6220 | 89 | * Common subroutine for jpeg_start_decompress and jpeg_start_output. |
shoaib_ahmed | 0:791a779d6220 | 90 | * Entry: global_state = DSTATE_PRESCAN only if previously suspended. |
shoaib_ahmed | 0:791a779d6220 | 91 | * Exit: If done, returns TRUE and sets global_state for proper output mode. |
shoaib_ahmed | 0:791a779d6220 | 92 | * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. |
shoaib_ahmed | 0:791a779d6220 | 93 | */ |
shoaib_ahmed | 0:791a779d6220 | 94 | |
shoaib_ahmed | 0:791a779d6220 | 95 | LOCAL(boolean) |
shoaib_ahmed | 0:791a779d6220 | 96 | output_pass_setup (j_decompress_ptr cinfo) |
shoaib_ahmed | 0:791a779d6220 | 97 | { |
shoaib_ahmed | 0:791a779d6220 | 98 | if (cinfo->global_state != DSTATE_PRESCAN) { |
shoaib_ahmed | 0:791a779d6220 | 99 | /* First call: do pass setup */ |
shoaib_ahmed | 0:791a779d6220 | 100 | (*cinfo->master->prepare_for_output_pass) (cinfo); |
shoaib_ahmed | 0:791a779d6220 | 101 | cinfo->output_scanline = 0; |
shoaib_ahmed | 0:791a779d6220 | 102 | cinfo->global_state = DSTATE_PRESCAN; |
shoaib_ahmed | 0:791a779d6220 | 103 | } |
shoaib_ahmed | 0:791a779d6220 | 104 | /* Loop over any required dummy passes */ |
shoaib_ahmed | 0:791a779d6220 | 105 | while (cinfo->master->is_dummy_pass) { |
shoaib_ahmed | 0:791a779d6220 | 106 | #ifdef QUANT_2PASS_SUPPORTED |
shoaib_ahmed | 0:791a779d6220 | 107 | /* Crank through the dummy pass */ |
shoaib_ahmed | 0:791a779d6220 | 108 | while (cinfo->output_scanline < cinfo->output_height) { |
shoaib_ahmed | 0:791a779d6220 | 109 | JDIMENSION last_scanline; |
shoaib_ahmed | 0:791a779d6220 | 110 | /* Call progress monitor hook if present */ |
shoaib_ahmed | 0:791a779d6220 | 111 | if (cinfo->progress != NULL) { |
shoaib_ahmed | 0:791a779d6220 | 112 | cinfo->progress->pass_counter = (long) cinfo->output_scanline; |
shoaib_ahmed | 0:791a779d6220 | 113 | cinfo->progress->pass_limit = (long) cinfo->output_height; |
shoaib_ahmed | 0:791a779d6220 | 114 | (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
shoaib_ahmed | 0:791a779d6220 | 115 | } |
shoaib_ahmed | 0:791a779d6220 | 116 | /* Process some data */ |
shoaib_ahmed | 0:791a779d6220 | 117 | last_scanline = cinfo->output_scanline; |
shoaib_ahmed | 0:791a779d6220 | 118 | (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, |
shoaib_ahmed | 0:791a779d6220 | 119 | &cinfo->output_scanline, (JDIMENSION) 0); |
shoaib_ahmed | 0:791a779d6220 | 120 | if (cinfo->output_scanline == last_scanline) |
shoaib_ahmed | 0:791a779d6220 | 121 | return FALSE; /* No progress made, must suspend */ |
shoaib_ahmed | 0:791a779d6220 | 122 | } |
shoaib_ahmed | 0:791a779d6220 | 123 | /* Finish up dummy pass, and set up for another one */ |
shoaib_ahmed | 0:791a779d6220 | 124 | (*cinfo->master->finish_output_pass) (cinfo); |
shoaib_ahmed | 0:791a779d6220 | 125 | (*cinfo->master->prepare_for_output_pass) (cinfo); |
shoaib_ahmed | 0:791a779d6220 | 126 | cinfo->output_scanline = 0; |
shoaib_ahmed | 0:791a779d6220 | 127 | #else |
shoaib_ahmed | 0:791a779d6220 | 128 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
shoaib_ahmed | 0:791a779d6220 | 129 | #endif /* QUANT_2PASS_SUPPORTED */ |
shoaib_ahmed | 0:791a779d6220 | 130 | } |
shoaib_ahmed | 0:791a779d6220 | 131 | /* Ready for application to drive output pass through |
shoaib_ahmed | 0:791a779d6220 | 132 | * jpeg_read_scanlines or jpeg_read_raw_data. |
shoaib_ahmed | 0:791a779d6220 | 133 | */ |
shoaib_ahmed | 0:791a779d6220 | 134 | cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; |
shoaib_ahmed | 0:791a779d6220 | 135 | return TRUE; |
shoaib_ahmed | 0:791a779d6220 | 136 | } |
shoaib_ahmed | 0:791a779d6220 | 137 | |
shoaib_ahmed | 0:791a779d6220 | 138 | |
shoaib_ahmed | 0:791a779d6220 | 139 | /* |
shoaib_ahmed | 0:791a779d6220 | 140 | * Read some scanlines of data from the JPEG decompressor. |
shoaib_ahmed | 0:791a779d6220 | 141 | * |
shoaib_ahmed | 0:791a779d6220 | 142 | * The return value will be the number of lines actually read. |
shoaib_ahmed | 0:791a779d6220 | 143 | * This may be less than the number requested in several cases, |
shoaib_ahmed | 0:791a779d6220 | 144 | * including bottom of image, data source suspension, and operating |
shoaib_ahmed | 0:791a779d6220 | 145 | * modes that emit multiple scanlines at a time. |
shoaib_ahmed | 0:791a779d6220 | 146 | * |
shoaib_ahmed | 0:791a779d6220 | 147 | * Note: we warn about excess calls to jpeg_read_scanlines() since |
shoaib_ahmed | 0:791a779d6220 | 148 | * this likely signals an application programmer error. However, |
shoaib_ahmed | 0:791a779d6220 | 149 | * an oversize buffer (max_lines > scanlines remaining) is not an error. |
shoaib_ahmed | 0:791a779d6220 | 150 | */ |
shoaib_ahmed | 0:791a779d6220 | 151 | |
shoaib_ahmed | 0:791a779d6220 | 152 | GLOBAL(JDIMENSION) |
shoaib_ahmed | 0:791a779d6220 | 153 | jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, |
shoaib_ahmed | 0:791a779d6220 | 154 | JDIMENSION max_lines) |
shoaib_ahmed | 0:791a779d6220 | 155 | { |
shoaib_ahmed | 0:791a779d6220 | 156 | JDIMENSION row_ctr; |
shoaib_ahmed | 0:791a779d6220 | 157 | |
shoaib_ahmed | 0:791a779d6220 | 158 | if (cinfo->global_state != DSTATE_SCANNING) |
shoaib_ahmed | 0:791a779d6220 | 159 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
shoaib_ahmed | 0:791a779d6220 | 160 | if (cinfo->output_scanline >= cinfo->output_height) { |
shoaib_ahmed | 0:791a779d6220 | 161 | WARNMS(cinfo, JWRN_TOO_MUCH_DATA); |
shoaib_ahmed | 0:791a779d6220 | 162 | return 0; |
shoaib_ahmed | 0:791a779d6220 | 163 | } |
shoaib_ahmed | 0:791a779d6220 | 164 | |
shoaib_ahmed | 0:791a779d6220 | 165 | /* Call progress monitor hook if present */ |
shoaib_ahmed | 0:791a779d6220 | 166 | if (cinfo->progress != NULL) { |
shoaib_ahmed | 0:791a779d6220 | 167 | cinfo->progress->pass_counter = (long) cinfo->output_scanline; |
shoaib_ahmed | 0:791a779d6220 | 168 | cinfo->progress->pass_limit = (long) cinfo->output_height; |
shoaib_ahmed | 0:791a779d6220 | 169 | (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
shoaib_ahmed | 0:791a779d6220 | 170 | } |
shoaib_ahmed | 0:791a779d6220 | 171 | |
shoaib_ahmed | 0:791a779d6220 | 172 | /* Process some data */ |
shoaib_ahmed | 0:791a779d6220 | 173 | row_ctr = 0; |
shoaib_ahmed | 0:791a779d6220 | 174 | (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); |
shoaib_ahmed | 0:791a779d6220 | 175 | cinfo->output_scanline += row_ctr; |
shoaib_ahmed | 0:791a779d6220 | 176 | return row_ctr; |
shoaib_ahmed | 0:791a779d6220 | 177 | } |
shoaib_ahmed | 0:791a779d6220 | 178 | |
shoaib_ahmed | 0:791a779d6220 | 179 | |
shoaib_ahmed | 0:791a779d6220 | 180 | /* |
shoaib_ahmed | 0:791a779d6220 | 181 | * Alternate entry point to read raw data. |
shoaib_ahmed | 0:791a779d6220 | 182 | * Processes exactly one iMCU row per call, unless suspended. |
shoaib_ahmed | 0:791a779d6220 | 183 | */ |
shoaib_ahmed | 0:791a779d6220 | 184 | |
shoaib_ahmed | 0:791a779d6220 | 185 | GLOBAL(JDIMENSION) |
shoaib_ahmed | 0:791a779d6220 | 186 | jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, |
shoaib_ahmed | 0:791a779d6220 | 187 | JDIMENSION max_lines) |
shoaib_ahmed | 0:791a779d6220 | 188 | { |
shoaib_ahmed | 0:791a779d6220 | 189 | JDIMENSION lines_per_iMCU_row; |
shoaib_ahmed | 0:791a779d6220 | 190 | |
shoaib_ahmed | 0:791a779d6220 | 191 | if (cinfo->global_state != DSTATE_RAW_OK) |
shoaib_ahmed | 0:791a779d6220 | 192 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
shoaib_ahmed | 0:791a779d6220 | 193 | if (cinfo->output_scanline >= cinfo->output_height) { |
shoaib_ahmed | 0:791a779d6220 | 194 | WARNMS(cinfo, JWRN_TOO_MUCH_DATA); |
shoaib_ahmed | 0:791a779d6220 | 195 | return 0; |
shoaib_ahmed | 0:791a779d6220 | 196 | } |
shoaib_ahmed | 0:791a779d6220 | 197 | |
shoaib_ahmed | 0:791a779d6220 | 198 | /* Call progress monitor hook if present */ |
shoaib_ahmed | 0:791a779d6220 | 199 | if (cinfo->progress != NULL) { |
shoaib_ahmed | 0:791a779d6220 | 200 | cinfo->progress->pass_counter = (long) cinfo->output_scanline; |
shoaib_ahmed | 0:791a779d6220 | 201 | cinfo->progress->pass_limit = (long) cinfo->output_height; |
shoaib_ahmed | 0:791a779d6220 | 202 | (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
shoaib_ahmed | 0:791a779d6220 | 203 | } |
shoaib_ahmed | 0:791a779d6220 | 204 | |
shoaib_ahmed | 0:791a779d6220 | 205 | /* Verify that at least one iMCU row can be returned. */ |
shoaib_ahmed | 0:791a779d6220 | 206 | lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size; |
shoaib_ahmed | 0:791a779d6220 | 207 | if (max_lines < lines_per_iMCU_row) |
shoaib_ahmed | 0:791a779d6220 | 208 | ERREXIT(cinfo, JERR_BUFFER_SIZE); |
shoaib_ahmed | 0:791a779d6220 | 209 | |
shoaib_ahmed | 0:791a779d6220 | 210 | /* Decompress directly into user's buffer. */ |
shoaib_ahmed | 0:791a779d6220 | 211 | if (! (*cinfo->coef->decompress_data) (cinfo, data)) |
shoaib_ahmed | 0:791a779d6220 | 212 | return 0; /* suspension forced, can do nothing more */ |
shoaib_ahmed | 0:791a779d6220 | 213 | |
shoaib_ahmed | 0:791a779d6220 | 214 | /* OK, we processed one iMCU row. */ |
shoaib_ahmed | 0:791a779d6220 | 215 | cinfo->output_scanline += lines_per_iMCU_row; |
shoaib_ahmed | 0:791a779d6220 | 216 | return lines_per_iMCU_row; |
shoaib_ahmed | 0:791a779d6220 | 217 | } |
shoaib_ahmed | 0:791a779d6220 | 218 | |
shoaib_ahmed | 0:791a779d6220 | 219 | |
shoaib_ahmed | 0:791a779d6220 | 220 | /* Additional entry points for buffered-image mode. */ |
shoaib_ahmed | 0:791a779d6220 | 221 | |
shoaib_ahmed | 0:791a779d6220 | 222 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
shoaib_ahmed | 0:791a779d6220 | 223 | |
shoaib_ahmed | 0:791a779d6220 | 224 | /* |
shoaib_ahmed | 0:791a779d6220 | 225 | * Initialize for an output pass in buffered-image mode. |
shoaib_ahmed | 0:791a779d6220 | 226 | */ |
shoaib_ahmed | 0:791a779d6220 | 227 | |
shoaib_ahmed | 0:791a779d6220 | 228 | GLOBAL(boolean) |
shoaib_ahmed | 0:791a779d6220 | 229 | jpeg_start_output (j_decompress_ptr cinfo, int scan_number) |
shoaib_ahmed | 0:791a779d6220 | 230 | { |
shoaib_ahmed | 0:791a779d6220 | 231 | if (cinfo->global_state != DSTATE_BUFIMAGE && |
shoaib_ahmed | 0:791a779d6220 | 232 | cinfo->global_state != DSTATE_PRESCAN) |
shoaib_ahmed | 0:791a779d6220 | 233 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
shoaib_ahmed | 0:791a779d6220 | 234 | /* Limit scan number to valid range */ |
shoaib_ahmed | 0:791a779d6220 | 235 | if (scan_number <= 0) |
shoaib_ahmed | 0:791a779d6220 | 236 | scan_number = 1; |
shoaib_ahmed | 0:791a779d6220 | 237 | if (cinfo->inputctl->eoi_reached && |
shoaib_ahmed | 0:791a779d6220 | 238 | scan_number > cinfo->input_scan_number) |
shoaib_ahmed | 0:791a779d6220 | 239 | scan_number = cinfo->input_scan_number; |
shoaib_ahmed | 0:791a779d6220 | 240 | cinfo->output_scan_number = scan_number; |
shoaib_ahmed | 0:791a779d6220 | 241 | /* Perform any dummy output passes, and set up for the real pass */ |
shoaib_ahmed | 0:791a779d6220 | 242 | return output_pass_setup(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 243 | } |
shoaib_ahmed | 0:791a779d6220 | 244 | |
shoaib_ahmed | 0:791a779d6220 | 245 | |
shoaib_ahmed | 0:791a779d6220 | 246 | /* |
shoaib_ahmed | 0:791a779d6220 | 247 | * Finish up after an output pass in buffered-image mode. |
shoaib_ahmed | 0:791a779d6220 | 248 | * |
shoaib_ahmed | 0:791a779d6220 | 249 | * Returns FALSE if suspended. The return value need be inspected only if |
shoaib_ahmed | 0:791a779d6220 | 250 | * a suspending data source is used. |
shoaib_ahmed | 0:791a779d6220 | 251 | */ |
shoaib_ahmed | 0:791a779d6220 | 252 | |
shoaib_ahmed | 0:791a779d6220 | 253 | GLOBAL(boolean) |
shoaib_ahmed | 0:791a779d6220 | 254 | jpeg_finish_output (j_decompress_ptr cinfo) |
shoaib_ahmed | 0:791a779d6220 | 255 | { |
shoaib_ahmed | 0:791a779d6220 | 256 | if ((cinfo->global_state == DSTATE_SCANNING || |
shoaib_ahmed | 0:791a779d6220 | 257 | cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { |
shoaib_ahmed | 0:791a779d6220 | 258 | /* Terminate this pass. */ |
shoaib_ahmed | 0:791a779d6220 | 259 | /* We do not require the whole pass to have been completed. */ |
shoaib_ahmed | 0:791a779d6220 | 260 | (*cinfo->master->finish_output_pass) (cinfo); |
shoaib_ahmed | 0:791a779d6220 | 261 | cinfo->global_state = DSTATE_BUFPOST; |
shoaib_ahmed | 0:791a779d6220 | 262 | } else if (cinfo->global_state != DSTATE_BUFPOST) { |
shoaib_ahmed | 0:791a779d6220 | 263 | /* BUFPOST = repeat call after a suspension, anything else is error */ |
shoaib_ahmed | 0:791a779d6220 | 264 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
shoaib_ahmed | 0:791a779d6220 | 265 | } |
shoaib_ahmed | 0:791a779d6220 | 266 | /* Read markers looking for SOS or EOI */ |
shoaib_ahmed | 0:791a779d6220 | 267 | while (cinfo->input_scan_number <= cinfo->output_scan_number && |
shoaib_ahmed | 0:791a779d6220 | 268 | ! cinfo->inputctl->eoi_reached) { |
shoaib_ahmed | 0:791a779d6220 | 269 | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) |
shoaib_ahmed | 0:791a779d6220 | 270 | return FALSE; /* Suspend, come back later */ |
shoaib_ahmed | 0:791a779d6220 | 271 | } |
shoaib_ahmed | 0:791a779d6220 | 272 | cinfo->global_state = DSTATE_BUFIMAGE; |
shoaib_ahmed | 0:791a779d6220 | 273 | return TRUE; |
shoaib_ahmed | 0:791a779d6220 | 274 | } |
shoaib_ahmed | 0:791a779d6220 | 275 | |
shoaib_ahmed | 0:791a779d6220 | 276 | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |