45 # define PRINT(format, args...) printf(format, ##args)
47 # define PRINT(format, ...) printf(__VA_ARGS__)
50 # define PRINT(format, ...)
104 return a->cache_owner->cmpfp(
a->userkey, b->
userkey);
121 PRINT(
"%s: cache '%s' free item %p buffer %p\n", __func__, cache->
name, item, item->
ibuf);
148 remove = !item->
ibuf;
151 PRINT(
"%s: cache '%s' remove item %p without buffer\n", __func__, cache->
name, item);
171 if (item && item->
ibuf) {
174 PRINT(
"%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->
name, item, item->
ibuf);
217 PRINT(
"%s: cache '%s' item %p use default priority %d\n",
223 return default_priority;
228 PRINT(
"%s: cache '%s' item %p priority %d\n", __func__, cache->
name, item, priority);
269 PRINT(
"%s: cache '%s' create\n", __func__, name);
283 cache->
cmpfp = cmpfp;
324 PRINT(
"%s: cache '%s' put %p, item %p\n", __func__, cache->
name, ibuf, item);
436 PRINT(
"%s: cache '%s' free\n", __func__, cache->
name);
456 bool(cleanup_check_cb)(
ImBuf *ibuf,
void *userkey,
void *userdata),
471 if (cleanup_check_cb(item->
ibuf, key->
userkey, userdata)) {
472 PRINT(
"%s: cache '%s' remove item %p\n", __func__, cache->
name, item);
481 MovieCache *cache,
int proxy,
int render_flags,
int *r_totseg,
int **r_points)
499 *r_totseg = cache->
totseg;
500 *r_points = cache->
points;
504 int *frames =
MEM_callocN(totframe *
sizeof(
int),
"movieclip cache frames");
512 int framenr, curproxy, curflags;
517 if (curproxy == proxy && curflags == render_flags) {
518 frames[
a++] = framenr;
526 for (
a = 0;
a < totframe;
a++) {
527 if (
a && frames[
a] - frames[
a - 1] != 1) {
531 if (
a == totframe - 1) {
539 points =
MEM_callocN(
sizeof(
int[2]) * totseg,
"movieclip cache segments");
542 for (
a = 0, b = 0;
a < totframe;
a++) {
544 points[b++] = frames[
a];
547 if (
a && frames[
a] - frames[
a - 1] != 1) {
548 points[b++] = frames[
a - 1];
549 points[b++] = frames[
a];
552 if (
a == totframe - 1) {
553 points[b++] = frames[
a];
562 cache->
proxy = proxy;
577 return (
struct 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)
BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
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
unsigned int BLI_ghash_len(GHash *gh) ATTR_WARN_UNUSED_RESULT
unsigned int(* GHashHashFP)(const void *key)
GHashIterator * BLI_ghashIterator_new(GHash *gh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int totelem, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
#define BLI_MUTEX_INITIALIZER
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
void IMB_freeImBuf(struct ImBuf *ibuf)
size_t IMB_get_size_in_memory(struct ImBuf *ibuf)
void IMB_refImBuf(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
int(* MovieCacheGetItemPriorityFP)(void *last_userkey, void *priority_data)
void(* MovieCachePriorityDeleterFP)(void *priority_data)
void *(* MovieCacheGetPriorityDataFP)(void *userkey)
void(* MovieCacheGetKeyDataFP)(void *userkey, int *framenr, int *proxy, int *render_flags)
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)
MEM_CacheLimiterHandleC * MEM_CacheLimiter_insert(MEM_CacheLimiterC *This, void *data)
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()
void MEM_CacheLimiter_ref(MEM_CacheLimiterHandleC *handle)
void MEM_CacheLimiter_unmanage(MEM_CacheLimiterHandleC *handle)
MEM_CacheLimiterC * new_MEM_CacheLimiter(MEM_CacheLimiter_Destruct_Func data_destructor, MEM_CacheLimiter_DataSize_Func data_size)
struct MEM_CacheLimiterHandle_s MEM_CacheLimiterHandleC
struct MEM_CacheLimiter_s MEM_CacheLimiterC
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
bool IMB_moviecache_put_if_possible(MovieCache *cache, void *userkey, ImBuf *ibuf)
struct MovieCacheKey MovieCacheKey
void IMB_moviecacheIter_free(struct MovieCacheIter *iter)
ImBuf * IMB_moviecache_get(MovieCache *cache, void *userkey)
static size_t get_size_in_memory(ImBuf *ibuf)
static pthread_mutex_t limitor_lock
struct MovieCacheIter * IMB_moviecacheIter_new(MovieCache *cache)
static bool moviecache_hashcmp(const void *av, const void *bv)
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)
MovieCache * IMB_moviecache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp)
static void check_unused_keys(MovieCache *cache)
void IMB_moviecache_destruct(void)
static int get_item_priority(void *item_v, int default_priority)
static unsigned int moviecache_hashhash(const void *keyv)
struct MovieCacheItem MovieCacheItem
void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf)
static size_t get_item_size(void *p)
bool IMB_moviecacheIter_done(struct MovieCacheIter *iter)
static int compare_int(const void *av, const void *bv)
void IMB_moviecache_set_getdata_callback(MovieCache *cache, MovieCacheGetKeyDataFP getdatafp)
void IMB_moviecacheIter_step(struct MovieCacheIter *iter)
static bool get_item_destroyable(void *item_v)
struct MovieCache MovieCache
void IMB_moviecache_set_priority_callback(struct MovieCache *cache, MovieCacheGetPriorityDataFP getprioritydatafp, MovieCacheGetItemPriorityFP getitempriorityfp, MovieCachePriorityDeleterFP prioritydeleterfp)
static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, bool need_lock)
void IMB_moviecache_init(void)
void * IMB_moviecacheIter_getUserKey(struct MovieCacheIter *iter)
static void moviecache_keyfree(void *val)
static void moviecache_valfree(void *val)
static void IMB_moviecache_destructor(void *p)
void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_flags, int *r_totseg, int **r_points)
static MEM_CacheLimiterC * limitor
#define PRINT(format,...)
void IMB_moviecache_remove(MovieCache *cache, void *userkey)
ImBuf * IMB_moviecacheIter_getImBuf(struct MovieCacheIter *iter)
MEM_CacheLimiterHandleC * c_handle
MovieCacheGetKeyDataFP getdatafp
struct BLI_mempool * keys_pool
MovieCacheGetItemPriorityFP getitempriorityfp
struct BLI_mempool * items_pool
struct BLI_mempool * userkeys_pool
MovieCachePriorityDeleterFP prioritydeleterfp
MovieCacheGetPriorityDataFP getprioritydatafp