尝试修复粉紫屏未果

This commit is contained in:
2026-01-16 21:11:24 +08:00
parent 3f774dfa53
commit e851653fa3
30 changed files with 1377 additions and 238 deletions
+38 -9
View File
@@ -1270,6 +1270,7 @@ RenderTicketWatcher *ViewerWidget::RequestNextFrameForQueue(bool increment)
}
watcher = new RenderTicketWatcher();
watcher->setProperty("start", QDateTime::currentMSecsSinceEpoch());
watcher->setProperty("time", QVariant::fromValue(next_time));
DetectMulticamNode(next_time);
connect(watcher, &RenderTicketWatcher::Finished, this,
@@ -1283,6 +1284,10 @@ RenderTicketWatcher *ViewerWidget::RequestNextFrameForQueue(bool increment)
RenderTicketPtr ViewerWidget::GetFrame(const rational &t)
{
if (IsPlaying() || prequeuing_video_) {
return GetSingleFrame(t);
}
QString cache_fn =
GetConnectedNode()->video_frame_cache()->GetValidCacheFilename(t);
@@ -1447,21 +1452,45 @@ void ViewerWidget::RendererGeneratedFrameForQueue()
if (watcher->HasResult()) {
QVariant frame = watcher->Get();
bool drop_frame = false;
// 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 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) {
drop_frame = true;
}
rational ts = watcher->property("time").value<rational>();
foreach (ViewerDisplayWidget *dw, playback_devices_) {
QVariant push;
if (dynamic_cast<MulticamDisplay *>(dw)) {
push =
watcher->GetTicket()->property("multicam_output");
} else {
push = frame;
}
if (!drop_frame) {
foreach (ViewerDisplayWidget *dw, playback_devices_) {
const bool is_multicam =
dynamic_cast<MulticamDisplay *>(dw);
QVariant push;
if (is_multicam) {
push = watcher->GetTicket()->property(
"multicam_output");
if (!push.isValid() || push.isNull()) {
// Fall back to the primary frame when multicam isn't available.
push = frame;
}
} else {
push = frame;
}
dw->queue()->AppendTimewise({ ts, push }, playback_speed_);
dw->queue()->AppendTimewise({ ts, push },
playback_speed_);
}
}
if (prequeuing_video_) {
+30 -2
View File
@@ -38,6 +38,7 @@
#include "config/config.h"
#include "core.h"
#include "node/block/subtitle/subtitle.h"
#include "codec/frame.h"
#include "node/gizmo/path.h"
#include "node/gizmo/point.h"
#include "node/gizmo/polygon.h"
@@ -401,8 +402,35 @@ void ViewerDisplayWidget::OnPaint()
texture_->Upload(frame->data(), frame->linesize_pixels());
}
} else if (TexturePtr texture = load_frame_.value<TexturePtr>()) {
// This is a GPU texture, switch to it directly
texture_ = texture;
// This is a GPU texture, switch to it directly when possible.
if (texture && texture->renderer() &&
texture->renderer() != renderer()) {
bool copied = false;
QOpenGLContext *ctx = QOpenGLContext::currentContext();
if (ctx) {
QOpenGLFunctions *funcs = ctx->functions();
GLuint tex_id = texture->id().value<GLuint>();
if (funcs && tex_id && funcs->glIsTexture(tex_id)) {
FramePtr frame = Frame::Create();
frame->set_video_params(texture->params());
if (frame->allocate()) {
renderer()->DownloadFromTexture(
texture->id(), texture->params(),
frame->data(), frame->linesize_pixels());
texture_ = renderer()->CreateTexture(
frame->video_params(), frame->data(),
frame->linesize_pixels());
copied = true;
}
}
}
if (!copied) {
texture_ = texture;
}
} else {
texture_ = texture;
}
} else {
texture_ = LoadCustomTextureFromFrame(load_frame_);
}