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_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 | SeqCache |
struct | SeqCacheItem |
Macros | |
#define | THUMB_CACHE_LIMIT 5000 |
Typedefs | |
typedef struct SeqCache | SeqCache |
typedef struct SeqCacheItem | SeqCacheItem |
Variables | |
static ThreadMutex | cache_create_lock = BLI_MUTEX_INITIALIZER |
#define THUMB_CACHE_LIMIT 5000 |
Function: All images created during rendering are added to cache, even if the cache is already full. This is because:
If the cache is full all entries for pending frame will have is_temp_cache set.
Linking: We use links to reduce number of iterations over entries needed to manage cache. Entries are linked in order as they are put into cache. Only permanent (is_temp_cache = 0) cache entries are linked. Putting SEQ_CACHE_STORE_FINAL_OUT will reset linking
Only entire frame can be freed to release resources for new entries (recycling). Once again, this is to reduce number of iterations, but also more controllable than removing entries one by one in reverse order to their creation.
User can exclude caching of some images. Such entries will have is_temp_cache set.
Definition at line 72 of file image_cache.c.
typedef struct SeqCacheItem SeqCacheItem |
|
static |
Definition at line 205 of file image_cache.c.
References Sequence::cache_flag, Editing::cache_flag, Scene::ed, scene, SeqCacheKey::seq, SEQ_CACHE_OVERRIDE, and SEQ_CACHE_STORE_FINAL_OUT.
Referenced by seq_cache_put_ex().
|
static |
Definition at line 534 of file image_cache.c.
References BLI_mempool_alloc(), blender::compositor::context, SeqCache::keys_pool, seq_cache_populate_key(), and type.
Referenced by seq_cache_get(), seq_cache_put(), and seq_cache_thumbnail_put().
|
static |
Definition at line 286 of file image_cache.c.
References Editing::cache_flag, RenderData::cfra, Scene::ed, NULL, Scene::r, scene, SEQ_CACHE_PREFETCH_ENABLE, seq_prefetch_get_time_range(), seq_prefetch_job_is_running(), and SeqCacheKey::timeline_frame.
Referenced by seq_cache_get_item_for_removal().
Definition at line 602 of file image_cache.c.
References BLI_ghash_remove(), BLI_ghashIterator_done(), BLI_ghashIterator_getKey(), BLI_ghashIterator_init(), BLI_ghashIterator_step(), SeqCache::hash, SeqCache::last_key, NULL, scene, seq_cache_get_from_scene(), seq_cache_keyfree(), seq_cache_lock(), seq_cache_unlock(), seq_cache_valfree(), SEQ_prefetch_stop(), and SeqCache::thumbnail_count.
Referenced by do_render_full_pipeline(), screen_render_exec(), screen_render_invoke(), seq_cache_cleanup_all(), and SEQ_relations_free_imbuf().
Definition at line 596 of file image_cache.c.
References ListBase::first, Scene::id, ID::next, NULL, scene, Main::scenes, and SEQ_cache_cleanup().
void seq_cache_cleanup_sequence | ( | Scene * | scene, |
Sequence * | seq, | ||
Sequence * | seq_changed, | ||
int | invalidate_types, | ||
bool | force_seq_changed_range | ||
) |
Definition at line 626 of file image_cache.c.
References BLI_ghash_remove(), BLI_ghashIterator_done(), BLI_ghashIterator_getKey(), BLI_ghashIterator_init(), BLI_ghashIterator_step(), SeqCache::bmain, SeqCache::disk_cache, SeqCache::hash, SeqCache::last_key, SeqCacheKey::link_next, SeqCacheKey::link_prev, max_ii(), min_ii(), NULL, scene, SeqCacheKey::seq, seq_cache_get_from_scene(), seq_cache_keyfree(), seq_cache_lock(), seq_cache_relink_keys(), SEQ_CACHE_STORE_COMPOSITE, SEQ_CACHE_STORE_FINAL_OUT, SEQ_CACHE_STORE_PREPROCESSED, SEQ_CACHE_STORE_RAW, seq_cache_unlock(), seq_cache_valfree(), seq_disk_cache_invalidate(), seq_disk_cache_is_enabled(), SEQ_time_left_handle_frame_get(), SEQ_time_right_handle_frame_get(), SeqCacheKey::timeline_frame, and SeqCacheKey::type.
Referenced by SEQ_relations_invalidate_cache_in_range(), sequence_do_invalidate_dependent(), and sequence_invalidate_cache().
Definition at line 494 of file image_cache.c.
References BLI_ghash_new(), BLI_mempool_create(), BLI_MEMPOOL_NOP, BLI_mutex_init(), BLI_mutex_lock(), BLI_mutex_unlock(), SeqCache::bmain, Editing::cache, cache_create_lock, Editing::disk_cache_timestamp, Scene::ed, SeqCache::hash, SeqCache::items_pool, SeqCache::iterator_mutex, SeqCache::keys_pool, SeqCache::last_key, MEM_callocN, NULL, scene, seq_cache_hashcmp(), seq_cache_hashhash(), SeqCache::thumbnail_count, and time.
Referenced by seq_cache_get(), seq_cache_put(), and seq_cache_thumbnail_put().
Definition at line 576 of file image_cache.c.
References BLI_ghash_free(), BLI_mempool_destroy(), BLI_mutex_end(), Editing::cache, SeqCache::disk_cache, Scene::ed, SeqCache::hash, SeqCache::items_pool, SeqCache::iterator_mutex, SeqCache::keys_pool, MEM_freeN, NULL, scene, seq_cache_get_from_scene(), seq_cache_keyfree(), seq_cache_valfree(), and seq_disk_cache_free().
Referenced by SEQ_editing_free().
Definition at line 151 of file image_cache.c.
References SEQ_time_start_frame_get().
Referenced by seq_disk_cache_delete_invalid_files().
Definition at line 547 of file image_cache.c.
References BLI_ghash_remove(), BLI_ghashIterator_done(), BLI_ghashIterator_getKey(), BLI_ghashIterator_init(), BLI_ghashIterator_step(), SeqCacheKey::frame_index, SeqCache::hash, SeqCacheKey::is_temp_cache, scene, SeqCacheKey::seq, seq_cache_get_from_scene(), seq_cache_keyfree(), seq_cache_lock(), SEQ_CACHE_STORE_THUMBNAIL, seq_cache_timeline_frame_to_frame_index(), seq_cache_unlock(), seq_cache_valfree(), SEQ_time_left_handle_frame_get(), SEQ_time_right_handle_frame_get(), SeqCacheKey::task_id, and SeqCacheKey::type.
Referenced by seq_prefetch_frames(), and SEQ_render_give_ibuf().
struct ImBuf* seq_cache_get | ( | const SeqRenderData * | context, |
Sequence * | seq, | ||
float | timeline_frame, | ||
int | type | ||
) |
Definition at line 726 of file image_cache.c.
References Editing::cache, blender::compositor::context, SeqCache::disk_cache, Scene::ed, NULL, scene, seq_cache_allocate_key(), seq_cache_create(), seq_cache_get_ex(), seq_cache_get_from_scene(), seq_cache_lock(), seq_cache_populate_key(), seq_cache_put_ex(), seq_cache_recycle_item(), SEQ_CACHE_STORE_FINAL_OUT, seq_cache_unlock(), seq_disk_cache_create(), seq_disk_cache_is_enabled(), seq_disk_cache_read_file(), seq_prefetch_get_original_context(), seq_prefetch_get_original_sequence(), type, and SeqCacheKey::type.
Referenced by seq_cache_put(), SEQ_get_thumbnail(), seq_prefetch_seq_has_disk_cache(), SEQ_render_give_ibuf(), seq_render_strip(), seq_render_strip_stack(), SEQ_render_thumbnails(), and SEQ_render_thumbnails_base_set().
|
static |
Definition at line 261 of file image_cache.c.
References BLI_ghash_lookup(), SeqCache::hash, SeqCacheItem::ibuf, IMB_refImBuf(), and NULL.
Referenced by seq_cache_get().
Definition at line 156 of file image_cache.c.
References Editing::cache, Scene::ed, NULL, and scene.
Referenced by SEQ_cache_cleanup(), seq_cache_cleanup_sequence(), seq_cache_destruct(), seq_cache_free_temp_cache(), seq_cache_get(), seq_cache_get_item_for_removal(), SEQ_cache_iterate(), seq_cache_lock(), seq_cache_populate_key(), seq_cache_put(), seq_cache_put_ex(), seq_cache_recycle_item(), seq_cache_recycle_linked(), seq_cache_set_temp_cache_linked(), seq_cache_thumbnail_cleanup(), seq_cache_thumbnail_put(), and seq_cache_unlock().
|
static |
Definition at line 390 of file image_cache.c.
References BLI_ghashIterator_done(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_ghashIterator_init(), BLI_ghashIterator_step(), SeqCache::hash, SeqCacheItem::ibuf, SeqCacheKey::is_temp_cache, SeqCacheKey::link_next, NULL, scene, seq_cache_choose_key(), seq_cache_get_from_scene(), seq_cache_recycle_linked(), and SeqCacheKey::timeline_frame.
Referenced by seq_cache_recycle_item().
|
static |
Definition at line 183 of file image_cache.c.
Referenced by seq_cache_is_full().
Definition at line 127 of file image_cache.c.
References Freestyle::a, usdtokens::b(), and seq_cmp_render_data().
Referenced by seq_cache_create().
|
static |
Definition at line 115 of file image_cache.c.
References SeqCacheKey::context, SeqCacheKey::frame_index, SeqCacheKey::seq, seq_hash_render_data(), and SeqCacheKey::type.
Referenced by seq_cache_create().
Definition at line 919 of file image_cache.c.
References MEM_get_memory_in_use, and seq_cache_get_mem_total().
Referenced by seq_cache_recycle_item(), and seq_prefetch_is_cache_full().
void SEQ_cache_iterate | ( | struct Scene * | scene, |
void * | userdata, | ||
bool | callback_initvoid *userdata, size_t item_count, | ||
bool | callback_itervoid *userdata, struct Sequence *seq, int timeline_frame, int cache_type | ||
) |
Definition at line 891 of file image_cache.c.
References BLI_ghash_len(), BLI_ghashIterator_done(), BLI_ghashIterator_getKey(), BLI_ghashIterator_init(), BLI_ghashIterator_step(), SeqCache::hash, SeqCache::last_key, NULL, scene, SeqCacheKey::seq, seq_cache_get_from_scene(), seq_cache_lock(), seq_cache_unlock(), SeqCacheKey::timeline_frame, SeqCacheKey::type, and ImBuf::userdata.
Referenced by draw_cache_view().
Definition at line 188 of file image_cache.c.
References BLI_mempool_free(), SeqCacheKey::cache_owner, and SeqCache::keys_pool.
Referenced by SEQ_cache_cleanup(), seq_cache_cleanup_sequence(), seq_cache_destruct(), seq_cache_free_temp_cache(), seq_cache_put_ex(), seq_cache_recycle_linked(), and seq_cache_thumbnail_cleanup().
Definition at line 165 of file image_cache.c.
References BLI_mutex_lock(), SeqCache::iterator_mutex, scene, and seq_cache_get_from_scene().
Referenced by SEQ_cache_cleanup(), seq_cache_cleanup_sequence(), seq_cache_free_temp_cache(), seq_cache_get(), SEQ_cache_iterate(), seq_cache_put(), seq_cache_recycle_item(), and seq_cache_thumbnail_put().
|
static |
Definition at line 515 of file image_cache.c.
References SeqCacheKey::cache_owner, blender::compositor::context, SeqCacheKey::context, SeqCacheKey::frame_index, SeqCacheKey::is_temp_cache, SeqCacheKey::link_next, SeqCacheKey::link_prev, NULL, SeqCacheKey::seq, seq_cache_get_from_scene(), seq_cache_timeline_frame_to_frame_index(), SeqCacheKey::task_id, SeqCacheKey::timeline_frame, type, and SeqCacheKey::type.
Referenced by seq_cache_allocate_key(), and seq_cache_get().
void seq_cache_put | ( | const SeqRenderData * | context, |
Sequence * | seq, | ||
float | timeline_frame, | ||
int | type, | ||
ImBuf * | i | ||
) |
Definition at line 846 of file image_cache.c.
References BLI_assert, Editing::cache, blender::compositor::context, SeqCache::disk_cache, Scene::ed, IMB_freeImBuf(), SeqCacheKey::is_temp_cache, NULL, scene, seq_cache_allocate_key(), seq_cache_create(), seq_cache_get(), seq_cache_get_from_scene(), seq_cache_lock(), seq_cache_put_ex(), seq_cache_unlock(), seq_disk_cache_create(), seq_disk_cache_enforce_limits(), seq_disk_cache_is_enabled(), seq_disk_cache_write_file(), seq_prefetch_get_original_context(), seq_prefetch_get_original_sequence(), and type.
Referenced by seq_cache_put_if_possible(), SEQ_render_give_ibuf(), seq_render_preprocess_ibuf(), seq_render_scene_strip(), and seq_render_strip_stack().
|
static |
Definition at line 221 of file image_cache.c.
References BLI_ghash_reinsert(), BLI_mempool_alloc(), SeqCacheItem::cache_owner, get_stored_types_flag(), SeqCache::hash, SeqCacheItem::ibuf, IMB_refImBuf(), SeqCacheKey::is_temp_cache, SeqCache::items_pool, SeqCache::last_key, SeqCacheKey::link_next, SeqCacheKey::link_prev, NULL, scene, seq_cache_get_from_scene(), seq_cache_keyfree(), SEQ_CACHE_STORE_FINAL_OUT, SEQ_CACHE_STORE_THUMBNAIL, seq_cache_valfree(), and SeqCacheKey::type.
Referenced by seq_cache_get(), seq_cache_put(), and seq_cache_thumbnail_put().
bool seq_cache_put_if_possible | ( | const SeqRenderData * | context, |
Sequence * | seq, | ||
float | timeline_frame, | ||
int | type, | ||
ImBuf * | ibuf | ||
) |
Definition at line 790 of file image_cache.c.
References Editing::cache, blender::compositor::context, Scene::ed, SeqCache::last_key, NULL, scene, seq_cache_put(), seq_cache_recycle_item(), seq_cache_set_temp_cache_linked(), seq_prefetch_get_original_context(), seq_prefetch_get_original_sequence(), and type.
Referenced by SEQ_render_give_ibuf().
Find only "base" keys. Sources(other types) for a frame must be freed all at once.
Definition at line 446 of file image_cache.c.
References scene, seq_cache_get_from_scene(), seq_cache_get_item_for_removal(), seq_cache_is_full(), seq_cache_lock(), seq_cache_recycle_linked(), and seq_cache_unlock().
Referenced by seq_cache_get(), seq_cache_put_if_possible(), and seq_prefetch_is_cache_full().
|
static |
Definition at line 347 of file image_cache.c.
References BLI_ghash_haskey(), BLI_ghash_remove(), SeqCache::hash, SeqCacheKey::link_next, SeqCacheKey::link_prev, next, NULL, blender::meshintersect::prev(), scene, seq_cache_get_from_scene(), seq_cache_keyfree(), and seq_cache_valfree().
Referenced by seq_cache_get_item_for_removal(), and seq_cache_recycle_item().
|
static |
Definition at line 274 of file image_cache.c.
References SeqCacheKey::link_next, and SeqCacheKey::link_prev.
Referenced by seq_cache_cleanup_sequence().
|
static |
Definition at line 470 of file image_cache.c.
References SeqCacheKey::is_temp_cache, SeqCacheKey::link_next, SeqCacheKey::link_prev, next, blender::meshintersect::prev(), scene, and seq_cache_get_from_scene().
Referenced by seq_cache_put_if_possible().
Definition at line 685 of file image_cache.c.
References BLI_ghash_remove(), BLI_ghashIterator_done(), BLI_ghashIterator_getKey(), BLI_ghashIterator_init(), BLI_ghashIterator_step(), SeqCache::hash, SeqCache::last_key, Sequence::machine, NULL, round_fl_to_int(), scene, SeqCacheKey::seq, seq_cache_get_from_scene(), seq_cache_keyfree(), SEQ_CACHE_STORE_THUMBNAIL, seq_cache_valfree(), SEQ_render_thumbnails_guaranteed_set_frame_step_get(), SEQ_time_left_handle_frame_get(), SeqCache::thumbnail_count, SeqCacheKey::timeline_frame, SeqCacheKey::type, rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.
Referenced by seq_cache_thumbnail_put().
void seq_cache_thumbnail_put | ( | const SeqRenderData * | context, |
Sequence * | seq, | ||
float | timeline_frame, | ||
ImBuf * | i, | ||
rctf * | view_area | ||
) |
Definition at line 815 of file image_cache.c.
References BLI_ghash_haskey(), Editing::cache, blender::compositor::context, Scene::ed, SeqCache::hash, scene, seq_cache_allocate_key(), seq_cache_create(), seq_cache_get_from_scene(), seq_cache_lock(), seq_cache_put_ex(), SEQ_CACHE_STORE_THUMBNAIL, seq_cache_thumbnail_cleanup(), seq_cache_unlock(), THUMB_CACHE_LIMIT, and SeqCache::thumbnail_count.
Referenced by SEQ_render_thumbnails(), and SEQ_render_thumbnails_base_set().
|
static |
Definition at line 136 of file image_cache.c.
References ELEM, scene, SEQ_CACHE_STORE_RAW, SEQ_CACHE_STORE_THUMBNAIL, seq_give_frame_index(), SEQ_time_start_frame_get(), and type.
Referenced by seq_cache_free_temp_cache(), and seq_cache_populate_key().
Definition at line 174 of file image_cache.c.
References BLI_mutex_unlock(), SeqCache::iterator_mutex, scene, and seq_cache_get_from_scene().
Referenced by SEQ_cache_cleanup(), seq_cache_cleanup_sequence(), seq_cache_free_temp_cache(), seq_cache_get(), SEQ_cache_iterate(), seq_cache_put(), seq_cache_recycle_item(), and seq_cache_thumbnail_put().
Definition at line 194 of file image_cache.c.
References BLI_mempool_free(), SeqCacheItem::cache_owner, SeqCacheItem::ibuf, IMB_freeImBuf(), and SeqCache::items_pool.
Referenced by SEQ_cache_cleanup(), seq_cache_cleanup_sequence(), seq_cache_destruct(), seq_cache_free_temp_cache(), seq_cache_put_ex(), seq_cache_recycle_linked(), and seq_cache_thumbnail_cleanup().
|
static |
Definition at line 92 of file image_cache.c.
References Freestyle::a, and usdtokens::b().
Referenced by seq_cache_hashcmp().
|
static |
Definition at line 101 of file image_cache.c.
References Freestyle::a.
Referenced by seq_cache_hashhash().
|
static |
Definition at line 90 of file image_cache.c.
Referenced by seq_cache_create().