53 *dst++ = (src[0] * 3 + src[1] * 2) / 5;
65 *dst++ = (src2[0] * 2 + src2[1]) / 3;
72 *dst++ = (src2[1] + src2[3] + src2[2] * 2) >> 2;
94 *dst++ = (src[0] * 3 + src[w] * 2) / 5;
104 *dst++ = (src[ 0] * 2 + src[ w]) / 3;
116 *dst++ = (src[ w] + src[w3] + src[w2] * 2) >> 2;
140 ((src[0] + src[2]) * 56 +
146 ((src[0] + src[4]) * 28 +
147 (src[1] + src[3]) * 56 +
156 ((src[0] + src[6]) * 8 +
157 (src[1] + src[5]) * 28 +
158 (src[2] + src[4]) * 56 +
167 (src[1] + src[5]) * 28 +
168 (src[2] + src[4]) * 56 +
175 (src[2] + src[4]) * 56 +
195 const env_size_t w2 = w + w, w3 = w2 + w, w4 = w3 + w, w5 = w4 + w, w6 = w5 + w;
212 ((src[ 0] + src[w2]) * 56 +
223 ((src[ 0] + src[w4]) * 28 +
224 (src[ w] + src[w3]) * 56 +
236 ((src[ 0] + src[w6]) * 8 +
237 (src[ w] + src[w5]) * 28 +
238 (src[w2] + src[w4]) * 56 +
248 (src[ w] + src[w5]) * 28 +
249 (src[w2] + src[w4]) * 56 +
259 (src[w2] + src[w4]) * 56 +
280 *xmini = *xmaxi = src[0];
283 if (src[i] < *xmini) *xmini = src[i];
284 else if (src[i] > *xmaxi) *xmaxi = src[i];
291 for (
env_size_t i = 0; i < sz; ++i)
if (dst[i] < 0) dst[i] = 0;
303 const intg32 old_scale = ma - mi;
304 if (old_scale == 0 || old_scale < rangeThresh)
305 {
for (
env_size_t i = 0; i < sz; ++i) dst[i] = 0;
return; }
306 const intg32 new_scale = nmax - nmin;
309 {
for (
env_size_t i = 0; i < sz; ++i) dst[i] = nmin;
return; }
312 intg32 actualmin, actualmax;
314 if (old_scale == new_scale)
316 const intg32 add = nmin - mi;
317 if (add != 0)
for (
env_size_t i = 0; i < sz; ++i) dst[i] += add;
322#if defined(ENV_INTG64_TYPE)
326 dst[i] = nmin + ((((intg64)(dst[i] - mi)) * new_scale) / old_scale);
329 actualmax = nmin + ((((intg64)(old_scale)) * new_scale) / old_scale);
332 else if (old_scale > new_scale)
339 intg32 new_scale_reduced = new_scale;
340 intg32 old_scale_reduced = old_scale;
342 while (new_scale_reduced > nscale_max)
344 new_scale_reduced /= 2;
345 old_scale_reduced /= 2;
352 dst[i] = nmin + (((dst[i] - mi) * new_scale_reduced) / (old_scale_reduced+1));
355 actualmax = nmin + ((old_scale * new_scale_reduced) / (old_scale_reduced+1));
359 const intg32 mul = new_scale / old_scale;
360 for (
env_size_t i = 0; i < sz; ++i) dst[i] = nmin + ((dst[i] - mi) * mul);
363 actualmax = nmin + (old_scale * mul);
370 if (actualmin_p) *actualmin_p = actualmin;
371 if (actualmax_p) *actualmax_p = actualmax;
380 dst[i] = ((src[i].p[0] + src[i].p[1] + src[i].p[2]) / 3) << (nbits - 8);
383 dst[i] = ((src[i].p[0] + src[i].p[1] + src[i].p[2]) / 3) >> (8 - nbits);
386 dst[i] = (src[i].p[0] + src[i].p[1] + src[i].p[2]) / 3;
392 for (
env_size_t i = 0; i < sz; ++i) dst[i] = a[i] / val;
398 for (
env_size_t i = 0; i < sz; ++i) dst[i] += a[i] / val;
404 for (
env_size_t i = 0; i < sz; ++i) dst[i] = a[i] - b[i];
void env_c_lowpass_9_y_fewbits_optim(const intg32 *src, const env_size_t w, const env_size_t h, intg32 *dst)
Like env_c_lowpass_9_y_fewbits() but uses optimized filter coefficients.
void env_c_get_min_max(const intg32 *src, const env_size_t sz, intg32 *xmini, intg32 *xmaxi)
Get min and max values.
void env_c_lowpass_9_x_fewbits_optim(const intg32 *src, const env_size_t w, const env_size_t h, intg32 *dst)
Like env_c_lowpass_9_x_fewbits() but uses optimized filter coefficients.
void env_c_luminance_from_byte(const struct env_rgb_pixel *const src, const env_size_t sz, const env_size_t nbits, intg32 *const dst)
get the luminance with nbits of precision of the input image
void env_c_lowpass_5_x_dec_x_fewbits_optim(const intg32 *src, const env_size_t w, const env_size_t h, intg32 *dst, const env_size_t w2)
void env_c_inplace_rectify(intg32 *dst, const env_size_t sz)
Saturate values < 0.
void env_c_lowpass_5_y_dec_y_fewbits_optim(const intg32 *src, const env_size_t w, const env_size_t h, intg32 *dst, const env_size_t h2)
void env_c_image_div_scalar_accum(const intg32 *const a, const env_size_t sz, intg32 val, intg32 *const dst)
result += a / val
void env_c_image_div_scalar(const intg32 *const a, const env_size_t sz, intg32 val, intg32 *const dst)
result = a / val
void env_c_inplace_normalize(intg32 *const dst, const env_size_t sz, const intg32 nmin, const intg32 nmax, intg32 *const actualmin_p, intg32 *const actualmax_p, const intg32 rangeThresh)
void env_c_image_minus_image(const intg32 *const a, const intg32 *const b, const env_size_t sz, intg32 *const dst)
result = a - b
ENV_INTG32_TYPE intg32
32-bit signed integer