[Bf-blender-cvs] [f4e8e70] master: Add really simple memory reduction scheme for internal animation player.

Antony Riakiotakis noreply at git.blender.org
Fri May 15 16:01:30 CEST 2015


Commit: f4e8e70b5d77c9a6430f64bc223ab0a04b38f815
Author: Antony Riakiotakis
Date:   Fri May 15 16:00:36 2015 +0200
Branches: master
https://developer.blender.org/rBf4e8e70b5d77c9a6430f64bc223ab0a04b38f815

Add really simple memory reduction scheme for internal animation player.

Holds 30 frames in memory. Could make it check memory instead but that
should suffice for now to make sure blender does not crash on me with
movie files.

Previously the system would load eveything in memory so something like
playing caminandes in player would swap after 30 seconds in local
computer.

===================================================================

M	source/blender/windowmanager/intern/wm_playanim.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 061357c..66c502c 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -222,6 +222,9 @@ typedef struct PlayAnimPict {
 } PlayAnimPict;
 
 static struct ListBase picsbase = {NULL, NULL};
+/* frames in memory - store them here to for easy deallocation later */
+static struct ListBase inmempicsbase = {NULL, NULL};
+static int added_images = 0;
 static bool fromdisk = false;
 static double ptottime = 0.0, swaptime = 0.04;
 
@@ -1130,10 +1133,33 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
 			}
 
 			if (ibuf) {
+				LinkData *node;
 
 #ifdef USE_IMB_CACHE
 				ps.picture->ibuf = ibuf;
 #endif
+				/* really basic memory conservation scheme. Keep frames in a fifo queue */
+				node = inmempicsbase.last;
+
+				while (added_images > 30) {
+					PlayAnimPict *pic = (PlayAnimPict *)node->data;
+
+					if (pic->ibuf != ibuf) {
+						LinkData *node_tmp;
+						IMB_freeImBuf(pic->ibuf);
+						pic->ibuf = NULL;
+						node_tmp = node->prev;
+						BLI_freelinkN(&inmempicsbase, node);
+						added_images--;
+						node = node_tmp;
+					}
+					else {
+						node = node->prev;
+					}
+				}
+
+				BLI_addhead(&inmempicsbase, BLI_genericNodeN(ps.picture));
+				added_images++;
 
 				BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name));




More information about the Bf-blender-cvs mailing list