30 # define PRINT(format, args...) printf(format, ##args)
32 # define PRINT(format, ...) printf(__VA_ARGS__)
35 # define PRINT(format, ...)
96 return a->cache_owner->cmpfp(
a->userkey,
b->userkey);
113 PRINT(
"%s: cache '%s' free item %p buffer %p\n", __func__, cache->
name, item, item->
ibuf);
153 PRINT(
"%s: cache '%s' remove item %p without buffer\n", __func__, cache->
name, item);
164 const int *
a = (
int *)av;
165 const int *
b = (
int *)bv;
173 if (item && item->
ibuf) {
176 PRINT(
"%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->
name, item, item->
ibuf);
180 item->
ibuf =
nullptr;
216 PRINT(
"%s: cache '%s' item %p use default priority %d\n",
222 return default_priority;
227 PRINT(
"%s: cache '%s' item %p priority %d\n", __func__, cache->
name, item, priority);
235 if (item->
ibuf ==
nullptr) {
272 PRINT(
"%s: cache '%s' create\n", __func__, name);
286 cache->
cmpfp = cmpfp;
318 if (ibuf !=
nullptr) {
329 PRINT(
"%s: cache '%s' put %p, item %p\n", __func__, cache->
name, ibuf, item);
410 if (r_is_cached_empty) {
411 *r_is_cached_empty =
false;
424 if (r_is_cached_empty) {
425 *r_is_cached_empty =
true;
441 return item !=
nullptr;
446 PRINT(
"%s: cache '%s' free\n", __func__, cache->
name);
466 bool(cleanup_check_cb)(
ImBuf *ibuf,
void *userkey,
void *userdata),
481 if (cleanup_check_cb(item->
ibuf, key->
userkey, userdata)) {
482 PRINT(
"%s: cache '%s' remove item %p\n", __func__, cache->
name, item);
490 MovieCache *cache,
int proxy,
int render_flags,
int *r_totseg,
int **r_points)
504 *r_totseg = cache->
totseg;
505 *r_points = cache->
points;
509 int *frames = (
int *)
MEM_callocN(totframe *
sizeof(
int),
"movieclip cache frames");
517 int framenr, curproxy, curflags;
522 if (curproxy == proxy && curflags == render_flags) {
523 frames[
a++] = framenr;
531 for (
a = 0;
a < totframe;
a++) {
532 if (
a && frames[
a] - frames[
a - 1] != 1) {
536 if (
a == totframe - 1) {
544 points = (
int *)
MEM_callocN(
sizeof(
int[2]) * totseg,
"movieclip cache segments");
547 for (
a = 0,
b = 0;
a < totframe;
a++) {
549 points[
b++] = frames[
a];
552 if (
a && frames[
a] - frames[
a - 1] != 1) {
553 points[
b++] = frames[
a - 1];
554 points[
b++] = frames[
a];
557 if (
a == totframe - 1) {
558 points[
b++] = frames[
a];
567 cache->
proxy = proxy;
582 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)
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(* GHashHashFP)(const void *key)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
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)
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) 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 elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
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 IMB_freeImBuf(ImBuf *UNUSED(ibuf))
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)
void IMB_moviecacheIter_free(struct MovieCacheIter *iter)
static std::recursive_mutex limitor_lock
static size_t get_size_in_memory(ImBuf *ibuf)
struct MovieCacheIter * IMB_moviecacheIter_new(MovieCache *cache)
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)
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)
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)
ImBuf * IMB_moviecache_get(MovieCache *cache, void *userkey, bool *r_is_cached_empty)
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)
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)
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)
bool remove(void *owner, const AttributeIDRef &attribute_id)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
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