| OLD | NEW |
| 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.ijg |
| 7 * file. |
| 7 * | 8 * |
| 8 * This file contains application interface code for the compression half | 9 * This file contains application interface code for the compression half |
| 9 * of the JPEG library. These are the "standard" API routines that are | 10 * 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 | 11 * used in the normal full-compression case. They are not used by a |
| 11 * transcoding-only application. Note that if an application links in | 12 * transcoding-only application. Note that if an application links in |
| 12 * jpeg_start_compress, it will end up linking in the entire compressor. | 13 * 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 | 14 * We thus must separate this file from jcapimin.c to avoid linking the |
| 14 * whole compression library into a transcoder. | 15 * whole compression library into a transcoder. |
| 15 */ | 16 */ |
| 16 | 17 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 * wrong thing. | 35 * wrong thing. |
| 35 */ | 36 */ |
| 36 | 37 |
| 37 GLOBAL(void) | 38 GLOBAL(void) |
| 38 jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) | 39 jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) |
| 39 { | 40 { |
| 40 if (cinfo->global_state != CSTATE_START) | 41 if (cinfo->global_state != CSTATE_START) |
| 41 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); | 42 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
| 42 | 43 |
| 43 if (write_all_tables) | 44 if (write_all_tables) |
| 44 jpeg_suppress_tables(cinfo, FALSE);»/* mark all tables to be written */ | 45 jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ |
| 45 | 46 |
| 46 /* (Re)initialize error mgr and destination modules */ | 47 /* (Re)initialize error mgr and destination modules */ |
| 47 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); | 48 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); |
| 48 (*cinfo->dest->init_destination) (cinfo); | 49 (*cinfo->dest->init_destination) (cinfo); |
| 49 /* Perform master selection of active modules */ | 50 /* Perform master selection of active modules */ |
| 50 jinit_compress_master(cinfo); | 51 jinit_compress_master(cinfo); |
| 51 /* Set up for the first pass */ | 52 /* Set up for the first pass */ |
| 52 (*cinfo->master->prepare_for_pass) (cinfo); | 53 (*cinfo->master->prepare_for_pass) (cinfo); |
| 53 /* Ready for application to drive first pass through jpeg_write_scanlines | 54 /* Ready for application to drive first pass through jpeg_write_scanlines |
| 54 * or jpeg_write_raw_data. | 55 * or jpeg_write_raw_data. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 68 * | 69 * |
| 69 * Note: we warn about excess calls to jpeg_write_scanlines() since | 70 * Note: we warn about excess calls to jpeg_write_scanlines() since |
| 70 * this likely signals an application programmer error. However, | 71 * this likely signals an application programmer error. However, |
| 71 * excess scanlines passed in the last valid call are *silently* ignored, | 72 * 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 | 73 * so that the application need not adjust num_lines for end-of-image |
| 73 * when using a multiple-scanline buffer. | 74 * when using a multiple-scanline buffer. |
| 74 */ | 75 */ |
| 75 | 76 |
| 76 GLOBAL(JDIMENSION) | 77 GLOBAL(JDIMENSION) |
| 77 jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, | 78 jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, |
| 78 » » JDIMENSION num_lines) | 79 JDIMENSION num_lines) |
| 79 { | 80 { |
| 80 JDIMENSION row_ctr, rows_left; | 81 JDIMENSION row_ctr, rows_left; |
| 81 | 82 |
| 82 if (cinfo->global_state != CSTATE_SCANNING) | 83 if (cinfo->global_state != CSTATE_SCANNING) |
| 83 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); | 84 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
| 84 if (cinfo->next_scanline >= cinfo->image_height) | 85 if (cinfo->next_scanline >= cinfo->image_height) |
| 85 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); | 86 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); |
| 86 | 87 |
| 87 /* Call progress monitor hook if present */ | 88 /* Call progress monitor hook if present */ |
| 88 if (cinfo->progress != NULL) { | 89 if (cinfo->progress != NULL) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 111 } | 112 } |
| 112 | 113 |
| 113 | 114 |
| 114 /* | 115 /* |
| 115 * Alternate entry point to write raw data. | 116 * Alternate entry point to write raw data. |
| 116 * Processes exactly one iMCU row per call, unless suspended. | 117 * Processes exactly one iMCU row per call, unless suspended. |
| 117 */ | 118 */ |
| 118 | 119 |
| 119 GLOBAL(JDIMENSION) | 120 GLOBAL(JDIMENSION) |
| 120 jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, | 121 jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, |
| 121 » » JDIMENSION num_lines) | 122 JDIMENSION num_lines) |
| 122 { | 123 { |
| 123 JDIMENSION lines_per_iMCU_row; | 124 JDIMENSION lines_per_iMCU_row; |
| 124 | 125 |
| 125 if (cinfo->global_state != CSTATE_RAW_OK) | 126 if (cinfo->global_state != CSTATE_RAW_OK) |
| 126 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); | 127 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
| 127 if (cinfo->next_scanline >= cinfo->image_height) { | 128 if (cinfo->next_scanline >= cinfo->image_height) { |
| 128 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); | 129 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); |
| 129 return 0; | 130 return 0; |
| 130 } | 131 } |
| 131 | 132 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 152 /* Directly compress the row. */ | 153 /* Directly compress the row. */ |
| 153 if (! (*cinfo->coef->compress_data) (cinfo, data)) { | 154 if (! (*cinfo->coef->compress_data) (cinfo, data)) { |
| 154 /* If compressor did not consume the whole row, suspend processing. */ | 155 /* If compressor did not consume the whole row, suspend processing. */ |
| 155 return 0; | 156 return 0; |
| 156 } | 157 } |
| 157 | 158 |
| 158 /* OK, we processed one iMCU row. */ | 159 /* OK, we processed one iMCU row. */ |
| 159 cinfo->next_scanline += lines_per_iMCU_row; | 160 cinfo->next_scanline += lines_per_iMCU_row; |
| 160 return lines_per_iMCU_row; | 161 return lines_per_iMCU_row; |
| 161 } | 162 } |
| OLD | NEW |