proxy: cleaned up, re-use the render cache's disk save system for proxies, multithreaded compression
This commit is contained in:
@@ -26,8 +26,6 @@
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
const int64_t VideoStream::kEndTimestamp = AV_NOPTS_VALUE;
|
||||
|
||||
VideoStream::VideoStream() :
|
||||
start_time_(0),
|
||||
is_image_sequence_(false),
|
||||
@@ -102,15 +100,15 @@ int VideoStream::using_proxy()
|
||||
return using_proxy_;
|
||||
}
|
||||
|
||||
void VideoStream::set_proxy(const int ÷r)
|
||||
void VideoStream::set_proxy(const int ÷r, const QVector<int64_t> &index)
|
||||
{
|
||||
QMutexLocker locker(proxy_access_lock());
|
||||
|
||||
using_proxy_ = divider;
|
||||
frame_index_ = index;
|
||||
is_generating_proxy_ = false;
|
||||
}
|
||||
|
||||
/*
|
||||
int64_t VideoStream::get_closest_timestamp_in_frame_index(const rational &time)
|
||||
{
|
||||
// Get rough approximation of what the timestamp would be in this timebase
|
||||
@@ -122,45 +120,31 @@ int64_t VideoStream::get_closest_timestamp_in_frame_index(const rational &time)
|
||||
|
||||
int64_t VideoStream::get_closest_timestamp_in_frame_index(int64_t timestamp)
|
||||
{
|
||||
QMutexLocker locker(&index_access_lock_);
|
||||
QMutexLocker locker(proxy_access_lock());
|
||||
|
||||
if (frame_index_.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
if (!frame_index_.isEmpty()) {
|
||||
if (timestamp <= frame_index_.first()) {
|
||||
return frame_index_.first();
|
||||
} else if (timestamp >= frame_index_.last()) {
|
||||
return frame_index_.last();
|
||||
} else {
|
||||
// Use index to find closest frame in file
|
||||
for (int i=1;i<frame_index_.size();i++) {
|
||||
int64_t this_ts = frame_index_.at(i);
|
||||
|
||||
// Adjust target by stream's start time
|
||||
timestamp += start_time_;
|
||||
|
||||
if (timestamp <= 0) {
|
||||
return frame_index_.first();
|
||||
}
|
||||
|
||||
int index_size = frame_index_.size();
|
||||
|
||||
if (frame_index_.last() == kEndTimestamp) {
|
||||
index_size--;
|
||||
}
|
||||
|
||||
// Use index to find closest frame in file
|
||||
for (int i=0;i<index_size;i++) {
|
||||
int64_t this_ts = frame_index_.at(i);
|
||||
|
||||
if (this_ts == timestamp) {
|
||||
return timestamp;
|
||||
} else if (this_ts > timestamp) {
|
||||
return frame_index_.at(i - 1);
|
||||
if (this_ts == timestamp) {
|
||||
return timestamp;
|
||||
} else if (this_ts > timestamp) {
|
||||
return frame_index_.at(i - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (frame_index_.last() == kEndTimestamp) {
|
||||
// Index is done
|
||||
return frame_index_.last();
|
||||
} else {
|
||||
// Index is not done yet
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
void VideoStream::clear_frame_index()
|
||||
{
|
||||
{
|
||||
|
||||
@@ -31,8 +31,6 @@ class VideoStream : public ImageStream
|
||||
public:
|
||||
VideoStream();
|
||||
|
||||
static const int64_t kEndTimestamp;
|
||||
|
||||
virtual QString description() const override;
|
||||
|
||||
/**
|
||||
@@ -49,9 +47,9 @@ public:
|
||||
bool is_image_sequence() const;
|
||||
void set_image_sequence(bool e);
|
||||
|
||||
/*
|
||||
int64_t get_closest_timestamp_in_frame_index(const rational& time);
|
||||
int64_t get_closest_timestamp_in_frame_index(int64_t timestamp);
|
||||
/*
|
||||
void clear_frame_index();
|
||||
void append_frame_index(const int64_t& ts);
|
||||
bool is_frame_index_ready();
|
||||
@@ -64,7 +62,7 @@ public:
|
||||
bool is_generating_proxy();
|
||||
bool try_start_proxy();
|
||||
int using_proxy();
|
||||
void set_proxy(const int& divider);
|
||||
void set_proxy(const int& divider, const QVector<int64_t>& index);
|
||||
|
||||
private:
|
||||
rational frame_rate_;
|
||||
|
||||
Reference in New Issue
Block a user