diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-05-15 17:00:36 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-05-15 17:01:01 +0300 |
commit | f4e8e70b5d77c9a6430f64bc223ab0a04b38f815 (patch) | |
tree | d471620b8f3a455f8857e42a8a5e88846fb0b40a /source/blender | |
parent | 31e96cbf96a2bd26b77a29bf4cd8475a53521539 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 061357c3906..66c502cba53 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)); |