28 float af, rf, gf, bf, *p1f, *_p1f, *destf;
29 bool do_rect, do_float;
40 for (
y = ibuf2->
y;
y > 0;
y--) {
43 for (
x = ibuf2->
x;
x > 0;
x--) {
67 *(destf++) = 0.5f * af;
68 *(destf++) = 0.5f * bf;
69 *(destf++) = 0.5f * gf;
70 *(destf++) = 0.5f * rf;
74 _p1 += (ibuf1->
x << 2);
77 _p1f += (ibuf1->
x << 2);
110 int *p1, *
dest, i,
col, do_rect, do_float;
128 p1 = (
int *)ibuf1->
rect;
133 for (i = ibuf1->
y * ibuf1->
x; i > 0; i--) {
140 destf[0] = destf[4] = p1f[0];
141 destf[1] = destf[5] = p1f[1];
142 destf[2] = destf[6] = p1f[2];
143 destf[3] = destf[7] = p1f[3];
174 float af, rf, gf, bf, *p1f, *p2f, *_p1f, *destf;
179 const bool do_rect = (ibuf1->
rect !=
NULL);
187 for (
y = ibuf2->
y;
y > 0;
y--) {
190 p2 = _p1 + (ibuf1->
x << 2);
194 p2f = _p1f + (ibuf1->
x << 2);
196 for (
x = ibuf2->
x;
x > 0;
x--) {
220 *(destf++) = 0.5f * af;
221 *(destf++) = 0.5f * bf;
222 *(destf++) = 0.5f * gf;
223 *(destf++) = 0.5f * rf;
227 _p1 += (ibuf1->
x << 3);
230 _p1f += (ibuf1->
x << 3);
263 int *p1, *dest1, *dest2;
264 float *p1f, *dest1f, *dest2f;
274 const bool do_rect = (ibuf1->
rect !=
NULL);
282 p1 = (
int *)ibuf1->
rect;
283 dest1 = (
int *)ibuf2->
rect;
287 for (
y = ibuf1->
y;
y > 0;
y--) {
289 dest2 = dest1 + ibuf2->
x;
290 for (
x = ibuf2->
x;
x > 0;
x--) {
291 *dest1++ = *dest2++ = *p1++;
296 dest2f = dest1f + (4 * ibuf2->
x);
297 for (
x = ibuf2->
x * 4;
x > 0;
x--) {
298 *dest1f++ = *dest2f++ = *p1f++;
328 const unsigned char color[4])
330 unsigned short alpha =
color[3];
340 if (
color[3] <= 255) {
347 unsigned short alpha =
color[3] / 256;
359 const bool do_rect = (ibuf1->
rect !=
NULL);
362 if (do_rect && (ibuf2->
rect ==
NULL)) {
376 unsigned char *cp1, *cp2, *
dest;
378 cp1 = (
unsigned char *)ibuf1->
rect;
379 dest = (
unsigned char *)ibuf2->
rect;
381 for (
y = ibuf2->
y;
y > 0;
y--) {
382 cp2 = cp1 + (ibuf1->
x << 2);
383 for (
x = ibuf2->
x;
x > 0;
x--) {
384 unsigned short p1i[8], p2i[8], desti[4];
391 desti[0] = ((
unsigned int)p1i[0] + p2i[0] + p1i[4] + p2i[4]) >> 2;
392 desti[1] = ((
unsigned int)p1i[1] + p2i[1] + p1i[5] + p2i[5]) >> 2;
393 desti[2] = ((
unsigned int)p1i[2] + p2i[2] + p1i[6] + p2i[6]) >> 2;
394 desti[3] = ((
unsigned int)p1i[3] + p2i[3] + p1i[7] + p2i[7]) >> 2;
410 float *p1f, *p2f, *destf;
414 for (
y = ibuf2->
y;
y > 0;
y--) {
415 p2f = p1f + (ibuf1->
x << 2);
416 for (
x = ibuf2->
x;
x > 0;
x--) {
417 destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
418 destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
419 destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
420 destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
470 double ratiox = (
double)(dst_width - 1.0) / (
double)(src_width - 1.001);
471 double ratioy = (
double)(dst_height - 1.0) / (
double)(src_height - 1.001);
475 dx_src = 65536.0 / ratiox;
476 dy_src = 65536.0 / ratioy;
479 for (y_dst = 0; y_dst < dst_height; y_dst++) {
480 unsigned char *line1 =
src + (y_src >> 16) * 4 * src_width;
481 unsigned char *line2 = line1 + 4 * src_width;
482 uintptr_t weight1y = 65536 - (y_src & 0xffff);
485 if ((y_src >> 16) == src_height - 1) {
490 for (x_dst = 0; x_dst < dst_width; x_dst++) {
491 uintptr_t weight1x = 65536 - (x_src & 0xffff);
494 unsigned long x = (x_src >> 16) * 4;
496 *dst++ = ((((line1[
x] * weight1y) >> 16) * weight1x) >> 16) +
497 ((((line2[
x] * weight2y) >> 16) * weight1x) >> 16) +
498 ((((line1[4 +
x] * weight1y) >> 16) * weight2x) >> 16) +
499 ((((line2[4 +
x] * weight2y) >> 16) * weight2x) >> 16);
501 *dst++ = ((((line1[
x + 1] * weight1y) >> 16) * weight1x) >> 16) +
502 ((((line2[
x + 1] * weight2y) >> 16) * weight1x) >> 16) +
503 ((((line1[4 +
x + 1] * weight1y) >> 16) * weight2x) >> 16) +
504 ((((line2[4 +
x + 1] * weight2y) >> 16) * weight2x) >> 16);
506 *dst++ = ((((line1[
x + 2] * weight1y) >> 16) * weight1x) >> 16) +
507 ((((line2[
x + 2] * weight2y) >> 16) * weight1x) >> 16) +
508 ((((line1[4 +
x + 2] * weight1y) >> 16) * weight2x) >> 16) +
509 ((((line2[4 +
x + 2] * weight2y) >> 16) * weight2x) >> 16);
511 *dst++ = ((((line1[
x + 3] * weight1y) >> 16) * weight1x) >> 16) +
512 ((((line2[
x + 3] * weight2y) >> 16) * weight1x) >> 16) +
513 ((((line1[4 +
x + 3] * weight1y) >> 16) * weight2x) >> 16) +
514 ((((line2[4 +
x + 3] * weight2y) >> 16) * weight2x) >> 16);
538 double ratiox = (
double)(dst_width) / (
double)(src_width);
539 double ratioy = (
double)(dst_height) / (
double)(src_height);
543 unsigned char *dst_begin = dst;
553 dx_dst = 65536.0 * ratiox;
554 dy_dst = 65536.0 * ratioy;
558 for (y_src = 0; y_src < src_height; y_src++) {
559 unsigned char *line =
src + y_src * 4 * src_width;
560 uintptr_t weight1y = 65535 - (y_dst & 0xffff);
563 for (x_src = 0; x_src < src_width; x_src++) {
564 uintptr_t weight1x = 65535 - (x_dst & 0xffff);
571 w = (weight1y * weight1x) >> 16;
575 dst_line1[
x].
r += (line[0] *
w + 32767) >> 16;
576 dst_line1[
x].
g += (line[1] *
w + 32767) >> 16;
577 dst_line1[
x].
b += (line[2] *
w + 32767) >> 16;
578 dst_line1[
x].
a += (line[3] *
w + 32767) >> 16;
581 w = (weight2y * weight1x) >> 16;
583 dst_line2[
x].
r += (line[0] *
w + 32767) >> 16;
584 dst_line2[
x].
g += (line[1] *
w + 32767) >> 16;
585 dst_line2[
x].
b += (line[2] *
w + 32767) >> 16;
586 dst_line2[
x].
a += (line[3] *
w + 32767) >> 16;
589 w = (weight1y * weight2x) >> 16;
591 dst_line1[
x + 1].
r += (line[0] *
w + 32767) >> 16;
592 dst_line1[
x + 1].
g += (line[1] *
w + 32767) >> 16;
593 dst_line1[
x + 1].
b += (line[2] *
w + 32767) >> 16;
594 dst_line1[
x + 1].
a += (line[3] *
w + 32767) >> 16;
597 w = (weight2y * weight2x) >> 16;
599 dst_line2[
x + 1].
r += (line[0] *
w + 32767) >> 16;
600 dst_line2[
x + 1].
g += (line[1] *
w + 32767) >> 16;
601 dst_line2[
x + 1].
b += (line[2] *
w + 32767) >> 16;
602 dst_line2[
x + 1].
a += (line[3] *
w + 32767) >> 16;
618 for (
x = 0;
x < dst_width;
x++) {
620 *dst++ = (val = (dst_line1[
x].
r * f) >> 15) > 255 ? 255 : val;
621 *dst++ = (val = (dst_line1[
x].
g * f) >> 15) > 255 ? 255 : val;
622 *dst++ = (val = (dst_line1[
x].
b * f) >> 15) > 255 ? 255 : val;
623 *dst++ = (val = (dst_line1[
x].
a * f) >> 15) > 255 ? 255 : val;
627 dst_line1 = dst_line2;
631 if (dst - dst_begin < dst_width * dst_height * 4) {
634 for (
x = 0;
x < dst_width;
x++) {
636 *dst++ = (val = (dst_line1[
x].
r * f) >> 15) > 255 ? 255 : val;
637 *dst++ = (val = (dst_line1[
x].
g * f) >> 15) > 255 ? 255 : val;
638 *dst++ = (val = (dst_line1[
x].
b * f) >> 15) > 255 ? 255 : val;
639 *dst++ = (val = (dst_line1[
x].
a * f) >> 15) > 255 ? 255 : val;
653 if (dst_width > in_width && dst_height > in_height) {
656 else if (dst_width < in_width && dst_height < in_height) {
662 float *
src,
float *dst,
int src_width,
int src_height,
int dst_width,
int dst_height)
664 double ratiox = (
double)(dst_width - 1.0) / (
double)(src_width - 1.001);
665 double ratioy = (
double)(dst_height - 1.0) / (
double)(src_height - 1.001);
668 double x_src, dx_src;
669 double y_src, dy_src;
671 dx_src = 1.0 / ratiox;
672 dy_src = 1.0 / ratioy;
675 for (y_dst = 0; y_dst < dst_height; y_dst++) {
676 float *line1 =
src + ((int)y_src) * 4 * src_width;
677 const float *line2 = line1 + 4 * src_width;
678 const float weight1y = (
float)(1.0 - (y_src - (
int)y_src));
679 const float weight2y = 1.0f - weight1y;
681 if ((
int)y_src == src_height - 1) {
686 for (x_dst = 0; x_dst < dst_width; x_dst++) {
687 const float weight1x = (
float)(1.0 - (x_src - (
int)x_src));
688 const float weight2x = (
float)(1.0f - weight1x);
690 const float w11 = weight1y * weight1x;
691 const float w21 = weight2y * weight1x;
692 const float w12 = weight1y * weight2x;
693 const float w22 = weight2y * weight2x;
697 *dst++ = line1[
x] * w11 + line2[
x] * w21 + line1[4 +
x] * w12 + line2[4 +
x] * w22;
699 *dst++ = line1[
x + 1] * w11 + line2[
x + 1] * w21 + line1[4 +
x + 1] * w12 +
700 line2[4 +
x + 1] * w22;
702 *dst++ = line1[
x + 2] * w11 + line2[
x + 2] * w21 + line1[4 +
x + 2] * w12 +
703 line2[4 +
x + 2] * w22;
705 *dst++ = line1[
x + 3] * w11 + line2[
x + 3] * w21 + line1[4 +
x + 3] * w12 +
706 line2[4 +
x + 3] * w22;
724 const float *
src,
float *dst,
int src_width,
int src_height,
int dst_width,
int dst_height)
726 double ratiox = (
double)(dst_width) / (
double)(src_width);
727 double ratioy = (
double)(dst_height) / (
double)(src_height);
733 const float *dst_begin = dst;
748 for (y_src = 0; y_src < src_height; y_src++) {
749 const float *line =
src + y_src * 4 * src_width;
750 uintptr_t weight1y = 1.0f - (y_dst - (int)y_dst);
753 for (x_src = 0; x_src < src_width; x_src++) {
754 uintptr_t weight1x = 1.0f - (x_dst - (int)x_dst);
761 w = weight1y * weight1x;
763 dst_line1[
x].
r += line[0] *
w;
764 dst_line1[
x].
g += line[1] *
w;
765 dst_line1[
x].
b += line[2] *
w;
766 dst_line1[
x].
a += line[3] *
w;
769 w = weight2y * weight1x;
771 dst_line2[
x].
r += line[0] *
w;
772 dst_line2[
x].
g += line[1] *
w;
773 dst_line2[
x].
b += line[2] *
w;
774 dst_line2[
x].
a += line[3] *
w;
777 w = weight1y * weight2x;
779 dst_line1[
x + 1].
r += line[0] *
w;
780 dst_line1[
x + 1].
g += line[1] *
w;
781 dst_line1[
x + 1].
b += line[2] *
w;
782 dst_line1[
x + 1].
a += line[3] *
w;
785 w = weight2y * weight2x;
787 dst_line2[
x + 1].
r += line[0] *
w;
788 dst_line2[
x + 1].
g += line[1] *
w;
789 dst_line2[
x + 1].
b += line[2] *
w;
790 dst_line2[
x + 1].
a += line[3] *
w;
805 for (
x = 0;
x < dst_width;
x++) {
806 float f = 1.0f / dst_line1[
x].
weight;
807 *dst++ = dst_line1[
x].
r * f;
808 *dst++ = dst_line1[
x].
g * f;
809 *dst++ = dst_line1[
x].
b * f;
810 *dst++ = dst_line1[
x].
a * f;
814 dst_line1 = dst_line2;
818 if (dst - dst_begin < dst_width * dst_height * 4) {
820 for (
x = 0;
x < dst_width;
x++) {
821 float f = 1.0f / dst_line1[
x].
weight;
822 *dst++ = dst_line1[
x].
r * f;
823 *dst++ = dst_line1[
x].
g * f;
824 *dst++ = dst_line1[
x].
b * f;
825 *dst++ = dst_line1[
x].
a * f;
833 float *in,
float *
out,
int in_width,
int in_height,
int dst_width,
int dst_height)
835 if (dst_width > in_width && dst_height > in_height) {
838 else if (dst_width < in_width && dst_height < in_height) {
866 if ((newx >= ibuf->
x && newy <= ibuf->
y) || (newx <= ibuf->
x && newy >= ibuf->
y)) {
871 unsigned char *newrect =
MEM_mallocN(
sizeof(
int) * newx * newy,
"q_scale rect");
876 ibuf->
rect = (
unsigned int *)newrect;
879 float *newrect =
MEM_mallocN(
sizeof(
float[4]) * newx * newy,
"q_scale rectfloat");
893 const bool do_rect = (ibuf->
rect !=
NULL);
897 uchar *rect, *_newrect, *newrect;
898 float *rectf, *_newrectf, *newrectf;
899 float sample,
add, val[4], nval[4], valf[4], nvalf[4];
902 rectf = _newrectf = newrectf =
NULL;
903 rect = _newrect = newrect =
NULL;
904 nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
905 nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
907 if (!do_rect && !do_float) {
913 if (_newrect ==
NULL) {
918 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newx * ibuf->
y,
"scaledownxf");
919 if (_newrectf ==
NULL) {
927 add = (ibuf->
x - 0.01) / newx;
935 newrectf = _newrectf;
938 for (
y = ibuf->
y;
y > 0;
y--) {
940 val[0] = val[1] = val[2] = val[3] = 0.0f;
941 valf[0] = valf[1] = valf[2] = valf[3] = 0.0f;
943 for (
x = newx;
x > 0;
x--) {
945 nval[0] = -val[0] *
sample;
946 nval[1] = -val[1] *
sample;
947 nval[2] = -val[2] *
sample;
948 nval[3] = -val[3] *
sample;
951 nvalf[0] = -valf[0] *
sample;
952 nvalf[1] = -valf[1] *
sample;
953 nvalf[2] = -valf[2] *
sample;
954 nvalf[3] = -valf[3] *
sample;
970 nvalf[0] += rectf[0];
971 nvalf[1] += rectf[1];
972 nvalf[2] += rectf[2];
973 nvalf[3] += rectf[3];
985 newrect[0] = roundf((nval[0] +
sample * val[0]) /
add);
986 newrect[1] = roundf((nval[1] +
sample * val[1]) /
add);
987 newrect[2] = roundf((nval[2] +
sample * val[2]) /
add);
988 newrect[3] = roundf((nval[3] +
sample * val[3]) /
add);
1000 newrectf[0] = ((nvalf[0] +
sample * valf[0]) /
add);
1001 newrectf[1] = ((nvalf[1] +
sample * valf[1]) /
add);
1002 newrectf[2] = ((nvalf[2] +
sample * valf[2]) /
add);
1003 newrectf[3] = ((nvalf[3] +
sample * valf[3]) /
add);
1017 ibuf->
rect = (
unsigned int *)_newrect;
1034 const bool do_rect = (ibuf->
rect !=
NULL);
1038 uchar *rect, *_newrect, *newrect;
1039 float *rectf, *_newrectf, *newrectf;
1040 float sample,
add, val[4], nval[4], valf[4], nvalf[4];
1043 rectf = _newrectf = newrectf =
NULL;
1044 rect = _newrect = newrect =
NULL;
1045 nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
1046 nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
1048 if (!do_rect && !do_float) {
1054 if (_newrect ==
NULL) {
1059 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newy * ibuf->
x,
"scaledownyf");
1060 if (_newrectf ==
NULL) {
1068 add = (ibuf->
y - 0.01) / newy;
1069 skipx = 4 * ibuf->
x;
1071 for (
x = skipx - 4;
x >= 0;
x -= 4) {
1074 newrect = _newrect +
x;
1078 newrectf = _newrectf +
x;
1082 val[0] = val[1] = val[2] = val[3] = 0.0f;
1083 valf[0] = valf[1] = valf[2] = valf[3] = 0.0f;
1085 for (
y = newy;
y > 0;
y--) {
1087 nval[0] = -val[0] *
sample;
1088 nval[1] = -val[1] *
sample;
1089 nval[2] = -val[2] *
sample;
1090 nval[3] = -val[3] *
sample;
1093 nvalf[0] = -valf[0] *
sample;
1094 nvalf[1] = -valf[1] *
sample;
1095 nvalf[2] = -valf[2] *
sample;
1096 nvalf[3] = -valf[3] *
sample;
1112 nvalf[0] += rectf[0];
1113 nvalf[1] += rectf[1];
1114 nvalf[2] += rectf[2];
1115 nvalf[3] += rectf[3];
1127 newrect[0] = roundf((nval[0] +
sample * val[0]) /
add);
1128 newrect[1] = roundf((nval[1] +
sample * val[1]) /
add);
1129 newrect[2] = roundf((nval[2] +
sample * val[2]) /
add);
1130 newrect[3] = roundf((nval[3] +
sample * val[3]) /
add);
1142 newrectf[0] = ((nvalf[0] +
sample * valf[0]) /
add);
1143 newrectf[1] = ((nvalf[1] +
sample * valf[1]) /
add);
1144 newrectf[2] = ((nvalf[2] +
sample * valf[2]) /
add);
1145 newrectf[3] = ((nvalf[3] +
sample * valf[3]) /
add);
1159 ibuf->
rect = (
unsigned int *)_newrect;
1176 uchar *rect, *_newrect =
NULL, *newrect;
1177 float *rectf, *_newrectf =
NULL, *newrectf;
1179 bool do_rect =
false, do_float =
false;
1190 _newrect =
MEM_mallocN(newx * ibuf->
y *
sizeof(
int),
"scaleupx");
1191 if (_newrect ==
NULL) {
1197 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newx * ibuf->
y,
"scaleupxf");
1198 if (_newrectf ==
NULL) {
1209 newrectf = _newrectf;
1215 for (
y = ibuf->
y;
y > 0;
y--) {
1216 for (
x = newx;
x > 0;
x--) {
1217 memcpy(newrect, rect,
sizeof(
char[4]));
1224 for (
y = ibuf->
y;
y > 0;
y--) {
1225 for (
x = newx;
x > 0;
x--) {
1226 memcpy(newrectf, rectf,
sizeof(
float[4]));
1234 const float add = (ibuf->
x - 1.001) / (newx - 1.0);
1237 float val_a, nval_a, diff_a;
1238 float val_b, nval_b, diff_b;
1239 float val_g, nval_g, diff_g;
1240 float val_r, nval_r, diff_r;
1241 float val_af, nval_af, diff_af;
1242 float val_bf, nval_bf, diff_bf;
1243 float val_gf, nval_gf, diff_gf;
1244 float val_rf, nval_rf, diff_rf;
1246 val_a = nval_a = diff_a = val_b = nval_b = diff_b = 0;
1247 val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
1248 val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
1249 val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
1251 for (
y = ibuf->
y;
y > 0;
y--) {
1258 diff_a = nval_a - val_a;
1263 diff_b = nval_b - val_b;
1268 diff_g = nval_g - val_g;
1273 diff_r = nval_r - val_r;
1281 diff_af = nval_af - val_af;
1285 diff_bf = nval_bf - val_bf;
1289 diff_gf = nval_gf - val_gf;
1293 diff_rf = nval_rf - val_rf;
1297 for (
x = newx;
x > 0;
x--) {
1304 diff_a = nval_a - val_a;
1309 diff_b = nval_b - val_b;
1314 diff_g = nval_g - val_g;
1319 diff_r = nval_r - val_r;
1326 diff_af = nval_af - val_af;
1330 diff_bf = nval_bf - val_bf;
1334 diff_gf = nval_gf - val_gf;
1338 diff_rf = nval_rf - val_rf;
1343 newrect[0] = val_a +
sample * diff_a;
1344 newrect[1] = val_b +
sample * diff_b;
1345 newrect[2] = val_g +
sample * diff_g;
1346 newrect[3] = val_r +
sample * diff_r;
1350 newrectf[0] = val_af +
sample * diff_af;
1351 newrectf[1] = val_bf +
sample * diff_bf;
1352 newrectf[2] = val_gf +
sample * diff_gf;
1353 newrectf[3] = val_rf +
sample * diff_rf;
1364 ibuf->
rect = (
unsigned int *)_newrect;
1378 uchar *rect, *_newrect =
NULL, *newrect;
1379 float *rectf, *_newrectf =
NULL, *newrectf;
1381 bool do_rect =
false, do_float =
false;
1392 _newrect =
MEM_mallocN(ibuf->
x * newy *
sizeof(
int),
"scaleupy");
1393 if (_newrect ==
NULL) {
1399 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * ibuf->
x * newy,
"scaleupyf");
1400 if (_newrectf ==
NULL) {
1411 newrectf = _newrectf;
1413 skipx = 4 * ibuf->
x;
1419 for (
y = newy;
y > 0;
y--) {
1420 memcpy(newrect, rect,
sizeof(
char) * skipx);
1425 for (
y = newy;
y > 0;
y--) {
1426 memcpy(newrectf, rectf,
sizeof(
float) * skipx);
1432 const float add = (ibuf->
y - 1.001) / (newy - 1.0);
1435 float val_a, nval_a, diff_a;
1436 float val_b, nval_b, diff_b;
1437 float val_g, nval_g, diff_g;
1438 float val_r, nval_r, diff_r;
1439 float val_af, nval_af, diff_af;
1440 float val_bf, nval_bf, diff_bf;
1441 float val_gf, nval_gf, diff_gf;
1442 float val_rf, nval_rf, diff_rf;
1444 val_a = nval_a = diff_a = val_b = nval_b = diff_b = 0;
1445 val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
1446 val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
1447 val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
1449 for (
x = ibuf->
x;
x > 0;
x--) {
1453 newrect = _newrect + 4 * (
x - 1);
1456 nval_a = rect[skipx];
1457 diff_a = nval_a - val_a;
1461 nval_b = rect[skipx + 1];
1462 diff_b = nval_b - val_b;
1466 nval_g = rect[skipx + 2];
1467 diff_g = nval_g - val_g;
1471 nval_r = rect[skipx + 3];
1472 diff_r = nval_r - val_r;
1479 newrectf = _newrectf + 4 * (
x - 1);
1482 nval_af = rectf[skipx];
1483 diff_af = nval_af - val_af;
1486 nval_bf = rectf[skipx + 1];
1487 diff_bf = nval_bf - val_bf;
1490 nval_gf = rectf[skipx + 2];
1491 diff_gf = nval_gf - val_gf;
1494 nval_rf = rectf[skipx + 3];
1495 diff_rf = nval_rf - val_rf;
1500 for (
y = newy;
y > 0;
y--) {
1507 diff_a = nval_a - val_a;
1512 diff_b = nval_b - val_b;
1517 diff_g = nval_g - val_g;
1522 diff_r = nval_r - val_r;
1529 diff_af = nval_af - val_af;
1533 diff_bf = nval_bf - val_bf;
1537 diff_gf = nval_gf - val_gf;
1541 diff_rf = nval_rf - val_rf;
1546 newrect[0] = val_a +
sample * diff_a;
1547 newrect[1] = val_b +
sample * diff_b;
1548 newrect[2] = val_g +
sample * diff_g;
1549 newrect[3] = val_r +
sample * diff_r;
1553 newrectf[0] = val_af +
sample * diff_af;
1554 newrectf[1] = val_bf +
sample * diff_bf;
1555 newrectf[2] = val_gf +
sample * diff_gf;
1556 newrectf[3] = val_rf +
sample * diff_rf;
1567 ibuf->
rect = (
unsigned int *)_newrect;
1581 int *zbuf, *newzbuf, *_newzbuf =
NULL;
1582 float *zbuf_float, *newzbuf_float, *_newzbuf_float =
NULL;
1584 int ofsx, ofsy, stepx, stepy;
1587 _newzbuf =
MEM_mallocN(newx * newy *
sizeof(
int), __func__);
1588 if (_newzbuf ==
NULL) {
1594 _newzbuf_float =
MEM_mallocN((
size_t)newx * newy *
sizeof(
float), __func__);
1595 if (_newzbuf_float ==
NULL) {
1600 if (!_newzbuf && !_newzbuf_float) {
1604 stepx = round(65536.0 * (ibuf->
x - 1.0) / (newx - 1.0));
1605 stepy = round(65536.0 * (ibuf->
y - 1.0) / (newy - 1.0));
1609 newzbuf_float = _newzbuf_float;
1611 for (
y = newy;
y > 0;
y--, ofsy += stepy) {
1614 zbuf += (ofsy >> 16) * ibuf->
x;
1616 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1617 *newzbuf++ = zbuf[ofsx >> 16];
1621 if (newzbuf_float) {
1623 zbuf_float += (ofsy >> 16) * ibuf->
x;
1625 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1626 *newzbuf_float++ = zbuf_float[ofsx >> 16];
1634 ibuf->
zbuf = _newzbuf;
1637 if (_newzbuf_float) {
1646 BLI_assert_msg(newx > 0 && newy > 0,
"Images must be at least 1 on both dimensions!");
1655 if (newx == ibuf->
x && newy == ibuf->
y) {
1669 if (newx && (newx < ibuf->
x)) {
1672 if (newy && (newy < ibuf->
y)) {
1675 if (newx && (newx > ibuf->
x)) {
1678 if (newy && (newy > ibuf->
y)) {
1691 BLI_assert_msg(newx > 0 && newy > 0,
"Images must be at least 1 on both dimensions!");
1693 unsigned int *rect, *_newrect, *newrect;
1694 struct imbufRGBA *rectf, *_newrectf, *newrectf;
1696 bool do_float =
false, do_rect =
false;
1697 size_t ofsx, ofsy, stepx, stepy;
1715 if (do_rect ==
false && do_float ==
false) {
1719 if (newx == ibuf->
x && newy == ibuf->
y) {
1724 _newrect =
MEM_mallocN(newx * newy *
sizeof(
int),
"scalefastimbuf");
1725 if (_newrect ==
NULL) {
1732 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newx * newy,
"scalefastimbuf f");
1733 if (_newrectf ==
NULL) {
1739 newrectf = _newrectf;
1742 stepx = round(65536.0 * (ibuf->
x - 1.0) / (newx - 1.0));
1743 stepy = round(65536.0 * (ibuf->
y - 1.0) / (newy - 1.0));
1746 for (
y = newy;
y > 0;
y--, ofsy += stepy) {
1749 rect += (ofsy >> 16) * ibuf->
x;
1752 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1753 *newrect++ = rect[ofsx >> 16];
1759 rectf += (ofsy >> 16) * ibuf->
x;
1762 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1763 *newrectf++ = rectf[ofsx >> 16];
1771 ibuf->
rect = _newrect;
1822 data->start_line = start_line;
1823 data->tot_line = tot_line;
1834 float factor_x = (
float)ibuf->
x /
data->newx;
1835 float factor_y = (
float)ibuf->
y /
data->newy;
1837 for (i = 0; i <
data->tot_line; i++) {
1838 int y =
data->start_line + i;
1841 for (
x = 0;
x <
data->newx;
x++) {
1842 float u = (
float)
x * factor_x;
1843 float v = (
float)
y * factor_y;
1846 if (
data->byte_buffer) {
1847 unsigned char *pixel =
data->byte_buffer + 4 *
offset;
1849 (
unsigned char *)ibuf->
rect, pixel, ibuf->
x, ibuf->
y, 4, u,
v);
1852 if (
data->float_buffer) {
1865 BLI_assert_msg(newx > 0 && newy > 0,
"Images must be at least 1 on both dimensions!");
1877 "threaded scale byte buffer");
1882 "threaded scale float buffer");
typedef float(TangentPoint)[2]
#define BLI_assert_msg(a, msg)
void BLI_bilinear_interpolation_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
void BLI_bilinear_interpolation_char(const unsigned char *buffer, unsigned char *output, int width, int height, int components, float u, float v)
typedef double(DMatrix)[4][4]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Function declarations for filter.c.
void imb_freerectfloatImBuf(struct ImBuf *ibuf)
void IMB_freezbuffloatImBuf(struct ImBuf *ibuf)
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_filtery(struct ImBuf *ibuf)
void imb_freerectImBuf(struct ImBuf *ibuf)
void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_customdata, void(init_handle)(void *handle, int start_line, int tot_line, void *customdata), void *(do_thread)(void *))
void IMB_freezbufImBuf(struct ImBuf *ibuf)
size_t IMB_get_rect_len(const struct ImBuf *ibuf)
Get the length of the rect of the given image buffer in terms of pixels.
bool imb_addrectImBuf(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SyclQueue void void * src
SyclQueue void void size_t num_bytes void
void imb_filterx(struct ImBuf *ibuf)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
MINLINE unsigned char unit_ushort_to_uchar(unsigned short val)
bool add(void *owner, const AttributeIDRef &attribute_id, eAttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
ccl_device_inline int rect_size(int4 rect)
static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
struct ImBuf * IMB_double_fast_x(struct ImBuf *ibuf1)
void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
struct ImBuf * IMB_double_x(struct ImBuf *ibuf1)
struct ImBuf * IMB_double_y(struct ImBuf *ibuf1)
static void enlarge_picture_byte(unsigned char *src, unsigned char *dst, int src_width, int src_height, int dst_width, int dst_height)
struct ScaleTreadInitData ScaleTreadInitData
static void q_scale_float(float *in, float *out, int in_width, int in_height, int dst_width, int dst_height)
static void imb_half_x_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
static void shrink_picture_byte(unsigned char *src, unsigned char *dst, int src_width, int src_height, int dst_width, int dst_height)
static void imb_half_y_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
static void q_scale_byte(unsigned char *in, unsigned char *out, int in_width, int in_height, int dst_width, int dst_height)
static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy)
static ImBuf * scaleupx(struct ImBuf *ibuf, int newx)
struct ImBuf * IMB_double_fast_y(struct ImBuf *ibuf1)
static void * do_scale_thread(void *data_v)
struct ImBuf * IMB_half_y(struct ImBuf *ibuf1)
void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
struct ImBuf * IMB_half_x(struct ImBuf *ibuf1)
static void scale_thread_init(void *data_v, int start_line, int tot_line, void *init_data_v)
static void enlarge_picture_float(float *src, float *dst, int src_width, int src_height, int dst_width, int dst_height)
ImBuf * IMB_onehalf(struct ImBuf *ibuf1)
MINLINE void straight_uchar_to_premul_ushort(unsigned short result[4], const unsigned char color[4])
static void shrink_picture_float(const float *src, float *dst, int src_width, int src_height, int dst_width, int dst_height)
MINLINE void premul_ushort_to_straight_uchar(unsigned char *result, const unsigned short color[4])
static ImBuf * scaledowny(struct ImBuf *ibuf, int newy)
static ImBuf * scaleupy(struct ImBuf *ibuf, int newy)
static ImBuf * scaledownx(struct ImBuf *ibuf, int newx)
bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
struct ScaleThreadData ScaleThreadData
_W64 unsigned int uintptr_t
unsigned char * byte_buffer
unsigned char * byte_buffer