Blender  V2.93
filter.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  * filter.c
19  */
20 
25 #include <math.h>
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include "BLI_math_base.h"
30 #include "BLI_utildefines.h"
31 
32 #include "IMB_filter.h"
33 #include "IMB_imbuf.h"
34 #include "IMB_imbuf_types.h"
35 
36 #include "imbuf.h"
37 
38 static void filtrow(unsigned char *point, int x)
39 {
40  unsigned int c1, c2, c3, error;
41 
42  if (x > 1) {
43  c1 = c2 = *point;
44  error = 2;
45  for (x--; x > 0; x--) {
46  c3 = point[4];
47  c1 += (c2 << 1) + c3 + error;
48  error = c1 & 3;
49  *point = c1 >> 2;
50  point += 4;
51  c1 = c2;
52  c2 = c3;
53  }
54  *point = (c1 + (c2 << 1) + c2 + error) >> 2;
55  }
56 }
57 
58 static void filtrowf(float *point, int x)
59 {
60  float c1, c2, c3;
61 
62  if (x > 1) {
63  c1 = c2 = *point;
64  for (x--; x > 0; x--) {
65  c3 = point[4];
66  c1 += (c2 * 2) + c3;
67  *point = 0.25f * c1;
68  point += 4;
69  c1 = c2;
70  c2 = c3;
71  }
72  *point = 0.25f * (c1 + (c2 * 2) + c2);
73  }
74 }
75 
76 static void filtcolum(unsigned char *point, int y, int skip)
77 {
78  unsigned int c1, c2, c3, error;
79  unsigned char *point2;
80 
81  if (y > 1) {
82  c1 = c2 = *point;
83  point2 = point;
84  error = 2;
85  for (y--; y > 0; y--) {
86  point2 += skip;
87  c3 = *point2;
88  c1 += (c2 << 1) + c3 + error;
89  error = c1 & 3;
90  *point = c1 >> 2;
91  point = point2;
92  c1 = c2;
93  c2 = c3;
94  }
95  *point = (c1 + (c2 << 1) + c2 + error) >> 2;
96  }
97 }
98 
99 static void filtcolumf(float *point, int y, int skip)
100 {
101  float c1, c2, c3, *point2;
102 
103  if (y > 1) {
104  c1 = c2 = *point;
105  point2 = point;
106  for (y--; y > 0; y--) {
107  point2 += skip;
108  c3 = *point2;
109  c1 += (c2 * 2) + c3;
110  *point = 0.25f * c1;
111  point = point2;
112  c1 = c2;
113  c2 = c3;
114  }
115  *point = 0.25f * (c1 + (c2 * 2) + c2);
116  }
117 }
118 
119 void IMB_filtery(struct ImBuf *ibuf)
120 {
121  unsigned char *point;
122  float *pointf;
123  int x, y, skip;
124 
125  point = (unsigned char *)ibuf->rect;
126  pointf = ibuf->rect_float;
127 
128  x = ibuf->x;
129  y = ibuf->y;
130  skip = x << 2;
131 
132  for (; x > 0; x--) {
133  if (point) {
134  if (ibuf->planes > 24) {
135  filtcolum(point, y, skip);
136  }
137  point++;
138  filtcolum(point, y, skip);
139  point++;
140  filtcolum(point, y, skip);
141  point++;
142  filtcolum(point, y, skip);
143  point++;
144  }
145  if (pointf) {
146  if (ibuf->planes > 24) {
147  filtcolumf(pointf, y, skip);
148  }
149  pointf++;
150  filtcolumf(pointf, y, skip);
151  pointf++;
152  filtcolumf(pointf, y, skip);
153  pointf++;
154  filtcolumf(pointf, y, skip);
155  pointf++;
156  }
157  }
158 }
159 
160 void imb_filterx(struct ImBuf *ibuf)
161 {
162  unsigned char *point;
163  float *pointf;
164  int x, y, skip;
165 
166  point = (unsigned char *)ibuf->rect;
167  pointf = ibuf->rect_float;
168 
169  x = ibuf->x;
170  y = ibuf->y;
171  skip = (x << 2) - 3;
172 
173  for (; y > 0; y--) {
174  if (point) {
175  if (ibuf->planes > 24) {
176  filtrow(point, x);
177  }
178  point++;
179  filtrow(point, x);
180  point++;
181  filtrow(point, x);
182  point++;
183  filtrow(point, x);
184  point += skip;
185  }
186  if (pointf) {
187  if (ibuf->planes > 24) {
188  filtrowf(pointf, x);
189  }
190  pointf++;
191  filtrowf(pointf, x);
192  pointf++;
193  filtrowf(pointf, x);
194  pointf++;
195  filtrowf(pointf, x);
196  pointf += skip;
197  }
198  }
199 }
200 
201 static void imb_filterN(ImBuf *out, ImBuf *in)
202 {
203  BLI_assert(out->channels == in->channels);
204  BLI_assert(out->x == in->x && out->y == in->y);
205 
206  const int channels = in->channels;
207  const int rowlen = in->x;
208 
209  if (in->rect && out->rect) {
210  for (int y = 0; y < in->y; y++) {
211  /* setup rows */
212  const char *row2 = (const char *)in->rect + y * channels * rowlen;
213  const char *row1 = (y == 0) ? row2 : row2 - channels * rowlen;
214  const char *row3 = (y == in->y - 1) ? row2 : row2 + channels * rowlen;
215 
216  char *cp = (char *)out->rect + y * channels * rowlen;
217 
218  for (int x = 0; x < rowlen; x++) {
219  const char *r11, *r13, *r21, *r23, *r31, *r33;
220 
221  if (x == 0) {
222  r11 = row1;
223  r21 = row2;
224  r31 = row3;
225  }
226  else {
227  r11 = row1 - channels;
228  r21 = row2 - channels;
229  r31 = row3 - channels;
230  }
231 
232  if (x == rowlen - 1) {
233  r13 = row1;
234  r23 = row2;
235  r33 = row3;
236  }
237  else {
238  r13 = row1 + channels;
239  r23 = row2 + channels;
240  r33 = row3 + channels;
241  }
242 
243  cp[0] = (r11[0] + 2 * row1[0] + r13[0] + 2 * r21[0] + 4 * row2[0] + 2 * r23[0] + r31[0] +
244  2 * row3[0] + r33[0]) >>
245  4;
246  cp[1] = (r11[1] + 2 * row1[1] + r13[1] + 2 * r21[1] + 4 * row2[1] + 2 * r23[1] + r31[1] +
247  2 * row3[1] + r33[1]) >>
248  4;
249  cp[2] = (r11[2] + 2 * row1[2] + r13[2] + 2 * r21[2] + 4 * row2[2] + 2 * r23[2] + r31[2] +
250  2 * row3[2] + r33[2]) >>
251  4;
252  cp[3] = (r11[3] + 2 * row1[3] + r13[3] + 2 * r21[3] + 4 * row2[3] + 2 * r23[3] + r31[3] +
253  2 * row3[3] + r33[3]) >>
254  4;
255  cp += channels;
256  row1 += channels;
257  row2 += channels;
258  row3 += channels;
259  }
260  }
261  }
262 
263  if (in->rect_float && out->rect_float) {
264  for (int y = 0; y < in->y; y++) {
265  /* setup rows */
266  const float *row2 = (const float *)in->rect_float + y * channels * rowlen;
267  const float *row1 = (y == 0) ? row2 : row2 - channels * rowlen;
268  const float *row3 = (y == in->y - 1) ? row2 : row2 + channels * rowlen;
269 
270  float *cp = (float *)out->rect_float + y * channels * rowlen;
271 
272  for (int x = 0; x < rowlen; x++) {
273  const float *r11, *r13, *r21, *r23, *r31, *r33;
274 
275  if (x == 0) {
276  r11 = row1;
277  r21 = row2;
278  r31 = row3;
279  }
280  else {
281  r11 = row1 - channels;
282  r21 = row2 - channels;
283  r31 = row3 - channels;
284  }
285 
286  if (x == rowlen - 1) {
287  r13 = row1;
288  r23 = row2;
289  r33 = row3;
290  }
291  else {
292  r13 = row1 + channels;
293  r23 = row2 + channels;
294  r33 = row3 + channels;
295  }
296 
297  cp[0] = (r11[0] + 2 * row1[0] + r13[0] + 2 * r21[0] + 4 * row2[0] + 2 * r23[0] + r31[0] +
298  2 * row3[0] + r33[0]) *
299  (1.0f / 16.0f);
300  cp[1] = (r11[1] + 2 * row1[1] + r13[1] + 2 * r21[1] + 4 * row2[1] + 2 * r23[1] + r31[1] +
301  2 * row3[1] + r33[1]) *
302  (1.0f / 16.0f);
303  cp[2] = (r11[2] + 2 * row1[2] + r13[2] + 2 * r21[2] + 4 * row2[2] + 2 * r23[2] + r31[2] +
304  2 * row3[2] + r33[2]) *
305  (1.0f / 16.0f);
306  cp[3] = (r11[3] + 2 * row1[3] + r13[3] + 2 * r21[3] + 4 * row2[3] + 2 * r23[3] + r31[3] +
307  2 * row3[3] + r33[3]) *
308  (1.0f / 16.0f);
309  cp += channels;
310  row1 += channels;
311  row2 += channels;
312  row3 += channels;
313  }
314  }
315  }
316 }
317 
318 void IMB_filter(struct ImBuf *ibuf)
319 {
320  IMB_filtery(ibuf);
321  imb_filterx(ibuf);
322 }
323 
325 {
326  const char *row1, *row2, *row3;
327  int rowlen, x, y;
328  char *temprect;
329 
330  rowlen = width;
331 
332  /* make a copy, to prevent flooding */
333  temprect = MEM_dupallocN(mask);
334 
335  for (y = 1; y <= height; y++) {
336  /* setup rows */
337  row1 = (char *)(temprect + (y - 2) * rowlen);
338  row2 = row1 + rowlen;
339  row3 = row2 + rowlen;
340  if (y == 1) {
341  row1 = row2;
342  }
343  else if (y == height) {
344  row3 = row2;
345  }
346 
347  for (x = 0; x < rowlen; x++) {
348  if (mask[((y - 1) * rowlen) + x] == 0) {
349  if (*row1 || *row2 || *row3 || *(row1 + 1) || *(row3 + 1)) {
350  mask[((y - 1) * rowlen) + x] = FILTER_MASK_MARGIN;
351  }
352  else if ((x != rowlen - 1) && (*(row1 + 2) || *(row2 + 2) || *(row3 + 2))) {
353  mask[((y - 1) * rowlen) + x] = FILTER_MASK_MARGIN;
354  }
355  }
356 
357  if (x != 0) {
358  row1++;
359  row2++;
360  row3++;
361  }
362  }
363  }
364 
365  MEM_freeN(temprect);
366 }
367 
368 void IMB_mask_clear(ImBuf *ibuf, const char *mask, int val)
369 {
370  int x, y;
371  if (ibuf->rect_float) {
372  for (x = 0; x < ibuf->x; x++) {
373  for (y = 0; y < ibuf->y; y++) {
374  if (mask[ibuf->x * y + x] == val) {
375  float *col = ibuf->rect_float + 4 * (ibuf->x * y + x);
376  col[0] = col[1] = col[2] = col[3] = 0.0f;
377  }
378  }
379  }
380  }
381  else {
382  /* char buffer */
383  for (x = 0; x < ibuf->x; x++) {
384  for (y = 0; y < ibuf->y; y++) {
385  if (mask[ibuf->x * y + x] == val) {
386  char *col = (char *)(ibuf->rect + ibuf->x * y + x);
387  col[0] = col[1] = col[2] = col[3] = 0;
388  }
389  }
390  }
391  }
392 }
393 
394 static int filter_make_index(const int x, const int y, const int w, const int h)
395 {
396  if (x < 0 || x >= w || y < 0 || y >= h) {
397  return -1; /* return bad index */
398  }
399 
400  return y * w + x;
401 }
402 
404  const void *buffer, const char *mask, const int index, const int depth, const bool is_float)
405 {
406  int res = 0;
407 
408  if (index >= 0) {
409  const int alpha_index = depth * index + (depth - 1);
410 
411  if (mask != NULL) {
412  res = mask[index] != 0 ? 1 : 0;
413  }
414  else if ((is_float && ((const float *)buffer)[alpha_index] != 0.0f) ||
415  (!is_float && ((const unsigned char *)buffer)[alpha_index] != 0)) {
416  res = 1;
417  }
418  }
419 
420  return res;
421 }
422 
429 void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
430 {
431  const int width = ibuf->x;
432  const int height = ibuf->y;
433  const int depth = 4; /* always 4 channels */
434  const int chsize = ibuf->rect_float ? sizeof(float) : sizeof(unsigned char);
435  const size_t bsize = ((size_t)width) * height * depth * chsize;
436  const bool is_float = (ibuf->rect_float != NULL);
437  void *dstbuf = (void *)MEM_dupallocN(ibuf->rect_float ? (void *)ibuf->rect_float :
438  (void *)ibuf->rect);
439  char *dstmask = mask == NULL ? NULL : (char *)MEM_dupallocN(mask);
440  void *srcbuf = ibuf->rect_float ? (void *)ibuf->rect_float : (void *)ibuf->rect;
441  char *srcmask = mask;
442  int cannot_early_out = 1, r, n, k, i, j, c;
443  float weight[25];
444 
445  /* build a weights buffer */
446  n = 1;
447 
448 #if 0
449  k = 0;
450  for (i = -n; i <= n; i++) {
451  for (j = -n; j <= n; j++) {
452  weight[k++] = sqrt((float)i * i + j * j);
453  }
454  }
455 #endif
456 
457  weight[0] = 1;
458  weight[1] = 2;
459  weight[2] = 1;
460  weight[3] = 2;
461  weight[4] = 0;
462  weight[5] = 2;
463  weight[6] = 1;
464  weight[7] = 2;
465  weight[8] = 1;
466 
467  /* run passes */
468  for (r = 0; cannot_early_out == 1 && r < filter; r++) {
469  int x, y;
470  cannot_early_out = 0;
471 
472  for (y = 0; y < height; y++) {
473  for (x = 0; x < width; x++) {
474  const int index = filter_make_index(x, y, width, height);
475 
476  /* only update unassigned pixels */
477  if (!check_pixel_assigned(srcbuf, srcmask, index, depth, is_float)) {
478  float tmp[4];
479  float wsum = 0;
480  float acc[4] = {0, 0, 0, 0};
481  k = 0;
482 
484  srcbuf, srcmask, filter_make_index(x - 1, y, width, height), depth, is_float) ||
486  srcbuf, srcmask, filter_make_index(x + 1, y, width, height), depth, is_float) ||
488  srcbuf, srcmask, filter_make_index(x, y - 1, width, height), depth, is_float) ||
490  srcbuf, srcmask, filter_make_index(x, y + 1, width, height), depth, is_float)) {
491  for (i = -n; i <= n; i++) {
492  for (j = -n; j <= n; j++) {
493  if (i != 0 || j != 0) {
494  const int tmpindex = filter_make_index(x + i, y + j, width, height);
495 
496  if (check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float)) {
497  if (is_float) {
498  for (c = 0; c < depth; c++) {
499  tmp[c] = ((const float *)srcbuf)[depth * tmpindex + c];
500  }
501  }
502  else {
503  for (c = 0; c < depth; c++) {
504  tmp[c] = (float)((const unsigned char *)srcbuf)[depth * tmpindex + c];
505  }
506  }
507 
508  wsum += weight[k];
509 
510  for (c = 0; c < depth; c++) {
511  acc[c] += weight[k] * tmp[c];
512  }
513  }
514  }
515  k++;
516  }
517  }
518 
519  if (wsum != 0) {
520  for (c = 0; c < depth; c++) {
521  acc[c] /= wsum;
522  }
523 
524  if (is_float) {
525  for (c = 0; c < depth; c++) {
526  ((float *)dstbuf)[depth * index + c] = acc[c];
527  }
528  }
529  else {
530  for (c = 0; c < depth; c++) {
531  ((unsigned char *)dstbuf)[depth * index + c] =
532  acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : (unsigned char)roundf(acc[c]));
533  }
534  }
535 
536  if (dstmask != NULL) {
537  dstmask[index] = FILTER_MASK_MARGIN; /* assigned */
538  }
539  cannot_early_out = 1;
540  }
541  }
542  }
543  }
544  }
545 
546  /* keep the original buffer up to date. */
547  memcpy(srcbuf, dstbuf, bsize);
548  if (dstmask != NULL) {
549  memcpy(srcmask, dstmask, ((size_t)width) * height);
550  }
551  }
552 
553  /* free memory */
554  MEM_freeN(dstbuf);
555  if (dstmask != NULL) {
556  MEM_freeN(dstmask);
557  }
558 }
559 
560 /* threadsafe version, only recreates existing maps */
561 void IMB_remakemipmap(ImBuf *ibuf, int use_filter)
562 {
563  ImBuf *hbuf = ibuf;
564  int curmap = 0;
565 
566  ibuf->miptot = 1;
567 
568  while (curmap < IMB_MIPMAP_LEVELS) {
569 
570  if (ibuf->mipmap[curmap]) {
571 
572  if (use_filter) {
573  ImBuf *nbuf = IMB_allocImBuf(hbuf->x, hbuf->y, hbuf->planes, hbuf->flags);
574  imb_filterN(nbuf, hbuf);
575  imb_onehalf_no_alloc(ibuf->mipmap[curmap], nbuf);
576  IMB_freeImBuf(nbuf);
577  }
578  else {
579  imb_onehalf_no_alloc(ibuf->mipmap[curmap], hbuf);
580  }
581  }
582 
583  ibuf->miptot = curmap + 2;
584  hbuf = ibuf->mipmap[curmap];
585  if (hbuf) {
586  hbuf->miplevel = curmap + 1;
587  }
588 
589  if (!hbuf || (hbuf->x <= 2 && hbuf->y <= 2)) {
590  break;
591  }
592 
593  curmap++;
594  }
595 }
596 
597 /* frees too (if there) and recreates new data */
598 void IMB_makemipmap(ImBuf *ibuf, int use_filter)
599 {
600  ImBuf *hbuf = ibuf;
601  int curmap = 0;
602 
603  imb_freemipmapImBuf(ibuf);
604 
605  /* no mipmap for non RGBA images */
606  if (ibuf->rect_float && ibuf->channels < 4) {
607  return;
608  }
609 
610  ibuf->miptot = 1;
611 
612  while (curmap < IMB_MIPMAP_LEVELS) {
613  if (use_filter) {
614  ImBuf *nbuf = IMB_allocImBuf(hbuf->x, hbuf->y, hbuf->planes, hbuf->flags);
615  imb_filterN(nbuf, hbuf);
616  ibuf->mipmap[curmap] = IMB_onehalf(nbuf);
617  IMB_freeImBuf(nbuf);
618  }
619  else {
620  ibuf->mipmap[curmap] = IMB_onehalf(hbuf);
621  }
622 
623  ibuf->miptot = curmap + 2;
624  hbuf = ibuf->mipmap[curmap];
625  hbuf->miplevel = curmap + 1;
626 
627  if (hbuf->x < 2 && hbuf->y < 2) {
628  break;
629  }
630 
631  curmap++;
632  }
633 }
634 
635 ImBuf *IMB_getmipmap(ImBuf *ibuf, int level)
636 {
637  CLAMP(level, 0, ibuf->miptot - 1);
638  return (level == 0) ? ibuf : ibuf->mipmap[level - 1];
639 }
640 
641 void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h)
642 {
643  char *cp;
644  int x, y, val;
645 
646  if (planes == 24) { /* put alpha at 255 */
647  cp = (char *)(rect);
648 
649  for (y = 0; y < h; y++) {
650  for (x = 0; x < w; x++, cp += 4) {
651  cp[3] = 255;
652  }
653  }
654  }
655  else {
656  cp = (char *)(rect);
657 
658  for (y = 0; y < h; y++) {
659  for (x = 0; x < w; x++, cp += 4) {
660  val = cp[3];
661  cp[0] = (cp[0] * val) >> 8;
662  cp[1] = (cp[1] * val) >> 8;
663  cp[2] = (cp[2] * val) >> 8;
664  }
665  }
666  }
667 }
668 
669 void IMB_premultiply_rect_float(float *rect_float, int channels, int w, int h)
670 {
671  float val, *cp;
672  int x, y;
673 
674  if (channels == 4) {
675  cp = rect_float;
676  for (y = 0; y < h; y++) {
677  for (x = 0; x < w; x++, cp += 4) {
678  val = cp[3];
679  cp[0] = cp[0] * val;
680  cp[1] = cp[1] * val;
681  cp[2] = cp[2] * val;
682  }
683  }
684  }
685 }
686 
688 {
689  if (ibuf == NULL) {
690  return;
691  }
692 
693  if (ibuf->rect) {
694  IMB_premultiply_rect(ibuf->rect, ibuf->planes, ibuf->x, ibuf->y);
695  }
696 
697  if (ibuf->rect_float) {
698  IMB_premultiply_rect_float(ibuf->rect_float, ibuf->channels, ibuf->x, ibuf->y);
699  }
700 }
701 
702 void IMB_unpremultiply_rect(unsigned int *rect, char planes, int w, int h)
703 {
704  char *cp;
705  int x, y;
706  float val;
707 
708  if (planes == 24) { /* put alpha at 255 */
709  cp = (char *)(rect);
710 
711  for (y = 0; y < h; y++) {
712  for (x = 0; x < w; x++, cp += 4) {
713  cp[3] = 255;
714  }
715  }
716  }
717  else {
718  cp = (char *)(rect);
719 
720  for (y = 0; y < h; y++) {
721  for (x = 0; x < w; x++, cp += 4) {
722  val = cp[3] != 0 ? 1.0f / (float)cp[3] : 1.0f;
723  cp[0] = unit_float_to_uchar_clamp(cp[0] * val);
724  cp[1] = unit_float_to_uchar_clamp(cp[1] * val);
725  cp[2] = unit_float_to_uchar_clamp(cp[2] * val);
726  }
727  }
728  }
729 }
730 
731 void IMB_unpremultiply_rect_float(float *rect_float, int channels, int w, int h)
732 {
733  float val, *fp;
734  int x, y;
735 
736  if (channels == 4) {
737  fp = rect_float;
738  for (y = 0; y < h; y++) {
739  for (x = 0; x < w; x++, fp += 4) {
740  val = fp[3] != 0.0f ? 1.0f / fp[3] : 1.0f;
741  fp[0] = fp[0] * val;
742  fp[1] = fp[1] * val;
743  fp[2] = fp[2] * val;
744  }
745  }
746  }
747 }
748 
750 {
751  if (ibuf == NULL) {
752  return;
753  }
754 
755  if (ibuf->rect) {
756  IMB_unpremultiply_rect(ibuf->rect, ibuf->planes, ibuf->x, ibuf->y);
757  }
758 
759  if (ibuf->rect_float) {
760  IMB_unpremultiply_rect_float(ibuf->rect_float, ibuf->channels, ibuf->x, ibuf->y);
761  }
762 }
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:58
sqrt(x)+1/max(0
_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 GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
Definition: scaling.c:376
struct ImBuf * IMB_onehalf(struct ImBuf *ibuf1)
Definition: scaling.c:453
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:478
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
void imb_freemipmapImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:80
#define FILTER_MASK_MARGIN
Definition: IMB_imbuf.h:420
Contains defines and structs used throughout the imbuf module.
#define IMB_MIPMAP_LEVELS
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
void IMB_premultiply_alpha(ImBuf *ibuf)
Definition: filter.c:687
void IMB_unpremultiply_rect_float(float *rect_float, int channels, int w, int h)
Definition: filter.c:731
void IMB_premultiply_rect_float(float *rect_float, int channels, int w, int h)
Definition: filter.c:669
void IMB_mask_filter_extend(char *mask, int width, int height)
Definition: filter.c:324
void IMB_filtery(struct ImBuf *ibuf)
Definition: filter.c:119
void IMB_makemipmap(ImBuf *ibuf, int use_filter)
Definition: filter.c:598
static void imb_filterN(ImBuf *out, ImBuf *in)
Definition: filter.c:201
void IMB_remakemipmap(ImBuf *ibuf, int use_filter)
Definition: filter.c:561
void IMB_unpremultiply_alpha(ImBuf *ibuf)
Definition: filter.c:749
static void filtcolumf(float *point, int y, int skip)
Definition: filter.c:99
static void filtrowf(float *point, int x)
Definition: filter.c:58
void IMB_mask_clear(ImBuf *ibuf, const char *mask, int val)
Definition: filter.c:368
static void filtcolum(unsigned char *point, int y, int skip)
Definition: filter.c:76
ImBuf * IMB_getmipmap(ImBuf *ibuf, int level)
Definition: filter.c:635
void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
Definition: filter.c:429
void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h)
Definition: filter.c:641
void imb_filterx(struct ImBuf *ibuf)
Definition: filter.c:160
void IMB_unpremultiply_rect(unsigned int *rect, char planes, int w, int h)
Definition: filter.c:702
void IMB_filter(struct ImBuf *ibuf)
Definition: filter.c:318
static void filtrow(unsigned char *point, int x)
Definition: filter.c:38
static int filter_make_index(const int x, const int y, const int w, const int h)
Definition: filter.c:394
static int check_pixel_assigned(const void *buffer, const char *mask, const int index, const int depth, const bool is_float)
Definition: filter.c:403
uint col
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
static void error(const char *str)
Definition: meshlaplacian.c:65
static unsigned c
Definition: RandGen.cpp:97
struct ImBuf * mipmap[IMB_MIPMAP_LEVELS]
int channels
unsigned char planes
unsigned int * rect
int miplevel
float * rect_float
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)