Blender  V3.3
Classes | Macros | Typedefs | Functions | Variables
disk_cache.c File Reference
#include <memory.h>
#include <stddef.h>
#include <time.h>
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_space_types.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#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_ghash.h"
#include "BLI_listbase.h"
#include "BLI_mempool.h"
#include "BLI_path_util.h"
#include "BLI_threads.h"
#include "BKE_main.h"
#include "BKE_scene.h"
#include "SEQ_prefetch.h"
#include "SEQ_relations.h"
#include "SEQ_render.h"
#include "SEQ_sequencer.h"
#include "SEQ_time.h"
#include "disk_cache.h"
#include "image_cache.h"
#include "prefetch.h"
#include "strip_time.h"

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. */
 

Typedefs

typedef struct DiskCacheHeaderEntry DiskCacheHeaderEntry
 
typedef struct DiskCacheHeader DiskCacheHeader
 
typedef struct SeqDiskCache SeqDiskCache
 
typedef struct DiskCacheFile DiskCacheFile
 

Functions

static char * seq_disk_cache_base_dir (void)
 
static int seq_disk_cache_compression_level (void)
 
static size_t seq_disk_cache_size_limit (void)
 
bool seq_disk_cache_is_enabled (Main *bmain)
 
static DiskCacheFileseq_disk_cache_add_file_to_list (SeqDiskCache *disk_cache, const char *path)
 
static void seq_disk_cache_get_files (SeqDiskCache *disk_cache, char *path)
 
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, char *path)
 
static void seq_disk_cache_update_file (SeqDiskCache *disk_cache, char *path)
 
static void seq_disk_cache_get_project_dir (SeqDiskCache *disk_cache, char *path, size_t path_len)
 
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_file_path (SeqDiskCache *disk_cache, SeqCacheKey *key, char *path, size_t path_len)
 
static void seq_disk_cache_create_version_file (char *path)
 
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, DiskCacheHeader *header)
 
static int seq_disk_cache_add_header_entry (SeqCacheKey *key, ImBuf *ibuf, DiskCacheHeader *header)
 
static int seq_disk_cache_get_header_entry (SeqCacheKey *key, 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 69 of file disk_cache.c.

◆ DCACHE_CURRENT_VERSION

#define DCACHE_CURRENT_VERSION   2

Definition at line 68 of file disk_cache.c.

◆ 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 66 of file disk_cache.c.

◆ DCACHE_IMAGES_PER_FILE

#define DCACHE_IMAGES_PER_FILE   100

Definition at line 67 of file disk_cache.c.

Typedef Documentation

◆ DiskCacheFile

typedef struct DiskCacheFile DiskCacheFile

◆ DiskCacheHeader

◆ DiskCacheHeaderEntry

◆ SeqDiskCache

typedef struct SeqDiskCache SeqDiskCache

Function Documentation

◆ deflate_imbuf_to_file()

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

◆ inflate_file_to_imbuf()

static size_t inflate_file_to_imbuf ( ImBuf ibuf,
FILE *  file,
DiskCacheHeaderEntry header_entry 
)
static

◆ seq_disk_cache_add_file_to_list()

static DiskCacheFile* seq_disk_cache_add_file_to_list ( SeqDiskCache disk_cache,
const char *  path 
)
static

◆ seq_disk_cache_add_header_entry()

static int seq_disk_cache_add_header_entry ( SeqCacheKey key,
ImBuf ibuf,
DiskCacheHeader header 
)
static

◆ seq_disk_cache_base_dir()

static char* seq_disk_cache_base_dir ( void  )
static

◆ seq_disk_cache_compression_level()

static int seq_disk_cache_compression_level ( void  )
static

◆ seq_disk_cache_create()

SeqDiskCache* seq_disk_cache_create ( Main bmain,
Scene scene 
)

◆ seq_disk_cache_create_version_file()

static void seq_disk_cache_create_version_file ( char *  path)
static

◆ seq_disk_cache_delete_file()

static void seq_disk_cache_delete_file ( SeqDiskCache disk_cache,
DiskCacheFile file 
)
static

◆ seq_disk_cache_delete_invalid_files()

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

◆ seq_disk_cache_enforce_limits()

bool seq_disk_cache_enforce_limits ( SeqDiskCache disk_cache)

◆ seq_disk_cache_free()

void seq_disk_cache_free ( SeqDiskCache disk_cache)

◆ seq_disk_cache_get_dir()

static void seq_disk_cache_get_dir ( SeqDiskCache disk_cache,
Scene scene,
Sequence seq,
char *  path,
size_t  path_len 
)
static

◆ seq_disk_cache_get_file_entry_by_path()

static DiskCacheFile* seq_disk_cache_get_file_entry_by_path ( SeqDiskCache disk_cache,
char *  path 
)
static

◆ seq_disk_cache_get_file_path()

static void seq_disk_cache_get_file_path ( SeqDiskCache disk_cache,
SeqCacheKey key,
char *  path,
size_t  path_len 
)
static

◆ seq_disk_cache_get_files()

static void seq_disk_cache_get_files ( SeqDiskCache disk_cache,
char *  path 
)
static

◆ seq_disk_cache_get_header_entry()

static int seq_disk_cache_get_header_entry ( SeqCacheKey key,
DiskCacheHeader header 
)
static

◆ seq_disk_cache_get_oldest_file()

static DiskCacheFile* seq_disk_cache_get_oldest_file ( SeqDiskCache disk_cache)
static

◆ seq_disk_cache_get_project_dir()

static void seq_disk_cache_get_project_dir ( SeqDiskCache disk_cache,
char *  path,
size_t  path_len 
)
static

◆ seq_disk_cache_handle_versioning()

static 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()

ImBuf* seq_disk_cache_read_file ( SeqDiskCache disk_cache,
SeqCacheKey key 
)

◆ seq_disk_cache_read_header()

static bool seq_disk_cache_read_header ( FILE *  file,
DiskCacheHeader header 
)
static

◆ seq_disk_cache_size_limit()

static size_t seq_disk_cache_size_limit ( void  )
static

Definition at line 127 of file disk_cache.c.

Referenced by seq_disk_cache_enforce_limits().

◆ seq_disk_cache_update_file()

static void seq_disk_cache_update_file ( SeqDiskCache disk_cache,
char *  path 
)
static

◆ seq_disk_cache_write_file()

bool seq_disk_cache_write_file ( SeqDiskCache disk_cache,
SeqCacheKey key,
ImBuf ibuf 
)

◆ seq_disk_cache_write_header()

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

Definition at line 480 of file disk_cache.c.

References BLI_fseek(), and file.

Referenced by seq_disk_cache_write_file().

Variable Documentation

◆ cache_create_lock

ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER
static

Definition at line 106 of file disk_cache.c.

Referenced by seq_disk_cache_create().