29# define PRINT(format, args...) printf(format, ##args)
31# define PRINT(format, ...) printf(__VA_ARGS__)
34# define PRINT(format, ...)
112 PRINT(
"%s: cache '%s' free item %p buffer %p\n", __func__, cache->
name, item, item->
ibuf);
149 bool remove = !item->
ibuf;
152 PRINT(
"%s: cache '%s' remove item %p without buffer\n", __func__, cache->
name, item);
163 const int *a = (
int *)av;
164 const int *
b = (
int *)bv;
172 if (item && item->
ibuf) {
175 PRINT(
"%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->
name, item, item->
ibuf);
179 item->
ibuf =
nullptr;
215 PRINT(
"%s: cache '%s' item %p use default priority %d\n",
221 return default_priority;
226 PRINT(
"%s: cache '%s' item %p priority %d\n", __func__, cache->
name, item, priority);
234 if (item->
ibuf ==
nullptr) {
271 PRINT(
"%s: cache '%s' create\n", __func__,
name);
285 cache->
cmpfp = cmpfp;
317 if (ibuf !=
nullptr) {
328 PRINT(
"%s: cache '%s' put %p, item %p\n", __func__, cache->
name, ibuf, item);
409 if (r_is_cached_empty) {
410 *r_is_cached_empty =
false;
424 *r_is_cached_empty =
true;
440 return item !=
nullptr;
445 PRINT(
"%s: cache '%s' free\n", __func__, cache->
name);
465 bool(cleanup_check_cb)(
ImBuf *ibuf,
void *userkey,
void *userdata),
480 if (cleanup_check_cb(item->
ibuf, key->
userkey, userdata)) {
481 PRINT(
"%s: cache '%s' remove item %p\n", __func__, cache->
name, item);
489 MovieCache *cache,
int proxy,
int render_flags,
int *r_totseg,
int **r_points)
503 *r_totseg = cache->
totseg;
504 *r_points = cache->
points;
516 int framenr, curproxy, curflags;
521 if (curproxy == proxy && curflags == render_flags) {
522 frames[a++] = framenr;
530 for (a = 0; a < totframe; a++) {
531 if (a && frames[a] - frames[a - 1] != 1) {
535 if (a == totframe - 1) {
546 for (a = 0,
b = 0; a < totframe; a++) {
548 points[
b++] = frames[a];
551 if (a && frames[a] - frames[a - 1] != 1) {
552 points[
b++] = frames[a - 1];
553 points[
b++] = frames[a];
556 if (a == totframe - 1) {
557 points[
b++] = frames[a];
566 cache->
proxy = proxy;
581 return (MovieCacheIter *)iter;
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_ghashIterator_step(GHashIterator *ghi)
void BLI_ghashIterator_free(GHashIterator *ghi)
bool(* GHashCmpFP)(const void *a, const void *b)
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHashIterator * BLI_ghashIterator_new(GHash *gh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
unsigned int(* GHashHashFP)(const void *key)
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
char * STRNCPY(char(&dst)[N], const char *src)
void IMB_freeImBuf(ImBuf *ibuf)
void IMB_refImBuf(ImBuf *ibuf)
size_t IMB_get_size_in_memory(const ImBuf *ibuf)
int(*)(void *last_userkey, void *priority_data) MovieCacheGetItemPriorityFP
void(*)(void *userkey, int *framenr, int *proxy, int *render_flags) MovieCacheGetKeyDataFP
void *(*)(void *userkey) MovieCacheGetPriorityDataFP
void(*)(void *priority_data) MovieCachePriorityDeleterFP
void MEM_CacheLimiter_ItemPriority_Func_set(MEM_CacheLimiterC *This, MEM_CacheLimiter_ItemPriority_Func item_priority_func)
void MEM_CacheLimiter_enforce_limits(MEM_CacheLimiterC *This)
void MEM_CacheLimiter_touch(MEM_CacheLimiterHandleC *handle)
void MEM_CacheLimiter_unref(MEM_CacheLimiterHandleC *handle)
void delete_MEM_CacheLimiter(MEM_CacheLimiterC *This)
void MEM_CacheLimiter_ItemDestroyable_Func_set(MEM_CacheLimiterC *This, MEM_CacheLimiter_ItemDestroyable_Func item_destroyable_func)
size_t MEM_CacheLimiter_get_memory_in_use(MEM_CacheLimiterC *This)
size_t MEM_CacheLimiter_get_maximum()
MEM_CacheLimiterC * new_MEM_CacheLimiter(MEM_CacheLimiter_Destruct_Func data_destructor, MEM_CacheLimiter_DataSize_Func data_size)
MEM_CacheLimiterHandleC * MEM_CacheLimiter_insert(MEM_CacheLimiterC *This, void *data)
void MEM_CacheLimiter_ref(MEM_CacheLimiterHandleC *handle)
void MEM_CacheLimiter_unmanage(MEM_CacheLimiterHandleC *handle)
struct MEM_CacheLimiter_s MEM_CacheLimiterC
struct MEM_CacheLimiterHandle_s MEM_CacheLimiterHandleC
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
bool IMB_moviecache_put_if_possible(MovieCache *cache, void *userkey, ImBuf *ibuf)
MovieCacheIter * IMB_moviecacheIter_new(MovieCache *cache)
static std::recursive_mutex limitor_lock
static size_t get_size_in_memory(ImBuf *ibuf)
void * IMB_moviecacheIter_getUserKey(MovieCacheIter *iter)
static bool moviecache_hashcmp(const void *av, const void *bv)
static void moviecache_destructor(void *p)
void IMB_moviecache_free(MovieCache *cache)
bool IMB_moviecache_has_frame(MovieCache *cache, void *userkey)
void IMB_moviecache_cleanup(MovieCache *cache, bool(cleanup_check_cb)(ImBuf *ibuf, void *userkey, void *userdata), void *userdata)
static void check_unused_keys(MovieCache *cache)
ImBuf * IMB_moviecache_get(MovieCache *cache, void *userkey, bool *r_is_cached_empty)
static int get_item_priority(void *item_v, int default_priority)
void IMB_moviecacheIter_free(MovieCacheIter *iter)
bool IMB_moviecacheIter_done(MovieCacheIter *iter)
void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf)
static uint moviecache_hashhash(const void *keyv)
static size_t get_item_size(void *p)
static int compare_int(const void *av, const void *bv)
void IMB_moviecache_set_getdata_callback(MovieCache *cache, MovieCacheGetKeyDataFP getdatafp)
static bool get_item_destroyable(void *item_v)
void IMB_moviecache_set_priority_callback(MovieCache *cache, MovieCacheGetPriorityDataFP getprioritydatafp, MovieCacheGetItemPriorityFP getitempriorityfp, MovieCachePriorityDeleterFP prioritydeleterfp)
void IMB_moviecacheIter_step(MovieCacheIter *iter)
static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, bool need_lock)
void IMB_moviecache_destruct()
void IMB_moviecache_init()
static void moviecache_keyfree(void *val)
ImBuf * IMB_moviecacheIter_getImBuf(MovieCacheIter *iter)
static void moviecache_valfree(void *val)
void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_flags, int *r_totseg, int **r_points)
static MEM_CacheLimiterC * limitor
MovieCache * IMB_moviecache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp)
#define PRINT(format,...)
void IMB_moviecache_remove(MovieCache *cache, void *userkey)
static bool moviecache_hashcmp(const void *av, const void *bv)
static uint moviecache_hashhash(const void *keyv)
MEM_CacheLimiterHandleC * c_handle
MovieCacheGetKeyDataFP getdatafp
BLI_mempool * userkeys_pool
MovieCacheGetItemPriorityFP getitempriorityfp
MovieCachePriorityDeleterFP prioritydeleterfp
MovieCacheGetPriorityDataFP getprioritydatafp