/* At present, jcsample.c can request context rows only for smoothing. *Inthefuture,wemightalsoneedcontextrowsforCCIR601sampling *orothermore-complexdownsamplingprocedures.Thecodetosupport *contextrowsshouldbecompiledonlyifneeded.
*/ #ifdef INPUT_SMOOTHING_SUPPORTED #define CONTEXT_ROWS_SUPPORTED #endif
typedefstruct { struct jpeg_c_prep_controller pub; /* public fields */
/* Downsampling input buffer. This buffer holds color-converted data *untilwehaveenoughtodoadownsamplestep.
*/
_JSAMPARRAY color_buf[MAX_COMPONENTS];
JDIMENSION rows_to_go; /* counts rows remaining in source image */ int next_buf_row; /* index of next row to store in color_buf */
#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ int this_row_group; /* starting row index of group to process */ int next_buf_stop; /* downsample when we reach this index */ #endif
} my_prep_controller;
if (pass_mode != JBUF_PASS_THRU)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
/* Initialize total-height counter for detecting bottom of image */
prep->rows_to_go = cinfo->image_height; /* Mark the conversion buffer empty */
prep->next_buf_row = 0; #ifdef CONTEXT_ROWS_SUPPORTED /* Preset additional state variables for context mode. *Thesearen'tusedinnon-contextmode,soweneedn'ttestwhichmode.
*/
prep->this_row_group = 0; /* Set next_buf_stop to stop after two row groups have been read in. */
prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; #endif
}
while (*out_row_group_ctr < out_row_groups_avail) { if (*in_row_ctr < in_rows_avail) { /* Do color conversion to fill the conversion buffer. */
inrows = in_rows_avail - *in_row_ctr;
numrows = prep->next_buf_stop - prep->next_buf_row;
numrows = (int)MIN((JDIMENSION)numrows, inrows);
(*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
prep->color_buf,
(JDIMENSION)prep->next_buf_row,
numrows); /* Pad at top of image, if first time through */ if (prep->rows_to_go == cinfo->image_height) { for (ci = 0; ci < cinfo->num_components; ci++) { int row; for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
_jcopy_sample_rows(prep->color_buf[ci], 0, prep->color_buf[ci],
-row, 1, cinfo->image_width);
}
}
}
*in_row_ctr += numrows;
prep->next_buf_row += numrows;
prep->rows_to_go -= numrows;
} else { /* Return for more data, unless we are at the bottom of the image. */ if (prep->rows_to_go != 0) break; /* When at bottom of image, pad to fill the conversion buffer. */ if (prep->next_buf_row < prep->next_buf_stop) { for (ci = 0; ci < cinfo->num_components; ci++) {
expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
prep->next_buf_row, prep->next_buf_stop);
}
prep->next_buf_row = prep->next_buf_stop;
}
} /* If we've gotten enough data, downsample a row group. */ if (prep->next_buf_row == prep->next_buf_stop) {
(*cinfo->downsample->_downsample) (cinfo, prep->color_buf,
(JDIMENSION)prep->this_row_group,
output_buf, *out_row_group_ctr);
(*out_row_group_ctr)++; /* Advance pointers with wraparound as necessary. */
prep->this_row_group += cinfo->max_v_samp_factor; if (prep->this_row_group >= buf_height)
prep->this_row_group = 0; if (prep->next_buf_row >= buf_height)
prep->next_buf_row = 0;
prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor;
}
}
}
/* Allocate the color conversion buffer. *Wemakethebufferwideenoughtoallowthedownsamplertoedge-expand *horizontallywithinthebuffer,ifitsochooses.
*/ if (cinfo->downsample->need_context_rows) { /* Set up to provide context rows */ #ifdef CONTEXT_ROWS_SUPPORTED
prep->pub._pre_process_data = pre_process_context;
create_context_buffer(cinfo); #else
ERREXIT(cinfo, JERR_NOT_COMPILED); #endif
} else { /* No context, just make it tall enough for one row group */
prep->pub._pre_process_data = pre_process_data; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
(JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
cinfo->max_h_samp_factor) / compptr->h_samp_factor),
(JDIMENSION)cinfo->max_v_samp_factor);
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.