Blender V4.3
disk_cache.cc File Reference
#include <cstddef>
#include <ctime>
#include <memory.h>
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "IMB_colormanagement.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "BLI_blenlib.h"
#include "BLI_endian_defines.h"
#include "BLI_endian_switch.h"
#include "BLI_fileops.h"
#include "BLI_fileops_types.h"
#include "BLI_listbase.h"
#include "BLI_path_utils.hh"
#include "BLI_threads.h"
#include "BKE_main.hh"
#include "SEQ_render.hh"
#include "SEQ_time.hh"
#include "disk_cache.hh"
#include "image_cache.hh"

Go to the source code of this file.

Classes

struct  DiskCacheHeaderEntry
struct  DiskCacheHeader
struct  SeqDiskCache
struct  DiskCacheFile

Macros

#define DCACHE_FNAME_FORMAT   "%d-%dx%d-%d%%(%d)-%d.dcf"
#define DCACHE_IMAGES_PER_FILE   100
#define DCACHE_CURRENT_VERSION   2
#define COLORSPACE_NAME_MAX   64 /* XXX: defined in IMB intern. */

Functions

static const char * seq_disk_cache_base_dir ()
static int seq_disk_cache_compression_level ()
static size_t seq_disk_cache_size_limit ()
bool seq_disk_cache_is_enabled (Main *bmain)
static DiskCacheFileseq_disk_cache_add_file_to_list (SeqDiskCache *disk_cache, const char *filepath)
static void seq_disk_cache_get_files (SeqDiskCache *disk_cache, const char *dirpath)
static DiskCacheFileseq_disk_cache_get_oldest_file (SeqDiskCache *disk_cache)
static void seq_disk_cache_delete_file (SeqDiskCache *disk_cache, DiskCacheFile *file)
bool seq_disk_cache_enforce_limits (SeqDiskCache *disk_cache)
static DiskCacheFileseq_disk_cache_get_file_entry_by_path (SeqDiskCache *disk_cache, const char *filepath)
static void seq_disk_cache_update_file (SeqDiskCache *disk_cache, const char *filepath)
static void seq_disk_cache_get_project_dir (SeqDiskCache *disk_cache, char *dirpath, size_t dirpath_maxncpy)
static void seq_disk_cache_get_dir (SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, char *dirpath, size_t dirpath_maxncpy)
static void seq_disk_cache_get_file_path (SeqDiskCache *disk_cache, SeqCacheKey *key, char *filepath, size_t filepath_maxncpy)
static void seq_disk_cache_create_version_file (const char *filepath)
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)
void seq_disk_cache_invalidate (SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, Sequence *seq_changed, int invalidate_types)
static size_t deflate_imbuf_to_file (ImBuf *ibuf, FILE *file, int level, DiskCacheHeaderEntry *header_entry)
static size_t inflate_file_to_imbuf (ImBuf *ibuf, FILE *file, DiskCacheHeaderEntry *header_entry)
static bool seq_disk_cache_read_header (FILE *file, DiskCacheHeader *header)
static size_t seq_disk_cache_write_header (FILE *file, const DiskCacheHeader *header)
static int seq_disk_cache_add_header_entry (const SeqCacheKey *key, ImBuf *ibuf, DiskCacheHeader *header)
static int seq_disk_cache_get_header_entry (const SeqCacheKey *key, const DiskCacheHeader *header)
bool seq_disk_cache_write_file (SeqDiskCache *disk_cache, SeqCacheKey *key, ImBuf *ibuf)
ImBufseq_disk_cache_read_file (SeqDiskCache *disk_cache, SeqCacheKey *key)
SeqDiskCacheseq_disk_cache_create (Main *bmain, Scene *scene)
void seq_disk_cache_free (SeqDiskCache *disk_cache)

Variables

static ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER

Macro Definition Documentation

◆ COLORSPACE_NAME_MAX

#define COLORSPACE_NAME_MAX   64 /* XXX: defined in IMB intern. */

Definition at line 61 of file disk_cache.cc.

◆ DCACHE_CURRENT_VERSION

#define DCACHE_CURRENT_VERSION   2

◆ DCACHE_FNAME_FORMAT

#define DCACHE_FNAME_FORMAT   "%d-%dx%d-%d%%(%d)-%d.dcf"

Disk Cache Design Notes

Disk cache uses directory specified in user preferences For each cached non-temp image, image data and supplementary info are written to HDD. Multiple(DCACHE_IMAGES_PER_FILE) images share the same file. Each of these files contains header DiskCacheHeader followed by image data. ZLIB compression with user definable level can be used to compress image data(per image) Images are written in order in which they are rendered. Overwriting of individual entry is not possible. Stored images are deleted by invalidation, or when size of all files exceeds maximum size specified in user preferences. To distinguish 2 blend files with same name, scene->ed->disk_cache_timestamp is used as UID. Blend file can still be copied manually which may cause conflict.

Definition at line 58 of file disk_cache.cc.

Referenced by seq_disk_cache_add_file_to_list(), and seq_disk_cache_get_file_path().

◆ DCACHE_IMAGES_PER_FILE

Function Documentation

◆ deflate_imbuf_to_file()

size_t deflate_imbuf_to_file ( ImBuf * ibuf,
FILE * file,
int level,
DiskCacheHeaderEntry * header_entry )
static

◆ inflate_file_to_imbuf()

◆ seq_disk_cache_add_file_to_list()

◆ seq_disk_cache_add_header_entry()

◆ seq_disk_cache_base_dir()

const char * seq_disk_cache_base_dir ( )
static

◆ seq_disk_cache_compression_level()

int seq_disk_cache_compression_level ( )
static

◆ seq_disk_cache_create()

◆ seq_disk_cache_create_version_file()

void seq_disk_cache_create_version_file ( const char * filepath)
static

◆ seq_disk_cache_delete_file()

◆ seq_disk_cache_delete_invalid_files()

◆ seq_disk_cache_enforce_limits()

◆ seq_disk_cache_free()

void seq_disk_cache_free ( SeqDiskCache * disk_cache)

◆ seq_disk_cache_get_dir()

void seq_disk_cache_get_dir ( SeqDiskCache * disk_cache,
Scene * scene,
Sequence * seq,
char * dirpath,
size_t dirpath_maxncpy )
static

◆ seq_disk_cache_get_file_entry_by_path()

DiskCacheFile * seq_disk_cache_get_file_entry_by_path ( SeqDiskCache * disk_cache,
const char * filepath )
static

◆ seq_disk_cache_get_file_path()

◆ seq_disk_cache_get_files()

◆ seq_disk_cache_get_header_entry()

int seq_disk_cache_get_header_entry ( const SeqCacheKey * key,
const DiskCacheHeader * header )
static

◆ seq_disk_cache_get_oldest_file()

DiskCacheFile * seq_disk_cache_get_oldest_file ( SeqDiskCache * disk_cache)
static

◆ seq_disk_cache_get_project_dir()

void seq_disk_cache_get_project_dir ( SeqDiskCache * disk_cache,
char * dirpath,
size_t dirpath_maxncpy )
static

◆ seq_disk_cache_handle_versioning()

void seq_disk_cache_handle_versioning ( SeqDiskCache * disk_cache)
static

◆ seq_disk_cache_invalidate()

void seq_disk_cache_invalidate ( SeqDiskCache * disk_cache,
Scene * scene,
Sequence * seq,
Sequence * seq_changed,
int invalidate_types )

◆ seq_disk_cache_is_enabled()

bool seq_disk_cache_is_enabled ( Main * bmain)

◆ seq_disk_cache_read_file()

◆ seq_disk_cache_read_header()

◆ seq_disk_cache_size_limit()

size_t seq_disk_cache_size_limit ( )
static

Definition at line 119 of file disk_cache.cc.

References U.

Referenced by seq_disk_cache_enforce_limits().

◆ seq_disk_cache_update_file()

void seq_disk_cache_update_file ( SeqDiskCache * disk_cache,
const char * filepath )
static

◆ seq_disk_cache_write_file()

◆ seq_disk_cache_write_header()

size_t seq_disk_cache_write_header ( FILE * file,
const DiskCacheHeader * header )
static

Definition at line 475 of file disk_cache.cc.

References BLI_fseek(), and LL.

Referenced by seq_disk_cache_write_file().

Variable Documentation

◆ cache_create_lock

ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER
static

Definition at line 98 of file disk_cache.cc.

Referenced by seq_cache_create(), and seq_disk_cache_create().