viewer: queue frames during playback
Rather than have to decode EXRs and display them in the span of one frame, decode into memory ahead of time so that they're ready for upload. Has the potential to speed up playback by about 5-6x.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <QPainter>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "common/functiontimer.h"
|
||||
#include "gizmotraverser.h"
|
||||
#include "render/backend/opengl/openglrenderfunctions.h"
|
||||
#include "render/backend/opengl/openglshader.h"
|
||||
@@ -61,63 +62,6 @@ void ViewerDisplayWidget::SetMatrix(const QMatrix4x4 &mat)
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::SetImage(const QString &fn)
|
||||
{
|
||||
has_image_ = false;
|
||||
|
||||
if (!fn.isEmpty() && QFileInfo::exists(fn)) {
|
||||
auto input = OIIO::ImageInput::open(fn.toStdString());
|
||||
|
||||
if (input) {
|
||||
|
||||
PixelFormat::Format image_format = PixelFormat::OIIOFormatToOliveFormat(input->spec().format,
|
||||
input->spec().nchannels == kRGBAChannels);
|
||||
|
||||
// Ensure the following texture operations are done in our context (in case we're in a separate window for instance)
|
||||
makeCurrent();
|
||||
|
||||
if (!texture_.IsCreated()
|
||||
|| texture_.width() != input->spec().width
|
||||
|| texture_.height() != input->spec().height
|
||||
|| texture_.format() != image_format) {
|
||||
load_buffer_.destroy();
|
||||
texture_.Destroy();
|
||||
|
||||
load_buffer_.set_video_params(VideoRenderingParams(input->spec().width, input->spec().height, image_format));
|
||||
load_buffer_.allocate();
|
||||
|
||||
texture_.Create(context(), VideoRenderingParams(input->spec().width, input->spec().height, image_format));
|
||||
}
|
||||
|
||||
input->read_image(input->spec().format, load_buffer_.data(), OIIO::AutoStride, load_buffer_.linesize_bytes());
|
||||
input->close();
|
||||
|
||||
texture_.Upload(&load_buffer_);
|
||||
|
||||
doneCurrent();
|
||||
|
||||
emit LoadedBuffer(&load_buffer_);
|
||||
|
||||
has_image_ = true;
|
||||
|
||||
#if OIIO_VERSION < 10903
|
||||
OIIO::ImageInput::destroy(input);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
qWarning() << "OIIO Error:" << OIIO::geterror().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
if (has_image_) {
|
||||
emit LoadedBuffer(&load_buffer_);
|
||||
} else {
|
||||
emit LoadedBuffer(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::SetSignalCursorColorEnabled(bool e)
|
||||
{
|
||||
signal_cursor_color_ = e;
|
||||
@@ -144,6 +88,8 @@ void ViewerDisplayWidget::SetImageFromLoadBuffer(Frame *in_buffer)
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
emit LoadedBuffer(in_buffer);
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::ConnectSibling(ViewerDisplayWidget *sibling)
|
||||
|
||||
Reference in New Issue
Block a user