Blender  V3.3
allocimbuf.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 /* It's become a bit messy... Basically, only the IMB_ prefixed files
9  * should remain. */
10 
11 #include <stddef.h>
12 
13 #include "IMB_imbuf.h"
14 #include "IMB_imbuf_types.h"
15 
16 #include "IMB_allocimbuf.h"
18 #include "IMB_filetype.h"
19 #include "IMB_metadata.h"
20 
21 #include "imbuf.h"
22 
23 #include "MEM_guardedalloc.h"
24 
25 #include "BLI_threads.h"
26 #include "BLI_utildefines.h"
27 
29 
31 {
33 }
34 
36 {
38 }
39 
40 #ifndef WIN32
42 
44 {
46 }
47 
49 {
51 }
52 
53 void imb_mmap_lock(void)
54 {
56 }
57 
58 void imb_mmap_unlock(void)
59 {
61 }
62 #endif
63 
65 {
66  int a;
67 
68  /* Do not trust ibuf->miptot, in some cases IMB_remakemipmap can leave unfreed unused levels,
69  * leading to memory leaks... */
70  for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
71  if (ibuf->mipmap[a] != NULL) {
72  IMB_freeImBuf(ibuf->mipmap[a]);
73  ibuf->mipmap[a] = NULL;
74  }
75  }
76 
77  ibuf->miptot = 0;
78 }
79 
81 {
82  if (ibuf == NULL) {
83  return;
84  }
85 
86  if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) {
87  MEM_freeN(ibuf->rect_float);
88  ibuf->rect_float = NULL;
89  }
90 
91  imb_freemipmapImBuf(ibuf);
92 
93  ibuf->rect_float = NULL;
94  ibuf->mall &= ~IB_rectfloat;
95 }
96 
98 {
99  if (ibuf == NULL) {
100  return;
101  }
102 
103  if (ibuf->rect && (ibuf->mall & IB_rect)) {
104  MEM_freeN(ibuf->rect);
105  }
106  ibuf->rect = NULL;
107 
108  imb_freemipmapImBuf(ibuf);
109 
110  ibuf->mall &= ~IB_rect;
111 }
112 
114 {
115  int tx, ty;
116 
117  if (ibuf == NULL) {
118  return;
119  }
120 
121  if (ibuf->tiles && (ibuf->mall & IB_tiles)) {
122  for (ty = 0; ty < ibuf->ytiles; ty++) {
123  for (tx = 0; tx < ibuf->xtiles; tx++) {
124  if (ibuf->tiles[ibuf->xtiles * ty + tx]) {
125  imb_tile_cache_tile_free(ibuf, tx, ty);
126  MEM_freeN(ibuf->tiles[ibuf->xtiles * ty + tx]);
127  }
128  }
129  }
130 
131  MEM_freeN(ibuf->tiles);
132  }
133 
134  ibuf->tiles = NULL;
135  ibuf->mall &= ~IB_tiles;
136 }
137 
138 static void freeencodedbufferImBuf(ImBuf *ibuf)
139 {
140  if (ibuf == NULL) {
141  return;
142  }
143 
144  if (ibuf->encodedbuffer && (ibuf->mall & IB_mem)) {
145  MEM_freeN(ibuf->encodedbuffer);
146  }
147 
148  ibuf->encodedbuffer = NULL;
149  ibuf->encodedbuffersize = 0;
150  ibuf->encodedsize = 0;
151  ibuf->mall &= ~IB_mem;
152 }
153 
155 {
156  if (ibuf == NULL) {
157  return;
158  }
159 
160  if (ibuf->zbuf && (ibuf->mall & IB_zbuf)) {
161  MEM_freeN(ibuf->zbuf);
162  }
163 
164  ibuf->zbuf = NULL;
165  ibuf->mall &= ~IB_zbuf;
166 }
167 
169 {
170  if (ibuf == NULL) {
171  return;
172  }
173 
174  if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat)) {
175  MEM_freeN(ibuf->zbuf_float);
176  }
177 
178  ibuf->zbuf_float = NULL;
179  ibuf->mall &= ~IB_zbuffloat;
180 }
181 
183 {
184  imb_freerectImBuf(ibuf);
186  imb_freetilesImBuf(ibuf);
187  IMB_freezbufImBuf(ibuf);
190 }
191 
192 void IMB_freeImBuf(ImBuf *ibuf)
193 {
194  if (ibuf) {
195  bool needs_free = false;
196 
198  if (ibuf->refcounter > 0) {
199  ibuf->refcounter--;
200  }
201  else {
202  needs_free = true;
203  }
205 
206  if (needs_free) {
207  imb_freerectImbuf_all(ibuf);
210 
211  if (ibuf->dds_data.data != NULL) {
212  /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
213  free(ibuf->dds_data.data);
214  }
215  MEM_freeN(ibuf);
216  }
217  }
218 }
219 
220 void IMB_refImBuf(ImBuf *ibuf)
221 {
223  ibuf->refcounter++;
225 }
226 
228 {
229  ImBuf *rval;
230 
231  if (ibuf) {
232  bool is_single;
234  is_single = (ibuf->refcounter == 0);
236  if (is_single) {
237  return ibuf;
238  }
239  }
240  else {
241  return NULL;
242  }
243 
244  rval = IMB_dupImBuf(ibuf);
245 
246  IMB_metadata_copy(rval, ibuf);
247 
248  IMB_freeImBuf(ibuf);
249 
250  return rval;
251 }
252 
253 bool addzbufImBuf(ImBuf *ibuf)
254 {
255  if (ibuf == NULL) {
256  return false;
257  }
258 
259  IMB_freezbufImBuf(ibuf);
260 
261  if ((ibuf->zbuf = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(unsigned int), __func__))) {
262  ibuf->mall |= IB_zbuf;
263  ibuf->flags |= IB_zbuf;
264  return true;
265  }
266 
267  return false;
268 }
269 
271 {
272  if (ibuf == NULL) {
273  return false;
274  }
275 
277 
278  if ((ibuf->zbuf_float = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(float), __func__))) {
279  ibuf->mall |= IB_zbuffloat;
280  ibuf->flags |= IB_zbuffloat;
281  return true;
282  }
283 
284  return false;
285 }
286 
288 {
289  if (ibuf == NULL) {
290  return false;
291  }
292 
294 
295  if (ibuf->encodedbuffersize == 0) {
296  ibuf->encodedbuffersize = 10000;
297  }
298 
299  ibuf->encodedsize = 0;
300 
301  if ((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, __func__))) {
302  ibuf->mall |= IB_mem;
303  ibuf->flags |= IB_mem;
304  return true;
305  }
306 
307  return false;
308 }
309 
311 {
312  unsigned int newsize, encodedsize;
313  void *newbuffer;
314 
315  if (ibuf == NULL) {
316  return false;
317  }
318 
319  if (ibuf->encodedbuffersize < ibuf->encodedsize) {
320  printf("%s: error in parameters\n", __func__);
321  return false;
322  }
323 
324  newsize = 2 * ibuf->encodedbuffersize;
325  if (newsize < 10000) {
326  newsize = 10000;
327  }
328 
329  newbuffer = MEM_mallocN(newsize, __func__);
330  if (newbuffer == NULL) {
331  return false;
332  }
333 
334  if (ibuf->encodedbuffer) {
335  memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize);
336  }
337  else {
338  ibuf->encodedsize = 0;
339  }
340 
341  encodedsize = ibuf->encodedsize;
342 
344 
345  ibuf->encodedbuffersize = newsize;
346  ibuf->encodedsize = encodedsize;
347  ibuf->encodedbuffer = newbuffer;
348  ibuf->mall |= IB_mem;
349  ibuf->flags |= IB_mem;
350 
351  return true;
352 }
353 
355  unsigned int x, unsigned int y, unsigned int channels, size_t typesize, const char *name)
356 {
357  /* Protect against buffer overflow vulnerabilities from files specifying
358  * a width and height that overflow and alloc too little memory. */
359  if (!((uint64_t)x * (uint64_t)y < (SIZE_MAX / (channels * typesize)))) {
360  return NULL;
361  }
362 
363  size_t size = (size_t)x * (size_t)y * (size_t)channels * typesize;
364  return MEM_callocN(size, name);
365 }
366 
367 bool imb_addrectfloatImBuf(ImBuf *ibuf, const unsigned int channels)
368 {
369  if (ibuf == NULL) {
370  return false;
371  }
372 
373  if (ibuf->rect_float) {
374  imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
375  }
376 
377  ibuf->channels = channels;
378  if ((ibuf->rect_float = imb_alloc_pixels(ibuf->x, ibuf->y, channels, sizeof(float), __func__))) {
379  ibuf->mall |= IB_rectfloat;
380  ibuf->flags |= IB_rectfloat;
381  return true;
382  }
383 
384  return false;
385 }
386 
388 {
389  /* Question; why also add ZBUF (when `planes > 32`)? */
390 
391  if (ibuf == NULL) {
392  return false;
393  }
394 
395  /* Don't call imb_freerectImBuf, it frees mipmaps,
396  * this call is used only too give float buffers display. */
397  if (ibuf->rect && (ibuf->mall & IB_rect)) {
398  MEM_freeN(ibuf->rect);
399  }
400  ibuf->rect = NULL;
401 
402  if ((ibuf->rect = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(unsigned char), __func__))) {
403  ibuf->mall |= IB_rect;
404  ibuf->flags |= IB_rect;
405  if (ibuf->planes > 32) {
406  return (addzbufImBuf(ibuf));
407  }
408 
409  return true;
410  }
411 
412  return false;
413 }
414 
416  unsigned int *rect, float *rectf, unsigned int w, unsigned int h, unsigned int channels)
417 {
418  ImBuf *ibuf = NULL;
419 
420  if (!(rect || rectf)) {
421  return NULL;
422  }
423 
424  ibuf = IMB_allocImBuf(w, h, 32, 0);
425 
426  ibuf->channels = channels;
427 
428  /* Avoid #MEM_dupallocN since the buffers might not be allocated using guarded-allocation. */
429  if (rectf) {
430  BLI_assert(MEM_allocN_len(rectf) == sizeof(float[4]) * w * h);
431  ibuf->rect_float = rectf;
432 
433  ibuf->flags |= IB_rectfloat;
434  ibuf->mall |= IB_rectfloat;
435  }
436  if (rect) {
437  BLI_assert(MEM_allocN_len(rect) == sizeof(uchar[4]) * w * h);
438  ibuf->rect = rect;
439 
440  ibuf->flags |= IB_rect;
441  ibuf->mall |= IB_rect;
442  }
443 
444  return ibuf;
445 }
446 
447 struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect,
448  const float *rectf,
449  unsigned int w,
450  unsigned int h,
451  unsigned int channels)
452 {
453  ImBuf *ibuf = NULL;
454 
455  if (!(rect || rectf)) {
456  return NULL;
457  }
458 
459  ibuf = IMB_allocImBuf(w, h, 32, 0);
460 
461  ibuf->channels = channels;
462 
463  /* Avoid #MEM_dupallocN since the buffers might not be allocated using guarded-allocation. */
464  if (rectf) {
465  const size_t size = sizeof(float[4]) * w * h;
466  ibuf->rect_float = MEM_mallocN(size, __func__);
467  memcpy(ibuf->rect_float, rectf, size);
468 
469  ibuf->flags |= IB_rectfloat;
470  ibuf->mall |= IB_rectfloat;
471  }
472  if (rect) {
473  const size_t size = sizeof(uchar[4]) * w * h;
474  ibuf->rect = MEM_mallocN(size, __func__);
475  memcpy(ibuf->rect, rect, size);
476 
477  ibuf->flags |= IB_rect;
478  ibuf->mall |= IB_rect;
479  }
480 
481  return ibuf;
482 }
483 
485 {
486  if (ibuf == NULL) {
487  return false;
488  }
489 
490  if (!ibuf->tiles) {
491  if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles,
492  "imb_tiles"))) {
493  ibuf->mall |= IB_tiles;
494  }
495  }
496 
497  return (ibuf->tiles != NULL);
498 }
499 
500 ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags)
501 {
502  ImBuf *ibuf;
503 
504  ibuf = MEM_mallocN(sizeof(ImBuf), "ImBuf_struct");
505 
506  if (ibuf) {
507  if (!IMB_initImBuf(ibuf, x, y, planes, flags)) {
508  IMB_freeImBuf(ibuf);
509  return NULL;
510  }
511  }
512 
513  return ibuf;
514 }
515 
517  struct ImBuf *ibuf, unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
518 {
519  memset(ibuf, 0, sizeof(ImBuf));
520 
521  ibuf->x = x;
522  ibuf->y = y;
523  ibuf->planes = planes;
524  ibuf->ftype = IMB_FTYPE_PNG;
525  /* The '15' means, set compression to low ratio but not time consuming. */
526  ibuf->foptions.quality = 15;
527  /* float option, is set to other values when buffers get assigned. */
528  ibuf->channels = 4;
529  /* IMB_DPI_DEFAULT -> pixels-per-meter. */
530  ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f;
531 
532  if (flags & IB_rect) {
533  if (imb_addrectImBuf(ibuf) == false) {
534  return false;
535  }
536  }
537 
538  if (flags & IB_rectfloat) {
539  if (imb_addrectfloatImBuf(ibuf, ibuf->channels) == false) {
540  return false;
541  }
542  }
543 
544  if (flags & IB_zbuf) {
545  if (addzbufImBuf(ibuf) == false) {
546  return false;
547  }
548  }
549 
550  if (flags & IB_zbuffloat) {
551  if (addzbuffloatImBuf(ibuf) == false) {
552  return false;
553  }
554  }
555 
556  /* assign default spaces */
558 
559  return true;
560 }
561 
562 ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
563 {
564  ImBuf *ibuf2, tbuf;
565  int flags = 0;
566  int a, x, y;
567 
568  if (ibuf1 == NULL) {
569  return NULL;
570  }
571 
572  if (ibuf1->rect) {
573  flags |= IB_rect;
574  }
575  if (ibuf1->rect_float) {
576  flags |= IB_rectfloat;
577  }
578  if (ibuf1->zbuf) {
579  flags |= IB_zbuf;
580  }
581  if (ibuf1->zbuf_float) {
582  flags |= IB_zbuffloat;
583  }
584 
585  x = ibuf1->x;
586  y = ibuf1->y;
587 
588  ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags);
589  if (ibuf2 == NULL) {
590  return NULL;
591  }
592 
593  if (flags & IB_rect) {
594  memcpy(ibuf2->rect, ibuf1->rect, ((size_t)x) * y * sizeof(int));
595  }
596 
597  if (flags & IB_rectfloat) {
598  memcpy(
599  ibuf2->rect_float, ibuf1->rect_float, ((size_t)ibuf1->channels) * x * y * sizeof(float));
600  }
601 
602  if (flags & IB_zbuf) {
603  memcpy(ibuf2->zbuf, ibuf1->zbuf, ((size_t)x) * y * sizeof(int));
604  }
605 
606  if (flags & IB_zbuffloat) {
607  memcpy(ibuf2->zbuf_float, ibuf1->zbuf_float, ((size_t)x) * y * sizeof(float));
608  }
609 
610  if (ibuf1->encodedbuffer) {
611  ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
612  if (imb_addencodedbufferImBuf(ibuf2) == false) {
613  IMB_freeImBuf(ibuf2);
614  return NULL;
615  }
616 
617  memcpy(ibuf2->encodedbuffer, ibuf1->encodedbuffer, ibuf1->encodedsize);
618  }
619 
620  /* silly trick to copy the entire contents of ibuf1 struct over to ibuf */
621  tbuf = *ibuf1;
622 
623  /* fix pointers */
624  tbuf.rect = ibuf2->rect;
625  tbuf.rect_float = ibuf2->rect_float;
626  tbuf.encodedbuffer = ibuf2->encodedbuffer;
627  tbuf.zbuf = ibuf2->zbuf;
628  tbuf.zbuf_float = ibuf2->zbuf_float;
629  for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
630  tbuf.mipmap[a] = NULL;
631  }
632  tbuf.dds_data.data = NULL;
633 
634  /* set malloc flag */
635  tbuf.mall = ibuf2->mall;
636  tbuf.c_handle = NULL;
637  tbuf.refcounter = 0;
638 
639  /* for now don't duplicate metadata */
640  tbuf.metadata = NULL;
641 
642  tbuf.display_buffer_flags = NULL;
643  tbuf.colormanage_cache = NULL;
644 
645  *ibuf2 = tbuf;
646 
647  return ibuf2;
648 }
649 
650 size_t IMB_get_rect_len(const ImBuf *ibuf)
651 {
652  return (size_t)ibuf->x * (size_t)ibuf->y;
653 }
654 
656 {
657  int a;
658  size_t size = 0, channel_size = 0;
659 
660  size += sizeof(ImBuf);
661 
662  if (ibuf->rect) {
663  channel_size += sizeof(char);
664  }
665 
666  if (ibuf->rect_float) {
667  channel_size += sizeof(float);
668  }
669 
670  size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
671 
672  if (ibuf->miptot) {
673  for (a = 0; a < ibuf->miptot; a++) {
674  if (ibuf->mipmap[a]) {
675  size += IMB_get_size_in_memory(ibuf->mipmap[a]);
676  }
677  }
678  }
679 
680  if (ibuf->tiles) {
681  size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
682  }
683 
684  return size;
685 }
686 
687 #if 0 /* remove? - campbell */
688 /* support for cache limiting */
689 
690 static void imbuf_cache_destructor(void *data)
691 {
692  ImBuf *ibuf = (ImBuf *)data;
693 
694  imb_freerectImBuf(ibuf);
696  IMB_freezbufImBuf(ibuf);
699 
700  ibuf->c_handle = NULL;
701 }
702 
703 static MEM_CacheLimiterC **get_imbuf_cache_limiter(void)
704 {
705  static MEM_CacheLimiterC *c = NULL;
706 
707  if (!c) {
708  c = new_MEM_CacheLimiter(imbuf_cache_destructor, NULL);
709  }
710 
711  return &c;
712 }
713 #endif
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:46
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
unsigned char uchar
Definition: BLI_sys_types.h:70
pthread_spinlock_t SpinLock
Definition: BLI_threads.h:110
void BLI_spin_init(SpinLock *spin)
Definition: threads.cc:419
void BLI_spin_unlock(SpinLock *spin)
Definition: threads.cc:452
void BLI_spin_lock(SpinLock *spin)
Definition: threads.cc:433
void BLI_spin_end(SpinLock *spin)
Definition: threads.cc:467
_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
Header file for allocimbuf.c.
Contains defines and structs used throughout the imbuf module.
#define IMB_MIPMAP_LEVELS
struct ImBuf ImBuf
@ IB_zbuf
@ IB_rectfloat
@ IB_tiles
@ IB_zbuffloat
@ IB_mem
@ IB_rect
void IMB_metadata_copy(struct ImBuf *dimb, struct ImBuf *simb)
Definition: metadata.c:64
void IMB_metadata_free(struct IDProperty *metadata)
Definition: metadata.c:35
MEM_CacheLimiterC * new_MEM_CacheLimiter(MEM_CacheLimiter_Destruct_Func data_destructor, MEM_CacheLimiter_DataSize_Func data_size)
struct MEM_CacheLimiter_s MEM_CacheLimiterC
Read Guarded memory(de)allocation.
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 producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
void imb_freerectImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:97
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:168
bool addzbufImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:253
void imb_freerectfloatImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:80
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags)
Definition: allocimbuf.c:500
size_t IMB_get_rect_len(const ImBuf *ibuf)
Definition: allocimbuf.c:650
bool imb_addtilesImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:484
void imb_mmap_lock(void)
Definition: allocimbuf.c:53
static SpinLock mmap_spin
Definition: allocimbuf.c:41
void imb_mmap_unlock(void)
Definition: allocimbuf.c:58
void imb_freetilesImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:113
void imb_freerectImbuf_all(ImBuf *ibuf)
Definition: allocimbuf.c:182
void imb_refcounter_lock_init(void)
Definition: allocimbuf.c:30
bool IMB_initImBuf(struct ImBuf *ibuf, unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:516
void IMB_freezbufImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:154
void imb_mmap_lock_exit(void)
Definition: allocimbuf.c:48
struct ImBuf * IMB_allocFromBufferOwn(unsigned int *rect, float *rectf, unsigned int w, unsigned int h, unsigned int channels)
Definition: allocimbuf.c:415
void * imb_alloc_pixels(unsigned int x, unsigned int y, unsigned int channels, size_t typesize, const char *name)
Definition: allocimbuf.c:354
void imb_freemipmapImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:64
ImBuf * IMB_dupImBuf(const ImBuf *ibuf1)
Definition: allocimbuf.c:562
bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:310
void IMB_freeImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:192
void IMB_refImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:220
static SpinLock refcounter_spin
Definition: allocimbuf.c:28
static void freeencodedbufferImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:138
bool imb_addrectImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:387
void imb_refcounter_lock_exit(void)
Definition: allocimbuf.c:35
size_t IMB_get_size_in_memory(ImBuf *ibuf)
Definition: allocimbuf.c:655
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:287
bool imb_addrectfloatImBuf(ImBuf *ibuf, const unsigned int channels)
Definition: allocimbuf.c:367
struct ImBuf * IMB_allocFromBuffer(const unsigned int *rect, const float *rectf, unsigned int w, unsigned int h, unsigned int channels)
Definition: allocimbuf.c:447
bool addzbuffloatImBuf(ImBuf *ibuf)
Definition: allocimbuf.c:270
ImBuf * IMB_makeSingleUser(ImBuf *ibuf)
Definition: allocimbuf.c:227
void imb_mmap_lock_init(void)
Definition: allocimbuf.c:43
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty)
Definition: cache.c:142
void colormanage_cache_free(ImBuf *ibuf)
void colormanage_imbuf_set_default_spaces(ImBuf *ibuf)
@ IMB_FTYPE_PNG
#define IMB_DPI_DEFAULT
Definition: imbuf.h:46
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
size_t(* MEM_allocN_len)(const void *vmemh)
Definition: mallocn.c:26
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
#define SIZE_MAX
Definition: stdint.h:206
unsigned __int64 uint64_t
Definition: stdint.h:90
unsigned char * data
struct DDSData dds_data
struct IDProperty * metadata
struct MEM_CacheLimiterHandle_s * c_handle
struct ImBuf * mipmap[IMB_MIPMAP_LEVELS]
unsigned int ** tiles
float * zbuf_float
int channels
ImbFormatOptions foptions
unsigned char * encodedbuffer
unsigned int encodedbuffersize
unsigned char planes
enum eImbFileType ftype
unsigned int * rect
unsigned int encodedsize
float * rect_float
unsigned int * display_buffer_flags
int * zbuf
double ppm[2]
struct ColormanageCache * colormanage_cache
int refcounter