cache: attempt to automatically re-match hashes on invalidate

This code is slow and unoptimized. Will require some more work.
This commit is contained in:
itsmattkc
2020-05-21 16:49:02 +10:00
parent cb72736f52
commit 34fade9d81
7 changed files with 73 additions and 21 deletions
+31
View File
@@ -29,6 +29,7 @@
#include "codec/frame.h"
#include "common/filefunctions.h"
#include "common/timecodefunctions.h"
#include "render/diskmanager.h"
OLIVE_NAMESPACE_ENTER
@@ -104,6 +105,36 @@ QString FrameHashCache::GetFormatExtension(const PixelFormat::Format &f)
}
}
QList<rational> FrameHashCache::GetFrameListFromTimeRange(TimeRangeList range_list, const rational &timebase)
{
QList<rational> times;
while (!range_list.isEmpty()) {
const TimeRange& range = range_list.first();
rational time = range.in();
rational snapped = Timecode::snap_time_to_timebase(time, timebase);
rational next;
if (snapped > time) {
next = snapped;
snapped -= timebase;
} else {
next = snapped + timebase;
}
times.append(snapped);
range_list.RemoveTimeRange(TimeRange(snapped, next));
}
return times;
}
QList<rational> FrameHashCache::GetFrameListFromTimeRange(const TimeRangeList &range) const
{
return GetFrameListFromTimeRange(range, timebase_);
}
void FrameHashCache::SaveCacheFrame(const QByteArray& hash,
char* data,
const VideoRenderingParams& vparam)