103 #define DCACHE_FNAME_FORMAT "%d-%dx%d-%d%%(%d)-%d.dcf"
104 #define DCACHE_IMAGES_PER_FILE 100
105 #define DCACHE_CURRENT_VERSION 1
106 #define COLORSPACE_NAME_MAX 64
176 float timeline_frame,
182 return U.sequencer_disk_cache_dir;
187 switch (
U.sequencer_disk_cache_compression) {
196 return U.sequencer_disk_cache_compression;
201 return (
size_t)
U.sequencer_disk_cache_size_limit * (1024 * 1024 * 1024);
206 return (
U.sequencer_disk_cache_dir[0] !=
'\0' &&
U.sequencer_disk_cache_size_limit != 0 &&
208 bmain->
name[0] !=
'\0');
262 if (ext && ext[1] ==
'd' && ext[2] ==
'c' && ext[3] ==
'f') {
264 cache_file->
fstat = fl->
s;
276 if (oldest_file ==
NULL) {
280 if (cache_file->fstat.st_mtime < oldest_file->
fstat.st_mtime) {
281 oldest_file = cache_file;
326 for (; cache_file; cache_file = cache_file->
next) {
343 size_before = cache_file->
fstat.st_size;
350 size_after = cache_file->
fstat.st_size;
351 disk_cache->
size_total += size_after - size_before;
363 const char *suffix =
"_seq_cache";
364 strncat(cache_dir, suffix,
sizeof(cache_dir) - strlen(cache_dir) - 1);
394 sprintf(cache_filename,
425 BLI_path_append(path_version_file,
sizeof(path_version_file),
"cache_version");
431 const int num_items_read = fscanf(
file,
"%d", &version);
432 if (num_items_read == 0) {
451 int invalidate_types,
461 next_file = cache_file->
next;
462 if (cache_file->
cache_type & invalidate_types) {
463 if (
STREQ(cache_dir, cache_file->
dir)) {
466 if (timeline_frame_start > range_start && timeline_frame_start <= range_end) {
471 cache_file = next_file;
478 int invalidate_types)
522 const size_t num_items_read = fread(header,
sizeof(*header), 1,
file);
523 if (num_items_read < 1) {
524 BLI_assert(!
"unable to read disk cache header");
525 perror(
"unable to read disk cache header");
544 return fwrite(header,
sizeof(*header), 1,
file);
564 memset(header, 0,
sizeof(*header));
583 const char *colorspace_name;
627 memset(&header, 0,
sizeof(header));
640 if (bytes_written != 0) {
675 if (entry_index < 0) {
683 size_t expected_size;
686 expected_size = size_char;
691 expected_size = size_float;
703 if (bytes_read != expected_size) {
715 #undef DCACHE_FNAME_FORMAT
716 #undef DCACHE_IMAGES_PER_FILE
717 #undef COLORSPACE_NAME_MAX
718 #undef DCACHE_CURRENT_VERSION
731 unsigned int rval =
a->rectx +
a->recty;
733 rval ^=
a->preview_render_size;
736 rval ^= (int)(
a->motion_blur_shutter * 100.0f) << 10;
737 rval ^=
a->motion_blur_samples << 16;
738 rval ^= ((
a->scene->r.views_format * 2) +
a->view_id) << 24;
773 return timeline_frame - seq->
start;
778 return frame_index + seq->
start;
810 return ((
size_t)
U.memcachelimit) * 1024 * 1024;
857 if (stored_types_flag & key->
type) {
890 if (item && item->
ibuf) {
926 int pfjob_start, pfjob_end;
954 if (l_diff > r_diff) {
1027 int total_count = 0;
1102 if (!cache || !base) {
1127 if (cache ==
NULL) {
1153 cache->
bmain = bmain;
1167 const float timeline_frame,
1185 const float timeline_frame,
1213 key->
seq, timeline_frame, key->
type);
1215 timeline_frame < key->seq->startdisp) {
1277 int invalidate_types,
1278 bool force_seq_changed_range)
1291 int range_start = seq_changed->
startdisp;
1292 int range_end = seq_changed->
enddisp;
1294 if (!force_seq_changed_range) {
1299 if (seq->
enddisp < range_end) {
1324 if (key->
type & invalidate_source && key->
seq == seq &&
1340 float timeline_frame,
1350 if (
context->is_prefetch_render) {
1409 if (
context->is_prefetch_render) {
1438 if (
context->is_prefetch_render) {
1479 bool callback_init(
void *
userdata,
size_t item_count),
1480 bool callback_iter(
void *
userdata,
struct Sequence *seq,
int timeline_frame,
int cache_type))
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) ATTR_NONNULL(1)
File and directory operations.
eFileAttributes BLI_file_attributes(const char *path)
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
size_t BLI_ungzip_file_to_mem_at_pos(void *buf, size_t len, FILE *file, size_t gz_stream_offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_file_touch(const char *file) ATTR_NONNULL()
#define FILE_ATTR_ANY_LINK
void BLI_filelist_free(struct direntry *filelist, const unsigned int nrentries)
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_delete(const char *file, bool dir, bool recursive) ATTR_NONNULL()
unsigned int BLI_filelist_dir_contents(const char *dir, struct direntry **r_filelist)
size_t BLI_gzip_mem_to_file_at_pos(void *buf, size_t len, FILE *file, size_t gz_stream_offset, int compression_level) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FILE * BLI_fopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Some types for dealing with directories.
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
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
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
bool BLI_ghash_haskey(GHash *gh, const void *key) 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 void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) 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 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)
const char * BLI_path_extension(const char *filepath) ATTR_NONNULL()
bool BLI_make_existing_file(const char *name)
void BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__restrict file) ATTR_NONNULL()
#define FILENAME_IS_CURRPAR(_n)
int BLI_path_slash_ensure(char *string) ATTR_NONNULL()
bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1)
void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen)
void BLI_split_file_part(const char *string, char *file, const size_t filelen)
int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
void BLI_mutex_end(ThreadMutex *mutex)
void BLI_mutex_init(ThreadMutex *mutex)
#define BLI_MUTEX_INITIALIZER
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
pthread_mutex_t ThreadMutex
@ SEQ_CACHE_STORE_PREPROCESSED
@ SEQ_CACHE_STORE_FINAL_OUT
@ SEQ_CACHE_STORE_COMPOSITE
@ SEQ_CACHE_DISK_CACHE_ENABLE
@ SEQ_CACHE_PREFETCH_ENABLE
@ USER_SEQ_DISK_CACHE_COMPRESSION_HIGH
@ USER_SEQ_DISK_CACHE_COMPRESSION_LOW
@ USER_SEQ_DISK_CACHE_COMPRESSION_NONE
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
const char * IMB_colormanagement_get_rect_colorspace(struct ImBuf *ibuf)
void IMB_colormanagement_assign_float_colorspace(struct ImBuf *ibuf, const char *name)
void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name)
const char * IMB_colormanagement_get_float_colorspace(struct ImBuf *ibuf)
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_freeImBuf(struct ImBuf *ibuf)
void IMB_refImBuf(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define DCACHE_IMAGES_PER_FILE
static unsigned int seq_cache_hashhash(const void *key_)
static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache)
static void seq_disk_cache_delete_invalid_files(SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, int invalidate_types, int range_start, int range_end)
static DiskCacheFile * seq_disk_cache_get_file_entry_by_path(SeqDiskCache *disk_cache, char *path)
static void seq_cache_recycle_linked(Scene *scene, SeqCacheKey *base)
void SEQ_cache_cleanup(Scene *scene)
static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, SeqCacheKey *key, char *path, size_t path_len)
static int seq_disk_cache_compression_level(void)
static void seq_cache_create(Main *bmain, Scene *scene)
static void seq_cache_unlock(Scene *scene)
bool seq_cache_put_if_possible(const SeqRenderData *context, Sequence *seq, float timeline_frame, int type, ImBuf *ibuf)
bool seq_cache_is_full(void)
static int get_stored_types_flag(Scene *scene, SeqCacheKey *key)
static ImBuf * seq_disk_cache_read_file(SeqDiskCache *disk_cache, SeqCacheKey *key)
static void seq_disk_cache_update_file(SeqDiskCache *disk_cache, char *path)
static float seq_cache_timeline_frame_to_frame_index(Sequence *seq, float timeline_frame, int type)
static void seq_cache_set_temp_cache_linked(Scene *scene, SeqCacheKey *base)
static unsigned int seq_hash_render_data(const SeqRenderData *a)
static void seq_cache_valfree(void *val)
static DiskCacheFile * seq_disk_cache_get_oldest_file(SeqDiskCache *disk_cache)
static void seq_disk_cache_delete_file(SeqDiskCache *disk_cache, DiskCacheFile *file)
static bool seq_disk_cache_read_header(FILE *file, DiskCacheHeader *header)
struct DiskCacheFile DiskCacheFile
void seq_cache_put(const SeqRenderData *context, Sequence *seq, float timeline_frame, int type, ImBuf *i)
#define COLORSPACE_NAME_MAX
struct SeqDiskCache SeqDiskCache
static SeqCache * seq_cache_get_from_scene(Scene *scene)
static SeqCacheKey * seq_cache_allocate_key(SeqCache *cache, const SeqRenderData *context, Sequence *seq, const float timeline_frame, const int type)
static ImBuf * seq_cache_get_ex(SeqCache *cache, SeqCacheKey *key)
static SeqCacheKey * seq_cache_get_item_for_removal(Scene *scene)
static void seq_cache_relink_keys(SeqCacheKey *link_next, SeqCacheKey *link_prev)
static void seq_disk_cache_create_version_file(char *path)
void seq_cache_free_temp_cache(Scene *scene, short id, int timeline_frame)
static char * seq_disk_cache_base_dir(void)
static void seq_disk_cache_invalidate(Scene *scene, Sequence *seq, Sequence *seq_changed, int invalidate_types)
void SEQ_cache_iterate(struct Scene *scene, void *userdata, bool callback_init(void *userdata, size_t item_count), bool callback_iter(void *userdata, struct Sequence *seq, int timeline_frame, int cache_type))
static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *path, size_t path_len)
static size_t deflate_imbuf_to_file(ImBuf *ibuf, FILE *file, int level, DiskCacheHeaderEntry *header_entry)
static size_t seq_disk_cache_size_limit(void)
static SeqCacheKey * seq_cache_choose_key(Scene *scene, SeqCacheKey *lkey, SeqCacheKey *rkey)
static bool seq_disk_cache_is_enabled(Main *bmain)
static ThreadMutex cache_create_lock
static DiskCacheFile * seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, const char *path)
static bool seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b)
static int seq_disk_cache_get_header_entry(SeqCacheKey *key, DiskCacheHeader *header)
static size_t seq_disk_cache_write_header(FILE *file, DiskCacheHeader *header)
struct ImBuf * seq_cache_get(const SeqRenderData *context, Sequence *seq, float timeline_frame, int type)
struct SeqCacheKey SeqCacheKey
static void seq_cache_keyfree(void *val)
static float seq_cache_frame_index_to_timeline_frame(Sequence *seq, float frame_index)
static void seq_cache_put_ex(Scene *scene, SeqCacheKey *key, ImBuf *ibuf)
#define DCACHE_FNAME_FORMAT
void seq_cache_cleanup_sequence(Scene *scene, Sequence *seq, Sequence *seq_changed, int invalidate_types, bool force_seq_changed_range)
static size_t inflate_file_to_imbuf(ImBuf *ibuf, FILE *file, DiskCacheHeaderEntry *header_entry)
static bool seq_disk_cache_write_file(SeqDiskCache *disk_cache, SeqCacheKey *key, ImBuf *ibuf)
static int seq_disk_cache_add_header_entry(SeqCacheKey *key, ImBuf *ibuf, DiskCacheHeader *header)
static void seq_disk_cache_get_dir(SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, char *path, size_t path_len)
static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *path)
static bool seq_cache_hashcmp(const void *a_, const void *b_)
struct DiskCacheHeaderEntry DiskCacheHeaderEntry
void seq_cache_cleanup_all(Main *bmain)
#define DCACHE_CURRENT_VERSION
static bool seq_disk_cache_enforce_limits(SeqDiskCache *disk_cache)
static void seq_cache_lock(Scene *scene)
static void seq_disk_cache_create(Main *bmain, Scene *scene)
void seq_cache_destruct(Scene *scene)
static void seq_cache_populate_key(SeqCacheKey *key, const SeqRenderData *context, Sequence *seq, const float timeline_frame, const int type)
static size_t seq_cache_get_mem_total(void)
struct DiskCacheHeader DiskCacheHeader
bool seq_cache_recycle_item(Scene *scene)
struct SeqCacheItem SeqCacheItem
void(* MEM_freeN)(void *vmemh)
size_t(* MEM_get_memory_in_use)(void)
void *(* MEM_callocN)(size_t len, const char *str)
void seq_prefetch_get_time_range(Scene *scene, int *start, int *end)
bool seq_prefetch_job_is_running(Scene *scene)
void SEQ_prefetch_stop(Scene *scene)
Sequence * seq_prefetch_get_original_sequence(Sequence *seq, Scene *scene)
SeqRenderData * seq_prefetch_get_original_context(const SeqRenderData *context)
struct SELECTID_Context context
unsigned __int64 uint64_t
float seq_give_frame_index(Sequence *seq, float timeline_frame)
struct DiskCacheFile * prev
struct DiskCacheFile * next
int64_t disk_cache_timestamp
struct SeqCache * cache_owner
struct SeqCacheKey * link_next
struct SeqCache * cache_owner
struct SeqCacheKey * link_prev
ThreadMutex iterator_mutex
struct SeqCacheKey * last_key
struct BLI_mempool * items_pool
struct BLI_mempool * keys_pool
SeqDiskCache * disk_cache
ThreadMutex read_write_mutex
float motion_blur_shutter