format: reformatting files
This commit is contained in:
@@ -15,26 +15,26 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/viewer/audiowaveformview.cpp
|
||||
widget/viewer/audiowaveformview.h
|
||||
widget/viewer/footageviewer.cpp
|
||||
widget/viewer/footageviewer.h
|
||||
widget/viewer/viewer.cpp
|
||||
widget/viewer/viewer.h
|
||||
widget/viewer/viewerdisplay.cpp
|
||||
widget/viewer/viewerdisplay.h
|
||||
widget/viewer/viewerplaybacktimer.cpp
|
||||
widget/viewer/viewerplaybacktimer.h
|
||||
widget/viewer/viewerpreventsleep.cpp
|
||||
widget/viewer/viewerpreventsleep.h
|
||||
widget/viewer/viewerqueue.h
|
||||
widget/viewer/viewersafemargininfo.h
|
||||
widget/viewer/viewersizer.cpp
|
||||
widget/viewer/viewersizer.h
|
||||
widget/viewer/viewertexteditor.cpp
|
||||
widget/viewer/viewertexteditor.h
|
||||
widget/viewer/viewerwindow.cpp
|
||||
widget/viewer/viewerwindow.h
|
||||
PARENT_SCOPE
|
||||
${OLIVE_SOURCES}
|
||||
widget/viewer/audiowaveformview.cpp
|
||||
widget/viewer/audiowaveformview.h
|
||||
widget/viewer/footageviewer.cpp
|
||||
widget/viewer/footageviewer.h
|
||||
widget/viewer/viewer.cpp
|
||||
widget/viewer/viewer.h
|
||||
widget/viewer/viewerdisplay.cpp
|
||||
widget/viewer/viewerdisplay.h
|
||||
widget/viewer/viewerplaybacktimer.cpp
|
||||
widget/viewer/viewerplaybacktimer.h
|
||||
widget/viewer/viewerpreventsleep.cpp
|
||||
widget/viewer/viewerpreventsleep.h
|
||||
widget/viewer/viewerqueue.h
|
||||
widget/viewer/viewersafemargininfo.h
|
||||
widget/viewer/viewersizer.cpp
|
||||
widget/viewer/viewersizer.h
|
||||
widget/viewer/viewertexteditor.cpp
|
||||
widget/viewer/viewertexteditor.h
|
||||
widget/viewer/viewerwindow.cpp
|
||||
widget/viewer/viewerwindow.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -69,7 +69,9 @@ void AudioWaveformView::SetViewer(ViewerOutput *playback)
|
||||
|
||||
rational tb = playback_->GetVideoParams().frame_rate_as_time_base();
|
||||
if (tb.isNull()) {
|
||||
tb = OLIVE_CONFIG("DefaultSequenceFrameRate").value<rational>().flipped();
|
||||
tb = OLIVE_CONFIG("DefaultSequenceFrameRate")
|
||||
.value<rational>()
|
||||
.flipped();
|
||||
}
|
||||
SetTimebase(tb);
|
||||
UpdateSceneRect();
|
||||
|
||||
@@ -97,11 +97,12 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent)
|
||||
&ViewerWidget::CursorColor);
|
||||
connect(display_widget_, &ViewerDisplayWidget::ColorProcessorChanged, this,
|
||||
&ViewerWidget::ColorProcessorChanged);
|
||||
connect(display_widget_, &ViewerDisplayWidget::ColorProcessorChanged, this,
|
||||
[](ColorProcessorPtr processor) {
|
||||
RenderManager::instance()->GetCacher()->SetDisplayColorProcessor(
|
||||
processor);
|
||||
});
|
||||
connect(
|
||||
display_widget_, &ViewerDisplayWidget::ColorProcessorChanged, this,
|
||||
[](ColorProcessorPtr processor) {
|
||||
RenderManager::instance()->GetCacher()->SetDisplayColorProcessor(
|
||||
processor);
|
||||
});
|
||||
RenderManager::instance()->GetCacher()->SetDisplayColorProcessor(
|
||||
display_widget_->GetCurrentColorProcessor());
|
||||
connect(display_widget_, &ViewerDisplayWidget::ColorManagerChanged, this,
|
||||
@@ -985,8 +986,7 @@ void ViewerWidget::ForceRequeueFromCurrentTime()
|
||||
// called from paintEvent paths (QueueStarved) where synchronously cancelling
|
||||
// watchers can re-enter the same RenderTicket mutex and deadlock.
|
||||
QMetaObject::invokeMethod(
|
||||
this,
|
||||
[this]() { ForceRequeueFromCurrentTimeInternal(); },
|
||||
this, [this]() { ForceRequeueFromCurrentTimeInternal(); },
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ void ViewerWidget::ForceRequeueFromCurrentTimeInternal()
|
||||
playback_queue_next_frame_ =
|
||||
GetTimestamp() +
|
||||
playback_speed_ * Timecode::time_to_timestamp(
|
||||
kRequeueWaitTime, timebase(), Timecode::kFloor);
|
||||
kRequeueWaitTime, timebase(), Timecode::kFloor);
|
||||
;
|
||||
first_requeue_watcher_ = nullptr;
|
||||
for (int i = 0; i < queue; i++) {
|
||||
@@ -1130,7 +1130,8 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
|
||||
// Verify audio processor output params are valid before using them
|
||||
AudioParams output_params = audio_processor_.to();
|
||||
if (!output_params.is_valid()) {
|
||||
qWarning() << "Audio processor output params are invalid, skipping audio playback";
|
||||
qWarning()
|
||||
<< "Audio processor output params are invalid, skipping audio playback";
|
||||
} else {
|
||||
AudioManager::instance()->SetOutputNotifyInterval(
|
||||
output_params.time_to_bytes(kAudioPlaybackInterval));
|
||||
@@ -1138,7 +1139,8 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
|
||||
&ViewerWidget::QueueNextAudioBuffer);
|
||||
|
||||
static const int prequeue_count = 2;
|
||||
prequeuing_audio_ = prequeue_count; // Queue two buffers ahead of time
|
||||
prequeuing_audio_ =
|
||||
prequeue_count; // Queue two buffers ahead of time
|
||||
audio_playback_queue_time_ = GetConnectedNode()->GetPlayhead();
|
||||
for (int i = 0; i < prequeue_count; i++) {
|
||||
QueueNextAudioBuffer();
|
||||
@@ -1506,17 +1508,13 @@ void ViewerWidget::RendererGeneratedFrameForQueue()
|
||||
|
||||
// Ignore this signal if we've paused now
|
||||
if (IsPlaying() || prequeuing_video_) {
|
||||
const qint64 start_ms =
|
||||
watcher->property("start").toLongLong();
|
||||
const qint64 now_ms =
|
||||
QDateTime::currentMSecsSinceEpoch();
|
||||
const qint64 start_ms = watcher->property("start").toLongLong();
|
||||
const qint64 now_ms = QDateTime::currentMSecsSinceEpoch();
|
||||
const int playback_step = qMax(1, qAbs(playback_speed_));
|
||||
const double frame_interval_ms = qMax(
|
||||
1.0,
|
||||
timebase().toDouble() * 1000.0 /
|
||||
static_cast<double>(playback_step));
|
||||
if (start_ms > 0 &&
|
||||
(now_ms - start_ms) > frame_interval_ms) {
|
||||
const double frame_interval_ms =
|
||||
qMax(1.0, timebase().toDouble() * 1000.0 /
|
||||
static_cast<double>(playback_step));
|
||||
if (start_ms > 0 && (now_ms - start_ms) > frame_interval_ms) {
|
||||
// If the queue is nearly empty, keep the frame anyway
|
||||
// to prevent the viewer from freezing entirely when
|
||||
// rendering can't keep up with playback speed.
|
||||
@@ -1544,7 +1542,7 @@ void ViewerWidget::RendererGeneratedFrameForQueue()
|
||||
}
|
||||
|
||||
dw->queue()->AppendTimewise({ ts, push },
|
||||
playback_speed_);
|
||||
playback_speed_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -385,15 +385,15 @@ void ViewerDisplayWidget::OnPaint()
|
||||
// image itself will be rendered offscreen, downloaded, and painted below.
|
||||
bg_painter.begin(paint_device());
|
||||
bg_painter_active = true;
|
||||
bg_painter.fillRect(GetInnerRect(),
|
||||
show_widget_background_ ? palette().window().color() :
|
||||
Qt::black);
|
||||
bg_painter.fillRect(GetInnerRect(), show_widget_background_ ?
|
||||
palette().window().color() :
|
||||
Qt::black);
|
||||
} else {
|
||||
// Clear background to empty
|
||||
QColor bg_color = show_widget_background_ ? palette().window().color() :
|
||||
Qt::black;
|
||||
renderer()->ClearDestination(nullptr, bg_color.redF(), bg_color.greenF(),
|
||||
bg_color.blueF());
|
||||
renderer()->ClearDestination(nullptr, bg_color.redF(),
|
||||
bg_color.greenF(), bg_color.blueF());
|
||||
}
|
||||
|
||||
VideoParams device_params;
|
||||
@@ -412,13 +412,14 @@ void ViewerDisplayWidget::OnPaint()
|
||||
} else if (color_service()) {
|
||||
bool drew_backend_neutral_frame = false;
|
||||
if (FramePtr frame = load_frame_.value<FramePtr>()) {
|
||||
if (!drew_backend_neutral_frame && (!texture_ ||
|
||||
texture_->renderer() !=
|
||||
renderer() // Some implementations don't like it if we upload to a texture created in another (albeit shared) context
|
||||
|| texture_->width() != frame->width() ||
|
||||
texture_->height() != frame->height() ||
|
||||
texture_->format() != frame->format() ||
|
||||
texture_->channel_count() != frame->channel_count())) {
|
||||
if (!drew_backend_neutral_frame &&
|
||||
(!texture_ ||
|
||||
texture_->renderer() !=
|
||||
renderer() // Some implementations don't like it if we upload to a texture created in another (albeit shared) context
|
||||
|| texture_->width() != frame->width() ||
|
||||
texture_->height() != frame->height() ||
|
||||
texture_->format() != frame->format() ||
|
||||
texture_->channel_count() != frame->channel_count())) {
|
||||
texture_ = renderer()->CreateTexture(
|
||||
frame->video_params(), frame->data(),
|
||||
frame->linesize_pixels());
|
||||
@@ -427,9 +428,10 @@ void ViewerDisplayWidget::OnPaint()
|
||||
}
|
||||
} else if (TexturePtr texture = load_frame_.value<TexturePtr>()) {
|
||||
// This is a GPU texture, switch to it directly when possible.
|
||||
if (!drew_backend_neutral_frame && texture && texture->renderer() &&
|
||||
texture->renderer() != renderer()) {
|
||||
if (texture->renderer()->IsOpenGL() && renderer()->IsOpenGL()) {
|
||||
if (!drew_backend_neutral_frame && texture &&
|
||||
texture->renderer() && texture->renderer() != renderer()) {
|
||||
if (texture->renderer()->IsOpenGL() &&
|
||||
renderer()->IsOpenGL()) {
|
||||
// Shared OpenGL contexts can display the producer texture
|
||||
// directly. Avoid readback here because the producer
|
||||
// renderer may belong to a render thread whose context
|
||||
@@ -441,8 +443,8 @@ void ViewerDisplayWidget::OnPaint()
|
||||
frame->set_video_params(texture->params());
|
||||
if (frame->allocate()) {
|
||||
texture->renderer()->DownloadFromTexture(
|
||||
texture->id(), texture->params(),
|
||||
frame->data(), frame->linesize_pixels());
|
||||
texture->id(), texture->params(), frame->data(),
|
||||
frame->linesize_pixels());
|
||||
texture_ = renderer()->CreateTexture(
|
||||
frame->video_params(), frame->data(),
|
||||
frame->linesize_pixels());
|
||||
@@ -475,9 +477,11 @@ void ViewerDisplayWidget::OnPaint()
|
||||
} else {
|
||||
if (deinterlace_) {
|
||||
if (deinterlace_shader_.isNull()) {
|
||||
deinterlace_shader_ = renderer()->CreateNativeShader(
|
||||
ShaderCode(FileFunctions::ReadFileAsString(
|
||||
QStringLiteral(":/shaders/deinterlace.frag"))));
|
||||
deinterlace_shader_ =
|
||||
renderer()->CreateNativeShader(
|
||||
ShaderCode(FileFunctions::ReadFileAsString(
|
||||
QStringLiteral(
|
||||
":/shaders/deinterlace.frag"))));
|
||||
}
|
||||
|
||||
if (!deinterlace_texture_ ||
|
||||
@@ -489,13 +493,15 @@ void ViewerDisplayWidget::OnPaint()
|
||||
}
|
||||
|
||||
ShaderJob job;
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
QVector2D(texture_to_draw->width(),
|
||||
texture_to_draw->height())));
|
||||
job.Insert(QStringLiteral("ove_maintex"),
|
||||
NodeValue(NodeValue::kTexture,
|
||||
QVariant::fromValue(texture_to_draw)));
|
||||
job.Insert(
|
||||
QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
QVector2D(texture_to_draw->width(),
|
||||
texture_to_draw->height())));
|
||||
job.Insert(
|
||||
QStringLiteral("ove_maintex"),
|
||||
NodeValue(NodeValue::kTexture,
|
||||
QVariant::fromValue(texture_to_draw)));
|
||||
|
||||
renderer()->BlitToTexture(deinterlace_shader_, job,
|
||||
deinterlace_texture_.get());
|
||||
@@ -1453,28 +1459,30 @@ bool ViewerDisplayWidget::DrawBackendNeutralFrame(const FramePtr &frame,
|
||||
if (display_frame->format() == PixelFormat::U8 &&
|
||||
display_frame->channel_count() == VideoParams::kRGBAChannelCount) {
|
||||
backend_neutral_cpu_display_frame_ = display_frame;
|
||||
backend_neutral_cpu_image_ = QImage(
|
||||
reinterpret_cast<const uchar *>(display_frame->const_data()),
|
||||
display_frame->width(), display_frame->height(),
|
||||
display_frame->linesize_bytes(), QImage::Format_RGBA8888);
|
||||
backend_neutral_cpu_image_ =
|
||||
QImage(reinterpret_cast<const uchar *>(display_frame->const_data()),
|
||||
display_frame->width(), display_frame->height(),
|
||||
display_frame->linesize_bytes(), QImage::Format_RGBA8888);
|
||||
source_image = backend_neutral_cpu_image_;
|
||||
} else if (display_frame->format() == PixelFormat::U8 &&
|
||||
display_frame->channel_count() == VideoParams::kRGBChannelCount) {
|
||||
display_frame->channel_count() ==
|
||||
VideoParams::kRGBChannelCount) {
|
||||
backend_neutral_cpu_display_frame_ = display_frame;
|
||||
backend_neutral_cpu_image_ = QImage(
|
||||
reinterpret_cast<const uchar *>(display_frame->const_data()),
|
||||
display_frame->width(), display_frame->height(),
|
||||
display_frame->linesize_bytes(), QImage::Format_RGB888);
|
||||
backend_neutral_cpu_image_ =
|
||||
QImage(reinterpret_cast<const uchar *>(display_frame->const_data()),
|
||||
display_frame->width(), display_frame->height(),
|
||||
display_frame->linesize_bytes(), QImage::Format_RGB888);
|
||||
source_image = backend_neutral_cpu_image_;
|
||||
} else {
|
||||
backend_neutral_cpu_display_frame_.reset();
|
||||
const int bytes_per_pixel = display_frame->video_params().GetBytesPerPixel();
|
||||
const int bytes_per_pixel =
|
||||
display_frame->video_params().GetBytesPerPixel();
|
||||
if (backend_neutral_cpu_image_.size() !=
|
||||
QSize(display_frame->width(), display_frame->height()) ||
|
||||
QSize(display_frame->width(), display_frame->height()) ||
|
||||
backend_neutral_cpu_image_.format() != QImage::Format_RGBA8888) {
|
||||
backend_neutral_cpu_image_ =
|
||||
QImage(display_frame->width(), display_frame->height(),
|
||||
QImage::Format_RGBA8888);
|
||||
backend_neutral_cpu_image_ = QImage(display_frame->width(),
|
||||
display_frame->height(),
|
||||
QImage::Format_RGBA8888);
|
||||
}
|
||||
|
||||
for (int y = 0; y < display_frame->height(); ++y) {
|
||||
@@ -1547,20 +1555,18 @@ bool ViewerDisplayWidget::DrawBackendNeutralTexture(const TexturePtr &texture,
|
||||
// Renders a backend-neutral frame by drawing into an offscreen backend texture,
|
||||
// downloading it to CPU memory, then painting that image with QPainter.
|
||||
void ViewerDisplayWidget::DrawBackendNeutral(const ColorTransformJob &ctj,
|
||||
QPainter *painter)
|
||||
QPainter *painter)
|
||||
{
|
||||
if (!painter || !painter->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int texture_width =
|
||||
static_cast<int>(width() * devicePixelRatioF());
|
||||
const int texture_height =
|
||||
static_cast<int>(height() * devicePixelRatioF());
|
||||
const int texture_width = static_cast<int>(width() * devicePixelRatioF());
|
||||
const int texture_height = static_cast<int>(height() * devicePixelRatioF());
|
||||
|
||||
const VideoParams offscreen_params(
|
||||
texture_width, texture_height, PixelFormat::U8,
|
||||
VideoParams::kRGBAChannelCount);
|
||||
const VideoParams offscreen_params(texture_width, texture_height,
|
||||
PixelFormat::U8,
|
||||
VideoParams::kRGBAChannelCount);
|
||||
|
||||
if (!backend_neutral_texture_ ||
|
||||
backend_neutral_texture_->params() != offscreen_params) {
|
||||
@@ -1570,7 +1576,7 @@ void ViewerDisplayWidget::DrawBackendNeutral(const ColorTransformJob &ctj,
|
||||
backend_neutral_buffer_.resize(
|
||||
texture_width * texture_height *
|
||||
VideoParams::GetBytesPerPixel(PixelFormat::U8,
|
||||
VideoParams::kRGBAChannelCount));
|
||||
VideoParams::kRGBAChannelCount));
|
||||
}
|
||||
|
||||
if (!backend_neutral_texture_ || backend_neutral_texture_->IsDummy()) {
|
||||
@@ -1589,11 +1595,10 @@ void ViewerDisplayWidget::DrawBackendNeutral(const ColorTransformJob &ctj,
|
||||
const int bytes_per_pixel = VideoParams::GetBytesPerPixel(
|
||||
PixelFormat::U8, VideoParams::kRGBAChannelCount);
|
||||
|
||||
QImage img(reinterpret_cast<const uchar *>(
|
||||
backend_neutral_buffer_.constData()),
|
||||
texture_width, texture_height,
|
||||
texture_width * bytes_per_pixel,
|
||||
QImage::Format_RGBA8888_Premultiplied);
|
||||
QImage img(
|
||||
reinterpret_cast<const uchar *>(backend_neutral_buffer_.constData()),
|
||||
texture_width, texture_height, texture_width * bytes_per_pixel,
|
||||
QImage::Format_RGBA8888_Premultiplied);
|
||||
img.setDevicePixelRatio(devicePixelRatioF());
|
||||
|
||||
// QImage references backend_neutral_buffer_ directly; draw it before the
|
||||
|
||||
@@ -336,7 +336,8 @@ private:
|
||||
|
||||
void DrawBackendNeutral(const ColorTransformJob &ctj, QPainter *painter);
|
||||
bool DrawBackendNeutralFrame(const FramePtr &frame, QPainter *painter);
|
||||
bool DrawBackendNeutralTexture(const TexturePtr &texture, QPainter *painter);
|
||||
bool DrawBackendNeutralTexture(const TexturePtr &texture,
|
||||
QPainter *painter);
|
||||
|
||||
/**
|
||||
* @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL().
|
||||
|
||||
@@ -38,10 +38,19 @@ struct ViewerPlaybackFrame {
|
||||
|
||||
class ViewerQueue : public std::list<ViewerPlaybackFrame> {
|
||||
public:
|
||||
ViewerQueue() : mutex_(new QMutex()) {}
|
||||
ViewerQueue()
|
||||
: mutex_(new QMutex())
|
||||
{
|
||||
}
|
||||
ViewerQueue(const ViewerQueue &other)
|
||||
: std::list<ViewerPlaybackFrame>(other), mutex_(new QMutex()) {}
|
||||
~ViewerQueue() { delete mutex_; }
|
||||
: std::list<ViewerPlaybackFrame>(other)
|
||||
, mutex_(new QMutex())
|
||||
{
|
||||
}
|
||||
~ViewerQueue()
|
||||
{
|
||||
delete mutex_;
|
||||
}
|
||||
ViewerQueue &operator=(const ViewerQueue &other)
|
||||
{
|
||||
std::list<ViewerPlaybackFrame>::operator=(other);
|
||||
|
||||
Reference in New Issue
Block a user