42 uchar *p1, *_p1, *dest;
45 float af, rf, gf, bf, *p1f, *_p1f, *destf;
46 bool do_rect, do_float;
57 for (
y = ibuf2->
y;
y > 0;
y--) {
60 for (
x = ibuf2->
x;
x > 0;
x--) {
84 *(destf++) = 0.5f * af;
85 *(destf++) = 0.5f * bf;
86 *(destf++) = 0.5f * gf;
87 *(destf++) = 0.5f * rf;
91 _p1 += (ibuf1->
x << 2);
94 _p1f += (ibuf1->
x << 2);
127 int *p1, *dest, i,
col, do_rect, do_float;
145 p1 = (
int *)ibuf1->
rect;
146 dest = (
int *)ibuf2->
rect;
150 for (i = ibuf1->
y * ibuf1->
x; i > 0; i--) {
157 destf[0] = destf[4] = p1f[0];
158 destf[1] = destf[5] = p1f[1];
159 destf[2] = destf[6] = p1f[2];
160 destf[3] = destf[7] = p1f[3];
188 uchar *p1, *p2, *_p1, *dest;
191 int do_rect, do_float;
192 float af, rf, gf, bf, *p1f, *p2f, *_p1f, *destf;
205 for (
y = ibuf2->
y;
y > 0;
y--) {
208 p2 = _p1 + (ibuf1->
x << 2);
212 p2f = _p1f + (ibuf1->
x << 2);
214 for (
x = ibuf2->
x;
x > 0;
x--) {
238 *(destf++) = 0.5f * af;
239 *(destf++) = 0.5f * bf;
240 *(destf++) = 0.5f * gf;
241 *(destf++) = 0.5f * rf;
245 _p1 += (ibuf1->
x << 3);
248 _p1f += (ibuf1->
x << 3);
281 int *p1, *dest1, *dest2;
282 float *p1f, *dest1f, *dest2f;
284 int do_rect, do_float;
301 p1 = (
int *)ibuf1->
rect;
302 dest1 = (
int *)ibuf2->
rect;
306 for (
y = ibuf1->
y;
y > 0;
y--) {
308 dest2 = dest1 + ibuf2->
x;
309 for (
x = ibuf2->
x;
x > 0;
x--) {
310 *dest1++ = *dest2++ = *p1++;
315 dest2f = dest1f + (4 * ibuf2->
x);
316 for (
x = ibuf2->
x * 4;
x > 0;
x--) {
317 *dest1f++ = *dest2f++ = *p1f++;
347 const unsigned char color[4])
349 unsigned short alpha = color[3];
359 if (color[3] <= 255) {
366 unsigned short alpha = color[3] / 256;
379 const short do_rect = (ibuf1->
rect !=
NULL);
382 if (do_rect && (ibuf2->
rect ==
NULL)) {
396 unsigned char *cp1, *cp2, *dest;
398 cp1 = (
unsigned char *)ibuf1->
rect;
399 dest = (
unsigned char *)ibuf2->
rect;
401 for (
y = ibuf2->
y;
y > 0;
y--) {
402 cp2 = cp1 + (ibuf1->
x << 2);
403 for (
x = ibuf2->
x;
x > 0;
x--) {
404 unsigned short p1i[8], p2i[8], desti[4];
411 desti[0] = ((
unsigned int)p1i[0] + p2i[0] + p1i[4] + p2i[4]) >> 2;
412 desti[1] = ((
unsigned int)p1i[1] + p2i[1] + p1i[5] + p2i[5]) >> 2;
413 desti[2] = ((
unsigned int)p1i[2] + p2i[2] + p1i[6] + p2i[6]) >> 2;
414 desti[3] = ((
unsigned int)p1i[3] + p2i[3] + p1i[7] + p2i[7]) >> 2;
430 float *p1f, *p2f, *destf;
434 for (
y = ibuf2->
y;
y > 0;
y--) {
435 p2f = p1f + (ibuf1->
x << 2);
436 for (
x = ibuf2->
x;
x > 0;
x--) {
437 destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
438 destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
439 destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
440 destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
490 double ratiox = (
double)(dst_width - 1.0) / (
double)(src_width - 1.001);
491 double ratioy = (
double)(dst_height - 1.0) / (
double)(src_height - 1.001);
495 dx_src = 65536.0 / ratiox;
496 dy_src = 65536.0 / ratioy;
499 for (y_dst = 0; y_dst < dst_height; y_dst++) {
500 unsigned char *line1 = src + (y_src >> 16) * 4 * src_width;
501 unsigned char *line2 = line1 + 4 * src_width;
502 uintptr_t weight1y = 65536 - (y_src & 0xffff);
505 if ((y_src >> 16) == src_height - 1) {
510 for (x_dst = 0; x_dst < dst_width; x_dst++) {
511 uintptr_t weight1x = 65536 - (x_src & 0xffff);
514 unsigned long x = (x_src >> 16) * 4;
516 *dst++ = ((((line1[
x] * weight1y) >> 16) * weight1x) >> 16) +
517 ((((line2[
x] * weight2y) >> 16) * weight1x) >> 16) +
518 ((((line1[4 +
x] * weight1y) >> 16) * weight2x) >> 16) +
519 ((((line2[4 +
x] * weight2y) >> 16) * weight2x) >> 16);
521 *dst++ = ((((line1[
x + 1] * weight1y) >> 16) * weight1x) >> 16) +
522 ((((line2[
x + 1] * weight2y) >> 16) * weight1x) >> 16) +
523 ((((line1[4 +
x + 1] * weight1y) >> 16) * weight2x) >> 16) +
524 ((((line2[4 +
x + 1] * weight2y) >> 16) * weight2x) >> 16);
526 *dst++ = ((((line1[
x + 2] * weight1y) >> 16) * weight1x) >> 16) +
527 ((((line2[
x + 2] * weight2y) >> 16) * weight1x) >> 16) +
528 ((((line1[4 +
x + 2] * weight1y) >> 16) * weight2x) >> 16) +
529 ((((line2[4 +
x + 2] * weight2y) >> 16) * weight2x) >> 16);
531 *dst++ = ((((line1[
x + 3] * weight1y) >> 16) * weight1x) >> 16) +
532 ((((line2[
x + 3] * weight2y) >> 16) * weight1x) >> 16) +
533 ((((line1[4 +
x + 3] * weight1y) >> 16) * weight2x) >> 16) +
534 ((((line2[4 +
x + 3] * weight2y) >> 16) * weight2x) >> 16);
558 double ratiox = (
double)(dst_width) / (
double)(src_width);
559 double ratioy = (
double)(dst_height) / (
double)(src_height);
563 unsigned char *dst_begin = dst;
573 dx_dst = 65536.0 * ratiox;
574 dy_dst = 65536.0 * ratioy;
578 for (y_src = 0; y_src < src_height; y_src++) {
579 unsigned char *line = src + y_src * 4 * src_width;
580 uintptr_t weight1y = 65535 - (y_dst & 0xffff);
583 for (x_src = 0; x_src < src_width; x_src++) {
584 uintptr_t weight1x = 65535 - (x_dst & 0xffff);
591 w = (weight1y * weight1x) >> 16;
595 dst_line1[
x].
r += (line[0] *
w + 32767) >> 16;
596 dst_line1[
x].
g += (line[1] *
w + 32767) >> 16;
597 dst_line1[
x].
b += (line[2] *
w + 32767) >> 16;
598 dst_line1[
x].
a += (line[3] *
w + 32767) >> 16;
601 w = (weight2y * weight1x) >> 16;
603 dst_line2[
x].
r += (line[0] *
w + 32767) >> 16;
604 dst_line2[
x].
g += (line[1] *
w + 32767) >> 16;
605 dst_line2[
x].
b += (line[2] *
w + 32767) >> 16;
606 dst_line2[
x].
a += (line[3] *
w + 32767) >> 16;
609 w = (weight1y * weight2x) >> 16;
611 dst_line1[
x + 1].
r += (line[0] *
w + 32767) >> 16;
612 dst_line1[
x + 1].
g += (line[1] *
w + 32767) >> 16;
613 dst_line1[
x + 1].
b += (line[2] *
w + 32767) >> 16;
614 dst_line1[
x + 1].
a += (line[3] *
w + 32767) >> 16;
617 w = (weight2y * weight2x) >> 16;
619 dst_line2[
x + 1].
r += (line[0] *
w + 32767) >> 16;
620 dst_line2[
x + 1].
g += (line[1] *
w + 32767) >> 16;
621 dst_line2[
x + 1].
b += (line[2] *
w + 32767) >> 16;
622 dst_line2[
x + 1].
a += (line[3] *
w + 32767) >> 16;
638 for (
x = 0;
x < dst_width;
x++) {
640 *dst++ = (val = (dst_line1[
x].
r * f) >> 15) > 255 ? 255 : val;
641 *dst++ = (val = (dst_line1[
x].
g * f) >> 15) > 255 ? 255 : val;
642 *dst++ = (val = (dst_line1[
x].
b * f) >> 15) > 255 ? 255 : val;
643 *dst++ = (val = (dst_line1[
x].
a * f) >> 15) > 255 ? 255 : val;
647 dst_line1 = dst_line2;
651 if (dst - dst_begin < dst_width * dst_height * 4) {
654 for (
x = 0;
x < dst_width;
x++) {
656 *dst++ = (val = (dst_line1[
x].
r * f) >> 15) > 255 ? 255 : val;
657 *dst++ = (val = (dst_line1[
x].
g * f) >> 15) > 255 ? 255 : val;
658 *dst++ = (val = (dst_line1[
x].
b * f) >> 15) > 255 ? 255 : val;
659 *dst++ = (val = (dst_line1[
x].
a * f) >> 15) > 255 ? 255 : val;
673 if (dst_width > in_width && dst_height > in_height) {
676 else if (dst_width < in_width && dst_height < in_height) {
682 float *src,
float *dst,
int src_width,
int src_height,
int dst_width,
int dst_height)
684 double ratiox = (
double)(dst_width - 1.0) / (
double)(src_width - 1.001);
685 double ratioy = (
double)(dst_height - 1.0) / (
double)(src_height - 1.001);
688 double x_src, dx_src;
689 double y_src, dy_src;
691 dx_src = 1.0 / ratiox;
692 dy_src = 1.0 / ratioy;
695 for (y_dst = 0; y_dst < dst_height; y_dst++) {
696 float *line1 = src + ((int)y_src) * 4 * src_width;
697 const float *line2 = line1 + 4 * src_width;
698 const float weight1y = (
float)(1.0 - (y_src - (
int)y_src));
699 const float weight2y = 1.0f - weight1y;
701 if ((
int)y_src == src_height - 1) {
706 for (x_dst = 0; x_dst < dst_width; x_dst++) {
707 const float weight1x = (
float)(1.0 - (x_src - (
int)x_src));
708 const float weight2x = (
float)(1.0f - weight1x);
710 const float w11 = weight1y * weight1x;
711 const float w21 = weight2y * weight1x;
712 const float w12 = weight1y * weight2x;
713 const float w22 = weight2y * weight2x;
717 *dst++ = line1[
x] * w11 + line2[
x] * w21 + line1[4 +
x] * w12 + line2[4 +
x] * w22;
719 *dst++ = line1[
x + 1] * w11 + line2[
x + 1] * w21 + line1[4 +
x + 1] * w12 +
720 line2[4 +
x + 1] * w22;
722 *dst++ = line1[
x + 2] * w11 + line2[
x + 2] * w21 + line1[4 +
x + 2] * w12 +
723 line2[4 +
x + 2] * w22;
725 *dst++ = line1[
x + 3] * w11 + line2[
x + 3] * w21 + line1[4 +
x + 3] * w12 +
726 line2[4 +
x + 3] * w22;
744 const float *src,
float *dst,
int src_width,
int src_height,
int dst_width,
int dst_height)
746 double ratiox = (
double)(dst_width) / (
double)(src_width);
747 double ratioy = (
double)(dst_height) / (
double)(src_height);
753 const float *dst_begin = dst;
768 for (y_src = 0; y_src < src_height; y_src++) {
769 const float *line = src + y_src * 4 * src_width;
770 uintptr_t weight1y = 1.0f - (y_dst - (int)y_dst);
773 for (x_src = 0; x_src < src_width; x_src++) {
774 uintptr_t weight1x = 1.0f - (x_dst - (int)x_dst);
781 w = weight1y * weight1x;
783 dst_line1[
x].
r += line[0] *
w;
784 dst_line1[
x].
g += line[1] *
w;
785 dst_line1[
x].
b += line[2] *
w;
786 dst_line1[
x].
a += line[3] *
w;
789 w = weight2y * weight1x;
791 dst_line2[
x].
r += line[0] *
w;
792 dst_line2[
x].
g += line[1] *
w;
793 dst_line2[
x].
b += line[2] *
w;
794 dst_line2[
x].
a += line[3] *
w;
797 w = weight1y * weight2x;
799 dst_line1[
x + 1].
r += line[0] *
w;
800 dst_line1[
x + 1].
g += line[1] *
w;
801 dst_line1[
x + 1].
b += line[2] *
w;
802 dst_line1[
x + 1].
a += line[3] *
w;
805 w = weight2y * weight2x;
807 dst_line2[
x + 1].
r += line[0] *
w;
808 dst_line2[
x + 1].
g += line[1] *
w;
809 dst_line2[
x + 1].
b += line[2] *
w;
810 dst_line2[
x + 1].
a += line[3] *
w;
825 for (
x = 0;
x < dst_width;
x++) {
826 float f = 1.0f / dst_line1[
x].
weight;
827 *dst++ = dst_line1[
x].
r * f;
828 *dst++ = dst_line1[
x].
g * f;
829 *dst++ = dst_line1[
x].
b * f;
830 *dst++ = dst_line1[
x].
a * f;
834 dst_line1 = dst_line2;
838 if (dst - dst_begin < dst_width * dst_height * 4) {
840 for (
x = 0;
x < dst_width;
x++) {
841 float f = 1.0f / dst_line1[
x].
weight;
842 *dst++ = dst_line1[
x].
r * f;
843 *dst++ = dst_line1[
x].
g * f;
844 *dst++ = dst_line1[
x].
b * f;
845 *dst++ = dst_line1[
x].
a * f;
853 float *in,
float *out,
int in_width,
int in_height,
int dst_width,
int dst_height)
855 if (dst_width > in_width && dst_height > in_height) {
858 else if (dst_width < in_width && dst_height < in_height) {
886 if ((newx >= ibuf->
x && newy <= ibuf->
y) || (newx <= ibuf->
x && newy >= ibuf->
y)) {
891 unsigned char *newrect =
MEM_mallocN(
sizeof(
int) * newx * newy,
"q_scale rect");
896 ibuf->
rect = (
unsigned int *)newrect;
899 float *newrect =
MEM_mallocN(
sizeof(
float[4]) * newx * newy,
"q_scale rectfloat");
913 const int do_rect = (ibuf->
rect !=
NULL);
917 uchar *rect, *_newrect, *newrect;
918 float *rectf, *_newrectf, *newrectf;
919 float sample,
add, val[4], nval[4], valf[4], nvalf[4];
922 rectf = _newrectf = newrectf =
NULL;
923 rect = _newrect = newrect =
NULL;
924 nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
925 nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
927 if (!do_rect && !do_float) {
933 if (_newrect ==
NULL) {
938 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newx * ibuf->
y,
"scaledownxf");
939 if (_newrectf ==
NULL) {
947 add = (ibuf->
x - 0.01) / newx;
955 newrectf = _newrectf;
958 for (
y = ibuf->
y;
y > 0;
y--) {
960 val[0] = val[1] = val[2] = val[3] = 0.0f;
961 valf[0] = valf[1] = valf[2] = valf[3] = 0.0f;
963 for (
x = newx;
x > 0;
x--) {
965 nval[0] = -val[0] *
sample;
966 nval[1] = -val[1] *
sample;
967 nval[2] = -val[2] *
sample;
968 nval[3] = -val[3] *
sample;
971 nvalf[0] = -valf[0] *
sample;
972 nvalf[1] = -valf[1] *
sample;
973 nvalf[2] = -valf[2] *
sample;
974 nvalf[3] = -valf[3] *
sample;
990 nvalf[0] += rectf[0];
991 nvalf[1] += rectf[1];
992 nvalf[2] += rectf[2];
993 nvalf[3] += rectf[3];
1005 newrect[0] = roundf((nval[0] +
sample * val[0]) /
add);
1006 newrect[1] = roundf((nval[1] +
sample * val[1]) /
add);
1007 newrect[2] = roundf((nval[2] +
sample * val[2]) /
add);
1008 newrect[3] = roundf((nval[3] +
sample * val[3]) /
add);
1020 newrectf[0] = ((nvalf[0] +
sample * valf[0]) /
add);
1021 newrectf[1] = ((nvalf[1] +
sample * valf[1]) /
add);
1022 newrectf[2] = ((nvalf[2] +
sample * valf[2]) /
add);
1023 newrectf[3] = ((nvalf[3] +
sample * valf[3]) /
add);
1037 ibuf->
rect = (
unsigned int *)_newrect;
1054 const int do_rect = (ibuf->
rect !=
NULL);
1058 uchar *rect, *_newrect, *newrect;
1059 float *rectf, *_newrectf, *newrectf;
1060 float sample,
add, val[4], nval[4], valf[4], nvalf[4];
1063 rectf = _newrectf = newrectf =
NULL;
1064 rect = _newrect = newrect =
NULL;
1065 nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
1066 nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
1068 if (!do_rect && !do_float) {
1074 if (_newrect ==
NULL) {
1079 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newy * ibuf->
x,
"scaledownyf");
1080 if (_newrectf ==
NULL) {
1088 add = (ibuf->
y - 0.01) / newy;
1089 skipx = 4 * ibuf->
x;
1091 for (
x = skipx - 4;
x >= 0;
x -= 4) {
1094 newrect = _newrect +
x;
1098 newrectf = _newrectf +
x;
1102 val[0] = val[1] = val[2] = val[3] = 0.0f;
1103 valf[0] = valf[1] = valf[2] = valf[3] = 0.0f;
1105 for (
y = newy;
y > 0;
y--) {
1107 nval[0] = -val[0] *
sample;
1108 nval[1] = -val[1] *
sample;
1109 nval[2] = -val[2] *
sample;
1110 nval[3] = -val[3] *
sample;
1113 nvalf[0] = -valf[0] *
sample;
1114 nvalf[1] = -valf[1] *
sample;
1115 nvalf[2] = -valf[2] *
sample;
1116 nvalf[3] = -valf[3] *
sample;
1132 nvalf[0] += rectf[0];
1133 nvalf[1] += rectf[1];
1134 nvalf[2] += rectf[2];
1135 nvalf[3] += rectf[3];
1147 newrect[0] = roundf((nval[0] +
sample * val[0]) /
add);
1148 newrect[1] = roundf((nval[1] +
sample * val[1]) /
add);
1149 newrect[2] = roundf((nval[2] +
sample * val[2]) /
add);
1150 newrect[3] = roundf((nval[3] +
sample * val[3]) /
add);
1162 newrectf[0] = ((nvalf[0] +
sample * valf[0]) /
add);
1163 newrectf[1] = ((nvalf[1] +
sample * valf[1]) /
add);
1164 newrectf[2] = ((nvalf[2] +
sample * valf[2]) /
add);
1165 newrectf[3] = ((nvalf[3] +
sample * valf[3]) /
add);
1179 ibuf->
rect = (
unsigned int *)_newrect;
1196 uchar *rect, *_newrect =
NULL, *newrect;
1197 float *rectf, *_newrectf =
NULL, *newrectf;
1199 bool do_rect =
false, do_float =
false;
1210 _newrect =
MEM_mallocN(newx * ibuf->
y *
sizeof(
int),
"scaleupx");
1211 if (_newrect ==
NULL) {
1217 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newx * ibuf->
y,
"scaleupxf");
1218 if (_newrectf ==
NULL) {
1229 newrectf = _newrectf;
1235 for (
y = ibuf->
y;
y > 0;
y--) {
1236 for (
x = newx;
x > 0;
x--) {
1237 memcpy(newrect, rect,
sizeof(
char[4]));
1244 for (
y = ibuf->
y;
y > 0;
y--) {
1245 for (
x = newx;
x > 0;
x--) {
1246 memcpy(newrectf, rectf,
sizeof(
float[4]));
1254 const float add = (ibuf->
x - 1.001) / (newx - 1.0);
1257 float val_a, nval_a, diff_a;
1258 float val_b, nval_b, diff_b;
1259 float val_g, nval_g, diff_g;
1260 float val_r, nval_r, diff_r;
1261 float val_af, nval_af, diff_af;
1262 float val_bf, nval_bf, diff_bf;
1263 float val_gf, nval_gf, diff_gf;
1264 float val_rf, nval_rf, diff_rf;
1266 val_a = nval_a = diff_a = val_b = nval_b = diff_b = 0;
1267 val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
1268 val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
1269 val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
1271 for (
y = ibuf->
y;
y > 0;
y--) {
1278 diff_a = nval_a - val_a;
1283 diff_b = nval_b - val_b;
1288 diff_g = nval_g - val_g;
1293 diff_r = nval_r - val_r;
1301 diff_af = nval_af - val_af;
1305 diff_bf = nval_bf - val_bf;
1309 diff_gf = nval_gf - val_gf;
1313 diff_rf = nval_rf - val_rf;
1317 for (
x = newx;
x > 0;
x--) {
1324 diff_a = nval_a - val_a;
1329 diff_b = nval_b - val_b;
1334 diff_g = nval_g - val_g;
1339 diff_r = nval_r - val_r;
1346 diff_af = nval_af - val_af;
1350 diff_bf = nval_bf - val_bf;
1354 diff_gf = nval_gf - val_gf;
1358 diff_rf = nval_rf - val_rf;
1363 newrect[0] = val_a +
sample * diff_a;
1364 newrect[1] = val_b +
sample * diff_b;
1365 newrect[2] = val_g +
sample * diff_g;
1366 newrect[3] = val_r +
sample * diff_r;
1370 newrectf[0] = val_af +
sample * diff_af;
1371 newrectf[1] = val_bf +
sample * diff_bf;
1372 newrectf[2] = val_gf +
sample * diff_gf;
1373 newrectf[3] = val_rf +
sample * diff_rf;
1384 ibuf->
rect = (
unsigned int *)_newrect;
1398 uchar *rect, *_newrect =
NULL, *newrect;
1399 float *rectf, *_newrectf =
NULL, *newrectf;
1401 bool do_rect =
false, do_float =
false;
1412 _newrect =
MEM_mallocN(ibuf->
x * newy *
sizeof(
int),
"scaleupy");
1413 if (_newrect ==
NULL) {
1419 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * ibuf->
x * newy,
"scaleupyf");
1420 if (_newrectf ==
NULL) {
1431 newrectf = _newrectf;
1433 skipx = 4 * ibuf->
x;
1439 for (
y = newy;
y > 0;
y--) {
1440 memcpy(newrect, rect,
sizeof(
char) * skipx);
1445 for (
y = newy;
y > 0;
y--) {
1446 memcpy(newrectf, rectf,
sizeof(
float) * skipx);
1452 const float add = (ibuf->
y - 1.001) / (newy - 1.0);
1455 float val_a, nval_a, diff_a;
1456 float val_b, nval_b, diff_b;
1457 float val_g, nval_g, diff_g;
1458 float val_r, nval_r, diff_r;
1459 float val_af, nval_af, diff_af;
1460 float val_bf, nval_bf, diff_bf;
1461 float val_gf, nval_gf, diff_gf;
1462 float val_rf, nval_rf, diff_rf;
1464 val_a = nval_a = diff_a = val_b = nval_b = diff_b = 0;
1465 val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
1466 val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
1467 val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
1469 for (
x = ibuf->
x;
x > 0;
x--) {
1473 newrect = _newrect + 4 * (
x - 1);
1476 nval_a = rect[skipx];
1477 diff_a = nval_a - val_a;
1481 nval_b = rect[skipx + 1];
1482 diff_b = nval_b - val_b;
1486 nval_g = rect[skipx + 2];
1487 diff_g = nval_g - val_g;
1491 nval_r = rect[skipx + 3];
1492 diff_r = nval_r - val_r;
1499 newrectf = _newrectf + 4 * (
x - 1);
1502 nval_af = rectf[skipx];
1503 diff_af = nval_af - val_af;
1506 nval_bf = rectf[skipx + 1];
1507 diff_bf = nval_bf - val_bf;
1510 nval_gf = rectf[skipx + 2];
1511 diff_gf = nval_gf - val_gf;
1514 nval_rf = rectf[skipx + 3];
1515 diff_rf = nval_rf - val_rf;
1520 for (
y = newy;
y > 0;
y--) {
1527 diff_a = nval_a - val_a;
1532 diff_b = nval_b - val_b;
1537 diff_g = nval_g - val_g;
1542 diff_r = nval_r - val_r;
1549 diff_af = nval_af - val_af;
1553 diff_bf = nval_bf - val_bf;
1557 diff_gf = nval_gf - val_gf;
1561 diff_rf = nval_rf - val_rf;
1566 newrect[0] = val_a +
sample * diff_a;
1567 newrect[1] = val_b +
sample * diff_b;
1568 newrect[2] = val_g +
sample * diff_g;
1569 newrect[3] = val_r +
sample * diff_r;
1573 newrectf[0] = val_af +
sample * diff_af;
1574 newrectf[1] = val_bf +
sample * diff_bf;
1575 newrectf[2] = val_gf +
sample * diff_gf;
1576 newrectf[3] = val_rf +
sample * diff_rf;
1587 ibuf->
rect = (
unsigned int *)_newrect;
1601 int *zbuf, *newzbuf, *_newzbuf =
NULL;
1602 float *zbuf_float, *newzbuf_float, *_newzbuf_float =
NULL;
1604 int ofsx, ofsy, stepx, stepy;
1607 _newzbuf =
MEM_mallocN(newx * newy *
sizeof(
int), __func__);
1608 if (_newzbuf ==
NULL) {
1614 _newzbuf_float =
MEM_mallocN((
size_t)newx * newy *
sizeof(
float), __func__);
1615 if (_newzbuf_float ==
NULL) {
1620 if (!_newzbuf && !_newzbuf_float) {
1624 stepx = round(65536.0 * (ibuf->
x - 1.0) / (newx - 1.0));
1625 stepy = round(65536.0 * (ibuf->
y - 1.0) / (newy - 1.0));
1629 newzbuf_float = _newzbuf_float;
1631 for (
y = newy;
y > 0;
y--, ofsy += stepy) {
1634 zbuf += (ofsy >> 16) * ibuf->
x;
1636 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1637 *newzbuf++ = zbuf[ofsx >> 16];
1641 if (newzbuf_float) {
1643 zbuf_float += (ofsy >> 16) * ibuf->
x;
1645 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1646 *newzbuf_float++ = zbuf_float[ofsx >> 16];
1654 ibuf->
zbuf = _newzbuf;
1657 if (_newzbuf_float) {
1678 if (newx == ibuf->
x && newy == ibuf->
y) {
1692 if (newx && (newx < ibuf->
x)) {
1695 if (newy && (newy < ibuf->
y)) {
1698 if (newx && (newx > ibuf->
x)) {
1701 if (newy && (newy > ibuf->
y)) {
1719 unsigned int *rect, *_newrect, *newrect;
1720 struct imbufRGBA *rectf, *_newrectf, *newrectf;
1722 bool do_float =
false, do_rect =
false;
1723 size_t ofsx, ofsy, stepx, stepy;
1741 if (do_rect ==
false && do_float ==
false) {
1745 if (newx == ibuf->
x && newy == ibuf->
y) {
1750 _newrect =
MEM_mallocN(newx * newy *
sizeof(
int),
"scalefastimbuf");
1751 if (_newrect ==
NULL) {
1758 _newrectf =
MEM_mallocN(
sizeof(
float[4]) * newx * newy,
"scalefastimbuf f");
1759 if (_newrectf ==
NULL) {
1765 newrectf = _newrectf;
1768 stepx = round(65536.0 * (ibuf->
x - 1.0) / (newx - 1.0));
1769 stepy = round(65536.0 * (ibuf->
y - 1.0) / (newy - 1.0));
1772 for (
y = newy;
y > 0;
y--, ofsy += stepy) {
1775 rect += (ofsy >> 16) * ibuf->
x;
1778 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1779 *newrect++ = rect[ofsx >> 16];
1785 rectf += (ofsy >> 16) * ibuf->
x;
1788 for (
x = newx;
x > 0;
x--, ofsx += stepx) {
1789 *newrectf++ = rectf[ofsx >> 16];
1797 ibuf->
rect = _newrect;
1848 data->start_line = start_line;
1849 data->tot_line = tot_line;
1860 float factor_x = (
float)ibuf->
x /
data->newx;
1861 float factor_y = (
float)ibuf->
y /
data->newy;
1863 for (i = 0; i <
data->tot_line; i++) {
1864 int y =
data->start_line + i;
1867 for (
x = 0;
x <
data->newx;
x++) {
1868 float u = (
float)
x * factor_x;
1869 float v = (
float)
y * factor_y;
1870 int offset =
y *
data->newx +
x;
1872 if (
data->byte_buffer) {
1873 unsigned char *pixel =
data->byte_buffer + 4 * offset;
1875 (
unsigned char *)ibuf->
rect, pixel, ibuf->
x, ibuf->
y, 4, u,
v);
1878 if (
data->float_buffer) {
1879 float *pixel =
data->float_buffer + ibuf->
channels * offset;
1903 "threaded scale byte buffer");
1908 "threaded scale float buffer");
typedef float(TangentPoint)[2]
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)
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)
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static CCL_NAMESPACE_BEGIN const double alpha
void imb_filterx(struct ImBuf *ibuf)
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)
static void add(GHash *messages, MemArena *memarena, const Message *msg)
static void sample(SocketReader *reader, int x, int y, float color[4])
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
ccl_device_inline int rect_size(int4 rect)