use a system of deferred maps to keep track of frames that don't need to be rendered twice

Mostly used for exporting to ensure all frames get accounted for when being
sent from the renderer to the exporter through signals/slots.
This commit is contained in:
itsmattkc
2019-12-22 03:03:08 +11:00
parent 8514590c83
commit 46855adea7
5 changed files with 39 additions and 29 deletions
+16 -5
View File
@@ -26,13 +26,15 @@ bool VideoRenderFrameCache::IsCaching(const QByteArray &hash)
return is_caching;
}
bool VideoRenderFrameCache::TryCache(const QByteArray &hash)
bool VideoRenderFrameCache::TryCache(const rational& time, const QByteArray &hash)
{
currently_caching_lock_.lock();
bool is_caching = currently_caching_list_.contains(hash);
if (!is_caching) {
if (is_caching) {
deferred_maps_.insert(time, hash);
} else {
currently_caching_list_.append(hash);
}
@@ -80,18 +82,27 @@ void VideoRenderFrameCache::Truncate(const rational &time)
}
}
QList<rational> VideoRenderFrameCache::TimesWithHash(const QByteArray &hash)
QList<rational> VideoRenderFrameCache::DeferredMapsWithHash(const QByteArray &hash)
{
QList<rational> list;
QMap<rational, QByteArray>::const_iterator iterator;
currently_caching_lock_.lock();
for (iterator=time_hash_map_.begin();iterator!=time_hash_map_.end();iterator++) {
QMap<rational, QByteArray>::iterator iterator = deferred_maps_.begin();
while (iterator != deferred_maps_.end()) {
if (iterator.value() == hash) {
list.append(iterator.key());
iterator = deferred_maps_.erase(iterator);
} else {
iterator++;
}
}
currently_caching_list_.removeOne(hash);
currently_caching_lock_.unlock();
return list;
}