66 #define DCACHE_FNAME_FORMAT "%d-%dx%d-%d%%(%d)-%d.dcf"
67 #define DCACHE_IMAGES_PER_FILE 100
68 #define DCACHE_CURRENT_VERSION 2
69 #define COLORSPACE_NAME_MAX 64
110 return U.sequencer_disk_cache_dir;
115 switch (
U.sequencer_disk_cache_compression) {
124 return U.sequencer_disk_cache_compression;
129 return (
size_t)
U.sequencer_disk_cache_size_limit * (1024 * 1024 * 1024);
134 return (
U.sequencer_disk_cache_dir[0] !=
'\0' &&
U.sequencer_disk_cache_size_limit != 0 &&
191 if (ext && ext[1] ==
'd' && ext[2] ==
'c' && ext[3] ==
'f') {
193 cache_file->
fstat = fl->
s;
205 if (oldest_file ==
NULL) {
209 if (cache_file->fstat.st_mtime < oldest_file->
fstat.st_mtime) {
210 oldest_file = cache_file;
255 for (; cache_file; cache_file = cache_file->
next) {
272 size_before = cache_file->
fstat.st_size;
279 size_after = cache_file->
fstat.st_size;
280 disk_cache->
size_total += size_after - size_before;
292 const char *suffix =
"_seq_cache";
293 strncat(cache_dir, suffix,
sizeof(cache_dir) - strlen(cache_dir) - 1);
323 sprintf(cache_filename,
353 BLI_strncpy(path_version_file, filepath,
sizeof(path_version_file));
354 BLI_path_append(path_version_file,
sizeof(path_version_file),
"cache_version");
360 const int num_items_read = fscanf(
file,
"%d", &version);
361 if (num_items_read == 0) {
380 int invalidate_types,
390 next_file = cache_file->
next;
391 if (cache_file->
cache_type & invalidate_types) {
392 if (
STREQ(cache_dir, cache_file->
dir)) {
395 if (timeline_frame_start > range_start && timeline_frame_start <= range_end) {
400 cache_file = next_file;
408 int invalidate_types)
445 if (fread(header, 1,
sizeof(header),
file) !=
sizeof(header)) {
461 const size_t num_items_read = fread(header,
sizeof(*header), 1,
file);
462 if (num_items_read < 1) {
464 perror(
"unable to read disk cache header");
483 return fwrite(header,
sizeof(*header), 1,
file);
503 memset(header, 0,
sizeof(*header));
522 const char *colorspace_name;
569 memset(&header, 0,
sizeof(header));
583 if (bytes_written != 0) {
624 if (entry_index < 0) {
633 size_t expected_size;
636 expected_size = size_char;
641 expected_size = size_float;
654 if (bytes_read != expected_size) {
671 disk_cache->
bmain = bmain;
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
#define BLI_assert_msg(a, msg)
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_file_zstd_from_mem_at_pos(void *buf, size_t len, FILE *file, size_t file_offset, int compression_level) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_file_touch(const char *file) ATTR_NONNULL()
#define FILE_ATTR_ANY_LINK
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
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_file_unzstd_to_mem_at_pos(void *buf, size_t len, FILE *file, size_t file_offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_file_magic_is_zstd(const char header[4])
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries)
int BLI_fseek(FILE *stream, int64_t offset, int whence)
Some types for dealing with directories.
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)
const char * BLI_path_extension(const char *filepath) ATTR_NONNULL()
bool BLI_make_existing_file(const char *name)
void BLI_split_dirfile(const char *string, char *dir, char *file, size_t dirlen, size_t filelen)
#define FILENAME_IS_CURRPAR(_n)
void BLI_path_append(char *__restrict dst, size_t maxlen, const char *__restrict file) ATTR_NONNULL()
int BLI_path_slash_ensure(char *string) ATTR_NONNULL()
bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1)
void BLI_split_file_part(const char *string, char *file, 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, 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_DISK_CACHE_ENABLE
@ USER_SEQ_DISK_CACHE_COMPRESSION_HIGH
@ USER_SEQ_DISK_CACHE_COMPRESSION_LOW
@ USER_SEQ_DISK_CACHE_COMPRESSION_NONE
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)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
SeqDiskCache * seq_disk_cache_create(Main *bmain, Scene *scene)
#define DCACHE_IMAGES_PER_FILE
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)
ImBuf * seq_disk_cache_read_file(SeqDiskCache *disk_cache, SeqCacheKey *key)
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_disk_cache_update_file(SeqDiskCache *disk_cache, char *path)
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
#define COLORSPACE_NAME_MAX
struct SeqDiskCache SeqDiskCache
static void seq_disk_cache_create_version_file(char *path)
static char * seq_disk_cache_base_dir(void)
void seq_disk_cache_invalidate(SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, Sequence *seq_changed, int invalidate_types)
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 ThreadMutex cache_create_lock
static DiskCacheFile * seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, const char *path)
static int seq_disk_cache_get_header_entry(SeqCacheKey *key, DiskCacheHeader *header)
static size_t seq_disk_cache_write_header(FILE *file, DiskCacheHeader *header)
#define DCACHE_FNAME_FORMAT
static size_t inflate_file_to_imbuf(ImBuf *ibuf, FILE *file, DiskCacheHeaderEntry *header_entry)
void seq_disk_cache_free(SeqDiskCache *disk_cache)
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)
struct DiskCacheHeaderEntry DiskCacheHeaderEntry
#define DCACHE_CURRENT_VERSION
bool seq_disk_cache_enforce_limits(SeqDiskCache *disk_cache)
bool seq_disk_cache_write_file(SeqDiskCache *disk_cache, SeqCacheKey *key, ImBuf *ibuf)
bool seq_disk_cache_is_enabled(Main *bmain)
struct DiskCacheHeader DiskCacheHeader
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
float seq_cache_frame_index_to_timeline_frame(Sequence *seq, float frame_index)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
unsigned __int64 uint64_t
int SEQ_time_left_handle_frame_get(const Scene *UNUSED(scene), const Sequence *seq)
int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq)
struct DiskCacheFile * prev
struct DiskCacheFile * next
int64_t disk_cache_timestamp
struct SeqRenderData context
ThreadMutex read_write_mutex