Final 350 project

Dependencies:   uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed

Committer:
shoaib_ahmed
Date:
Mon Jul 31 09:16:35 2017 +0000
Revision:
0:791a779d6220
final project;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shoaib_ahmed 0:791a779d6220 1 /*
shoaib_ahmed 0:791a779d6220 2 * jcmainct.c
shoaib_ahmed 0:791a779d6220 3 *
shoaib_ahmed 0:791a779d6220 4 * Copyright (C) 1994-1996, Thomas G. Lane.
shoaib_ahmed 0:791a779d6220 5 * Modified 2003-2012 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 the main buffer controller for compression.
shoaib_ahmed 0:791a779d6220 10 * The main buffer lies between the pre-processor and the JPEG
shoaib_ahmed 0:791a779d6220 11 * compressor proper; it holds downsampled data in the JPEG colorspace.
shoaib_ahmed 0:791a779d6220 12 */
shoaib_ahmed 0:791a779d6220 13
shoaib_ahmed 0:791a779d6220 14 #define JPEG_INTERNALS
shoaib_ahmed 0:791a779d6220 15 #include "jinclude.h"
shoaib_ahmed 0:791a779d6220 16 #include "jpeglib.h"
shoaib_ahmed 0:791a779d6220 17
shoaib_ahmed 0:791a779d6220 18
shoaib_ahmed 0:791a779d6220 19 /* Note: currently, there is no operating mode in which a full-image buffer
shoaib_ahmed 0:791a779d6220 20 * is needed at this step. If there were, that mode could not be used with
shoaib_ahmed 0:791a779d6220 21 * "raw data" input, since this module is bypassed in that case. However,
shoaib_ahmed 0:791a779d6220 22 * we've left the code here for possible use in special applications.
shoaib_ahmed 0:791a779d6220 23 */
shoaib_ahmed 0:791a779d6220 24 #undef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 25
shoaib_ahmed 0:791a779d6220 26
shoaib_ahmed 0:791a779d6220 27 /* Private buffer controller object */
shoaib_ahmed 0:791a779d6220 28
shoaib_ahmed 0:791a779d6220 29 typedef struct {
shoaib_ahmed 0:791a779d6220 30 struct jpeg_c_main_controller pub; /* public fields */
shoaib_ahmed 0:791a779d6220 31
shoaib_ahmed 0:791a779d6220 32 JDIMENSION cur_iMCU_row; /* number of current iMCU row */
shoaib_ahmed 0:791a779d6220 33 JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */
shoaib_ahmed 0:791a779d6220 34 boolean suspended; /* remember if we suspended output */
shoaib_ahmed 0:791a779d6220 35 J_BUF_MODE pass_mode; /* current operating mode */
shoaib_ahmed 0:791a779d6220 36
shoaib_ahmed 0:791a779d6220 37 /* If using just a strip buffer, this points to the entire set of buffers
shoaib_ahmed 0:791a779d6220 38 * (we allocate one for each component). In the full-image case, this
shoaib_ahmed 0:791a779d6220 39 * points to the currently accessible strips of the virtual arrays.
shoaib_ahmed 0:791a779d6220 40 */
shoaib_ahmed 0:791a779d6220 41 JSAMPARRAY buffer[MAX_COMPONENTS];
shoaib_ahmed 0:791a779d6220 42
shoaib_ahmed 0:791a779d6220 43 #ifdef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 44 /* If using full-image storage, this array holds pointers to virtual-array
shoaib_ahmed 0:791a779d6220 45 * control blocks for each component. Unused if not full-image storage.
shoaib_ahmed 0:791a779d6220 46 */
shoaib_ahmed 0:791a779d6220 47 jvirt_sarray_ptr whole_image[MAX_COMPONENTS];
shoaib_ahmed 0:791a779d6220 48 #endif
shoaib_ahmed 0:791a779d6220 49 } my_main_controller;
shoaib_ahmed 0:791a779d6220 50
shoaib_ahmed 0:791a779d6220 51 typedef my_main_controller * my_main_ptr;
shoaib_ahmed 0:791a779d6220 52
shoaib_ahmed 0:791a779d6220 53
shoaib_ahmed 0:791a779d6220 54 /* Forward declarations */
shoaib_ahmed 0:791a779d6220 55 METHODDEF(void) process_data_simple_main
shoaib_ahmed 0:791a779d6220 56 JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,
shoaib_ahmed 0:791a779d6220 57 JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));
shoaib_ahmed 0:791a779d6220 58 #ifdef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 59 METHODDEF(void) process_data_buffer_main
shoaib_ahmed 0:791a779d6220 60 JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,
shoaib_ahmed 0:791a779d6220 61 JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));
shoaib_ahmed 0:791a779d6220 62 #endif
shoaib_ahmed 0:791a779d6220 63
shoaib_ahmed 0:791a779d6220 64
shoaib_ahmed 0:791a779d6220 65 /*
shoaib_ahmed 0:791a779d6220 66 * Initialize for a processing pass.
shoaib_ahmed 0:791a779d6220 67 */
shoaib_ahmed 0:791a779d6220 68
shoaib_ahmed 0:791a779d6220 69 METHODDEF(void)
shoaib_ahmed 0:791a779d6220 70 start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
shoaib_ahmed 0:791a779d6220 71 {
shoaib_ahmed 0:791a779d6220 72 my_main_ptr mainp = (my_main_ptr) cinfo->main;
shoaib_ahmed 0:791a779d6220 73
shoaib_ahmed 0:791a779d6220 74 /* Do nothing in raw-data mode. */
shoaib_ahmed 0:791a779d6220 75 if (cinfo->raw_data_in)
shoaib_ahmed 0:791a779d6220 76 return;
shoaib_ahmed 0:791a779d6220 77
shoaib_ahmed 0:791a779d6220 78 mainp->cur_iMCU_row = 0; /* initialize counters */
shoaib_ahmed 0:791a779d6220 79 mainp->rowgroup_ctr = 0;
shoaib_ahmed 0:791a779d6220 80 mainp->suspended = FALSE;
shoaib_ahmed 0:791a779d6220 81 mainp->pass_mode = pass_mode; /* save mode for use by process_data */
shoaib_ahmed 0:791a779d6220 82
shoaib_ahmed 0:791a779d6220 83 switch (pass_mode) {
shoaib_ahmed 0:791a779d6220 84 case JBUF_PASS_THRU:
shoaib_ahmed 0:791a779d6220 85 #ifdef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 86 if (mainp->whole_image[0] != NULL)
shoaib_ahmed 0:791a779d6220 87 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
shoaib_ahmed 0:791a779d6220 88 #endif
shoaib_ahmed 0:791a779d6220 89 mainp->pub.process_data = process_data_simple_main;
shoaib_ahmed 0:791a779d6220 90 break;
shoaib_ahmed 0:791a779d6220 91 #ifdef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 92 case JBUF_SAVE_SOURCE:
shoaib_ahmed 0:791a779d6220 93 case JBUF_CRANK_DEST:
shoaib_ahmed 0:791a779d6220 94 case JBUF_SAVE_AND_PASS:
shoaib_ahmed 0:791a779d6220 95 if (mainp->whole_image[0] == NULL)
shoaib_ahmed 0:791a779d6220 96 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
shoaib_ahmed 0:791a779d6220 97 mainp->pub.process_data = process_data_buffer_main;
shoaib_ahmed 0:791a779d6220 98 break;
shoaib_ahmed 0:791a779d6220 99 #endif
shoaib_ahmed 0:791a779d6220 100 default:
shoaib_ahmed 0:791a779d6220 101 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
shoaib_ahmed 0:791a779d6220 102 break;
shoaib_ahmed 0:791a779d6220 103 }
shoaib_ahmed 0:791a779d6220 104 }
shoaib_ahmed 0:791a779d6220 105
shoaib_ahmed 0:791a779d6220 106
shoaib_ahmed 0:791a779d6220 107 /*
shoaib_ahmed 0:791a779d6220 108 * Process some data.
shoaib_ahmed 0:791a779d6220 109 * This routine handles the simple pass-through mode,
shoaib_ahmed 0:791a779d6220 110 * where we have only a strip buffer.
shoaib_ahmed 0:791a779d6220 111 */
shoaib_ahmed 0:791a779d6220 112
shoaib_ahmed 0:791a779d6220 113 METHODDEF(void)
shoaib_ahmed 0:791a779d6220 114 process_data_simple_main (j_compress_ptr cinfo,
shoaib_ahmed 0:791a779d6220 115 JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
shoaib_ahmed 0:791a779d6220 116 JDIMENSION in_rows_avail)
shoaib_ahmed 0:791a779d6220 117 {
shoaib_ahmed 0:791a779d6220 118 my_main_ptr mainp = (my_main_ptr) cinfo->main;
shoaib_ahmed 0:791a779d6220 119
shoaib_ahmed 0:791a779d6220 120 while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) {
shoaib_ahmed 0:791a779d6220 121 /* Read input data if we haven't filled the main buffer yet */
shoaib_ahmed 0:791a779d6220 122 if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
shoaib_ahmed 0:791a779d6220 123 (*cinfo->prep->pre_process_data) (cinfo,
shoaib_ahmed 0:791a779d6220 124 input_buf, in_row_ctr, in_rows_avail,
shoaib_ahmed 0:791a779d6220 125 mainp->buffer, &mainp->rowgroup_ctr,
shoaib_ahmed 0:791a779d6220 126 (JDIMENSION) cinfo->min_DCT_v_scaled_size);
shoaib_ahmed 0:791a779d6220 127
shoaib_ahmed 0:791a779d6220 128 /* If we don't have a full iMCU row buffered, return to application for
shoaib_ahmed 0:791a779d6220 129 * more data. Note that preprocessor will always pad to fill the iMCU row
shoaib_ahmed 0:791a779d6220 130 * at the bottom of the image.
shoaib_ahmed 0:791a779d6220 131 */
shoaib_ahmed 0:791a779d6220 132 if (mainp->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size)
shoaib_ahmed 0:791a779d6220 133 return;
shoaib_ahmed 0:791a779d6220 134
shoaib_ahmed 0:791a779d6220 135 /* Send the completed row to the compressor */
shoaib_ahmed 0:791a779d6220 136 if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) {
shoaib_ahmed 0:791a779d6220 137 /* If compressor did not consume the whole row, then we must need to
shoaib_ahmed 0:791a779d6220 138 * suspend processing and return to the application. In this situation
shoaib_ahmed 0:791a779d6220 139 * we pretend we didn't yet consume the last input row; otherwise, if
shoaib_ahmed 0:791a779d6220 140 * it happened to be the last row of the image, the application would
shoaib_ahmed 0:791a779d6220 141 * think we were done.
shoaib_ahmed 0:791a779d6220 142 */
shoaib_ahmed 0:791a779d6220 143 if (! mainp->suspended) {
shoaib_ahmed 0:791a779d6220 144 (*in_row_ctr)--;
shoaib_ahmed 0:791a779d6220 145 mainp->suspended = TRUE;
shoaib_ahmed 0:791a779d6220 146 }
shoaib_ahmed 0:791a779d6220 147 return;
shoaib_ahmed 0:791a779d6220 148 }
shoaib_ahmed 0:791a779d6220 149 /* We did finish the row. Undo our little suspension hack if a previous
shoaib_ahmed 0:791a779d6220 150 * call suspended; then mark the main buffer empty.
shoaib_ahmed 0:791a779d6220 151 */
shoaib_ahmed 0:791a779d6220 152 if (mainp->suspended) {
shoaib_ahmed 0:791a779d6220 153 (*in_row_ctr)++;
shoaib_ahmed 0:791a779d6220 154 mainp->suspended = FALSE;
shoaib_ahmed 0:791a779d6220 155 }
shoaib_ahmed 0:791a779d6220 156 mainp->rowgroup_ctr = 0;
shoaib_ahmed 0:791a779d6220 157 mainp->cur_iMCU_row++;
shoaib_ahmed 0:791a779d6220 158 }
shoaib_ahmed 0:791a779d6220 159 }
shoaib_ahmed 0:791a779d6220 160
shoaib_ahmed 0:791a779d6220 161
shoaib_ahmed 0:791a779d6220 162 #ifdef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 163
shoaib_ahmed 0:791a779d6220 164 /*
shoaib_ahmed 0:791a779d6220 165 * Process some data.
shoaib_ahmed 0:791a779d6220 166 * This routine handles all of the modes that use a full-size buffer.
shoaib_ahmed 0:791a779d6220 167 */
shoaib_ahmed 0:791a779d6220 168
shoaib_ahmed 0:791a779d6220 169 METHODDEF(void)
shoaib_ahmed 0:791a779d6220 170 process_data_buffer_main (j_compress_ptr cinfo,
shoaib_ahmed 0:791a779d6220 171 JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
shoaib_ahmed 0:791a779d6220 172 JDIMENSION in_rows_avail)
shoaib_ahmed 0:791a779d6220 173 {
shoaib_ahmed 0:791a779d6220 174 my_main_ptr mainp = (my_main_ptr) cinfo->main;
shoaib_ahmed 0:791a779d6220 175 int ci;
shoaib_ahmed 0:791a779d6220 176 jpeg_component_info *compptr;
shoaib_ahmed 0:791a779d6220 177 boolean writing = (mainp->pass_mode != JBUF_CRANK_DEST);
shoaib_ahmed 0:791a779d6220 178
shoaib_ahmed 0:791a779d6220 179 while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) {
shoaib_ahmed 0:791a779d6220 180 /* Realign the virtual buffers if at the start of an iMCU row. */
shoaib_ahmed 0:791a779d6220 181 if (mainp->rowgroup_ctr == 0) {
shoaib_ahmed 0:791a779d6220 182 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
shoaib_ahmed 0:791a779d6220 183 ci++, compptr++) {
shoaib_ahmed 0:791a779d6220 184 mainp->buffer[ci] = (*cinfo->mem->access_virt_sarray)
shoaib_ahmed 0:791a779d6220 185 ((j_common_ptr) cinfo, mainp->whole_image[ci], mainp->cur_iMCU_row *
shoaib_ahmed 0:791a779d6220 186 ((JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size)),
shoaib_ahmed 0:791a779d6220 187 (JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size),
shoaib_ahmed 0:791a779d6220 188 writing);
shoaib_ahmed 0:791a779d6220 189 }
shoaib_ahmed 0:791a779d6220 190 /* In a read pass, pretend we just read some source data. */
shoaib_ahmed 0:791a779d6220 191 if (! writing) {
shoaib_ahmed 0:791a779d6220 192 *in_row_ctr += (JDIMENSION)
shoaib_ahmed 0:791a779d6220 193 (cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size);
shoaib_ahmed 0:791a779d6220 194 mainp->rowgroup_ctr = (JDIMENSION) cinfo->min_DCT_v_scaled_size;
shoaib_ahmed 0:791a779d6220 195 }
shoaib_ahmed 0:791a779d6220 196 }
shoaib_ahmed 0:791a779d6220 197
shoaib_ahmed 0:791a779d6220 198 /* If a write pass, read input data until the current iMCU row is full. */
shoaib_ahmed 0:791a779d6220 199 /* Note: preprocessor will pad if necessary to fill the last iMCU row. */
shoaib_ahmed 0:791a779d6220 200 if (writing) {
shoaib_ahmed 0:791a779d6220 201 (*cinfo->prep->pre_process_data) (cinfo,
shoaib_ahmed 0:791a779d6220 202 input_buf, in_row_ctr, in_rows_avail,
shoaib_ahmed 0:791a779d6220 203 mainp->buffer, &mainp->rowgroup_ctr,
shoaib_ahmed 0:791a779d6220 204 (JDIMENSION) cinfo->min_DCT_v_scaled_size);
shoaib_ahmed 0:791a779d6220 205 /* Return to application if we need more data to fill the iMCU row. */
shoaib_ahmed 0:791a779d6220 206 if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
shoaib_ahmed 0:791a779d6220 207 return;
shoaib_ahmed 0:791a779d6220 208 }
shoaib_ahmed 0:791a779d6220 209
shoaib_ahmed 0:791a779d6220 210 /* Emit data, unless this is a sink-only pass. */
shoaib_ahmed 0:791a779d6220 211 if (mainp->pass_mode != JBUF_SAVE_SOURCE) {
shoaib_ahmed 0:791a779d6220 212 if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) {
shoaib_ahmed 0:791a779d6220 213 /* If compressor did not consume the whole row, then we must need to
shoaib_ahmed 0:791a779d6220 214 * suspend processing and return to the application. In this situation
shoaib_ahmed 0:791a779d6220 215 * we pretend we didn't yet consume the last input row; otherwise, if
shoaib_ahmed 0:791a779d6220 216 * it happened to be the last row of the image, the application would
shoaib_ahmed 0:791a779d6220 217 * think we were done.
shoaib_ahmed 0:791a779d6220 218 */
shoaib_ahmed 0:791a779d6220 219 if (! mainp->suspended) {
shoaib_ahmed 0:791a779d6220 220 (*in_row_ctr)--;
shoaib_ahmed 0:791a779d6220 221 mainp->suspended = TRUE;
shoaib_ahmed 0:791a779d6220 222 }
shoaib_ahmed 0:791a779d6220 223 return;
shoaib_ahmed 0:791a779d6220 224 }
shoaib_ahmed 0:791a779d6220 225 /* We did finish the row. Undo our little suspension hack if a previous
shoaib_ahmed 0:791a779d6220 226 * call suspended; then mark the main buffer empty.
shoaib_ahmed 0:791a779d6220 227 */
shoaib_ahmed 0:791a779d6220 228 if (mainp->suspended) {
shoaib_ahmed 0:791a779d6220 229 (*in_row_ctr)++;
shoaib_ahmed 0:791a779d6220 230 mainp->suspended = FALSE;
shoaib_ahmed 0:791a779d6220 231 }
shoaib_ahmed 0:791a779d6220 232 }
shoaib_ahmed 0:791a779d6220 233
shoaib_ahmed 0:791a779d6220 234 /* If get here, we are done with this iMCU row. Mark buffer empty. */
shoaib_ahmed 0:791a779d6220 235 mainp->rowgroup_ctr = 0;
shoaib_ahmed 0:791a779d6220 236 mainp->cur_iMCU_row++;
shoaib_ahmed 0:791a779d6220 237 }
shoaib_ahmed 0:791a779d6220 238 }
shoaib_ahmed 0:791a779d6220 239
shoaib_ahmed 0:791a779d6220 240 #endif /* FULL_MAIN_BUFFER_SUPPORTED */
shoaib_ahmed 0:791a779d6220 241
shoaib_ahmed 0:791a779d6220 242
shoaib_ahmed 0:791a779d6220 243 /*
shoaib_ahmed 0:791a779d6220 244 * Initialize main buffer controller.
shoaib_ahmed 0:791a779d6220 245 */
shoaib_ahmed 0:791a779d6220 246
shoaib_ahmed 0:791a779d6220 247 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 248 jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
shoaib_ahmed 0:791a779d6220 249 {
shoaib_ahmed 0:791a779d6220 250 my_main_ptr mainp;
shoaib_ahmed 0:791a779d6220 251 int ci;
shoaib_ahmed 0:791a779d6220 252 jpeg_component_info *compptr;
shoaib_ahmed 0:791a779d6220 253
shoaib_ahmed 0:791a779d6220 254 mainp = (my_main_ptr)
shoaib_ahmed 0:791a779d6220 255 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
shoaib_ahmed 0:791a779d6220 256 SIZEOF(my_main_controller));
shoaib_ahmed 0:791a779d6220 257 cinfo->main = &mainp->pub;
shoaib_ahmed 0:791a779d6220 258 mainp->pub.start_pass = start_pass_main;
shoaib_ahmed 0:791a779d6220 259
shoaib_ahmed 0:791a779d6220 260 /* We don't need to create a buffer in raw-data mode. */
shoaib_ahmed 0:791a779d6220 261 if (cinfo->raw_data_in)
shoaib_ahmed 0:791a779d6220 262 return;
shoaib_ahmed 0:791a779d6220 263
shoaib_ahmed 0:791a779d6220 264 /* Create the buffer. It holds downsampled data, so each component
shoaib_ahmed 0:791a779d6220 265 * may be of a different size.
shoaib_ahmed 0:791a779d6220 266 */
shoaib_ahmed 0:791a779d6220 267 if (need_full_buffer) {
shoaib_ahmed 0:791a779d6220 268 #ifdef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 269 /* Allocate a full-image virtual array for each component */
shoaib_ahmed 0:791a779d6220 270 /* Note we pad the bottom to a multiple of the iMCU height */
shoaib_ahmed 0:791a779d6220 271 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
shoaib_ahmed 0:791a779d6220 272 ci++, compptr++) {
shoaib_ahmed 0:791a779d6220 273 mainp->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
shoaib_ahmed 0:791a779d6220 274 ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
shoaib_ahmed 0:791a779d6220 275 compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
shoaib_ahmed 0:791a779d6220 276 ((JDIMENSION) jround_up((long) compptr->height_in_blocks,
shoaib_ahmed 0:791a779d6220 277 (long) compptr->v_samp_factor)) *
shoaib_ahmed 0:791a779d6220 278 ((JDIMENSION) cinfo->min_DCT_v_scaled_size),
shoaib_ahmed 0:791a779d6220 279 (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
shoaib_ahmed 0:791a779d6220 280 }
shoaib_ahmed 0:791a779d6220 281 #else
shoaib_ahmed 0:791a779d6220 282 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
shoaib_ahmed 0:791a779d6220 283 #endif
shoaib_ahmed 0:791a779d6220 284 } else {
shoaib_ahmed 0:791a779d6220 285 #ifdef FULL_MAIN_BUFFER_SUPPORTED
shoaib_ahmed 0:791a779d6220 286 mainp->whole_image[0] = NULL; /* flag for no virtual arrays */
shoaib_ahmed 0:791a779d6220 287 #endif
shoaib_ahmed 0:791a779d6220 288 /* Allocate a strip buffer for each component */
shoaib_ahmed 0:791a779d6220 289 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
shoaib_ahmed 0:791a779d6220 290 ci++, compptr++) {
shoaib_ahmed 0:791a779d6220 291 mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
shoaib_ahmed 0:791a779d6220 292 ((j_common_ptr) cinfo, JPOOL_IMAGE,
shoaib_ahmed 0:791a779d6220 293 compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
shoaib_ahmed 0:791a779d6220 294 (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
shoaib_ahmed 0:791a779d6220 295 }
shoaib_ahmed 0:791a779d6220 296 }
shoaib_ahmed 0:791a779d6220 297 }