ReactOS 0.4.16-dev-122-g325d74c
jcsample.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jcsample.c:

Go to the source code of this file.

Classes

struct  my_downsampler
 

Macros

#define JPEG_INTERNALS
 

Typedefs

typedef my_downsamplermy_downsample_ptr
 

Functions

typedef JMETHOD (void, downsample1_ptr,(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data))
 
 start_pass_downsample (j_compress_ptr cinfo)
 
 expand_right_edge (JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols, JDIMENSION output_cols)
 
 sep_downsample (j_compress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION in_row_index, JSAMPIMAGE output_buf, JDIMENSION out_row_group_index)
 
 int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
 
 fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
 
 h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
 
 h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
 
 jinit_downsampler (j_compress_ptr cinfo)
 

Macro Definition Documentation

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 48 of file jcsample.c.

Typedef Documentation

◆ my_downsample_ptr

Definition at line 76 of file jcsample.c.

Function Documentation

◆ expand_right_edge()

expand_right_edge ( JSAMPARRAY  image_data,
int  num_rows,
JDIMENSION  input_cols,
JDIMENSION  output_cols 
)

Definition at line 96 of file jcsample.c.

98{
99 register JSAMPROW ptr;
100 register JSAMPLE pixval;
101 register int count;
102 int row;
103 int numcols = (int) (output_cols - input_cols);
104
105 if (numcols > 0) {
106 for (row = 0; row < num_rows; row++) {
107 ptr = image_data[row] + input_cols;
108 pixval = ptr[-1]; /* don't need GETJSAMPLE() here */
109 for (count = numcols; count > 0; count--)
110 *ptr++ = pixval;
111 }
112 }
113}
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint GLuint GLsizei count
Definition: gl.h:1545
char JSAMPLE
Definition: jmorecfg.h:74
int JSAMPARRAY int int num_rows
Definition: jpegint.h:421
JSAMPLE FAR * JSAMPROW
Definition: jpeglib.h:75
static PVOID ptr
Definition: dispmode.c:27

Referenced by fullsize_downsample(), h2v1_downsample(), h2v2_downsample(), and int_downsample().

◆ fullsize_downsample()

fullsize_downsample ( j_compress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY  output_data 
)

Definition at line 199 of file jcsample.c.

201{
202 /* Copy the data */
203 jcopy_sample_rows(input_data, 0, output_data, 0,
204 cinfo->max_v_samp_factor, cinfo->image_width);
205 /* Edge-expand */
206 expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
208}
expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols, JDIMENSION output_cols)
Definition: jcsample.c:96
jpeg_component_info * compptr
Definition: jdct.h:238
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
JDIMENSION width_in_blocks
Definition: jpeglib.h:148
JDIMENSION image_width
Definition: jpeglib.h:302

Referenced by jinit_downsampler().

◆ h2v1_downsample()

h2v1_downsample ( j_compress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY  output_data 
)

Definition at line 224 of file jcsample.c.

226{
227 int inrow;
228 JDIMENSION outcol;
230 register JSAMPROW inptr, outptr;
231 register int bias;
232
233 /* Expand input data enough to let all the output samples be generated
234 * by the standard loop. Special-casing padded output would be more
235 * efficient.
236 */
237 expand_right_edge(input_data, cinfo->max_v_samp_factor,
238 cinfo->image_width, output_cols * 2);
239
240 for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
241 outptr = output_data[inrow];
242 inptr = input_data[inrow];
243 bias = 0; /* bias = 0,1,0,1,... for successive samples */
244 for (outcol = 0; outcol < output_cols; outcol++) {
245 *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])
246 + bias) >> 1);
247 bias ^= 1; /* 0=>1, 1=>0 */
248 inptr += 2;
249 }
250 }
251}
GLfloat bias
Definition: glext.h:7909
unsigned int JDIMENSION
Definition: jmorecfg.h:229
#define GETJSAMPLE(value)
Definition: jmorecfg.h:78

Referenced by jinit_downsampler().

◆ h2v2_downsample()

h2v2_downsample ( j_compress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY  output_data 
)

Definition at line 261 of file jcsample.c.

263{
264 int inrow, outrow;
265 JDIMENSION outcol;
267 register JSAMPROW inptr0, inptr1, outptr;
268 register int bias;
269
270 /* Expand input data enough to let all the output samples be generated
271 * by the standard loop. Special-casing padded output would be more
272 * efficient.
273 */
274 expand_right_edge(input_data, cinfo->max_v_samp_factor,
275 cinfo->image_width, output_cols * 2);
276
277 inrow = outrow = 0;
278 while (inrow < cinfo->max_v_samp_factor) {
279 outptr = output_data[outrow];
280 inptr0 = input_data[inrow];
281 inptr1 = input_data[inrow+1];
282 bias = 1; /* bias = 1,2,1,2,... for successive samples */
283 for (outcol = 0; outcol < output_cols; outcol++) {
284 *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
285 GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1])
286 + bias) >> 2);
287 bias ^= 3; /* 1=>2, 2=>1 */
288 inptr0 += 2; inptr1 += 2;
289 }
290 inrow += 2;
291 outrow++;
292 }
293}

Referenced by jinit_downsampler().

◆ int_downsample()

int_downsample ( j_compress_ptr  cinfo,
jpeg_component_info compptr,
JSAMPARRAY  input_data,
JSAMPARRAY  output_data 
)

Definition at line 150 of file jcsample.c.

152{
153 my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
154 int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
155 JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */
157 JSAMPROW inptr, outptr;
158 INT32 outvalue;
159
160 h_expand = downsample->h_expand[compptr->component_index];
161 v_expand = downsample->v_expand[compptr->component_index];
162 numpix = h_expand * v_expand;
163 numpix2 = numpix/2;
164
165 /* Expand input data enough to let all the output samples be generated
166 * by the standard loop. Special-casing padded output would be more
167 * efficient.
168 */
169 expand_right_edge(input_data, cinfo->max_v_samp_factor,
170 cinfo->image_width, output_cols * h_expand);
171
172 inrow = outrow = 0;
173 while (inrow < cinfo->max_v_samp_factor) {
174 outptr = output_data[outrow];
175 for (outcol = 0, outcol_h = 0; outcol < output_cols;
176 outcol++, outcol_h += h_expand) {
177 outvalue = 0;
178 for (v = 0; v < v_expand; v++) {
179 inptr = input_data[inrow+v] + outcol_h;
180 for (h = 0; h < h_expand; h++) {
181 outvalue += (INT32) GETJSAMPLE(*inptr++);
182 }
183 }
184 *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);
185 }
186 inrow += v_expand;
187 outrow++;
188 }
189}
signed int INT32
const GLdouble * v
Definition: gl.h:2040
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
my_downsampler * my_downsample_ptr
Definition: jcsample.c:76
struct jpeg_downsampler * downsample
Definition: jpeglib.h:449
UINT8 h_expand[MAX_COMPONENTS]
Definition: jcsample.c:72
UINT8 v_expand[MAX_COMPONENTS]
Definition: jcsample.c:73

Referenced by jinit_downsampler().

◆ jinit_downsampler()

jinit_downsampler ( j_compress_ptr  cinfo)

Definition at line 478 of file jcsample.c.

479{
480 my_downsample_ptr downsample;
481 int ci;
483 boolean smoothok = TRUE;
484 int h_in_group, v_in_group, h_out_group, v_out_group;
485
486 downsample = (my_downsample_ptr)
487 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
489 cinfo->downsample = (struct jpeg_downsampler *) downsample;
490 downsample->pub.start_pass = start_pass_downsample;
491 downsample->pub.downsample = sep_downsample;
492 downsample->pub.need_context_rows = FALSE;
493
494 if (cinfo->CCIR601_sampling)
495 ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
496
497 /* Verify we can handle the sampling factors, and set up method pointers */
498 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
499 ci++, compptr++) {
500 /* Compute size of an "output group" for DCT scaling. This many samples
501 * are to be converted from max_h_samp_factor * max_v_samp_factor pixels.
502 */
503 h_out_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) /
505 v_out_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
507 h_in_group = cinfo->max_h_samp_factor;
508 v_in_group = cinfo->max_v_samp_factor;
509 downsample->rowgroup_height[ci] = v_out_group; /* save for use later */
510 if (h_in_group == h_out_group && v_in_group == v_out_group) {
511#ifdef INPUT_SMOOTHING_SUPPORTED
512 if (cinfo->smoothing_factor) {
513 downsample->methods[ci] = fullsize_smooth_downsample;
514 downsample->pub.need_context_rows = TRUE;
515 } else
516#endif
517 downsample->methods[ci] = fullsize_downsample;
518 } else if (h_in_group == h_out_group * 2 &&
519 v_in_group == v_out_group) {
520 smoothok = FALSE;
521 downsample->methods[ci] = h2v1_downsample;
522 } else if (h_in_group == h_out_group * 2 &&
523 v_in_group == v_out_group * 2) {
524#ifdef INPUT_SMOOTHING_SUPPORTED
525 if (cinfo->smoothing_factor) {
526 downsample->methods[ci] = h2v2_smooth_downsample;
527 downsample->pub.need_context_rows = TRUE;
528 } else
529#endif
530 downsample->methods[ci] = h2v2_downsample;
531 } else if ((h_in_group % h_out_group) == 0 &&
532 (v_in_group % v_out_group) == 0) {
533 smoothok = FALSE;
534 downsample->methods[ci] = int_downsample;
535 downsample->h_expand[ci] = (UINT8) (h_in_group / h_out_group);
536 downsample->v_expand[ci] = (UINT8) (v_in_group / v_out_group);
537 } else
538 ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
539 }
540
541#ifdef INPUT_SMOOTHING_SUPPORTED
542 if (cinfo->smoothing_factor && !smoothok)
543 TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);
544#endif
545}
unsigned char UINT8
#define SIZEOF(_ar)
Definition: calc.h:97
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
Definition: jcsample.c:199
start_pass_downsample(j_compress_ptr cinfo)
Definition: jcsample.c:84
h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
Definition: jcsample.c:261
h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
Definition: jcsample.c:224
int_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
Definition: jcsample.c:150
sep_downsample(j_compress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION in_row_index, JSAMPIMAGE output_buf, JDIMENSION out_row_group_index)
Definition: jcsample.c:123
#define TRACEMS(cinfo, lvl, code)
Definition: jerror.h:265
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define JPOOL_IMAGE
Definition: jpeglib.h:808
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
jpeg_component_info * comp_info
Definition: jpeglib.h:333
boolean CCIR601_sampling
Definition: jpeglib.h:360
struct jpeg_downsampler pub
Definition: jcsample.c:61
int rowgroup_height[MAX_COMPONENTS]
Definition: jcsample.c:67
downsample1_ptr methods[MAX_COMPONENTS]
Definition: jcsample.c:64

Referenced by jinit_compress_master().

◆ JMETHOD()

typedef JMETHOD ( void  ,
downsample1_ptr  ,
(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)   
)

◆ sep_downsample()

sep_downsample ( j_compress_ptr  cinfo,
JSAMPIMAGE  input_buf,
JDIMENSION  in_row_index,
JSAMPIMAGE  output_buf,
JDIMENSION  out_row_group_index 
)

Definition at line 123 of file jcsample.c.

126{
127 my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
128 int ci;
130 JSAMPARRAY in_ptr, out_ptr;
131
132 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
133 ci++, compptr++) {
134 in_ptr = input_buf[ci] + in_row_index;
135 out_ptr = output_buf[ci] +
136 (out_row_group_index * downsample->rowgroup_height[ci]);
137 (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
138 }
139}
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:239
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:76
#define for
Definition: utility.h:88

Referenced by jinit_downsampler().

◆ start_pass_downsample()

start_pass_downsample ( j_compress_ptr  cinfo)

Definition at line 84 of file jcsample.c.

85{
86 /* no work for now */
87}

Referenced by jinit_downsampler().