diff options
author | Richard Antalik <richardantalik@gmail.com> | 2019-05-21 22:29:17 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2019-05-21 22:29:17 +0300 |
commit | d5ffa805b2b372a25badb670cc85ff7aaf29fca6 (patch) | |
tree | 963beffbfbe19a946779153322a5f277da0cb148 /source/blender/blenkernel/intern | |
parent | 9be7c831f67bce4a23de96de651f0f7a8975a690 (diff) |
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
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/seqcache.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 1c0aa63f590..f77b3e99e30 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -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; |