VSE: Don't store `cfra` in cache
Strips can move in time. Using cfra may give us erratic results. Reviewed by: brecht Differential Revision: https://developer.blender.org/D4898
This commit is contained in:
parent
9be7c831f6
commit
d5ffa805b2
|
@ -90,7 +90,6 @@ typedef struct SeqCacheKey {
|
|||
struct SeqCacheKey *link_next; /* Used for linking intermediate items to final frame */
|
||||
struct Sequence *seq;
|
||||
SeqRenderData context;
|
||||
float cfra;
|
||||
float nfra;
|
||||
float cost;
|
||||
bool is_temp_cache;
|
||||
|
@ -232,14 +231,17 @@ static SeqCacheKey *seq_cache_choose_key(Scene *scene, SeqCacheKey *lkey, SeqCac
|
|||
SeqCacheKey *finalkey = NULL;
|
||||
|
||||
if (rkey && lkey) {
|
||||
if (lkey->cfra > rkey->cfra) {
|
||||
int lkey_cfra = lkey->seq->start + lkey->nfra;
|
||||
int rkey_cfra = rkey->seq->start + rkey->nfra;
|
||||
|
||||
if (lkey_cfra > rkey_cfra) {
|
||||
SeqCacheKey *swapkey = lkey;
|
||||
lkey = rkey;
|
||||
rkey = swapkey;
|
||||
}
|
||||
|
||||
int l_diff = scene->r.cfra - lkey->cfra;
|
||||
int r_diff = rkey->cfra - scene->r.cfra;
|
||||
int l_diff = scene->r.cfra - lkey_cfra;
|
||||
int r_diff = rkey_cfra - scene->r.cfra;
|
||||
|
||||
if (l_diff > r_diff) {
|
||||
finalkey = lkey;
|
||||
|
@ -319,7 +321,7 @@ static SeqCacheKey *seq_cache_get_item_for_removal(Scene *scene)
|
|||
if (key->cost <= scene->ed->recycle_max_cost) {
|
||||
cheap_count++;
|
||||
if (lkey) {
|
||||
if (key->cfra < lkey->cfra) {
|
||||
if (key->seq->start + key->nfra < lkey->seq->start + lkey->nfra) {
|
||||
lkey = key;
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +329,7 @@ static SeqCacheKey *seq_cache_get_item_for_removal(Scene *scene)
|
|||
lkey = key;
|
||||
}
|
||||
if (rkey) {
|
||||
if (key->cfra > rkey->cfra) {
|
||||
if (key->seq->start + key->nfra > rkey->seq->start + rkey->nfra) {
|
||||
rkey = key;
|
||||
}
|
||||
}
|
||||
|
@ -425,7 +427,7 @@ void BKE_sequencer_cache_free_temp_cache(Scene *scene, short id, int cfra)
|
|||
SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
|
||||
BLI_ghashIterator_step(&gh_iter);
|
||||
|
||||
if (key->is_temp_cache && key->creator_id == id && key->cfra != cfra) {
|
||||
if (key->is_temp_cache && key->creator_id == id && key->seq->start + key->nfra != cfra) {
|
||||
BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
|
||||
}
|
||||
}
|
||||
|
@ -592,7 +594,6 @@ void BKE_sequencer_cache_put(
|
|||
key->cache_owner = cache;
|
||||
key->seq = seq;
|
||||
key->context = *context;
|
||||
key->cfra = cfra;
|
||||
key->nfra = cfra - seq->start;
|
||||
key->type = type;
|
||||
key->cost = cost;
|
||||
|
@ -634,7 +635,7 @@ void BKE_sequencer_cache_put(
|
|||
void BKE_sequencer_cache_iterate(
|
||||
struct Scene *scene,
|
||||
void *userdata,
|
||||
bool callback(void *userdata, struct Sequence *seq, int cfra, int cache_type, float cost))
|
||||
bool callback(void *userdata, struct Sequence *seq, int nfra, int cache_type, float cost))
|
||||
{
|
||||
SeqCache *cache = seq_cache_get_from_scene(scene);
|
||||
if (!cache) {
|
||||
|
@ -650,7 +651,7 @@ void BKE_sequencer_cache_iterate(
|
|||
SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
|
||||
BLI_ghashIterator_step(&gh_iter);
|
||||
|
||||
interrupt = callback(userdata, key->seq, key->cfra, key->type, key->cost);
|
||||
interrupt = callback(userdata, key->seq, key->nfra, key->type, key->cost);
|
||||
}
|
||||
|
||||
cache->last_key = NULL;
|
||||
|
|
|
@ -1821,7 +1821,7 @@ typedef struct CacheDrawData {
|
|||
|
||||
/* Called as a callback */
|
||||
static bool draw_cache_view_cb(
|
||||
void *userdata, struct Sequence *seq, int cfra, int cache_type, float UNUSED(cost))
|
||||
void *userdata, struct Sequence *seq, int nfra, int cache_type, float UNUSED(cost))
|
||||
{
|
||||
CacheDrawData *drawdata = userdata;
|
||||
const bContext *C = drawdata->C;
|
||||
|
@ -1901,6 +1901,7 @@ static bool draw_cache_view_cb(
|
|||
}
|
||||
}
|
||||
|
||||
int cfra = seq->start + nfra;
|
||||
immUniformColor4f(color[0], color[1], color[2], color[3]);
|
||||
immRectf(pos, cfra, stripe_bot, cfra + 1, stripe_top);
|
||||
|
||||
|
|
Loading…
Reference in New Issue