Page MenuHome

image_anim_free.diff

image_anim_free.diff

Index: source/blender/blenkernel/intern/image.c
===================================================================
--- source/blender/blenkernel/intern/image.c (revision 37295)
+++ source/blender/blenkernel/intern/image.c (working copy)
@@ -245,17 +245,50 @@
/* this function is intended to be thread safe. with IMA_NO_INDEX this
* should be OK, but when iterating over the list this is more tricky
* */
- if(index==IMA_NO_INDEX)
+ if(index==IMA_NO_INDEX) {
return ima->ibufs.first;
+ }
else {
+ const int mem_limit_kb= U.memcachelimit * 1024;
+ /* this is an approximation */
+# define IMB_SIZE_KB(imb) (((ibuf)->x * (ibuf)->y) / (4 * 1024))
+
ImBuf *ibuf;
+ ImBuf *ibuf_ret= NULL;
+ int tot= 0;
+ int size= 0;
index= IMA_MAKE_INDEX(frame, index);
- for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next)
- if(ibuf->index==index)
- return ibuf;
+ for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next, tot++) {
+ size += IMB_SIZE_KB(ibuf);
+ if(ibuf->index==index) {
+ ibuf_ret= ibuf;
+ break;
+ }
+ }
- return NULL;
+ for( ; ibuf; ibuf= ibuf->next, tot++) {
+ size += IMB_SIZE_KB(ibuf);
+ }
+
+ while(tot > 2 && size > mem_limit_kb) {
+ if(
+ ibuf_ret != (ibuf= ima->ibufs.first) ||
+ ibuf_ret != (ibuf= ima->ibufs.last)
+ ) {
+ size -= IMB_SIZE_KB(ibuf);
+ tot--;
+ BLI_remlink(&ima->ibufs, ibuf);
+ IMB_freeImBuf(ibuf);
+ }
+ else {
+ break;
+ }
+ }
+
+ return ibuf_ret;
+
+# undef IMB_SIZE_KB
}
}

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b9/74/340f8e1813011933576fe85600a4

Event Timeline