/src/libjpeg-turbo.dev/src/jdsample.c
Line | Count | Source |
1 | | /* |
2 | | * jdsample.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1991-1996, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
8 | | * Copyright (C) 2010, 2015-2016, 2022, 2024-2025, D. R. Commander. |
9 | | * Copyright (C) 2014, MIPS Technologies, Inc., California. |
10 | | * Copyright (C) 2015, Google, Inc. |
11 | | * Copyright (C) 2019-2020, Arm Limited. |
12 | | * For conditions of distribution and use, see the accompanying README.ijg |
13 | | * file. |
14 | | * |
15 | | * This file contains upsampling routines. |
16 | | * |
17 | | * Upsampling input data is counted in "row groups". A row group |
18 | | * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) |
19 | | * sample rows of each component. Upsampling will normally produce |
20 | | * max_v_samp_factor pixel rows from each row group (but this could vary |
21 | | * if the upsampler is applying a scale factor of its own). |
22 | | * |
23 | | * An excellent reference for image resampling is |
24 | | * Digital Image Warping, George Wolberg, 1990. |
25 | | * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. |
26 | | */ |
27 | | |
28 | | #include "jinclude.h" |
29 | | #include "jdsample.h" |
30 | | #ifdef WITH_SIMD |
31 | | #include "../simd/jsimd.h" |
32 | | #endif |
33 | | #include "jpegapicomp.h" |
34 | | #ifdef WITH_PROFILE |
35 | | #include "tjutil.h" |
36 | | #endif |
37 | | |
38 | | |
39 | | |
40 | | #if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) |
41 | | |
42 | | /* |
43 | | * Initialize for an upsampling pass. |
44 | | */ |
45 | | |
46 | | METHODDEF(void) |
47 | | start_pass_upsample(j_decompress_ptr cinfo) |
48 | 5.57k | { |
49 | 5.57k | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; |
50 | | |
51 | | /* Mark the conversion buffer empty */ |
52 | 5.57k | upsample->next_row_out = cinfo->max_v_samp_factor; |
53 | | /* Initialize total-height counter for detecting bottom of image */ |
54 | 5.57k | upsample->rows_to_go = cinfo->output_height; |
55 | 5.57k | } jdsample-8.c:start_pass_upsample Line | Count | Source | 48 | 2.70k | { | 49 | 2.70k | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 50 | | | 51 | | /* Mark the conversion buffer empty */ | 52 | 2.70k | upsample->next_row_out = cinfo->max_v_samp_factor; | 53 | | /* Initialize total-height counter for detecting bottom of image */ | 54 | 2.70k | upsample->rows_to_go = cinfo->output_height; | 55 | 2.70k | } |
jdsample-12.c:start_pass_upsample Line | Count | Source | 48 | 2.50k | { | 49 | 2.50k | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 50 | | | 51 | | /* Mark the conversion buffer empty */ | 52 | 2.50k | upsample->next_row_out = cinfo->max_v_samp_factor; | 53 | | /* Initialize total-height counter for detecting bottom of image */ | 54 | 2.50k | upsample->rows_to_go = cinfo->output_height; | 55 | 2.50k | } |
jdsample-16.c:start_pass_upsample Line | Count | Source | 48 | 362 | { | 49 | 362 | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 50 | | | 51 | | /* Mark the conversion buffer empty */ | 52 | 362 | upsample->next_row_out = cinfo->max_v_samp_factor; | 53 | | /* Initialize total-height counter for detecting bottom of image */ | 54 | 362 | upsample->rows_to_go = cinfo->output_height; | 55 | 362 | } |
|
56 | | |
57 | | |
58 | | /* |
59 | | * Control routine to do upsampling (and color conversion). |
60 | | * |
61 | | * In this version we upsample each component independently. |
62 | | * We upsample one row group into the conversion buffer, then apply |
63 | | * color conversion a row at a time. |
64 | | */ |
65 | | |
66 | | METHODDEF(void) |
67 | | sep_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
68 | | JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail, |
69 | | _JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, |
70 | | JDIMENSION out_rows_avail) |
71 | 8.53M | { |
72 | 8.53M | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; |
73 | 8.53M | int ci; |
74 | 8.53M | jpeg_component_info *compptr; |
75 | 8.53M | JDIMENSION num_rows; |
76 | | |
77 | | /* Fill the conversion buffer, if it's empty */ |
78 | 8.53M | if (upsample->next_row_out >= cinfo->max_v_samp_factor) { |
79 | 24.8M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
80 | 16.3M | ci++, compptr++) { |
81 | | /* Invoke per-component upsample method. Notice we pass a POINTER |
82 | | * to color_buf[ci], so that fullsize_upsample can change it. |
83 | | */ |
84 | | #ifdef WITH_PROFILE |
85 | | cinfo->master->start = getTime(); |
86 | | #endif |
87 | 16.3M | (*upsample->methods[ci]) (cinfo, compptr, |
88 | 16.3M | input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), |
89 | 16.3M | upsample->color_buf + ci); |
90 | | #ifdef WITH_PROFILE |
91 | | cinfo->master->upsample_elapsed += getTime() - cinfo->master->start; |
92 | | cinfo->master->upsample_msamples += |
93 | | (double)cinfo->output_width * cinfo->max_v_samp_factor / 1000000.; |
94 | | #endif |
95 | 16.3M | } |
96 | 8.53M | upsample->next_row_out = 0; |
97 | 8.53M | } |
98 | | |
99 | | /* Color-convert and emit rows */ |
100 | | |
101 | | /* How many we have in the buffer: */ |
102 | 8.53M | num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out); |
103 | | /* Not more than the distance to the end of the image. Need this test |
104 | | * in case the image height is not a multiple of max_v_samp_factor: |
105 | | */ |
106 | 8.53M | if (num_rows > upsample->rows_to_go) |
107 | 1.83k | num_rows = upsample->rows_to_go; |
108 | | /* And not more than what the client can accept: */ |
109 | 8.53M | out_rows_avail -= *out_row_ctr; |
110 | 8.53M | if (num_rows > out_rows_avail) |
111 | 0 | num_rows = out_rows_avail; |
112 | | |
113 | | #ifdef WITH_PROFILE |
114 | | cinfo->master->start = getTime(); |
115 | | #endif |
116 | 8.53M | (*cinfo->cconvert->_color_convert) (cinfo, upsample->color_buf, |
117 | 8.53M | (JDIMENSION)upsample->next_row_out, |
118 | 8.53M | output_buf + *out_row_ctr, |
119 | 8.53M | (int)num_rows); |
120 | | #ifdef WITH_PROFILE |
121 | | cinfo->master->cconvert_elapsed += getTime() - cinfo->master->start; |
122 | | cinfo->master->cconvert_mpixels += |
123 | | (double)cinfo->output_width * num_rows / 1000000.; |
124 | | #endif |
125 | | |
126 | | /* Adjust counts */ |
127 | 8.53M | *out_row_ctr += num_rows; |
128 | 8.53M | upsample->rows_to_go -= num_rows; |
129 | 8.53M | upsample->next_row_out += num_rows; |
130 | | /* When the buffer is emptied, declare this input row group consumed */ |
131 | 8.53M | if (upsample->next_row_out >= cinfo->max_v_samp_factor) |
132 | 8.53M | (*in_row_group_ctr)++; |
133 | 8.53M | } jdsample-8.c:sep_upsample Line | Count | Source | 71 | 3.98M | { | 72 | 3.98M | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 73 | 3.98M | int ci; | 74 | 3.98M | jpeg_component_info *compptr; | 75 | 3.98M | JDIMENSION num_rows; | 76 | | | 77 | | /* Fill the conversion buffer, if it's empty */ | 78 | 3.98M | if (upsample->next_row_out >= cinfo->max_v_samp_factor) { | 79 | 11.9M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 80 | 7.99M | ci++, compptr++) { | 81 | | /* Invoke per-component upsample method. Notice we pass a POINTER | 82 | | * to color_buf[ci], so that fullsize_upsample can change it. | 83 | | */ | 84 | | #ifdef WITH_PROFILE | 85 | | cinfo->master->start = getTime(); | 86 | | #endif | 87 | 7.99M | (*upsample->methods[ci]) (cinfo, compptr, | 88 | 7.99M | input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), | 89 | 7.99M | upsample->color_buf + ci); | 90 | | #ifdef WITH_PROFILE | 91 | | cinfo->master->upsample_elapsed += getTime() - cinfo->master->start; | 92 | | cinfo->master->upsample_msamples += | 93 | | (double)cinfo->output_width * cinfo->max_v_samp_factor / 1000000.; | 94 | | #endif | 95 | 7.99M | } | 96 | 3.98M | upsample->next_row_out = 0; | 97 | 3.98M | } | 98 | | | 99 | | /* Color-convert and emit rows */ | 100 | | | 101 | | /* How many we have in the buffer: */ | 102 | 3.98M | num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out); | 103 | | /* Not more than the distance to the end of the image. Need this test | 104 | | * in case the image height is not a multiple of max_v_samp_factor: | 105 | | */ | 106 | 3.98M | if (num_rows > upsample->rows_to_go) | 107 | 1.06k | num_rows = upsample->rows_to_go; | 108 | | /* And not more than what the client can accept: */ | 109 | 3.98M | out_rows_avail -= *out_row_ctr; | 110 | 3.98M | if (num_rows > out_rows_avail) | 111 | 0 | num_rows = out_rows_avail; | 112 | | | 113 | | #ifdef WITH_PROFILE | 114 | | cinfo->master->start = getTime(); | 115 | | #endif | 116 | 3.98M | (*cinfo->cconvert->_color_convert) (cinfo, upsample->color_buf, | 117 | 3.98M | (JDIMENSION)upsample->next_row_out, | 118 | 3.98M | output_buf + *out_row_ctr, | 119 | 3.98M | (int)num_rows); | 120 | | #ifdef WITH_PROFILE | 121 | | cinfo->master->cconvert_elapsed += getTime() - cinfo->master->start; | 122 | | cinfo->master->cconvert_mpixels += | 123 | | (double)cinfo->output_width * num_rows / 1000000.; | 124 | | #endif | 125 | | | 126 | | /* Adjust counts */ | 127 | 3.98M | *out_row_ctr += num_rows; | 128 | 3.98M | upsample->rows_to_go -= num_rows; | 129 | 3.98M | upsample->next_row_out += num_rows; | 130 | | /* When the buffer is emptied, declare this input row group consumed */ | 131 | 3.98M | if (upsample->next_row_out >= cinfo->max_v_samp_factor) | 132 | 3.98M | (*in_row_group_ctr)++; | 133 | 3.98M | } |
jdsample-12.c:sep_upsample Line | Count | Source | 71 | 4.34M | { | 72 | 4.34M | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 73 | 4.34M | int ci; | 74 | 4.34M | jpeg_component_info *compptr; | 75 | 4.34M | JDIMENSION num_rows; | 76 | | | 77 | | /* Fill the conversion buffer, if it's empty */ | 78 | 4.34M | if (upsample->next_row_out >= cinfo->max_v_samp_factor) { | 79 | 12.0M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 80 | 7.70M | ci++, compptr++) { | 81 | | /* Invoke per-component upsample method. Notice we pass a POINTER | 82 | | * to color_buf[ci], so that fullsize_upsample can change it. | 83 | | */ | 84 | | #ifdef WITH_PROFILE | 85 | | cinfo->master->start = getTime(); | 86 | | #endif | 87 | 7.70M | (*upsample->methods[ci]) (cinfo, compptr, | 88 | 7.70M | input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), | 89 | 7.70M | upsample->color_buf + ci); | 90 | | #ifdef WITH_PROFILE | 91 | | cinfo->master->upsample_elapsed += getTime() - cinfo->master->start; | 92 | | cinfo->master->upsample_msamples += | 93 | | (double)cinfo->output_width * cinfo->max_v_samp_factor / 1000000.; | 94 | | #endif | 95 | 7.70M | } | 96 | 4.34M | upsample->next_row_out = 0; | 97 | 4.34M | } | 98 | | | 99 | | /* Color-convert and emit rows */ | 100 | | | 101 | | /* How many we have in the buffer: */ | 102 | 4.34M | num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out); | 103 | | /* Not more than the distance to the end of the image. Need this test | 104 | | * in case the image height is not a multiple of max_v_samp_factor: | 105 | | */ | 106 | 4.34M | if (num_rows > upsample->rows_to_go) | 107 | 728 | num_rows = upsample->rows_to_go; | 108 | | /* And not more than what the client can accept: */ | 109 | 4.34M | out_rows_avail -= *out_row_ctr; | 110 | 4.34M | if (num_rows > out_rows_avail) | 111 | 0 | num_rows = out_rows_avail; | 112 | | | 113 | | #ifdef WITH_PROFILE | 114 | | cinfo->master->start = getTime(); | 115 | | #endif | 116 | 4.34M | (*cinfo->cconvert->_color_convert) (cinfo, upsample->color_buf, | 117 | 4.34M | (JDIMENSION)upsample->next_row_out, | 118 | 4.34M | output_buf + *out_row_ctr, | 119 | 4.34M | (int)num_rows); | 120 | | #ifdef WITH_PROFILE | 121 | | cinfo->master->cconvert_elapsed += getTime() - cinfo->master->start; | 122 | | cinfo->master->cconvert_mpixels += | 123 | | (double)cinfo->output_width * num_rows / 1000000.; | 124 | | #endif | 125 | | | 126 | | /* Adjust counts */ | 127 | 4.34M | *out_row_ctr += num_rows; | 128 | 4.34M | upsample->rows_to_go -= num_rows; | 129 | 4.34M | upsample->next_row_out += num_rows; | 130 | | /* When the buffer is emptied, declare this input row group consumed */ | 131 | 4.34M | if (upsample->next_row_out >= cinfo->max_v_samp_factor) | 132 | 4.34M | (*in_row_group_ctr)++; | 133 | 4.34M | } |
jdsample-16.c:sep_upsample Line | Count | Source | 71 | 209k | { | 72 | 209k | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 73 | 209k | int ci; | 74 | 209k | jpeg_component_info *compptr; | 75 | 209k | JDIMENSION num_rows; | 76 | | | 77 | | /* Fill the conversion buffer, if it's empty */ | 78 | 209k | if (upsample->next_row_out >= cinfo->max_v_samp_factor) { | 79 | 839k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 80 | 629k | ci++, compptr++) { | 81 | | /* Invoke per-component upsample method. Notice we pass a POINTER | 82 | | * to color_buf[ci], so that fullsize_upsample can change it. | 83 | | */ | 84 | | #ifdef WITH_PROFILE | 85 | | cinfo->master->start = getTime(); | 86 | | #endif | 87 | 629k | (*upsample->methods[ci]) (cinfo, compptr, | 88 | 629k | input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), | 89 | 629k | upsample->color_buf + ci); | 90 | | #ifdef WITH_PROFILE | 91 | | cinfo->master->upsample_elapsed += getTime() - cinfo->master->start; | 92 | | cinfo->master->upsample_msamples += | 93 | | (double)cinfo->output_width * cinfo->max_v_samp_factor / 1000000.; | 94 | | #endif | 95 | 629k | } | 96 | 209k | upsample->next_row_out = 0; | 97 | 209k | } | 98 | | | 99 | | /* Color-convert and emit rows */ | 100 | | | 101 | | /* How many we have in the buffer: */ | 102 | 209k | num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out); | 103 | | /* Not more than the distance to the end of the image. Need this test | 104 | | * in case the image height is not a multiple of max_v_samp_factor: | 105 | | */ | 106 | 209k | if (num_rows > upsample->rows_to_go) | 107 | 40 | num_rows = upsample->rows_to_go; | 108 | | /* And not more than what the client can accept: */ | 109 | 209k | out_rows_avail -= *out_row_ctr; | 110 | 209k | if (num_rows > out_rows_avail) | 111 | 0 | num_rows = out_rows_avail; | 112 | | | 113 | | #ifdef WITH_PROFILE | 114 | | cinfo->master->start = getTime(); | 115 | | #endif | 116 | 209k | (*cinfo->cconvert->_color_convert) (cinfo, upsample->color_buf, | 117 | 209k | (JDIMENSION)upsample->next_row_out, | 118 | 209k | output_buf + *out_row_ctr, | 119 | 209k | (int)num_rows); | 120 | | #ifdef WITH_PROFILE | 121 | | cinfo->master->cconvert_elapsed += getTime() - cinfo->master->start; | 122 | | cinfo->master->cconvert_mpixels += | 123 | | (double)cinfo->output_width * num_rows / 1000000.; | 124 | | #endif | 125 | | | 126 | | /* Adjust counts */ | 127 | 209k | *out_row_ctr += num_rows; | 128 | 209k | upsample->rows_to_go -= num_rows; | 129 | 209k | upsample->next_row_out += num_rows; | 130 | | /* When the buffer is emptied, declare this input row group consumed */ | 131 | 209k | if (upsample->next_row_out >= cinfo->max_v_samp_factor) | 132 | 209k | (*in_row_group_ctr)++; | 133 | 209k | } |
|
134 | | |
135 | | |
136 | | /* |
137 | | * These are the routines invoked by sep_upsample to upsample pixel values |
138 | | * of a single component. One row group is processed per call. |
139 | | */ |
140 | | |
141 | | |
142 | | /* |
143 | | * For full-size components, we just make color_buf[ci] point at the |
144 | | * input buffer, and thus avoid copying any data. Note that this is |
145 | | * safe only because sep_upsample doesn't declare the input row group |
146 | | * "consumed" until we are done color converting and emitting it. |
147 | | */ |
148 | | |
149 | | METHODDEF(void) |
150 | | fullsize_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
151 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
152 | 7.85M | { |
153 | 7.85M | *output_data_ptr = input_data; |
154 | 7.85M | } jdsample-8.c:fullsize_upsample Line | Count | Source | 152 | 3.54M | { | 153 | 3.54M | *output_data_ptr = input_data; | 154 | 3.54M | } |
jdsample-12.c:fullsize_upsample Line | Count | Source | 152 | 4.12M | { | 153 | 4.12M | *output_data_ptr = input_data; | 154 | 4.12M | } |
jdsample-16.c:fullsize_upsample Line | Count | Source | 152 | 184k | { | 153 | 184k | *output_data_ptr = input_data; | 154 | 184k | } |
|
155 | | |
156 | | |
157 | | /* |
158 | | * This is a no-op version used for "uninteresting" components. |
159 | | * These components will not be referenced by color conversion. |
160 | | */ |
161 | | |
162 | | METHODDEF(void) |
163 | | noop_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
164 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
165 | 1.41M | { |
166 | 1.41M | *output_data_ptr = NULL; /* safety check */ |
167 | 1.41M | } jdsample-8.c:noop_upsample Line | Count | Source | 165 | 602k | { | 166 | | *output_data_ptr = NULL; /* safety check */ | 167 | 602k | } |
jdsample-12.c:noop_upsample Line | Count | Source | 165 | 813k | { | 166 | | *output_data_ptr = NULL; /* safety check */ | 167 | 813k | } |
Unexecuted instantiation: jdsample-16.c:noop_upsample |
168 | | |
169 | | |
170 | | /* |
171 | | * This version handles any integral sampling ratios. |
172 | | * This is not used for typical JPEG files, so it need not be fast. |
173 | | * Nor, for that matter, is it particularly accurate: the algorithm is |
174 | | * simple replication of the input pixel onto the corresponding output |
175 | | * pixels. The hi-falutin sampling literature refers to this as a |
176 | | * "box filter". A box filter tends to introduce visible artifacts, |
177 | | * so if you are actually going to use 3:1 or 4:1 sampling ratios |
178 | | * you would be well advised to improve this code. |
179 | | */ |
180 | | |
181 | | METHODDEF(void) |
182 | | int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
183 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
184 | 3.40M | { |
185 | 3.40M | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; |
186 | 3.40M | _JSAMPARRAY output_data = *output_data_ptr; |
187 | 3.40M | register _JSAMPROW inptr, outptr; |
188 | 3.40M | register _JSAMPLE invalue; |
189 | 3.40M | register int h; |
190 | 3.40M | _JSAMPROW outend; |
191 | 3.40M | int h_expand, v_expand; |
192 | 3.40M | int inrow, outrow; |
193 | | |
194 | 3.40M | h_expand = upsample->h_expand[compptr->component_index]; |
195 | 3.40M | v_expand = upsample->v_expand[compptr->component_index]; |
196 | | |
197 | 3.40M | inrow = outrow = 0; |
198 | 7.18M | while (outrow < cinfo->max_v_samp_factor) { |
199 | | /* Generate one output row with proper horizontal expansion */ |
200 | 3.78M | inptr = input_data[inrow]; |
201 | 3.78M | outptr = output_data[outrow]; |
202 | 3.78M | outend = outptr + cinfo->output_width; |
203 | 126M | while (outptr < outend) { |
204 | 122M | invalue = *inptr++; |
205 | 311M | for (h = h_expand; h > 0; h--) { |
206 | 189M | *outptr++ = invalue; |
207 | 189M | } |
208 | 122M | } |
209 | | /* Generate any additional output rows by duplicating the first one */ |
210 | 3.78M | if (v_expand > 1) { |
211 | 2.68M | _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, |
212 | 2.68M | v_expand - 1, cinfo->output_width); |
213 | 2.68M | } |
214 | 3.78M | inrow++; |
215 | 3.78M | outrow += v_expand; |
216 | 3.78M | } |
217 | 3.40M | } jdsample-8.c:int_upsample Line | Count | Source | 184 | 2.04M | { | 185 | 2.04M | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 186 | 2.04M | _JSAMPARRAY output_data = *output_data_ptr; | 187 | 2.04M | register _JSAMPROW inptr, outptr; | 188 | 2.04M | register _JSAMPLE invalue; | 189 | 2.04M | register int h; | 190 | 2.04M | _JSAMPROW outend; | 191 | 2.04M | int h_expand, v_expand; | 192 | 2.04M | int inrow, outrow; | 193 | | | 194 | 2.04M | h_expand = upsample->h_expand[compptr->component_index]; | 195 | 2.04M | v_expand = upsample->v_expand[compptr->component_index]; | 196 | | | 197 | 2.04M | inrow = outrow = 0; | 198 | 4.29M | while (outrow < cinfo->max_v_samp_factor) { | 199 | | /* Generate one output row with proper horizontal expansion */ | 200 | 2.24M | inptr = input_data[inrow]; | 201 | 2.24M | outptr = output_data[outrow]; | 202 | 2.24M | outend = outptr + cinfo->output_width; | 203 | 92.2M | while (outptr < outend) { | 204 | 90.0M | invalue = *inptr++; | 205 | 226M | for (h = h_expand; h > 0; h--) { | 206 | 136M | *outptr++ = invalue; | 207 | 136M | } | 208 | 90.0M | } | 209 | | /* Generate any additional output rows by duplicating the first one */ | 210 | 2.24M | if (v_expand > 1) { | 211 | 1.82M | _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, | 212 | 1.82M | v_expand - 1, cinfo->output_width); | 213 | 1.82M | } | 214 | 2.24M | inrow++; | 215 | 2.24M | outrow += v_expand; | 216 | 2.24M | } | 217 | 2.04M | } |
jdsample-12.c:int_upsample Line | Count | Source | 184 | 1.05M | { | 185 | 1.05M | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 186 | 1.05M | _JSAMPARRAY output_data = *output_data_ptr; | 187 | 1.05M | register _JSAMPROW inptr, outptr; | 188 | 1.05M | register _JSAMPLE invalue; | 189 | 1.05M | register int h; | 190 | 1.05M | _JSAMPROW outend; | 191 | 1.05M | int h_expand, v_expand; | 192 | 1.05M | int inrow, outrow; | 193 | | | 194 | 1.05M | h_expand = upsample->h_expand[compptr->component_index]; | 195 | 1.05M | v_expand = upsample->v_expand[compptr->component_index]; | 196 | | | 197 | 1.05M | inrow = outrow = 0; | 198 | 2.20M | while (outrow < cinfo->max_v_samp_factor) { | 199 | | /* Generate one output row with proper horizontal expansion */ | 200 | 1.15M | inptr = input_data[inrow]; | 201 | 1.15M | outptr = output_data[outrow]; | 202 | 1.15M | outend = outptr + cinfo->output_width; | 203 | 29.7M | while (outptr < outend) { | 204 | 28.5M | invalue = *inptr++; | 205 | 74.7M | for (h = h_expand; h > 0; h--) { | 206 | 46.1M | *outptr++ = invalue; | 207 | 46.1M | } | 208 | 28.5M | } | 209 | | /* Generate any additional output rows by duplicating the first one */ | 210 | 1.15M | if (v_expand > 1) { | 211 | 770k | _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, | 212 | 770k | v_expand - 1, cinfo->output_width); | 213 | 770k | } | 214 | 1.15M | inrow++; | 215 | 1.15M | outrow += v_expand; | 216 | 1.15M | } | 217 | 1.05M | } |
jdsample-16.c:int_upsample Line | Count | Source | 184 | 302k | { | 185 | 302k | my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample; | 186 | 302k | _JSAMPARRAY output_data = *output_data_ptr; | 187 | 302k | register _JSAMPROW inptr, outptr; | 188 | 302k | register _JSAMPLE invalue; | 189 | 302k | register int h; | 190 | 302k | _JSAMPROW outend; | 191 | 302k | int h_expand, v_expand; | 192 | 302k | int inrow, outrow; | 193 | | | 194 | 302k | h_expand = upsample->h_expand[compptr->component_index]; | 195 | 302k | v_expand = upsample->v_expand[compptr->component_index]; | 196 | | | 197 | 302k | inrow = outrow = 0; | 198 | 687k | while (outrow < cinfo->max_v_samp_factor) { | 199 | | /* Generate one output row with proper horizontal expansion */ | 200 | 385k | inptr = input_data[inrow]; | 201 | 385k | outptr = output_data[outrow]; | 202 | 385k | outend = outptr + cinfo->output_width; | 203 | 4.07M | while (outptr < outend) { | 204 | 3.69M | invalue = *inptr++; | 205 | 9.87M | for (h = h_expand; h > 0; h--) { | 206 | 6.18M | *outptr++ = invalue; | 207 | 6.18M | } | 208 | 3.69M | } | 209 | | /* Generate any additional output rows by duplicating the first one */ | 210 | 385k | if (v_expand > 1) { | 211 | 93.5k | _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, | 212 | 93.5k | v_expand - 1, cinfo->output_width); | 213 | 93.5k | } | 214 | 385k | inrow++; | 215 | 385k | outrow += v_expand; | 216 | 385k | } | 217 | 302k | } |
|
218 | | |
219 | | |
220 | | /* |
221 | | * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. |
222 | | * It's still a box filter. |
223 | | */ |
224 | | |
225 | | METHODDEF(void) |
226 | | h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
227 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
228 | 1.04M | { |
229 | 1.04M | _JSAMPARRAY output_data = *output_data_ptr; |
230 | 1.04M | register _JSAMPROW inptr, outptr; |
231 | 1.04M | register _JSAMPLE invalue; |
232 | 1.04M | _JSAMPROW outend; |
233 | 1.04M | int inrow; |
234 | | |
235 | 2.67M | for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { |
236 | 1.62M | inptr = input_data[inrow]; |
237 | 1.62M | outptr = output_data[inrow]; |
238 | 1.62M | outend = outptr + cinfo->output_width; |
239 | 16.3M | while (outptr < outend) { |
240 | 14.7M | invalue = *inptr++; |
241 | 14.7M | *outptr++ = invalue; |
242 | 14.7M | *outptr++ = invalue; |
243 | 14.7M | } |
244 | 1.62M | } |
245 | 1.04M | } Unexecuted instantiation: jdsample-8.c:h2v1_upsample jdsample-12.c:h2v1_upsample Line | Count | Source | 228 | 945k | { | 229 | 945k | _JSAMPARRAY output_data = *output_data_ptr; | 230 | 945k | register _JSAMPROW inptr, outptr; | 231 | 945k | register _JSAMPLE invalue; | 232 | 945k | _JSAMPROW outend; | 233 | 945k | int inrow; | 234 | | | 235 | 2.46M | for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { | 236 | 1.52M | inptr = input_data[inrow]; | 237 | 1.52M | outptr = output_data[inrow]; | 238 | 1.52M | outend = outptr + cinfo->output_width; | 239 | 13.7M | while (outptr < outend) { | 240 | 12.1M | invalue = *inptr++; | 241 | 12.1M | *outptr++ = invalue; | 242 | 12.1M | *outptr++ = invalue; | 243 | 12.1M | } | 244 | 1.52M | } | 245 | 945k | } |
jdsample-16.c:h2v1_upsample Line | Count | Source | 228 | 100k | { | 229 | 100k | _JSAMPARRAY output_data = *output_data_ptr; | 230 | 100k | register _JSAMPROW inptr, outptr; | 231 | 100k | register _JSAMPLE invalue; | 232 | 100k | _JSAMPROW outend; | 233 | 100k | int inrow; | 234 | | | 235 | 203k | for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { | 236 | 103k | inptr = input_data[inrow]; | 237 | 103k | outptr = output_data[inrow]; | 238 | 103k | outend = outptr + cinfo->output_width; | 239 | 2.61M | while (outptr < outend) { | 240 | 2.51M | invalue = *inptr++; | 241 | 2.51M | *outptr++ = invalue; | 242 | 2.51M | *outptr++ = invalue; | 243 | 2.51M | } | 244 | 103k | } | 245 | 100k | } |
|
246 | | |
247 | | |
248 | | /* |
249 | | * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. |
250 | | * It's still a box filter. |
251 | | */ |
252 | | |
253 | | METHODDEF(void) |
254 | | h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
255 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
256 | 452k | { |
257 | 452k | _JSAMPARRAY output_data = *output_data_ptr; |
258 | 452k | register _JSAMPROW inptr, outptr; |
259 | 452k | register _JSAMPLE invalue; |
260 | 452k | _JSAMPROW outend; |
261 | 452k | int inrow, outrow; |
262 | | |
263 | 452k | inrow = outrow = 0; |
264 | 999k | while (outrow < cinfo->max_v_samp_factor) { |
265 | 547k | inptr = input_data[inrow]; |
266 | 547k | outptr = output_data[outrow]; |
267 | 547k | outend = outptr + cinfo->output_width; |
268 | 9.26M | while (outptr < outend) { |
269 | 8.72M | invalue = *inptr++; |
270 | 8.72M | *outptr++ = invalue; |
271 | 8.72M | *outptr++ = invalue; |
272 | 8.72M | } |
273 | 547k | _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1, |
274 | 547k | cinfo->output_width); |
275 | 547k | inrow++; |
276 | 547k | outrow += 2; |
277 | 547k | } |
278 | 452k | } Unexecuted instantiation: jdsample-8.c:h2v2_upsample jdsample-12.c:h2v2_upsample Line | Count | Source | 256 | 409k | { | 257 | 409k | _JSAMPARRAY output_data = *output_data_ptr; | 258 | 409k | register _JSAMPROW inptr, outptr; | 259 | 409k | register _JSAMPLE invalue; | 260 | 409k | _JSAMPROW outend; | 261 | 409k | int inrow, outrow; | 262 | | | 263 | 409k | inrow = outrow = 0; | 264 | 874k | while (outrow < cinfo->max_v_samp_factor) { | 265 | 464k | inptr = input_data[inrow]; | 266 | 464k | outptr = output_data[outrow]; | 267 | 464k | outend = outptr + cinfo->output_width; | 268 | 7.77M | while (outptr < outend) { | 269 | 7.31M | invalue = *inptr++; | 270 | 7.31M | *outptr++ = invalue; | 271 | 7.31M | *outptr++ = invalue; | 272 | 7.31M | } | 273 | 464k | _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1, | 274 | 464k | cinfo->output_width); | 275 | 464k | inrow++; | 276 | 464k | outrow += 2; | 277 | 464k | } | 278 | 409k | } |
jdsample-16.c:h2v2_upsample Line | Count | Source | 256 | 42.2k | { | 257 | 42.2k | _JSAMPARRAY output_data = *output_data_ptr; | 258 | 42.2k | register _JSAMPROW inptr, outptr; | 259 | 42.2k | register _JSAMPLE invalue; | 260 | 42.2k | _JSAMPROW outend; | 261 | 42.2k | int inrow, outrow; | 262 | | | 263 | 42.2k | inrow = outrow = 0; | 264 | 124k | while (outrow < cinfo->max_v_samp_factor) { | 265 | 82.5k | inptr = input_data[inrow]; | 266 | 82.5k | outptr = output_data[outrow]; | 267 | 82.5k | outend = outptr + cinfo->output_width; | 268 | 1.49M | while (outptr < outend) { | 269 | 1.41M | invalue = *inptr++; | 270 | 1.41M | *outptr++ = invalue; | 271 | 1.41M | *outptr++ = invalue; | 272 | 1.41M | } | 273 | 82.5k | _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1, | 274 | 82.5k | cinfo->output_width); | 275 | 82.5k | inrow++; | 276 | 82.5k | outrow += 2; | 277 | 82.5k | } | 278 | 42.2k | } |
|
279 | | |
280 | | |
281 | | /* |
282 | | * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. |
283 | | * |
284 | | * The upsampling algorithm is linear interpolation between pixel centers, |
285 | | * also known as a "triangle filter". This is a good compromise between |
286 | | * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 |
287 | | * of the way between input pixel centers. |
288 | | * |
289 | | * A note about the "bias" calculations: when rounding fractional values to |
290 | | * integer, we do not want to always round 0.5 up to the next integer. |
291 | | * If we did that, we'd introduce a noticeable bias towards larger values. |
292 | | * Instead, this code is arranged so that 0.5 will be rounded up or down at |
293 | | * alternate pixel locations (a simple ordered dither pattern). |
294 | | */ |
295 | | |
296 | | METHODDEF(void) |
297 | | h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
298 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
299 | 79.1k | { |
300 | 79.1k | _JSAMPARRAY output_data = *output_data_ptr; |
301 | 79.1k | register _JSAMPROW inptr, outptr; |
302 | 79.1k | register int invalue; |
303 | 79.1k | register JDIMENSION colctr; |
304 | 79.1k | int inrow; |
305 | | |
306 | 252k | for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { |
307 | 173k | inptr = input_data[inrow]; |
308 | 173k | outptr = output_data[inrow]; |
309 | | /* Special case for first column */ |
310 | 173k | invalue = *inptr++; |
311 | 173k | *outptr++ = (_JSAMPLE)invalue; |
312 | 173k | *outptr++ = (_JSAMPLE)((invalue * 3 + inptr[0] + 2) >> 2); |
313 | | |
314 | 3.69M | for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { |
315 | | /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ |
316 | 3.51M | invalue = (*inptr++) * 3; |
317 | 3.51M | *outptr++ = (_JSAMPLE)((invalue + inptr[-2] + 1) >> 2); |
318 | 3.51M | *outptr++ = (_JSAMPLE)((invalue + inptr[0] + 2) >> 2); |
319 | 3.51M | } |
320 | | |
321 | | /* Special case for last column */ |
322 | 173k | invalue = *inptr; |
323 | 173k | *outptr++ = (_JSAMPLE)((invalue * 3 + inptr[-1] + 1) >> 2); |
324 | 173k | *outptr++ = (_JSAMPLE)invalue; |
325 | 173k | } |
326 | 79.1k | } Unexecuted instantiation: jdsample-8.c:h2v1_fancy_upsample jdsample-12.c:h2v1_fancy_upsample Line | Count | Source | 299 | 79.1k | { | 300 | 79.1k | _JSAMPARRAY output_data = *output_data_ptr; | 301 | 79.1k | register _JSAMPROW inptr, outptr; | 302 | 79.1k | register int invalue; | 303 | 79.1k | register JDIMENSION colctr; | 304 | 79.1k | int inrow; | 305 | | | 306 | 252k | for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { | 307 | 173k | inptr = input_data[inrow]; | 308 | 173k | outptr = output_data[inrow]; | 309 | | /* Special case for first column */ | 310 | 173k | invalue = *inptr++; | 311 | 173k | *outptr++ = (_JSAMPLE)invalue; | 312 | 173k | *outptr++ = (_JSAMPLE)((invalue * 3 + inptr[0] + 2) >> 2); | 313 | | | 314 | 3.69M | for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { | 315 | | /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ | 316 | 3.51M | invalue = (*inptr++) * 3; | 317 | 3.51M | *outptr++ = (_JSAMPLE)((invalue + inptr[-2] + 1) >> 2); | 318 | 3.51M | *outptr++ = (_JSAMPLE)((invalue + inptr[0] + 2) >> 2); | 319 | 3.51M | } | 320 | | | 321 | | /* Special case for last column */ | 322 | 173k | invalue = *inptr; | 323 | 173k | *outptr++ = (_JSAMPLE)((invalue * 3 + inptr[-1] + 1) >> 2); | 324 | 173k | *outptr++ = (_JSAMPLE)invalue; | 325 | 173k | } | 326 | 79.1k | } |
Unexecuted instantiation: jdsample-16.c:h2v1_fancy_upsample |
327 | | |
328 | | |
329 | | /* |
330 | | * Fancy processing for 1:1 horizontal and 2:1 vertical (4:4:0 subsampling). |
331 | | * |
332 | | * This is a less common case, but it can be encountered when losslessly |
333 | | * rotating/transposing a JPEG file that uses 4:2:2 chroma subsampling. |
334 | | */ |
335 | | |
336 | | METHODDEF(void) |
337 | | h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
338 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
339 | 278k | { |
340 | 278k | _JSAMPARRAY output_data = *output_data_ptr; |
341 | 278k | _JSAMPROW inptr0, inptr1, outptr; |
342 | | #if BITS_IN_JSAMPLE == 8 |
343 | | int thiscolsum, bias; |
344 | | #else |
345 | | JLONG thiscolsum, bias; |
346 | | #endif |
347 | 278k | JDIMENSION colctr; |
348 | 278k | int inrow, outrow, v; |
349 | | |
350 | 278k | inrow = outrow = 0; |
351 | 597k | while (outrow < cinfo->max_v_samp_factor) { |
352 | 958k | for (v = 0; v < 2; v++) { |
353 | | /* inptr0 points to nearest input row, inptr1 points to next nearest */ |
354 | 639k | inptr0 = input_data[inrow]; |
355 | 639k | if (v == 0) { /* next nearest is row above */ |
356 | 319k | inptr1 = input_data[inrow - 1]; |
357 | 319k | bias = 1; |
358 | 319k | } else { /* next nearest is row below */ |
359 | 319k | inptr1 = input_data[inrow + 1]; |
360 | 319k | bias = 2; |
361 | 319k | } |
362 | 639k | outptr = output_data[outrow++]; |
363 | | |
364 | 24.0M | for (colctr = 0; colctr < compptr->downsampled_width; colctr++) { |
365 | 23.4M | thiscolsum = (*inptr0++) * 3 + (*inptr1++); |
366 | 23.4M | *outptr++ = (_JSAMPLE)((thiscolsum + bias) >> 2); |
367 | 23.4M | } |
368 | 639k | } |
369 | 319k | inrow++; |
370 | 319k | } |
371 | 278k | } jdsample-8.c:h1v2_fancy_upsample Line | Count | Source | 339 | 81.4k | { | 340 | 81.4k | _JSAMPARRAY output_data = *output_data_ptr; | 341 | 81.4k | _JSAMPROW inptr0, inptr1, outptr; | 342 | 81.4k | #if BITS_IN_JSAMPLE == 8 | 343 | 81.4k | int thiscolsum, bias; | 344 | | #else | 345 | | JLONG thiscolsum, bias; | 346 | | #endif | 347 | 81.4k | JDIMENSION colctr; | 348 | 81.4k | int inrow, outrow, v; | 349 | | | 350 | 81.4k | inrow = outrow = 0; | 351 | 178k | while (outrow < cinfo->max_v_samp_factor) { | 352 | 290k | for (v = 0; v < 2; v++) { | 353 | | /* inptr0 points to nearest input row, inptr1 points to next nearest */ | 354 | 193k | inptr0 = input_data[inrow]; | 355 | 193k | if (v == 0) { /* next nearest is row above */ | 356 | 96.7k | inptr1 = input_data[inrow - 1]; | 357 | 96.7k | bias = 1; | 358 | 96.7k | } else { /* next nearest is row below */ | 359 | 96.7k | inptr1 = input_data[inrow + 1]; | 360 | 96.7k | bias = 2; | 361 | 96.7k | } | 362 | 193k | outptr = output_data[outrow++]; | 363 | | | 364 | 9.18M | for (colctr = 0; colctr < compptr->downsampled_width; colctr++) { | 365 | 8.99M | thiscolsum = (*inptr0++) * 3 + (*inptr1++); | 366 | 8.99M | *outptr++ = (_JSAMPLE)((thiscolsum + bias) >> 2); | 367 | 8.99M | } | 368 | 193k | } | 369 | 96.7k | inrow++; | 370 | 96.7k | } | 371 | 81.4k | } |
jdsample-12.c:h1v2_fancy_upsample Line | Count | Source | 339 | 196k | { | 340 | 196k | _JSAMPARRAY output_data = *output_data_ptr; | 341 | 196k | _JSAMPROW inptr0, inptr1, outptr; | 342 | | #if BITS_IN_JSAMPLE == 8 | 343 | | int thiscolsum, bias; | 344 | | #else | 345 | 196k | JLONG thiscolsum, bias; | 346 | 196k | #endif | 347 | 196k | JDIMENSION colctr; | 348 | 196k | int inrow, outrow, v; | 349 | | | 350 | 196k | inrow = outrow = 0; | 351 | 419k | while (outrow < cinfo->max_v_samp_factor) { | 352 | 668k | for (v = 0; v < 2; v++) { | 353 | | /* inptr0 points to nearest input row, inptr1 points to next nearest */ | 354 | 445k | inptr0 = input_data[inrow]; | 355 | 445k | if (v == 0) { /* next nearest is row above */ | 356 | 222k | inptr1 = input_data[inrow - 1]; | 357 | 222k | bias = 1; | 358 | 222k | } else { /* next nearest is row below */ | 359 | 222k | inptr1 = input_data[inrow + 1]; | 360 | 222k | bias = 2; | 361 | 222k | } | 362 | 445k | outptr = output_data[outrow++]; | 363 | | | 364 | 14.8M | for (colctr = 0; colctr < compptr->downsampled_width; colctr++) { | 365 | 14.4M | thiscolsum = (*inptr0++) * 3 + (*inptr1++); | 366 | 14.4M | *outptr++ = (_JSAMPLE)((thiscolsum + bias) >> 2); | 367 | 14.4M | } | 368 | 445k | } | 369 | 222k | inrow++; | 370 | 222k | } | 371 | 196k | } |
Unexecuted instantiation: jdsample-16.c:h1v2_fancy_upsample |
372 | | |
373 | | |
374 | | /* |
375 | | * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. |
376 | | * Again a triangle filter; see comments for h2v1 case, above. |
377 | | * |
378 | | * It is OK for us to reference the adjacent input rows because we demanded |
379 | | * context from the main buffer controller (see initialization code). |
380 | | */ |
381 | | |
382 | | METHODDEF(void) |
383 | | h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
384 | | _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr) |
385 | 85.9k | { |
386 | 85.9k | _JSAMPARRAY output_data = *output_data_ptr; |
387 | 85.9k | register _JSAMPROW inptr0, inptr1, outptr; |
388 | | #if BITS_IN_JSAMPLE == 8 |
389 | | register int thiscolsum, lastcolsum, nextcolsum; |
390 | | #else |
391 | | register JLONG thiscolsum, lastcolsum, nextcolsum; |
392 | | #endif |
393 | 85.9k | register JDIMENSION colctr; |
394 | 85.9k | int inrow, outrow, v; |
395 | | |
396 | 85.9k | inrow = outrow = 0; |
397 | 212k | while (outrow < cinfo->max_v_samp_factor) { |
398 | 380k | for (v = 0; v < 2; v++) { |
399 | | /* inptr0 points to nearest input row, inptr1 points to next nearest */ |
400 | 253k | inptr0 = input_data[inrow]; |
401 | 253k | if (v == 0) /* next nearest is row above */ |
402 | 126k | inptr1 = input_data[inrow - 1]; |
403 | 126k | else /* next nearest is row below */ |
404 | 126k | inptr1 = input_data[inrow + 1]; |
405 | 253k | outptr = output_data[outrow++]; |
406 | | |
407 | | /* Special case for first column */ |
408 | 253k | thiscolsum = (*inptr0++) * 3 + (*inptr1++); |
409 | 253k | nextcolsum = (*inptr0++) * 3 + (*inptr1++); |
410 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 4 + 8) >> 4); |
411 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4); |
412 | 253k | lastcolsum = thiscolsum; thiscolsum = nextcolsum; |
413 | | |
414 | 6.06M | for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { |
415 | | /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ |
416 | | /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ |
417 | 5.81M | nextcolsum = (*inptr0++) * 3 + (*inptr1++); |
418 | 5.81M | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4); |
419 | 5.81M | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4); |
420 | 5.81M | lastcolsum = thiscolsum; thiscolsum = nextcolsum; |
421 | 5.81M | } |
422 | | |
423 | | /* Special case for last column */ |
424 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4); |
425 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 4 + 7) >> 4); |
426 | 253k | } |
427 | 126k | inrow++; |
428 | 126k | } |
429 | 85.9k | } Unexecuted instantiation: jdsample-8.c:h2v2_fancy_upsample jdsample-12.c:h2v2_fancy_upsample Line | Count | Source | 385 | 85.9k | { | 386 | 85.9k | _JSAMPARRAY output_data = *output_data_ptr; | 387 | 85.9k | register _JSAMPROW inptr0, inptr1, outptr; | 388 | | #if BITS_IN_JSAMPLE == 8 | 389 | | register int thiscolsum, lastcolsum, nextcolsum; | 390 | | #else | 391 | 85.9k | register JLONG thiscolsum, lastcolsum, nextcolsum; | 392 | 85.9k | #endif | 393 | 85.9k | register JDIMENSION colctr; | 394 | 85.9k | int inrow, outrow, v; | 395 | | | 396 | 85.9k | inrow = outrow = 0; | 397 | 212k | while (outrow < cinfo->max_v_samp_factor) { | 398 | 380k | for (v = 0; v < 2; v++) { | 399 | | /* inptr0 points to nearest input row, inptr1 points to next nearest */ | 400 | 253k | inptr0 = input_data[inrow]; | 401 | 253k | if (v == 0) /* next nearest is row above */ | 402 | 126k | inptr1 = input_data[inrow - 1]; | 403 | 126k | else /* next nearest is row below */ | 404 | 126k | inptr1 = input_data[inrow + 1]; | 405 | 253k | outptr = output_data[outrow++]; | 406 | | | 407 | | /* Special case for first column */ | 408 | 253k | thiscolsum = (*inptr0++) * 3 + (*inptr1++); | 409 | 253k | nextcolsum = (*inptr0++) * 3 + (*inptr1++); | 410 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 4 + 8) >> 4); | 411 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4); | 412 | 253k | lastcolsum = thiscolsum; thiscolsum = nextcolsum; | 413 | | | 414 | 6.06M | for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { | 415 | | /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ | 416 | | /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ | 417 | 5.81M | nextcolsum = (*inptr0++) * 3 + (*inptr1++); | 418 | 5.81M | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4); | 419 | 5.81M | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4); | 420 | 5.81M | lastcolsum = thiscolsum; thiscolsum = nextcolsum; | 421 | 5.81M | } | 422 | | | 423 | | /* Special case for last column */ | 424 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4); | 425 | 253k | *outptr++ = (_JSAMPLE)((thiscolsum * 4 + 7) >> 4); | 426 | 253k | } | 427 | 126k | inrow++; | 428 | 126k | } | 429 | 85.9k | } |
Unexecuted instantiation: jdsample-16.c:h2v2_fancy_upsample |
430 | | |
431 | | |
432 | | /* |
433 | | * Module initialization routine for upsampling. |
434 | | */ |
435 | | |
436 | | GLOBAL(void) |
437 | | _jinit_upsampler(j_decompress_ptr cinfo) |
438 | 6.78k | { |
439 | 6.78k | my_upsample_ptr upsample; |
440 | 6.78k | int ci; |
441 | 6.78k | jpeg_component_info *compptr; |
442 | 6.78k | boolean need_buffer, do_fancy; |
443 | 6.78k | int h_in_group, v_in_group, h_out_group, v_out_group; |
444 | | |
445 | 6.78k | #ifdef D_LOSSLESS_SUPPORTED |
446 | 6.78k | if (cinfo->master->lossless) { |
447 | | #if BITS_IN_JSAMPLE == 8 |
448 | 440 | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) |
449 | | #else |
450 | 987 | if (cinfo->data_precision > BITS_IN_JSAMPLE || |
451 | 987 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) |
452 | 0 | #endif |
453 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
454 | 1.42k | } else |
455 | 5.35k | #endif |
456 | 5.35k | { |
457 | 5.35k | if (cinfo->data_precision != BITS_IN_JSAMPLE) |
458 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
459 | 5.35k | } |
460 | | |
461 | 6.78k | if (!cinfo->master->jinit_upsampler_no_alloc) { |
462 | 6.78k | upsample = (my_upsample_ptr) |
463 | 6.78k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
464 | 6.78k | sizeof(my_upsampler)); |
465 | 6.78k | cinfo->upsample = (struct jpeg_upsampler *)upsample; |
466 | 6.78k | upsample->pub.start_pass = start_pass_upsample; |
467 | 6.78k | upsample->pub._upsample = sep_upsample; |
468 | 6.78k | upsample->pub.need_context_rows = FALSE; /* until we find out differently */ |
469 | 6.78k | } else |
470 | 0 | upsample = (my_upsample_ptr)cinfo->upsample; |
471 | | |
472 | 6.78k | if (cinfo->CCIR601_sampling) /* this isn't supported */ |
473 | 0 | ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); |
474 | | |
475 | | /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, |
476 | | * so don't ask for it. |
477 | | */ |
478 | 6.78k | do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1; |
479 | | |
480 | | /* Verify we can handle the sampling factors, select per-component methods, |
481 | | * and create storage as needed. |
482 | | */ |
483 | 21.9k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
484 | 15.1k | ci++, compptr++) { |
485 | | /* Compute size of an "input group" after IDCT scaling. This many samples |
486 | | * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. |
487 | | */ |
488 | 15.1k | h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) / |
489 | 15.1k | cinfo->_min_DCT_scaled_size; |
490 | 15.1k | v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / |
491 | 15.1k | cinfo->_min_DCT_scaled_size; |
492 | 15.1k | h_out_group = cinfo->max_h_samp_factor; |
493 | 15.1k | v_out_group = cinfo->max_v_samp_factor; |
494 | 15.1k | upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ |
495 | 15.1k | need_buffer = TRUE; |
496 | 15.1k | if (!compptr->component_needed) { |
497 | | /* Don't bother to upsample an uninteresting component. */ |
498 | 1.08k | upsample->methods[ci] = noop_upsample; |
499 | 1.08k | need_buffer = FALSE; |
500 | 14.0k | } else if (h_in_group == h_out_group && v_in_group == v_out_group) { |
501 | | /* Fullsize components can be processed without any work. */ |
502 | 6.39k | upsample->methods[ci] = fullsize_upsample; |
503 | 6.39k | need_buffer = FALSE; |
504 | 7.64k | } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) { |
505 | | /* Special cases for 2h1v upsampling */ |
506 | 1.97k | if (do_fancy && compptr->downsampled_width > 2) { |
507 | | #ifdef WITH_SIMD |
508 | 57 | if (jsimd_set_h2v1_fancy_upsample(cinfo)) |
509 | 57 | upsample->methods[ci] = jsimd_h2v1_fancy_upsample; |
510 | 0 | else |
511 | 0 | #endif |
512 | 0 | upsample->methods[ci] = h2v1_fancy_upsample; |
513 | 1.85k | } else { |
514 | | #ifdef WITH_SIMD |
515 | 1.03k | if (jsimd_set_h2v1_upsample(cinfo)) |
516 | 1.03k | upsample->methods[ci] = jsimd_h2v1_upsample; |
517 | 0 | else |
518 | 0 | #endif |
519 | 0 | upsample->methods[ci] = h2v1_upsample; |
520 | 1.85k | } |
521 | 5.67k | } else if (h_in_group == h_out_group && |
522 | 2.77k | v_in_group * 2 == v_out_group && do_fancy) { |
523 | | /* Non-fancy upsampling is handled by the generic method */ |
524 | | #if defined(WITH_SIMD) && (SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM) |
525 | | if (jsimd_set_h1v2_fancy_upsample(cinfo)) |
526 | | upsample->methods[ci] = jsimd_h1v2_fancy_upsample; |
527 | | else |
528 | | #endif |
529 | 267 | upsample->methods[ci] = h1v2_fancy_upsample; |
530 | 267 | upsample->pub.need_context_rows = TRUE; |
531 | 5.40k | } else if (h_in_group * 2 == h_out_group && |
532 | 2.01k | v_in_group * 2 == v_out_group) { |
533 | | /* Special cases for 2h2v upsampling */ |
534 | 718 | if (do_fancy && compptr->downsampled_width > 2) { |
535 | | #ifdef WITH_SIMD |
536 | 22 | if (jsimd_set_h2v2_fancy_upsample(cinfo)) |
537 | 22 | upsample->methods[ci] = jsimd_h2v2_fancy_upsample; |
538 | 0 | else |
539 | 0 | #endif |
540 | 0 | upsample->methods[ci] = h2v2_fancy_upsample; |
541 | 57 | upsample->pub.need_context_rows = TRUE; |
542 | 661 | } else { |
543 | | #ifdef WITH_SIMD |
544 | 258 | if (jsimd_set_h2v2_upsample(cinfo)) |
545 | 258 | upsample->methods[ci] = jsimd_h2v2_upsample; |
546 | 0 | else |
547 | 0 | #endif |
548 | 0 | upsample->methods[ci] = h2v2_upsample; |
549 | 661 | } |
550 | 4.69k | } else if ((h_out_group % h_in_group) == 0 && |
551 | 4.67k | (v_out_group % v_in_group) == 0) { |
552 | | /* Generic integral-factors upsampling method */ |
553 | | #if defined(WITH_SIMD) && SIMD_ARCHITECTURE == MIPS |
554 | | if (jsimd_set_int_upsample(cinfo)) |
555 | | upsample->methods[ci] = jsimd_int_upsample; |
556 | | else |
557 | | #endif |
558 | 4.65k | upsample->methods[ci] = int_upsample; |
559 | 4.65k | upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group); |
560 | 4.65k | upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group); |
561 | 4.65k | } else |
562 | 34 | ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); |
563 | 15.1k | if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) { |
564 | 7.61k | upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray) |
565 | 7.61k | ((j_common_ptr)cinfo, JPOOL_IMAGE, |
566 | 7.61k | (JDIMENSION)jround_up((long)cinfo->output_width, |
567 | 7.61k | (long)cinfo->max_h_samp_factor), |
568 | 7.61k | (JDIMENSION)cinfo->max_v_samp_factor); |
569 | 7.61k | } |
570 | 15.1k | } |
571 | 6.78k | } Line | Count | Source | 438 | 3.46k | { | 439 | 3.46k | my_upsample_ptr upsample; | 440 | 3.46k | int ci; | 441 | 3.46k | jpeg_component_info *compptr; | 442 | 3.46k | boolean need_buffer, do_fancy; | 443 | 3.46k | int h_in_group, v_in_group, h_out_group, v_out_group; | 444 | | | 445 | 3.46k | #ifdef D_LOSSLESS_SUPPORTED | 446 | 3.46k | if (cinfo->master->lossless) { | 447 | 440 | #if BITS_IN_JSAMPLE == 8 | 448 | 440 | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 449 | | #else | 450 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 451 | | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 452 | | #endif | 453 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 454 | 440 | } else | 455 | 3.02k | #endif | 456 | 3.02k | { | 457 | 3.02k | if (cinfo->data_precision != BITS_IN_JSAMPLE) | 458 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 459 | 3.02k | } | 460 | | | 461 | 3.46k | if (!cinfo->master->jinit_upsampler_no_alloc) { | 462 | 3.46k | upsample = (my_upsample_ptr) | 463 | 3.46k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 464 | 3.46k | sizeof(my_upsampler)); | 465 | 3.46k | cinfo->upsample = (struct jpeg_upsampler *)upsample; | 466 | 3.46k | upsample->pub.start_pass = start_pass_upsample; | 467 | 3.46k | upsample->pub._upsample = sep_upsample; | 468 | 3.46k | upsample->pub.need_context_rows = FALSE; /* until we find out differently */ | 469 | 3.46k | } else | 470 | 0 | upsample = (my_upsample_ptr)cinfo->upsample; | 471 | | | 472 | 3.46k | if (cinfo->CCIR601_sampling) /* this isn't supported */ | 473 | 0 | ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); | 474 | | | 475 | | /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, | 476 | | * so don't ask for it. | 477 | | */ | 478 | 3.46k | do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1; | 479 | | | 480 | | /* Verify we can handle the sampling factors, select per-component methods, | 481 | | * and create storage as needed. | 482 | | */ | 483 | 11.5k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 484 | 8.07k | ci++, compptr++) { | 485 | | /* Compute size of an "input group" after IDCT scaling. This many samples | 486 | | * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. | 487 | | */ | 488 | 8.07k | h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) / | 489 | 8.07k | cinfo->_min_DCT_scaled_size; | 490 | 8.07k | v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / | 491 | 8.07k | cinfo->_min_DCT_scaled_size; | 492 | 8.07k | h_out_group = cinfo->max_h_samp_factor; | 493 | 8.07k | v_out_group = cinfo->max_v_samp_factor; | 494 | 8.07k | upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ | 495 | 8.07k | need_buffer = TRUE; | 496 | 8.07k | if (!compptr->component_needed) { | 497 | | /* Don't bother to upsample an uninteresting component. */ | 498 | 670 | upsample->methods[ci] = noop_upsample; | 499 | 670 | need_buffer = FALSE; | 500 | 7.40k | } else if (h_in_group == h_out_group && v_in_group == v_out_group) { | 501 | | /* Fullsize components can be processed without any work. */ | 502 | 3.44k | upsample->methods[ci] = fullsize_upsample; | 503 | 3.44k | need_buffer = FALSE; | 504 | 3.95k | } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) { | 505 | | /* Special cases for 2h1v upsampling */ | 506 | 1.09k | if (do_fancy && compptr->downsampled_width > 2) { | 507 | 57 | #ifdef WITH_SIMD | 508 | 57 | if (jsimd_set_h2v1_fancy_upsample(cinfo)) | 509 | 57 | upsample->methods[ci] = jsimd_h2v1_fancy_upsample; | 510 | 0 | else | 511 | 0 | #endif | 512 | 0 | upsample->methods[ci] = h2v1_fancy_upsample; | 513 | 1.03k | } else { | 514 | 1.03k | #ifdef WITH_SIMD | 515 | 1.03k | if (jsimd_set_h2v1_upsample(cinfo)) | 516 | 1.03k | upsample->methods[ci] = jsimd_h2v1_upsample; | 517 | 0 | else | 518 | 0 | #endif | 519 | 0 | upsample->methods[ci] = h2v1_upsample; | 520 | 1.03k | } | 521 | 2.86k | } else if (h_in_group == h_out_group && | 522 | 1.46k | v_in_group * 2 == v_out_group && do_fancy) { | 523 | | /* Non-fancy upsampling is handled by the generic method */ | 524 | | #if defined(WITH_SIMD) && (SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM) | 525 | | if (jsimd_set_h1v2_fancy_upsample(cinfo)) | 526 | | upsample->methods[ci] = jsimd_h1v2_fancy_upsample; | 527 | | else | 528 | | #endif | 529 | 94 | upsample->methods[ci] = h1v2_fancy_upsample; | 530 | 94 | upsample->pub.need_context_rows = TRUE; | 531 | 2.77k | } else if (h_in_group * 2 == h_out_group && | 532 | 933 | v_in_group * 2 == v_out_group) { | 533 | | /* Special cases for 2h2v upsampling */ | 534 | 280 | if (do_fancy && compptr->downsampled_width > 2) { | 535 | 22 | #ifdef WITH_SIMD | 536 | 22 | if (jsimd_set_h2v2_fancy_upsample(cinfo)) | 537 | 22 | upsample->methods[ci] = jsimd_h2v2_fancy_upsample; | 538 | 0 | else | 539 | 0 | #endif | 540 | 0 | upsample->methods[ci] = h2v2_fancy_upsample; | 541 | 22 | upsample->pub.need_context_rows = TRUE; | 542 | 258 | } else { | 543 | 258 | #ifdef WITH_SIMD | 544 | 258 | if (jsimd_set_h2v2_upsample(cinfo)) | 545 | 258 | upsample->methods[ci] = jsimd_h2v2_upsample; | 546 | 0 | else | 547 | 0 | #endif | 548 | 0 | upsample->methods[ci] = h2v2_upsample; | 549 | 258 | } | 550 | 2.49k | } else if ((h_out_group % h_in_group) == 0 && | 551 | 2.48k | (v_out_group % v_in_group) == 0) { | 552 | | /* Generic integral-factors upsampling method */ | 553 | | #if defined(WITH_SIMD) && SIMD_ARCHITECTURE == MIPS | 554 | | if (jsimd_set_int_upsample(cinfo)) | 555 | | upsample->methods[ci] = jsimd_int_upsample; | 556 | | else | 557 | | #endif | 558 | 2.48k | upsample->methods[ci] = int_upsample; | 559 | 2.48k | upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group); | 560 | 2.48k | upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group); | 561 | 2.48k | } else | 562 | 15 | ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); | 563 | 8.07k | if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) { | 564 | 3.94k | upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray) | 565 | 3.94k | ((j_common_ptr)cinfo, JPOOL_IMAGE, | 566 | 3.94k | (JDIMENSION)jround_up((long)cinfo->output_width, | 567 | 3.94k | (long)cinfo->max_h_samp_factor), | 568 | 3.94k | (JDIMENSION)cinfo->max_v_samp_factor); | 569 | 3.94k | } | 570 | 8.07k | } | 571 | 3.46k | } |
Line | Count | Source | 438 | 2.79k | { | 439 | 2.79k | my_upsample_ptr upsample; | 440 | 2.79k | int ci; | 441 | 2.79k | jpeg_component_info *compptr; | 442 | 2.79k | boolean need_buffer, do_fancy; | 443 | 2.79k | int h_in_group, v_in_group, h_out_group, v_out_group; | 444 | | | 445 | 2.79k | #ifdef D_LOSSLESS_SUPPORTED | 446 | 2.79k | if (cinfo->master->lossless) { | 447 | | #if BITS_IN_JSAMPLE == 8 | 448 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 449 | | #else | 450 | 471 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 451 | 471 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 452 | 0 | #endif | 453 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 454 | 471 | } else | 455 | 2.32k | #endif | 456 | 2.32k | { | 457 | 2.32k | if (cinfo->data_precision != BITS_IN_JSAMPLE) | 458 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 459 | 2.32k | } | 460 | | | 461 | 2.79k | if (!cinfo->master->jinit_upsampler_no_alloc) { | 462 | 2.79k | upsample = (my_upsample_ptr) | 463 | 2.79k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 464 | 2.79k | sizeof(my_upsampler)); | 465 | 2.79k | cinfo->upsample = (struct jpeg_upsampler *)upsample; | 466 | 2.79k | upsample->pub.start_pass = start_pass_upsample; | 467 | 2.79k | upsample->pub._upsample = sep_upsample; | 468 | 2.79k | upsample->pub.need_context_rows = FALSE; /* until we find out differently */ | 469 | 2.79k | } else | 470 | 0 | upsample = (my_upsample_ptr)cinfo->upsample; | 471 | | | 472 | 2.79k | if (cinfo->CCIR601_sampling) /* this isn't supported */ | 473 | 0 | ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); | 474 | | | 475 | | /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, | 476 | | * so don't ask for it. | 477 | | */ | 478 | 2.79k | do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1; | 479 | | | 480 | | /* Verify we can handle the sampling factors, select per-component methods, | 481 | | * and create storage as needed. | 482 | | */ | 483 | 8.31k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 484 | 5.51k | ci++, compptr++) { | 485 | | /* Compute size of an "input group" after IDCT scaling. This many samples | 486 | | * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. | 487 | | */ | 488 | 5.51k | h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) / | 489 | 5.51k | cinfo->_min_DCT_scaled_size; | 490 | 5.51k | v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / | 491 | 5.51k | cinfo->_min_DCT_scaled_size; | 492 | 5.51k | h_out_group = cinfo->max_h_samp_factor; | 493 | 5.51k | v_out_group = cinfo->max_v_samp_factor; | 494 | 5.51k | upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ | 495 | 5.51k | need_buffer = TRUE; | 496 | 5.51k | if (!compptr->component_needed) { | 497 | | /* Don't bother to upsample an uninteresting component. */ | 498 | 414 | upsample->methods[ci] = noop_upsample; | 499 | 414 | need_buffer = FALSE; | 500 | 5.09k | } else if (h_in_group == h_out_group && v_in_group == v_out_group) { | 501 | | /* Fullsize components can be processed without any work. */ | 502 | 2.61k | upsample->methods[ci] = fullsize_upsample; | 503 | 2.61k | need_buffer = FALSE; | 504 | 2.61k | } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) { | 505 | | /* Special cases for 2h1v upsampling */ | 506 | 568 | if (do_fancy && compptr->downsampled_width > 2) { | 507 | | #ifdef WITH_SIMD | 508 | | if (jsimd_set_h2v1_fancy_upsample(cinfo)) | 509 | | upsample->methods[ci] = jsimd_h2v1_fancy_upsample; | 510 | | else | 511 | | #endif | 512 | 55 | upsample->methods[ci] = h2v1_fancy_upsample; | 513 | 513 | } else { | 514 | | #ifdef WITH_SIMD | 515 | | if (jsimd_set_h2v1_upsample(cinfo)) | 516 | | upsample->methods[ci] = jsimd_h2v1_upsample; | 517 | | else | 518 | | #endif | 519 | 513 | upsample->methods[ci] = h2v1_upsample; | 520 | 513 | } | 521 | 1.91k | } else if (h_in_group == h_out_group && | 522 | 928 | v_in_group * 2 == v_out_group && do_fancy) { | 523 | | /* Non-fancy upsampling is handled by the generic method */ | 524 | | #if defined(WITH_SIMD) && (SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM) | 525 | | if (jsimd_set_h1v2_fancy_upsample(cinfo)) | 526 | | upsample->methods[ci] = jsimd_h1v2_fancy_upsample; | 527 | | else | 528 | | #endif | 529 | 173 | upsample->methods[ci] = h1v2_fancy_upsample; | 530 | 173 | upsample->pub.need_context_rows = TRUE; | 531 | 1.74k | } else if (h_in_group * 2 == h_out_group && | 532 | 709 | v_in_group * 2 == v_out_group) { | 533 | | /* Special cases for 2h2v upsampling */ | 534 | 326 | if (do_fancy && compptr->downsampled_width > 2) { | 535 | | #ifdef WITH_SIMD | 536 | | if (jsimd_set_h2v2_fancy_upsample(cinfo)) | 537 | | upsample->methods[ci] = jsimd_h2v2_fancy_upsample; | 538 | | else | 539 | | #endif | 540 | 35 | upsample->methods[ci] = h2v2_fancy_upsample; | 541 | 35 | upsample->pub.need_context_rows = TRUE; | 542 | 291 | } else { | 543 | | #ifdef WITH_SIMD | 544 | | if (jsimd_set_h2v2_upsample(cinfo)) | 545 | | upsample->methods[ci] = jsimd_h2v2_upsample; | 546 | | else | 547 | | #endif | 548 | 291 | upsample->methods[ci] = h2v2_upsample; | 549 | 291 | } | 550 | 1.41k | } else if ((h_out_group % h_in_group) == 0 && | 551 | 1.41k | (v_out_group % v_in_group) == 0) { | 552 | | /* Generic integral-factors upsampling method */ | 553 | | #if defined(WITH_SIMD) && SIMD_ARCHITECTURE == MIPS | 554 | | if (jsimd_set_int_upsample(cinfo)) | 555 | | upsample->methods[ci] = jsimd_int_upsample; | 556 | | else | 557 | | #endif | 558 | 1.40k | upsample->methods[ci] = int_upsample; | 559 | 1.40k | upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group); | 560 | 1.40k | upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group); | 561 | 1.40k | } else | 562 | 11 | ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); | 563 | 5.51k | if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) { | 564 | 2.47k | upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray) | 565 | 2.47k | ((j_common_ptr)cinfo, JPOOL_IMAGE, | 566 | 2.47k | (JDIMENSION)jround_up((long)cinfo->output_width, | 567 | 2.47k | (long)cinfo->max_h_samp_factor), | 568 | 2.47k | (JDIMENSION)cinfo->max_v_samp_factor); | 569 | 2.47k | } | 570 | 5.51k | } | 571 | 2.79k | } |
Line | Count | Source | 438 | 516 | { | 439 | 516 | my_upsample_ptr upsample; | 440 | 516 | int ci; | 441 | 516 | jpeg_component_info *compptr; | 442 | 516 | boolean need_buffer, do_fancy; | 443 | 516 | int h_in_group, v_in_group, h_out_group, v_out_group; | 444 | | | 445 | 516 | #ifdef D_LOSSLESS_SUPPORTED | 446 | 516 | if (cinfo->master->lossless) { | 447 | | #if BITS_IN_JSAMPLE == 8 | 448 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 449 | | #else | 450 | 516 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 451 | 516 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 452 | 0 | #endif | 453 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 454 | 516 | } else | 455 | 0 | #endif | 456 | 0 | { | 457 | 0 | if (cinfo->data_precision != BITS_IN_JSAMPLE) | 458 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 459 | 0 | } | 460 | | | 461 | 516 | if (!cinfo->master->jinit_upsampler_no_alloc) { | 462 | 516 | upsample = (my_upsample_ptr) | 463 | 516 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 464 | 516 | sizeof(my_upsampler)); | 465 | 516 | cinfo->upsample = (struct jpeg_upsampler *)upsample; | 466 | 516 | upsample->pub.start_pass = start_pass_upsample; | 467 | 516 | upsample->pub._upsample = sep_upsample; | 468 | 516 | upsample->pub.need_context_rows = FALSE; /* until we find out differently */ | 469 | 516 | } else | 470 | 0 | upsample = (my_upsample_ptr)cinfo->upsample; | 471 | | | 472 | 516 | if (cinfo->CCIR601_sampling) /* this isn't supported */ | 473 | 0 | ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); | 474 | | | 475 | | /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, | 476 | | * so don't ask for it. | 477 | | */ | 478 | 516 | do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1; | 479 | | | 480 | | /* Verify we can handle the sampling factors, select per-component methods, | 481 | | * and create storage as needed. | 482 | | */ | 483 | 2.05k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 484 | 1.53k | ci++, compptr++) { | 485 | | /* Compute size of an "input group" after IDCT scaling. This many samples | 486 | | * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. | 487 | | */ | 488 | 1.53k | h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) / | 489 | 1.53k | cinfo->_min_DCT_scaled_size; | 490 | 1.53k | v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / | 491 | 1.53k | cinfo->_min_DCT_scaled_size; | 492 | 1.53k | h_out_group = cinfo->max_h_samp_factor; | 493 | 1.53k | v_out_group = cinfo->max_v_samp_factor; | 494 | 1.53k | upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ | 495 | 1.53k | need_buffer = TRUE; | 496 | 1.53k | if (!compptr->component_needed) { | 497 | | /* Don't bother to upsample an uninteresting component. */ | 498 | 0 | upsample->methods[ci] = noop_upsample; | 499 | 0 | need_buffer = FALSE; | 500 | 1.53k | } else if (h_in_group == h_out_group && v_in_group == v_out_group) { | 501 | | /* Fullsize components can be processed without any work. */ | 502 | 333 | upsample->methods[ci] = fullsize_upsample; | 503 | 333 | need_buffer = FALSE; | 504 | 1.20k | } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) { | 505 | | /* Special cases for 2h1v upsampling */ | 506 | 313 | if (do_fancy && compptr->downsampled_width > 2) { | 507 | | #ifdef WITH_SIMD | 508 | | if (jsimd_set_h2v1_fancy_upsample(cinfo)) | 509 | | upsample->methods[ci] = jsimd_h2v1_fancy_upsample; | 510 | | else | 511 | | #endif | 512 | 0 | upsample->methods[ci] = h2v1_fancy_upsample; | 513 | 313 | } else { | 514 | | #ifdef WITH_SIMD | 515 | | if (jsimd_set_h2v1_upsample(cinfo)) | 516 | | upsample->methods[ci] = jsimd_h2v1_upsample; | 517 | | else | 518 | | #endif | 519 | 313 | upsample->methods[ci] = h2v1_upsample; | 520 | 313 | } | 521 | 890 | } else if (h_in_group == h_out_group && | 522 | 383 | v_in_group * 2 == v_out_group && do_fancy) { | 523 | | /* Non-fancy upsampling is handled by the generic method */ | 524 | | #if defined(WITH_SIMD) && (SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM) | 525 | | if (jsimd_set_h1v2_fancy_upsample(cinfo)) | 526 | | upsample->methods[ci] = jsimd_h1v2_fancy_upsample; | 527 | | else | 528 | | #endif | 529 | 0 | upsample->methods[ci] = h1v2_fancy_upsample; | 530 | 0 | upsample->pub.need_context_rows = TRUE; | 531 | 890 | } else if (h_in_group * 2 == h_out_group && | 532 | 370 | v_in_group * 2 == v_out_group) { | 533 | | /* Special cases for 2h2v upsampling */ | 534 | 112 | if (do_fancy && compptr->downsampled_width > 2) { | 535 | | #ifdef WITH_SIMD | 536 | | if (jsimd_set_h2v2_fancy_upsample(cinfo)) | 537 | | upsample->methods[ci] = jsimd_h2v2_fancy_upsample; | 538 | | else | 539 | | #endif | 540 | 0 | upsample->methods[ci] = h2v2_fancy_upsample; | 541 | 0 | upsample->pub.need_context_rows = TRUE; | 542 | 112 | } else { | 543 | | #ifdef WITH_SIMD | 544 | | if (jsimd_set_h2v2_upsample(cinfo)) | 545 | | upsample->methods[ci] = jsimd_h2v2_upsample; | 546 | | else | 547 | | #endif | 548 | 112 | upsample->methods[ci] = h2v2_upsample; | 549 | 112 | } | 550 | 778 | } else if ((h_out_group % h_in_group) == 0 && | 551 | 775 | (v_out_group % v_in_group) == 0) { | 552 | | /* Generic integral-factors upsampling method */ | 553 | | #if defined(WITH_SIMD) && SIMD_ARCHITECTURE == MIPS | 554 | | if (jsimd_set_int_upsample(cinfo)) | 555 | | upsample->methods[ci] = jsimd_int_upsample; | 556 | | else | 557 | | #endif | 558 | 770 | upsample->methods[ci] = int_upsample; | 559 | 770 | upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group); | 560 | 770 | upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group); | 561 | 770 | } else | 562 | 8 | ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); | 563 | 1.53k | if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) { | 564 | 1.19k | upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray) | 565 | 1.19k | ((j_common_ptr)cinfo, JPOOL_IMAGE, | 566 | 1.19k | (JDIMENSION)jround_up((long)cinfo->output_width, | 567 | 1.19k | (long)cinfo->max_h_samp_factor), | 568 | 1.19k | (JDIMENSION)cinfo->max_v_samp_factor); | 569 | 1.19k | } | 570 | 1.53k | } | 571 | 516 | } |
|
572 | | |
573 | | #endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */ |