/src/libjpeg-turbo.dev/src/jdmerge.c
Line | Count | Source |
1 | | /* |
2 | | * jdmerge.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1994-1996, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
8 | | * Copyright (C) 2009, 2011, 2014-2015, 2020, 2022, 2025, D. R. Commander. |
9 | | * Copyright (C) 2013, Linaro Limited. |
10 | | * For conditions of distribution and use, see the accompanying README.ijg |
11 | | * file. |
12 | | * |
13 | | * This file contains code for merged upsampling/color conversion. |
14 | | * |
15 | | * This file combines functions from jdsample.c and jdcolor.c; |
16 | | * read those files first to understand what's going on. |
17 | | * |
18 | | * When the chroma components are to be upsampled by simple replication |
19 | | * (ie, box filtering), we can save some work in color conversion by |
20 | | * calculating all the output pixels corresponding to a pair of chroma |
21 | | * samples at one time. In the conversion equations |
22 | | * R = Y + K1 * Cr |
23 | | * G = Y + K2 * Cb + K3 * Cr |
24 | | * B = Y + K4 * Cb |
25 | | * only the Y term varies among the group of pixels corresponding to a pair |
26 | | * of chroma samples, so the rest of the terms can be calculated just once. |
27 | | * At typical sampling ratios, this eliminates half or three-quarters of the |
28 | | * multiplications needed for color conversion. |
29 | | * |
30 | | * This file currently provides implementations for the following cases: |
31 | | * YCbCr => RGB color conversion only. |
32 | | * Sampling ratios of 2h1v or 2h2v. |
33 | | * No scaling needed at upsample time. |
34 | | * Corner-aligned (non-CCIR601) sampling alignment. |
35 | | * Other special cases could be added, but in most applications these are |
36 | | * the only common cases. (For uncommon cases we fall back on the more |
37 | | * general code in jdsample.c and jdcolor.c.) |
38 | | */ |
39 | | |
40 | | #define JPEG_INTERNALS |
41 | | #include "jinclude.h" |
42 | | #include "jpeglib.h" |
43 | | #include "jdmerge.h" |
44 | | #ifdef WITH_SIMD |
45 | | #include "../simd/jsimd.h" |
46 | | #endif |
47 | | #ifdef WITH_PROFILE |
48 | | #include "tjutil.h" |
49 | | #endif |
50 | | |
51 | | #ifdef UPSAMPLE_MERGING_SUPPORTED |
52 | | |
53 | | |
54 | 0 | #define SCALEBITS 16 /* speediest right-shift on some machines */ |
55 | 0 | #define ONE_HALF ((JLONG)1 << (SCALEBITS - 1)) |
56 | 0 | #define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5)) |
57 | | |
58 | | |
59 | | /* Include inline routines for colorspace extensions */ |
60 | | |
61 | | #include "jdmrgext.c" |
62 | | #undef RGB_RED |
63 | | #undef RGB_GREEN |
64 | | #undef RGB_BLUE |
65 | | #undef RGB_PIXELSIZE |
66 | | |
67 | 0 | #define RGB_RED EXT_RGB_RED |
68 | 0 | #define RGB_GREEN EXT_RGB_GREEN |
69 | 0 | #define RGB_BLUE EXT_RGB_BLUE |
70 | 0 | #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE |
71 | | #define h2v1_merged_upsample extrgb_h2v1_merged_upsample |
72 | | #define h2v2_merged_upsample extrgb_h2v2_merged_upsample |
73 | | #include "jdmrgext.c" |
74 | | #undef RGB_RED |
75 | | #undef RGB_GREEN |
76 | | #undef RGB_BLUE |
77 | | #undef RGB_PIXELSIZE |
78 | | #undef h2v1_merged_upsample |
79 | | #undef h2v2_merged_upsample |
80 | | |
81 | 0 | #define RGB_RED EXT_RGBX_RED |
82 | 0 | #define RGB_GREEN EXT_RGBX_GREEN |
83 | 0 | #define RGB_BLUE EXT_RGBX_BLUE |
84 | 0 | #define RGB_ALPHA 3 |
85 | 0 | #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE |
86 | | #define h2v1_merged_upsample extrgbx_h2v1_merged_upsample |
87 | | #define h2v2_merged_upsample extrgbx_h2v2_merged_upsample |
88 | | #include "jdmrgext.c" |
89 | | #undef RGB_RED |
90 | | #undef RGB_GREEN |
91 | | #undef RGB_BLUE |
92 | | #undef RGB_ALPHA |
93 | | #undef RGB_PIXELSIZE |
94 | | #undef h2v1_merged_upsample |
95 | | #undef h2v2_merged_upsample |
96 | | |
97 | 0 | #define RGB_RED EXT_BGR_RED |
98 | 0 | #define RGB_GREEN EXT_BGR_GREEN |
99 | 0 | #define RGB_BLUE EXT_BGR_BLUE |
100 | 0 | #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE |
101 | | #define h2v1_merged_upsample extbgr_h2v1_merged_upsample |
102 | | #define h2v2_merged_upsample extbgr_h2v2_merged_upsample |
103 | | #include "jdmrgext.c" |
104 | | #undef RGB_RED |
105 | | #undef RGB_GREEN |
106 | | #undef RGB_BLUE |
107 | | #undef RGB_PIXELSIZE |
108 | | #undef h2v1_merged_upsample |
109 | | #undef h2v2_merged_upsample |
110 | | |
111 | 0 | #define RGB_RED EXT_BGRX_RED |
112 | 0 | #define RGB_GREEN EXT_BGRX_GREEN |
113 | 0 | #define RGB_BLUE EXT_BGRX_BLUE |
114 | 0 | #define RGB_ALPHA 3 |
115 | 0 | #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE |
116 | | #define h2v1_merged_upsample extbgrx_h2v1_merged_upsample |
117 | | #define h2v2_merged_upsample extbgrx_h2v2_merged_upsample |
118 | | #include "jdmrgext.c" |
119 | | #undef RGB_RED |
120 | | #undef RGB_GREEN |
121 | | #undef RGB_BLUE |
122 | | #undef RGB_ALPHA |
123 | | #undef RGB_PIXELSIZE |
124 | | #undef h2v1_merged_upsample |
125 | | #undef h2v2_merged_upsample |
126 | | |
127 | 0 | #define RGB_RED EXT_XBGR_RED |
128 | 0 | #define RGB_GREEN EXT_XBGR_GREEN |
129 | 0 | #define RGB_BLUE EXT_XBGR_BLUE |
130 | 0 | #define RGB_ALPHA 0 |
131 | 0 | #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE |
132 | | #define h2v1_merged_upsample extxbgr_h2v1_merged_upsample |
133 | | #define h2v2_merged_upsample extxbgr_h2v2_merged_upsample |
134 | | #include "jdmrgext.c" |
135 | | #undef RGB_RED |
136 | | #undef RGB_GREEN |
137 | | #undef RGB_BLUE |
138 | | #undef RGB_ALPHA |
139 | | #undef RGB_PIXELSIZE |
140 | | #undef h2v1_merged_upsample |
141 | | #undef h2v2_merged_upsample |
142 | | |
143 | 0 | #define RGB_RED EXT_XRGB_RED |
144 | 0 | #define RGB_GREEN EXT_XRGB_GREEN |
145 | 0 | #define RGB_BLUE EXT_XRGB_BLUE |
146 | 0 | #define RGB_ALPHA 0 |
147 | 0 | #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE |
148 | | #define h2v1_merged_upsample extxrgb_h2v1_merged_upsample |
149 | | #define h2v2_merged_upsample extxrgb_h2v2_merged_upsample |
150 | | #include "jdmrgext.c" |
151 | | #undef RGB_RED |
152 | | #undef RGB_GREEN |
153 | | #undef RGB_BLUE |
154 | | #undef RGB_ALPHA |
155 | | #undef RGB_PIXELSIZE |
156 | | #undef h2v1_merged_upsample |
157 | | #undef h2v2_merged_upsample |
158 | | |
159 | | |
160 | | /* |
161 | | * Initialize tables for YCC->RGB colorspace conversion. |
162 | | * This is taken directly from jdcolor.c; see that file for more info. |
163 | | */ |
164 | | |
165 | | LOCAL(void) |
166 | | build_ycc_rgb_table(j_decompress_ptr cinfo) |
167 | 0 | { |
168 | 0 | my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample; |
169 | 0 | int i; |
170 | 0 | JLONG x; |
171 | 0 | SHIFT_TEMPS |
172 | |
|
173 | 0 | upsample->Cr_r_tab = (int *) |
174 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
175 | 0 | (_MAXJSAMPLE + 1) * sizeof(int)); |
176 | 0 | upsample->Cb_b_tab = (int *) |
177 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
178 | 0 | (_MAXJSAMPLE + 1) * sizeof(int)); |
179 | 0 | upsample->Cr_g_tab = (JLONG *) |
180 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
181 | 0 | (_MAXJSAMPLE + 1) * sizeof(JLONG)); |
182 | 0 | upsample->Cb_g_tab = (JLONG *) |
183 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
184 | 0 | (_MAXJSAMPLE + 1) * sizeof(JLONG)); |
185 | |
|
186 | 0 | for (i = 0, x = -_CENTERJSAMPLE; i <= _MAXJSAMPLE; i++, x++) { |
187 | | /* i is the actual input pixel value, in the range 0.._MAXJSAMPLE */ |
188 | | /* The Cb or Cr value we are thinking of is x = i - _CENTERJSAMPLE */ |
189 | | /* Cr=>R value is nearest int to 1.40200 * x */ |
190 | 0 | upsample->Cr_r_tab[i] = (int) |
191 | 0 | RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); |
192 | | /* Cb=>B value is nearest int to 1.77200 * x */ |
193 | 0 | upsample->Cb_b_tab[i] = (int) |
194 | 0 | RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); |
195 | | /* Cr=>G value is scaled-up -0.71414 * x */ |
196 | 0 | upsample->Cr_g_tab[i] = (-FIX(0.71414)) * x; |
197 | | /* Cb=>G value is scaled-up -0.34414 * x */ |
198 | | /* We also add in ONE_HALF so that need not do it in inner loop */ |
199 | 0 | upsample->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF; |
200 | 0 | } |
201 | 0 | } Unexecuted instantiation: jdmerge-8.c:build_ycc_rgb_table Unexecuted instantiation: jdmerge-12.c:build_ycc_rgb_table |
202 | | |
203 | | |
204 | | /* |
205 | | * Initialize for an upsampling pass. |
206 | | */ |
207 | | |
208 | | METHODDEF(void) |
209 | | start_pass_merged_upsample(j_decompress_ptr cinfo) |
210 | 0 | { |
211 | 0 | my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample; |
212 | | |
213 | | /* Mark the spare buffer empty */ |
214 | 0 | upsample->spare_full = FALSE; |
215 | | /* Initialize total-height counter for detecting bottom of image */ |
216 | 0 | upsample->rows_to_go = cinfo->output_height; |
217 | 0 | } Unexecuted instantiation: jdmerge-8.c:start_pass_merged_upsample Unexecuted instantiation: jdmerge-12.c:start_pass_merged_upsample |
218 | | |
219 | | |
220 | | /* |
221 | | * Control routine to do upsampling (and color conversion). |
222 | | * |
223 | | * The control routine just handles the row buffering considerations. |
224 | | */ |
225 | | |
226 | | METHODDEF(void) |
227 | | merged_2v_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
228 | | JDIMENSION *in_row_group_ctr, |
229 | | JDIMENSION in_row_groups_avail, _JSAMPARRAY output_buf, |
230 | | JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail) |
231 | | /* 2:1 vertical sampling case: may need a spare row. */ |
232 | 0 | { |
233 | 0 | my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample; |
234 | 0 | _JSAMPROW work_ptrs[2]; |
235 | 0 | JDIMENSION num_rows; /* number of rows returned to caller */ |
236 | |
|
237 | 0 | if (upsample->spare_full) { |
238 | | /* If we have a spare row saved from a previous cycle, just return it. */ |
239 | 0 | JDIMENSION size = upsample->out_row_width; |
240 | 0 | if (cinfo->out_color_space == JCS_RGB565) |
241 | 0 | size = cinfo->output_width * 2; |
242 | 0 | _jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0, |
243 | 0 | 1, size); |
244 | 0 | num_rows = 1; |
245 | 0 | upsample->spare_full = FALSE; |
246 | 0 | } else { |
247 | | /* Figure number of rows to return to caller. */ |
248 | 0 | num_rows = 2; |
249 | | /* Not more than the distance to the end of the image. */ |
250 | 0 | if (num_rows > upsample->rows_to_go) |
251 | 0 | num_rows = upsample->rows_to_go; |
252 | | /* And not more than what the client can accept: */ |
253 | 0 | out_rows_avail -= *out_row_ctr; |
254 | 0 | if (num_rows > out_rows_avail) |
255 | 0 | num_rows = out_rows_avail; |
256 | | /* Create output pointer array for upsampler. */ |
257 | 0 | work_ptrs[0] = output_buf[*out_row_ctr]; |
258 | 0 | if (num_rows > 1) { |
259 | 0 | work_ptrs[1] = output_buf[*out_row_ctr + 1]; |
260 | 0 | } else { |
261 | 0 | work_ptrs[1] = upsample->spare_row; |
262 | 0 | upsample->spare_full = TRUE; |
263 | 0 | } |
264 | | /* Now do the upsampling. */ |
265 | | #ifdef WITH_PROFILE |
266 | | cinfo->master->start = getTime(); |
267 | | #endif |
268 | 0 | (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); |
269 | | #ifdef WITH_PROFILE |
270 | | cinfo->master->merged_upsample_elapsed += getTime() - cinfo->master->start; |
271 | | cinfo->master->merged_upsample_mpixels += |
272 | | (double)cinfo->output_width * 2 / 1000000.; |
273 | | #endif |
274 | 0 | } |
275 | | |
276 | | /* Adjust counts */ |
277 | 0 | *out_row_ctr += num_rows; |
278 | 0 | upsample->rows_to_go -= num_rows; |
279 | | /* When the buffer is emptied, declare this input row group consumed */ |
280 | 0 | if (!upsample->spare_full) |
281 | 0 | (*in_row_group_ctr)++; |
282 | 0 | } Unexecuted instantiation: jdmerge-8.c:merged_2v_upsample Unexecuted instantiation: jdmerge-12.c:merged_2v_upsample |
283 | | |
284 | | |
285 | | METHODDEF(void) |
286 | | merged_1v_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
287 | | JDIMENSION *in_row_group_ctr, |
288 | | JDIMENSION in_row_groups_avail, _JSAMPARRAY output_buf, |
289 | | JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail) |
290 | | /* 1:1 vertical sampling case: much easier, never need a spare row. */ |
291 | 0 | { |
292 | 0 | my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample; |
293 | | |
294 | | /* Just do the upsampling. */ |
295 | | #ifdef WITH_PROFILE |
296 | | cinfo->master->start = getTime(); |
297 | | #endif |
298 | 0 | (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, |
299 | 0 | output_buf + *out_row_ctr); |
300 | | #ifdef WITH_PROFILE |
301 | | cinfo->master->merged_upsample_elapsed += getTime() - cinfo->master->start; |
302 | | cinfo->master->merged_upsample_mpixels += |
303 | | (double)cinfo->output_width / 1000000.; |
304 | | #endif |
305 | | /* Adjust counts */ |
306 | 0 | (*out_row_ctr)++; |
307 | 0 | (*in_row_group_ctr)++; |
308 | 0 | } Unexecuted instantiation: jdmerge-8.c:merged_1v_upsample Unexecuted instantiation: jdmerge-12.c:merged_1v_upsample |
309 | | |
310 | | |
311 | | /* |
312 | | * These are the routines invoked by the control routines to do |
313 | | * the actual upsampling/conversion. One row group is processed per call. |
314 | | * |
315 | | * Note: since we may be writing directly into application-supplied buffers, |
316 | | * we have to be honest about the output width; we can't assume the buffer |
317 | | * has been rounded up to an even width. |
318 | | */ |
319 | | |
320 | | |
321 | | /* |
322 | | * RGB565 conversion |
323 | | */ |
324 | | |
325 | | #define PACK_SHORT_565_LE(r, g, b) \ |
326 | 0 | ((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3)) |
327 | | #define PACK_SHORT_565_BE(r, g, b) \ |
328 | 0 | (((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00)) |
329 | | |
330 | 0 | #define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l) |
331 | 0 | #define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r) |
332 | | |
333 | 0 | #define WRITE_TWO_PIXELS_LE(addr, pixels) { \ |
334 | 0 | ((INT16 *)(addr))[0] = (INT16)(pixels); \ |
335 | 0 | ((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \ |
336 | 0 | } |
337 | 0 | #define WRITE_TWO_PIXELS_BE(addr, pixels) { \ |
338 | 0 | ((INT16 *)(addr))[1] = (INT16)(pixels); \ |
339 | 0 | ((INT16 *)(addr))[0] = (INT16)((pixels) >> 16); \ |
340 | 0 | } |
341 | | |
342 | 0 | #define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF)) |
343 | 0 | #define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1)) |
344 | 0 | #define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF)) |
345 | | |
346 | | |
347 | | /* Declarations for ordered dithering |
348 | | * |
349 | | * We use a 4x4 ordered dither array packed into 32 bits. This array is |
350 | | * sufficient for dithering RGB888 to RGB565. |
351 | | */ |
352 | | |
353 | 0 | #define DITHER_MASK 0x3 |
354 | 0 | #define DITHER_ROTATE(x) ((((x) & 0xFF) << 24) | (((x) >> 8) & 0x00FFFFFF)) |
355 | | static const JLONG dither_matrix[4] = { |
356 | | 0x0008020A, |
357 | | 0x0C040E06, |
358 | | 0x030B0109, |
359 | | 0x0F070D05 |
360 | | }; |
361 | | |
362 | | |
363 | | /* Include inline routines for RGB565 conversion */ |
364 | | |
365 | 0 | #define PACK_SHORT_565 PACK_SHORT_565_LE |
366 | 0 | #define PACK_TWO_PIXELS PACK_TWO_PIXELS_LE |
367 | 0 | #define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_LE |
368 | | #define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_le |
369 | | #define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_le |
370 | | #define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_le |
371 | | #define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_le |
372 | | #include "jdmrg565.c" |
373 | | #undef PACK_SHORT_565 |
374 | | #undef PACK_TWO_PIXELS |
375 | | #undef WRITE_TWO_PIXELS |
376 | | #undef h2v1_merged_upsample_565_internal |
377 | | #undef h2v1_merged_upsample_565D_internal |
378 | | #undef h2v2_merged_upsample_565_internal |
379 | | #undef h2v2_merged_upsample_565D_internal |
380 | | |
381 | 0 | #define PACK_SHORT_565 PACK_SHORT_565_BE |
382 | 0 | #define PACK_TWO_PIXELS PACK_TWO_PIXELS_BE |
383 | 0 | #define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_BE |
384 | | #define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_be |
385 | | #define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_be |
386 | | #define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_be |
387 | | #define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_be |
388 | | #include "jdmrg565.c" |
389 | | #undef PACK_SHORT_565 |
390 | | #undef PACK_TWO_PIXELS |
391 | | #undef WRITE_TWO_PIXELS |
392 | | #undef h2v1_merged_upsample_565_internal |
393 | | #undef h2v1_merged_upsample_565D_internal |
394 | | #undef h2v2_merged_upsample_565_internal |
395 | | #undef h2v2_merged_upsample_565D_internal |
396 | | |
397 | | |
398 | | static INLINE boolean is_big_endian(void) |
399 | 0 | { |
400 | 0 | int test_value = 1; |
401 | 0 | if (*(char *)&test_value != 1) |
402 | 0 | return TRUE; |
403 | 0 | return FALSE; |
404 | 0 | } Unexecuted instantiation: jdmerge-8.c:is_big_endian Unexecuted instantiation: jdmerge-12.c:is_big_endian |
405 | | |
406 | | |
407 | | METHODDEF(void) |
408 | | h2v1_merged_upsample_565(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
409 | | JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf) |
410 | 0 | { |
411 | 0 | if (is_big_endian()) |
412 | 0 | h2v1_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr, |
413 | 0 | output_buf); |
414 | 0 | else |
415 | 0 | h2v1_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr, |
416 | 0 | output_buf); |
417 | 0 | } Unexecuted instantiation: jdmerge-8.c:h2v1_merged_upsample_565 Unexecuted instantiation: jdmerge-12.c:h2v1_merged_upsample_565 |
418 | | |
419 | | |
420 | | METHODDEF(void) |
421 | | h2v1_merged_upsample_565D(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
422 | | JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf) |
423 | 0 | { |
424 | 0 | if (is_big_endian()) |
425 | 0 | h2v1_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr, |
426 | 0 | output_buf); |
427 | 0 | else |
428 | 0 | h2v1_merged_upsample_565D_le(cinfo, input_buf, in_row_group_ctr, |
429 | 0 | output_buf); |
430 | 0 | } Unexecuted instantiation: jdmerge-8.c:h2v1_merged_upsample_565D Unexecuted instantiation: jdmerge-12.c:h2v1_merged_upsample_565D |
431 | | |
432 | | |
433 | | METHODDEF(void) |
434 | | h2v2_merged_upsample_565(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
435 | | JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf) |
436 | 0 | { |
437 | 0 | if (is_big_endian()) |
438 | 0 | h2v2_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr, |
439 | 0 | output_buf); |
440 | 0 | else |
441 | 0 | h2v2_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr, |
442 | 0 | output_buf); |
443 | 0 | } Unexecuted instantiation: jdmerge-8.c:h2v2_merged_upsample_565 Unexecuted instantiation: jdmerge-12.c:h2v2_merged_upsample_565 |
444 | | |
445 | | |
446 | | METHODDEF(void) |
447 | | h2v2_merged_upsample_565D(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
448 | | JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf) |
449 | 0 | { |
450 | 0 | if (is_big_endian()) |
451 | 0 | h2v2_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr, |
452 | 0 | output_buf); |
453 | 0 | else |
454 | 0 | h2v2_merged_upsample_565D_le(cinfo, input_buf, in_row_group_ctr, |
455 | 0 | output_buf); |
456 | 0 | } Unexecuted instantiation: jdmerge-8.c:h2v2_merged_upsample_565D Unexecuted instantiation: jdmerge-12.c:h2v2_merged_upsample_565D |
457 | | |
458 | | |
459 | | /* |
460 | | * Module initialization routine for merged upsampling/color conversion. |
461 | | * |
462 | | * NB: this is called under the conditions determined by use_merged_upsample() |
463 | | * in jdmaster.c. That routine MUST correspond to the actual capabilities |
464 | | * of this module; no safety checks are made here. |
465 | | */ |
466 | | |
467 | | GLOBAL(void) |
468 | | _jinit_merged_upsampler(j_decompress_ptr cinfo) |
469 | 0 | { |
470 | 0 | my_merged_upsample_ptr upsample; |
471 | |
|
472 | 0 | if (cinfo->data_precision != BITS_IN_JSAMPLE) |
473 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
474 | |
|
475 | 0 | upsample = (my_merged_upsample_ptr) |
476 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
477 | 0 | sizeof(my_merged_upsampler)); |
478 | 0 | cinfo->upsample = (struct jpeg_upsampler *)upsample; |
479 | 0 | upsample->pub.start_pass = start_pass_merged_upsample; |
480 | 0 | upsample->pub.need_context_rows = FALSE; |
481 | |
|
482 | 0 | upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; |
483 | |
|
484 | 0 | if (cinfo->max_v_samp_factor == 2) { |
485 | 0 | upsample->pub._upsample = merged_2v_upsample; |
486 | | #ifdef WITH_SIMD |
487 | 0 | if (jsimd_set_h2v2_merged_upsample(cinfo)) |
488 | 0 | upsample->upmethod = jsimd_h2v2_merged_upsample; |
489 | 0 | else |
490 | 0 | #endif |
491 | 0 | { |
492 | 0 | switch (cinfo->out_color_space) { |
493 | 0 | case JCS_EXT_RGB: |
494 | 0 | upsample->upmethod = extrgb_h2v2_merged_upsample; |
495 | 0 | break; |
496 | 0 | case JCS_EXT_RGBX: |
497 | 0 | case JCS_EXT_RGBA: |
498 | 0 | upsample->upmethod = extrgbx_h2v2_merged_upsample; |
499 | 0 | break; |
500 | 0 | case JCS_EXT_BGR: |
501 | 0 | upsample->upmethod = extbgr_h2v2_merged_upsample; |
502 | 0 | break; |
503 | 0 | case JCS_EXT_BGRX: |
504 | 0 | case JCS_EXT_BGRA: |
505 | 0 | upsample->upmethod = extbgrx_h2v2_merged_upsample; |
506 | 0 | break; |
507 | 0 | case JCS_EXT_XBGR: |
508 | 0 | case JCS_EXT_ABGR: |
509 | 0 | upsample->upmethod = extxbgr_h2v2_merged_upsample; |
510 | 0 | break; |
511 | 0 | case JCS_EXT_XRGB: |
512 | 0 | case JCS_EXT_ARGB: |
513 | 0 | upsample->upmethod = extxrgb_h2v2_merged_upsample; |
514 | 0 | break; |
515 | 0 | default: |
516 | 0 | upsample->upmethod = h2v2_merged_upsample; |
517 | 0 | } |
518 | 0 | } |
519 | 0 | if (cinfo->out_color_space == JCS_RGB565) { |
520 | 0 | if (cinfo->dither_mode != JDITHER_NONE) { |
521 | 0 | upsample->upmethod = h2v2_merged_upsample_565D; |
522 | 0 | } else { |
523 | 0 | upsample->upmethod = h2v2_merged_upsample_565; |
524 | 0 | } |
525 | 0 | } |
526 | | /* Allocate a spare row buffer */ |
527 | 0 | upsample->spare_row = (_JSAMPROW) |
528 | 0 | (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
529 | 0 | (size_t)(upsample->out_row_width * sizeof(_JSAMPLE))); |
530 | 0 | } else { |
531 | 0 | upsample->pub._upsample = merged_1v_upsample; |
532 | | #ifdef WITH_SIMD |
533 | 0 | if (jsimd_set_h2v1_merged_upsample(cinfo)) |
534 | 0 | upsample->upmethod = jsimd_h2v1_merged_upsample; |
535 | 0 | else |
536 | 0 | #endif |
537 | 0 | { |
538 | 0 | switch (cinfo->out_color_space) { |
539 | 0 | case JCS_EXT_RGB: |
540 | 0 | upsample->upmethod = extrgb_h2v1_merged_upsample; |
541 | 0 | break; |
542 | 0 | case JCS_EXT_RGBX: |
543 | 0 | case JCS_EXT_RGBA: |
544 | 0 | upsample->upmethod = extrgbx_h2v1_merged_upsample; |
545 | 0 | break; |
546 | 0 | case JCS_EXT_BGR: |
547 | 0 | upsample->upmethod = extbgr_h2v1_merged_upsample; |
548 | 0 | break; |
549 | 0 | case JCS_EXT_BGRX: |
550 | 0 | case JCS_EXT_BGRA: |
551 | 0 | upsample->upmethod = extbgrx_h2v1_merged_upsample; |
552 | 0 | break; |
553 | 0 | case JCS_EXT_XBGR: |
554 | 0 | case JCS_EXT_ABGR: |
555 | 0 | upsample->upmethod = extxbgr_h2v1_merged_upsample; |
556 | 0 | break; |
557 | 0 | case JCS_EXT_XRGB: |
558 | 0 | case JCS_EXT_ARGB: |
559 | 0 | upsample->upmethod = extxrgb_h2v1_merged_upsample; |
560 | 0 | break; |
561 | 0 | default: |
562 | 0 | upsample->upmethod = h2v1_merged_upsample; |
563 | 0 | } |
564 | 0 | } |
565 | 0 | if (cinfo->out_color_space == JCS_RGB565) { |
566 | 0 | if (cinfo->dither_mode != JDITHER_NONE) { |
567 | 0 | upsample->upmethod = h2v1_merged_upsample_565D; |
568 | 0 | } else { |
569 | 0 | upsample->upmethod = h2v1_merged_upsample_565; |
570 | 0 | } |
571 | 0 | } |
572 | | /* No spare row needed */ |
573 | 0 | upsample->spare_row = NULL; |
574 | 0 | } |
575 | | |
576 | 0 | build_ycc_rgb_table(cinfo); |
577 | 0 | } Unexecuted instantiation: jinit_merged_upsampler Unexecuted instantiation: j12init_merged_upsampler |
578 | | |
579 | | #endif /* UPSAMPLE_MERGING_SUPPORTED */ |