Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_playanim.c
| Show First 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | |||||
| static double ptottime = 0.0, swaptime = 0.04; | static double ptottime = 0.0, swaptime = 0.04; | ||||
| #ifdef WITH_AUDASPACE | #ifdef WITH_AUDASPACE | ||||
| static double fps_movie; | static double fps_movie; | ||||
| #endif | #endif | ||||
| #ifdef USE_FRAME_CACHE_LIMIT | #ifdef USE_FRAME_CACHE_LIMIT | ||||
| static struct ListBase inmempicsbase = {NULL, NULL}; | static struct ListBase inmempicsbase = {NULL, NULL}; | ||||
| static int added_images = 0; | static int added_images = 0; | ||||
| /** Limit the amount of memory used for cache (in bytes). */ | |||||
| static size_t frame_cache_memory_limit = 0; | |||||
| #endif | #endif | ||||
| static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step) | static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step) | ||||
| { | { | ||||
| if (step > 0) { | if (step > 0) { | ||||
| while (step-- && playanim) { | while (step-- && playanim) { | ||||
| playanim = playanim->next; | playanim = playanim->next; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 956 Lines • ▼ Show 20 Lines | if (argv[1][0] == '-') { | ||||
| break; | break; | ||||
| case 'j': | case 'j': | ||||
| ps.fstep = atoi(argv[2]); | ps.fstep = atoi(argv[2]); | ||||
| CLAMP(ps.fstep, 1, MAXFRAME); | CLAMP(ps.fstep, 1, MAXFRAME); | ||||
| swaptime *= ps.fstep; | swaptime *= ps.fstep; | ||||
| argc--; | argc--; | ||||
| argv++; | argv++; | ||||
| break; | break; | ||||
| case 'c': { | |||||
| #ifdef USE_FRAME_CACHE_LIMIT | |||||
| int memory_in_mb = atoi(argv[2]); | |||||
| CLAMP_MIN(memory_in_mb, 0); | |||||
sergey: `const int memory_in_mb = max(0, atoi(argv[2]));` | |||||
| frame_cache_memory_limit = (size_t)memory_in_mb * (1024 * 1024); | |||||
| #endif | |||||
| argc--; | |||||
| argv++; | |||||
| break; | |||||
| } | |||||
| default: | default: | ||||
| printf("unknown option '%c': skipping\n", argv[1][1]); | printf("unknown option '%c': skipping\n", argv[1][1]); | ||||
| break; | break; | ||||
| } | } | ||||
| argc--; | argc--; | ||||
| argv++; | argv++; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | #ifdef USE_FRAME_CACHE_LIMIT | ||||
| BLI_assert(ps.picture->frame_cache_node->data == ps.picture); | BLI_assert(ps.picture->frame_cache_node->data == ps.picture); | ||||
| BLI_remlink(&inmempicsbase, ps.picture->frame_cache_node); | BLI_remlink(&inmempicsbase, ps.picture->frame_cache_node); | ||||
| BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node); | BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node); | ||||
| } | } | ||||
| /* Really basic memory conservation scheme. Keep frames in a FIFO queue. */ | /* Really basic memory conservation scheme. Keep frames in a FIFO queue. */ | ||||
| LinkData *node = inmempicsbase.last; | LinkData *node = inmempicsbase.last; | ||||
| while (node && added_images > PLAY_FRAME_CACHE_MAX) { | while (node != NULL) { | ||||
| if (frame_cache_memory_limit != 0) { | |||||
| if (MEM_get_memory_in_use() <= frame_cache_memory_limit) { | |||||
sergeyUnsubmitted Done Inline ActionsUse IMB_get_size_in_memory() to more accurately estimate size of the cache. sergey: Use `IMB_get_size_in_memory()` to more accurately estimate size of the cache. | |||||
| break; | |||||
| } | |||||
| } | |||||
| else { | |||||
| /* No memory limit, use hard coded default. */ | |||||
| if (added_images <= PLAY_FRAME_CACHE_MAX) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| PlayAnimPict *pic = node->data; | PlayAnimPict *pic = node->data; | ||||
| BLI_assert(pic->frame_cache_node == node); | BLI_assert(pic->frame_cache_node == node); | ||||
| if (pic->ibuf && pic->ibuf != ibuf) { | if (pic->ibuf && pic->ibuf != ibuf) { | ||||
| LinkData *node_tmp; | LinkData *node_tmp; | ||||
| IMB_freeImBuf(pic->ibuf); | IMB_freeImBuf(pic->ibuf); | ||||
| pic->ibuf = NULL; | pic->ibuf = NULL; | ||||
| pic->frame_cache_node = NULL; | pic->frame_cache_node = NULL; | ||||
| ▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines | |||||
const int memory_in_mb = max(0, atoi(argv[2]));