exporttask: improved progress signalling
This commit is contained in:
@@ -33,6 +33,7 @@ ExportTask::ExportTask(ViewerOutput *viewer_node,
|
||||
params_(params)
|
||||
{
|
||||
SetTitle(tr("Exporting \"%1\"").arg(viewer_node->GetLabel()));
|
||||
SetNativeProgressSignallingEnabled(false);
|
||||
}
|
||||
|
||||
bool ExportTask::Run()
|
||||
@@ -156,7 +157,7 @@ void ExportTask::FrameDownloaded(FramePtr f, const QByteArray &hash, const QVect
|
||||
time_map_.insert(actual_time, f);
|
||||
}
|
||||
|
||||
forever {
|
||||
while (!IsCancelled()) {
|
||||
rational real_time = Timecode::timestamp_to_time(frame_time_,
|
||||
video_params().frame_rate_as_time_base());
|
||||
|
||||
@@ -169,6 +170,7 @@ void ExportTask::FrameDownloaded(FramePtr f, const QByteArray &hash, const QVect
|
||||
encoder_->WriteFrame(time_map_.take(real_time), real_time);
|
||||
|
||||
frame_time_++;
|
||||
emit ProgressChanged(double(frame_time_) / double(GetTotalNumberOfFrames()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-11
@@ -29,7 +29,8 @@ RenderTask::RenderTask(ViewerOutput *viewer, const VideoParams &vparams, const A
|
||||
viewer_(viewer),
|
||||
video_params_(vparams),
|
||||
audio_params_(aparams),
|
||||
running_tickets_(0)
|
||||
running_tickets_(0),
|
||||
native_progress_signalling_(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -51,7 +52,6 @@ bool RenderTask::Render(ColorManager* manager,
|
||||
|
||||
double progress_counter = 0;
|
||||
double total_length = 0;
|
||||
double video_frame_sz = video_params().frame_rate_as_time_base().toDouble();
|
||||
|
||||
// Store real time before any rendering takes place
|
||||
qint64 job_time = QDateTime::currentMSecsSinceEpoch();
|
||||
@@ -112,7 +112,9 @@ bool RenderTask::Render(ColorManager* manager,
|
||||
}
|
||||
|
||||
// Add to "total progress"
|
||||
total_length += video_frame_sz * time_map.size();
|
||||
total_number_of_frames_ = times.size();
|
||||
total_number_of_unique_frames_ = time_map.size();
|
||||
total_length += total_number_of_unique_frames_;
|
||||
}
|
||||
|
||||
// Start a render of a limited amount, and then render one frame for each frame that gets
|
||||
@@ -158,8 +160,10 @@ bool RenderTask::Render(ColorManager* manager,
|
||||
watcher->Get().value<FramePtr>(),
|
||||
watcher->property("hash").toByteArray());
|
||||
|
||||
progress_counter += video_frame_sz * 0.5;
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
if (native_progress_signalling_) {
|
||||
progress_counter += 0.5;
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -167,13 +171,15 @@ bool RenderTask::Render(ColorManager* manager,
|
||||
QByteArray rendered_hash = watcher->property("hash").toByteArray();
|
||||
FrameDownloaded(watcher->Get().value<FramePtr>(), rendered_hash, time_map.value(rendered_hash), job_time);
|
||||
|
||||
double progress_to_add = video_frame_sz;
|
||||
if (TwoStepFrameRendering()) {
|
||||
progress_to_add *= 0.5;
|
||||
}
|
||||
progress_counter += progress_to_add;
|
||||
if (native_progress_signalling_) {
|
||||
double progress_to_add = 1.0;
|
||||
if (TwoStepFrameRendering()) {
|
||||
progress_to_add *= 0.5;
|
||||
}
|
||||
progress_counter += progress_to_add;
|
||||
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
}
|
||||
|
||||
if (frame_iterator != frame_render_order.cend()) {
|
||||
StartTicket(frame_iterator->second, &watcher_thread, manager, frame_iterator->first,
|
||||
|
||||
@@ -80,6 +80,27 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetNativeProgressSignallingEnabled(bool e)
|
||||
{
|
||||
native_progress_signalling_ = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Only valid after Render() is called
|
||||
*/
|
||||
int64_t GetTotalNumberOfFrames() const
|
||||
{
|
||||
return total_number_of_frames_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Only valid after Render() is called
|
||||
*/
|
||||
int64_t GetTotalNumberOfUniqueFrames() const
|
||||
{
|
||||
return total_number_of_unique_frames_;
|
||||
}
|
||||
|
||||
private:
|
||||
void PrepareWatcher(RenderTicketWatcher* watcher, QThread *thread);
|
||||
|
||||
@@ -99,6 +120,11 @@ private:
|
||||
QMutex finished_watcher_mutex_;
|
||||
QWaitCondition finished_watcher_wait_cond_;
|
||||
|
||||
bool native_progress_signalling_;
|
||||
|
||||
int64_t total_number_of_frames_;
|
||||
int64_t total_number_of_unique_frames_;
|
||||
|
||||
private slots:
|
||||
void TicketDone(RenderTicketWatcher *watcher);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user