MCPcopy Create free account
hub / github.com/davisking/dlib / int_downsample

Function int_downsample

dlib/external/libjpeg/jcsample.c:150–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148 */
149
150METHODDEF(void)
151int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
152 JSAMPARRAY input_data, JSAMPARRAY output_data)
153{
154 my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
155 int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
156 JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */
157 JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size;
158 JSAMPROW inptr, outptr;
159 INT32 outvalue;
160
161 h_expand = downsample->h_expand[compptr->component_index];
162 v_expand = downsample->v_expand[compptr->component_index];
163 numpix = h_expand * v_expand;
164 numpix2 = numpix/2;
165
166 /* Expand input data enough to let all the output samples be generated
167 * by the standard loop. Special-casing padded output would be more
168 * efficient.
169 */
170 expand_right_edge(input_data, cinfo->max_v_samp_factor,
171 cinfo->image_width, output_cols * h_expand);
172
173 inrow = outrow = 0;
174 while (inrow < cinfo->max_v_samp_factor) {
175 outptr = output_data[outrow];
176 for (outcol = 0, outcol_h = 0; outcol < output_cols;
177 outcol++, outcol_h += h_expand) {
178 outvalue = 0;
179 for (v = 0; v < v_expand; v++) {
180 inptr = input_data[inrow+v] + outcol_h;
181 for (h = 0; h < h_expand; h++) {
182 outvalue += (INT32) GETJSAMPLE(*inptr++);
183 }
184 }
185 *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);
186 }
187 inrow += v_expand;
188 outrow++;
189 }
190}
191
192
193/*

Callers

nothing calls this directly

Calls 1

expand_right_edgeFunction · 0.85

Tested by

no test coverage detected