ReactOS 0.4.16-dev-340-g0540c21
jdsample.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jdsample.c:

Go to the source code of this file.

Classes

struct  my_upsampler
 

Macros

#define JPEG_INTERNALS
 

Typedefs

typedef my_upsamplermy_upsample_ptr
 

Functions

typedef JMETHOD (void, upsample1_ptr,(j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr))
 
 start_pass_upsample (j_decompress_ptr cinfo)
 
 sep_upsample (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
 
 fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
 
 noop_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
 
 int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
 
 h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
 
 h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
 
 jinit_upsampler (j_decompress_ptr cinfo)
 

Macro Definition Documentation

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 22 of file jdsample.c.

Typedef Documentation

◆ my_upsample_ptr

Definition at line 62 of file jdsample.c.

Function Documentation

◆ fullsize_upsample()

fullsize_upsample ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY output_data_ptr 
)

Definition at line 158 of file jdsample.c.

160{
161 *output_data_ptr = input_data;
162}

Referenced by jinit_upsampler().

◆ h2v1_upsample()

h2v1_upsample ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY output_data_ptr 
)

Definition at line 234 of file jdsample.c.

236{
237 JSAMPARRAY output_data = *output_data_ptr;
238 register JSAMPROW inptr, outptr;
239 register JSAMPLE invalue;
240 JSAMPROW outend;
241 int outrow;
242
243 for (outrow = 0; outrow < cinfo->max_v_samp_factor; outrow++) {
244 inptr = input_data[outrow];
245 outptr = output_data[outrow];
246 outend = outptr + cinfo->output_width;
247 while (outptr < outend) {
248 invalue = *inptr++; /* don't need GETJSAMPLE() here */
249 *outptr++ = invalue;
250 *outptr++ = invalue;
251 }
252 }
253}
char JSAMPLE
Definition: jmorecfg.h:74
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:76
JSAMPLE FAR * JSAMPROW
Definition: jpeglib.h:75
JDIMENSION output_width
Definition: jpeglib.h:507

Referenced by jinit_upsampler().

◆ h2v2_upsample()

h2v2_upsample ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY output_data_ptr 
)

Definition at line 262 of file jdsample.c.

264{
265 JSAMPARRAY output_data = *output_data_ptr;
266 register JSAMPROW inptr, outptr;
267 register JSAMPLE invalue;
268 JSAMPROW outend;
269 int inrow, outrow;
270
271 inrow = outrow = 0;
272 while (outrow < cinfo->max_v_samp_factor) {
273 inptr = input_data[inrow];
274 outptr = output_data[outrow];
275 outend = outptr + cinfo->output_width;
276 while (outptr < outend) {
277 invalue = *inptr++; /* don't need GETJSAMPLE() here */
278 *outptr++ = invalue;
279 *outptr++ = invalue;
280 }
281 jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
282 1, cinfo->output_width);
283 inrow++;
284 outrow += 2;
285 }
286}
jcopy_sample_rows(JSAMPARRAY input_array, int source_row, JSAMPARRAY output_array, int dest_row, int num_rows, JDIMENSION num_cols)
Definition: jutils.c:177

Referenced by jinit_upsampler().

◆ int_upsample()

int_upsample ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY output_data_ptr 
)

Definition at line 190 of file jdsample.c.

192{
193 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
194 JSAMPARRAY output_data = *output_data_ptr;
195 register JSAMPROW inptr, outptr;
196 register JSAMPLE invalue;
197 register int h;
198 JSAMPROW outend;
199 int h_expand, v_expand;
200 int inrow, outrow;
201
202 h_expand = upsample->h_expand[compptr->component_index];
203 v_expand = upsample->v_expand[compptr->component_index];
204
205 inrow = outrow = 0;
206 while (outrow < cinfo->max_v_samp_factor) {
207 /* Generate one output row with proper horizontal expansion */
208 inptr = input_data[inrow];
209 outptr = output_data[outrow];
210 outend = outptr + cinfo->output_width;
211 while (outptr < outend) {
212 invalue = *inptr++; /* don't need GETJSAMPLE() here */
213 for (h = h_expand; h > 0; h--) {
214 *outptr++ = invalue;
215 }
216 }
217 /* Generate any additional output rows by duplicating the first one */
218 if (v_expand > 1) {
219 jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
220 v_expand-1, cinfo->output_width);
221 }
222 inrow++;
223 outrow += v_expand;
224 }
225}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
jpeg_component_info * compptr
Definition: jdct.h:238
my_upsampler * my_upsample_ptr
Definition: jdsample.c:62
struct jpeg_upsampler * upsample
Definition: jpeglib.h:686
UINT8 v_expand[MAX_COMPONENTS]
Definition: jdsample.c:59
UINT8 h_expand[MAX_COMPONENTS]
Definition: jdsample.c:58

Referenced by jinit_upsampler().

◆ jinit_upsampler()

jinit_upsampler ( j_decompress_ptr  cinfo)

Definition at line 294 of file jdsample.c.

295{
296 my_upsample_ptr upsample;
297 int ci;
299 int h_in_group, v_in_group, h_out_group, v_out_group;
300
301 upsample = (my_upsample_ptr)
302 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
304 cinfo->upsample = &upsample->pub;
305 upsample->pub.start_pass = start_pass_upsample;
306 upsample->pub.upsample = sep_upsample;
307 upsample->pub.need_context_rows = FALSE; /* until we find out differently */
308
309 if (cinfo->CCIR601_sampling) /* this isn't supported */
310 ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
311
312 /* Verify we can handle the sampling factors, select per-component methods,
313 * and create storage as needed.
314 */
315 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
316 ci++, compptr++) {
317 /* Compute size of an "input group" after IDCT scaling. This many samples
318 * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
319 */
324 h_out_group = cinfo->max_h_samp_factor;
325 v_out_group = cinfo->max_v_samp_factor;
326 upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
327 if (! compptr->component_needed) {
328 /* Don't bother to upsample an uninteresting component. */
329 upsample->methods[ci] = noop_upsample;
330 continue; /* don't need to allocate buffer */
331 }
332 if (h_in_group == h_out_group && v_in_group == v_out_group) {
333 /* Fullsize components can be processed without any work. */
334 upsample->methods[ci] = fullsize_upsample;
335 continue; /* don't need to allocate buffer */
336 }
337 if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
338 /* Special case for 2h1v upsampling */
339 upsample->methods[ci] = h2v1_upsample;
340 } else if (h_in_group * 2 == h_out_group &&
341 v_in_group * 2 == v_out_group) {
342 /* Special case for 2h2v upsampling */
343 upsample->methods[ci] = h2v2_upsample;
344 } else if ((h_out_group % h_in_group) == 0 &&
345 (v_out_group % v_in_group) == 0) {
346 /* Generic integral-factors upsampling method */
347 upsample->methods[ci] = int_upsample;
348 upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);
349 upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
350 } else
351 ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
352 upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
353 ((j_common_ptr) cinfo, JPOOL_IMAGE,
354 (JDIMENSION) jround_up((long) cinfo->output_width,
355 (long) cinfo->max_h_samp_factor),
357 }
358}
unsigned char UINT8
#define SIZEOF(_ar)
Definition: calc.h:97
#define FALSE
Definition: types.h:117
h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
Definition: jdsample.c:234
h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
Definition: jdsample.c:262
int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
Definition: jdsample.c:190
start_pass_upsample(j_decompress_ptr cinfo)
Definition: jdsample.c:70
fullsize_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
Definition: jdsample.c:158
noop_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
Definition: jdsample.c:171
sep_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
Definition: jdsample.c:90
unsigned int JDIMENSION
Definition: jmorecfg.h:229
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define JPOOL_IMAGE
Definition: jpeglib.h:808
jround_up(long a, long b)
Definition: jutils.c:133
#define long
Definition: qsort.c:33
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
boolean component_needed
Definition: jpeglib.h:174
boolean CCIR601_sampling
Definition: jpeglib.h:612
jpeg_component_info * comp_info
Definition: jpeglib.h:583
int rowgroup_height[MAX_COMPONENTS]
Definition: jdsample.c:53
struct jpeg_upsampler pub
Definition: jdsample.c:35
upsample1_ptr methods[MAX_COMPONENTS]
Definition: jdsample.c:47
JSAMPARRAY color_buf[MAX_COMPONENTS]
Definition: jdsample.c:44

Referenced by master_selection().

◆ JMETHOD()

typedef JMETHOD ( void  ,
upsample1_ptr  ,
(j_decompress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)   
)

◆ noop_upsample()

noop_upsample ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY output_data_ptr 
)

Definition at line 171 of file jdsample.c.

173{
174 *output_data_ptr = NULL; /* safety check */
175}
#define NULL
Definition: types.h:112

Referenced by jinit_upsampler().

◆ sep_upsample()

sep_upsample ( j_decompress_ptr  cinfo,
JSAMPIMAGE  input_buf,
JDIMENSION in_row_group_ctr,
JDIMENSION  in_row_groups_avail,
JSAMPARRAY  output_buf,
JDIMENSION out_row_ctr,
JDIMENSION  out_rows_avail 
)

Definition at line 90 of file jdsample.c.

95{
96 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
97 int ci;
100
101 /* Fill the conversion buffer, if it's empty */
102 if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
103 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
104 ci++, compptr++) {
105 /* Invoke per-component upsample method. Notice we pass a POINTER
106 * to color_buf[ci], so that fullsize_upsample can change it.
107 */
108 (*upsample->methods[ci]) (cinfo, compptr,
109 input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
110 upsample->color_buf + ci);
111 }
112 upsample->next_row_out = 0;
113 }
114
115 /* Color-convert and emit rows */
116
117 /* How many we have in the buffer: */
118 num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out);
119 /* Not more than the distance to the end of the image. Need this test
120 * in case the image height is not a multiple of max_v_samp_factor:
121 */
122 if (num_rows > upsample->rows_to_go)
123 num_rows = upsample->rows_to_go;
124 /* And not more than what the client can accept: */
125 out_rows_avail -= *out_row_ctr;
126 if (num_rows > out_rows_avail)
127 num_rows = out_rows_avail;
128
129 (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
130 (JDIMENSION) upsample->next_row_out,
131 output_buf + *out_row_ctr,
132 (int) num_rows);
133
134 /* Adjust counts */
135 *out_row_ctr += num_rows;
136 upsample->rows_to_go -= num_rows;
137 upsample->next_row_out += num_rows;
138 /* When the buffer is emptied, declare this input row group consumed */
139 if (upsample->next_row_out >= cinfo->max_v_samp_factor)
140 (*in_row_group_ctr)++;
141}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:239
int JSAMPARRAY int int num_rows
Definition: jpegint.h:421
if(dx< 0)
Definition: linetemp.h:194
struct jpeg_color_deconverter * cconvert
Definition: jpeglib.h:687
JDIMENSION rows_to_go
Definition: jdsample.c:50
int next_row_out
Definition: jdsample.c:49

Referenced by jinit_upsampler().

◆ start_pass_upsample()

start_pass_upsample ( j_decompress_ptr  cinfo)

Definition at line 70 of file jdsample.c.

71{
72 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
73
74 /* Mark the conversion buffer empty */
75 upsample->next_row_out = cinfo->max_v_samp_factor;
76 /* Initialize total-height counter for detecting bottom of image */
77 upsample->rows_to_go = cinfo->output_height;
78}
JDIMENSION output_height
Definition: jpeglib.h:508

Referenced by jinit_upsampler().