Blender
V3.3
|
#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 |
Variables | |
static ThreadMutex | cache_create_lock = BLI_MUTEX_INITIALIZER |
#define COLORSPACE_NAME_MAX 64 /* XXX: defined in IMB intern. */ |
Definition at line 69 of file disk_cache.c.
#define DCACHE_CURRENT_VERSION 2 |
Definition at line 68 of file disk_cache.c.
#define DCACHE_FNAME_FORMAT "%d-%dx%d-%d%%(%d)-%d.dcf" |
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.
#define DCACHE_IMAGES_PER_FILE 100 |
Definition at line 67 of file disk_cache.c.
typedef struct DiskCacheFile DiskCacheFile |
typedef struct DiskCacheHeader DiskCacheHeader |
typedef struct DiskCacheHeaderEntry DiskCacheHeaderEntry |
typedef struct SeqDiskCache SeqDiskCache |
|
static |
Definition at line 423 of file disk_cache.c.
References BLI_file_zstd_from_mem_at_pos(), data, file, if(), NULL, DiskCacheHeaderEntry::offset, ImBuf::rect, ImBuf::rect_float, and DiskCacheHeaderEntry::size_raw.
Referenced by seq_disk_cache_write_file().
|
static |
Definition at line 440 of file disk_cache.c.
References BLI_file_magic_is_zstd(), BLI_file_unzstd_to_mem_at_pos(), data, file, NULL, DiskCacheHeaderEntry::offset, ImBuf::rect, ImBuf::rect_float, and DiskCacheHeaderEntry::size_raw.
Referenced by seq_disk_cache_read_file().
|
static |
Definition at line 139 of file disk_cache.c.
References BLI_addtail(), BLI_split_dirfile(), BLI_strncpy(), DiskCacheFile::cache_type, DCACHE_FNAME_FORMAT, DCACHE_IMAGES_PER_FILE, DiskCacheFile::dir, file, DiskCacheFile::file, FILE_MAX, FILE_MAXDIR, SeqDiskCache::files, MEM_callocN, DiskCacheFile::path, DiskCacheFile::rectx, DiskCacheFile::recty, DiskCacheFile::render_size, DiskCacheFile::start_frame, and DiskCacheFile::view_id.
Referenced by seq_disk_cache_get_files(), and seq_disk_cache_write_file().
|
static |
Definition at line 486 of file disk_cache.c.
References B_ENDIAN, BLI_strncpy(), ImBuf::channels, DiskCacheHeaderEntry::colorspace_name, DCACHE_IMAGES_PER_FILE, DiskCacheHeaderEntry::encoding, ENDIAN_ORDER, DiskCacheHeader::entry, SeqCacheKey::frame_index, DiskCacheHeaderEntry::frameno, IMB_colormanagement_get_float_colorspace(), IMB_colormanagement_get_rect_colorspace(), offset, DiskCacheHeaderEntry::offset, ImBuf::rect, DiskCacheHeaderEntry::size_compressed, DiskCacheHeaderEntry::size_raw, ImBuf::x, and ImBuf::y.
Referenced by seq_disk_cache_write_file().
|
static |
Definition at line 108 of file disk_cache.c.
Referenced by seq_disk_cache_create(), seq_disk_cache_enforce_limits(), and seq_disk_cache_get_project_dir().
|
static |
Definition at line 113 of file disk_cache.c.
References USER_SEQ_DISK_CACHE_COMPRESSION_HIGH, USER_SEQ_DISK_CACHE_COMPRESSION_LOW, and USER_SEQ_DISK_CACHE_COMPRESSION_NONE.
Referenced by seq_disk_cache_write_file().
SeqDiskCache* seq_disk_cache_create | ( | Main * | bmain, |
Scene * | scene | ||
) |
Definition at line 668 of file disk_cache.c.
References BLI_mutex_init(), BLI_mutex_unlock(), SeqDiskCache::bmain, cache_create_lock, Editing::disk_cache_timestamp, Scene::ed, MEM_callocN, SeqDiskCache::read_write_mutex, scene, seq_disk_cache_base_dir(), seq_disk_cache_get_files(), seq_disk_cache_handle_versioning(), and SeqDiskCache::timestamp.
Referenced by seq_cache_get(), and seq_cache_put().
|
static |
Definition at line 335 of file disk_cache.c.
References BLI_fopen(), BLI_make_existing_file(), DCACHE_CURRENT_VERSION, file, and direntry::path.
Referenced by seq_disk_cache_handle_versioning().
|
static |
Definition at line 217 of file disk_cache.c.
References BLI_delete(), BLI_remlink(), file, SeqDiskCache::files, MEM_freeN, and SeqDiskCache::size_total.
Referenced by seq_disk_cache_delete_invalid_files(), seq_disk_cache_enforce_limits(), and seq_disk_cache_write_file().
|
static |
Definition at line 377 of file disk_cache.c.
References BLI_path_slash_ensure(), DiskCacheFile::cache_type, DiskCacheFile::dir, FILE_MAX, SeqDiskCache::files, ListBase::first, DiskCacheFile::next, scene, seq_cache_frame_index_to_timeline_frame(), seq_disk_cache_delete_file(), seq_disk_cache_get_dir(), DiskCacheFile::start_frame, and STREQ.
Referenced by seq_disk_cache_invalidate().
bool seq_disk_cache_enforce_limits | ( | SeqDiskCache * | disk_cache | ) |
Definition at line 225 of file disk_cache.c.
References BLI_exists(), BLI_freelistN(), BLI_mutex_lock(), BLI_mutex_unlock(), SeqDiskCache::files, DiskCacheFile::path, SeqDiskCache::read_write_mutex, seq_disk_cache_base_dir(), seq_disk_cache_delete_file(), seq_disk_cache_get_files(), seq_disk_cache_get_oldest_file(), seq_disk_cache_size_limit(), and SeqDiskCache::size_total.
Referenced by seq_cache_put().
void seq_disk_cache_free | ( | SeqDiskCache * | disk_cache | ) |
Definition at line 680 of file disk_cache.c.
References BLI_freelistN(), BLI_mutex_end(), SeqDiskCache::files, MEM_freeN, and SeqDiskCache::read_write_mutex.
Referenced by seq_cache_destruct().
|
static |
Definition at line 298 of file disk_cache.c.
References BLI_filename_make_safe(), BLI_path_append(), BLI_strncpy(), FILE_MAX, Scene::id, MAX_ID_NAME, Sequence::name, ID::name, direntry::path, PRId64, scene, seq_disk_cache_get_project_dir(), SEQ_NAME_MAXSTR, and SeqDiskCache::timestamp.
Referenced by seq_disk_cache_delete_invalid_files(), and seq_disk_cache_get_file_path().
|
static |
Definition at line 251 of file disk_cache.c.
References BLI_strcasecmp(), SeqDiskCache::files, ListBase::first, DiskCacheFile::next, NULL, direntry::path, and DiskCacheFile::path.
Referenced by seq_disk_cache_update_file(), and seq_disk_cache_write_file().
|
static |
Definition at line 315 of file disk_cache.c.
References BLI_path_append(), SeqCacheKey::context, DCACHE_FNAME_FORMAT, DCACHE_IMAGES_PER_FILE, FILE_MAXFILE, SeqCacheKey::frame_index, direntry::path, SeqRenderData::preview_render_size, SeqRenderData::rectx, SeqRenderData::recty, SeqRenderData::scene, SeqCacheKey::seq, seq_disk_cache_get_dir(), SeqCacheKey::type, and SeqRenderData::view_id.
Referenced by seq_disk_cache_read_file(), and seq_disk_cache_write_file().
|
static |
Definition at line 161 of file disk_cache.c.
References BLI_file_attributes(), BLI_filelist_dir_contents(), BLI_filelist_free(), BLI_is_dir(), BLI_path_extension(), BLI_path_slash_ensure(), BLI_split_dirfile(), BLI_strncpy(), file, FILE_ATTR_ANY_LINK, FILE_MAX, FILENAME_IS_CURRPAR, DiskCacheFile::fstat, NULL, direntry::path, direntry::s, seq_disk_cache_add_file_to_list(), and SeqDiskCache::size_total.
Referenced by seq_disk_cache_create(), and seq_disk_cache_enforce_limits().
|
static |
Definition at line 537 of file disk_cache.c.
References DCACHE_IMAGES_PER_FILE, DiskCacheHeader::entry, SeqCacheKey::frame_index, and DiskCacheHeaderEntry::frameno.
Referenced by seq_disk_cache_read_file().
|
static |
Definition at line 202 of file disk_cache.c.
References SeqDiskCache::files, ListBase::first, DiskCacheFile::fstat, DiskCacheFile::next, and NULL.
Referenced by seq_disk_cache_enforce_limits().
|
static |
Definition at line 287 of file disk_cache.c.
References BKE_main_blendfile_path(), BLI_path_append(), BLI_split_file_part(), BLI_strncpy(), SeqDiskCache::bmain, FILE_MAX, direntry::path, and seq_disk_cache_base_dir().
Referenced by seq_disk_cache_get_dir(), and seq_disk_cache_handle_versioning().
|
static |
Definition at line 346 of file disk_cache.c.
References BLI_delete(), BLI_exists(), BLI_fopen(), BLI_is_dir(), BLI_path_append(), BLI_strncpy(), DCACHE_CURRENT_VERSION, file, FILE_MAX, seq_disk_cache_create_version_file(), and seq_disk_cache_get_project_dir().
Referenced by seq_disk_cache_create().
void seq_disk_cache_invalidate | ( | SeqDiskCache * | disk_cache, |
Scene * | scene, | ||
Sequence * | seq, | ||
Sequence * | seq_changed, | ||
int | invalidate_types | ||
) |
Definition at line 404 of file disk_cache.c.
References BLI_mutex_lock(), BLI_mutex_unlock(), DCACHE_IMAGES_PER_FILE, SeqDiskCache::read_write_mutex, scene, seq_disk_cache_delete_invalid_files(), SEQ_time_left_handle_frame_get(), and SEQ_time_right_handle_frame_get().
Referenced by seq_cache_cleanup_sequence().
Definition at line 132 of file disk_cache.c.
References Main::filepath, and SEQ_CACHE_DISK_CACHE_ENABLE.
Referenced by seq_cache_cleanup_sequence(), seq_cache_get(), and seq_cache_put().
ImBuf* seq_disk_cache_read_file | ( | SeqDiskCache * | disk_cache, |
SeqCacheKey * | key | ||
) |
Definition at line 600 of file disk_cache.c.
References BLI_file_touch(), BLI_fopen(), BLI_make_existing_file(), BLI_mutex_lock(), BLI_mutex_unlock(), DiskCacheHeaderEntry::colorspace_name, SeqCacheKey::context, DiskCacheHeader::entry, file, FILE_MAX, IB_rect, IB_rectfloat, IMB_allocImBuf(), IMB_colormanagement_assign_float_colorspace(), IMB_colormanagement_assign_rect_colorspace(), IMB_freeImBuf(), inflate_file_to_imbuf(), NULL, SeqDiskCache::read_write_mutex, SeqRenderData::rectx, SeqRenderData::recty, seq_disk_cache_get_file_path(), seq_disk_cache_get_header_entry(), seq_disk_cache_read_header(), seq_disk_cache_update_file(), and DiskCacheHeaderEntry::size_raw.
Referenced by seq_cache_get().
|
static |
Definition at line 458 of file disk_cache.c.
References B_ENDIAN, BLI_assert_msg, BLI_endian_switch_uint64(), BLI_fseek(), DCACHE_IMAGES_PER_FILE, DiskCacheHeaderEntry::encoding, ENDIAN_ORDER, DiskCacheHeader::entry, file, DiskCacheHeaderEntry::frameno, DiskCacheHeaderEntry::offset, DiskCacheHeaderEntry::size_compressed, and DiskCacheHeaderEntry::size_raw.
Referenced by seq_disk_cache_read_file(), and seq_disk_cache_write_file().
|
static |
Definition at line 127 of file disk_cache.c.
Referenced by seq_disk_cache_enforce_limits().
|
static |
Definition at line 265 of file disk_cache.c.
References BLI_assert, BLI_stat(), DiskCacheFile::fstat, direntry::path, seq_disk_cache_get_file_entry_by_path(), and SeqDiskCache::size_total.
Referenced by seq_disk_cache_read_file(), and seq_disk_cache_write_file().
bool seq_disk_cache_write_file | ( | SeqDiskCache * | disk_cache, |
SeqCacheKey * | key, | ||
ImBuf * | ibuf | ||
) |
Definition at line 548 of file disk_cache.c.
References BLI_fopen(), BLI_make_existing_file(), BLI_mutex_lock(), BLI_mutex_unlock(), deflate_imbuf_to_file(), DiskCacheHeader::entry, file, FILE_MAX, DiskCacheFile::fstat, SeqDiskCache::read_write_mutex, seq_disk_cache_add_file_to_list(), seq_disk_cache_add_header_entry(), seq_disk_cache_compression_level(), seq_disk_cache_delete_file(), seq_disk_cache_get_file_entry_by_path(), seq_disk_cache_get_file_path(), seq_disk_cache_read_header(), seq_disk_cache_update_file(), seq_disk_cache_write_header(), and DiskCacheHeaderEntry::size_compressed.
Referenced by seq_cache_put().
|
static |
Definition at line 480 of file disk_cache.c.
References BLI_fseek(), and file.
Referenced by seq_disk_cache_write_file().
|
static |
Definition at line 106 of file disk_cache.c.
Referenced by seq_disk_cache_create().