58#define DCACHE_FNAME_FORMAT "%d-%dx%d-%d%%(%d)-%d.dcf"
59#define DCACHE_IMAGES_PER_FILE 100
60#define DCACHE_CURRENT_VERSION 2
61#define COLORSPACE_NAME_MAX 64
102 return U.sequencer_disk_cache_dir;
107 switch (
U.sequencer_disk_cache_compression) {
116 return U.sequencer_disk_cache_compression;
121 return size_t(
U.sequencer_disk_cache_size_limit) * (1024 * 1024 * 1024);
126 return (
U.sequencer_disk_cache_dir[0] !=
'\0' &&
U.sequencer_disk_cache_size_limit != 0 &&
132 const char *filepath)
185 if (ext && ext[1] ==
'd' && ext[2] ==
'c' && ext[3] ==
'f') {
187 cache_file->
fstat = fl->
s;
199 if (oldest_file ==
nullptr) {
202 for (
DiskCacheFile *cache_file = oldest_file->
next; cache_file; cache_file = cache_file->next) {
203 if (cache_file->fstat.st_mtime < oldest_file->
fstat.st_mtime) {
204 oldest_file = cache_file;
213 disk_cache->
size_total -= file->fstat.st_size;
246 const char *filepath)
250 for (; cache_file; cache_file = cache_file->
next) {
267 size_before = cache_file->
fstat.st_size;
274 size_after = cache_file->
fstat.st_size;
275 disk_cache->
size_total += size_after - size_before;
284 size_t dirpath_maxncpy)
306 BLI_path_join(dirpath, dirpath_maxncpy, project_dir, scene_name, seq_name);
312 size_t filepath_maxncpy)
347 BLI_path_join(path_version_file,
sizeof(path_version_file), dirpath,
"cache_version");
350 FILE *file =
BLI_fopen(path_version_file,
"r");
353 const int num_items_read = fscanf(file,
"%d", &version);
354 if (num_items_read == 0) {
373 int invalidate_types,
383 next_file = cache_file->
next;
384 if (cache_file->
cache_type & invalidate_types) {
385 if (
STREQ(cache_dir, cache_file->
dir)) {
388 if (timeline_frame_start > range_start && timeline_frame_start <= range_end) {
393 cache_file = next_file;
401 int invalidate_types)
430 fseek(file, header_entry->
offset, SEEK_SET);
431 return fwrite(data, 1, header_entry->
size_raw, file);
439 fseek(file, header_entry->
offset, SEEK_SET);
440 if (fread(header, 1,
sizeof(header), file) !=
sizeof(header)) {
449 fseek(file, header_entry->
offset, SEEK_SET);
450 return fread(data, 1, header_entry->
size_raw, file);
456 const size_t num_items_read = fread(header,
sizeof(*header), 1, file);
457 if (num_items_read < 1) {
459 perror(
"unable to read disk cache header");
478 return fwrite(header,
sizeof(*header), 1, file);
500 memset(header, 0,
sizeof(*header));
519 const char *colorspace_name;
566 memset(&header, 0,
sizeof(header));
580 if (bytes_written != 0) {
621 if (entry_index < 0) {
630 size_t expected_size;
633 expected_size = size_char;
639 expected_size = size_float;
653 if (bytes_read != expected_size) {
671 disk_cache->
bmain = bmain;
675 disk_cache->
timestamp = scene->ed->disk_cache_timestamp;
const char * BKE_main_blendfile_path(const 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.
bool BLI_file_touch(const char *filepath) ATTR_NONNULL(1)
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()
#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()
unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_filelist)
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
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)
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
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)
size_t BLI_path_append(char *__restrict dst, size_t dst_maxncpy, const char *__restrict file) ATTR_NONNULL(1
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define BLI_path_join(...)
#define FILENAME_IS_CURRPAR(_n)
void void void BLI_path_split_file_part(const char *filepath, char *file, size_t file_maxncpy) ATTR_NONNULL(1
void BLI_path_split_dir_file(const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
bool BLI_path_make_safe_filename(char *filename) ATTR_NONNULL(1)
const char * BLI_path_extension(const char *filepath) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define STRNCPY(dst, src)
#define SNPRINTF(dst, format,...)
int char char int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
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
void IMB_colormanagement_assign_byte_colorspace(ImBuf *ibuf, const char *name)
void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name)
const char * IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
const char * IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
@ IB_uninitialized_pixels
Read Guarded memory(de)allocation.
static size_t seq_disk_cache_write_header(FILE *file, const DiskCacheHeader *header)
#define DCACHE_IMAGES_PER_FILE
static size_t seq_disk_cache_size_limit()
static int seq_disk_cache_compression_level()
static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache)
static void seq_disk_cache_update_file(SeqDiskCache *disk_cache, const char *filepath)
static void seq_disk_cache_delete_invalid_files(SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, int invalidate_types, int range_start, int range_end)
ImBuf * seq_disk_cache_read_file(SeqDiskCache *disk_cache, SeqCacheKey *key)
static int seq_disk_cache_get_header_entry(const SeqCacheKey *key, const DiskCacheHeader *header)
static DiskCacheFile * seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, const char *filepath)
static int seq_disk_cache_add_header_entry(const SeqCacheKey *key, ImBuf *ibuf, DiskCacheHeader *header)
static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *dirpath, size_t dirpath_maxncpy)
static void seq_disk_cache_delete_file(SeqDiskCache *disk_cache, DiskCacheFile *file)
static bool seq_disk_cache_read_header(FILE *file, DiskCacheHeader *header)
#define COLORSPACE_NAME_MAX
static const char * seq_disk_cache_base_dir()
void seq_disk_cache_invalidate(SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, Sequence *seq_changed, int invalidate_types)
static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, SeqCacheKey *key, char *filepath, size_t filepath_maxncpy)
static size_t deflate_imbuf_to_file(ImBuf *ibuf, FILE *file, int level, DiskCacheHeaderEntry *header_entry)
static ThreadMutex cache_create_lock
static void seq_disk_cache_get_dir(SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, char *dirpath, size_t dirpath_maxncpy)
static DiskCacheFile * seq_disk_cache_get_oldest_file(SeqDiskCache *disk_cache)
static void seq_disk_cache_create_version_file(const char *filepath)
#define DCACHE_FNAME_FORMAT
SeqDiskCache * seq_disk_cache_create(Main *bmain, Scene *scene)
static size_t inflate_file_to_imbuf(ImBuf *ibuf, FILE *file, DiskCacheHeaderEntry *header_entry)
void seq_disk_cache_free(SeqDiskCache *disk_cache)
#define DCACHE_CURRENT_VERSION
static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, const char *dirpath)
bool seq_disk_cache_enforce_limits(SeqDiskCache *disk_cache)
bool seq_disk_cache_write_file(SeqDiskCache *disk_cache, SeqCacheKey *key, ImBuf *ibuf)
static DiskCacheFile * seq_disk_cache_get_file_entry_by_path(SeqDiskCache *disk_cache, const char *filepath)
bool seq_disk_cache_is_enabled(Main *bmain)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
struct ImBuf * IMB_allocImBuf(unsigned int, unsigned int, unsigned char, unsigned int)
void IMB_freeImBuf(ImBuf *)
float seq_cache_frame_index_to_timeline_frame(Sequence *seq, float frame_index)
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 *, const Sequence *seq)
int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
ThreadMutex read_write_mutex