Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
feat(ui-mig): complete trim-aware export slice
Veyra Goal Agent7444a2dbe943
diff --git a/CMakeLists.txt b/CMakeLists.txtindex c15512e6..c0090118 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -1,9 +1,9 @@cmake_minimum_required(VERSION 3.24)-project(veyra VERSION 1.4.4 LANGUAGES CXX RC)+project(veyra VERSION 2.0.0 LANGUAGES CXX RC)# Shown in the EXE's version resource and in the package name. CMake versions# must be numeric, so the beta marker lives here instead.-set(VEYRA_DISPLAY_VERSION "1.4.4beta" CACHE STRING "Human-readable version string")+set(VEYRA_DISPLAY_VERSION "2.0.0" CACHE STRING "Human-readable version string")# The cache keeps the first value it ever saw, so a release that bumps# project(VERSION) used to ship an EXE still stamped with the previous display# string. Re-align it whenever the cached label does not start with the project@@ -745,12 +745,13 @@ endif()# separate small library rather than into veyra_engine: the product build must# never depend on Qt being installed.if(VEYRA_BUILD_QML_UI AND Qt6_FOUND)- add_library(veyra_qml_bridge STATIC src/ui/QmlPlayerBridge.cpp include/veyra/ui/QmlPlayerBridge.h)+ add_library(veyra_qml_bridge STATIC src/ui/QmlPlayerBridge.cpp src/ui/ThumbnailProvider.cpp+ include/veyra/ui/QmlPlayerBridge.h include/veyra/ui/ThumbnailProvider.h)# AUTOMOC: QmlPlayerBridge declares Q_OBJECT, so its meta-object has to be# generated. Without this the library links but every signal is unresolved.set_target_properties(veyra_qml_bridge PROPERTIES AUTOMOC ON)target_compile_features(veyra_qml_bridge PRIVATE cxx_std_20)- target_include_directories(veyra_qml_bridge PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)+ target_include_directories(veyra_qml_bridge PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src ${FFMPEG_INCLUDE_DIRS})# Widgets is needed only for QFileDialog: the native file picker is the one# piece of the old shell worth keeping, and its own dialog is what users# expect from a desktop app. No QWidget UI is created.@@ -766,7 +767,7 @@ if(VEYRA_BUILD_QML_UI AND Qt6_FOUND)# WIN32: a GUI subsystem binary. Without it a console window follows the app# around, which is not what a player should look like. Diagnostics still reach# the log file through the logger.- add_executable(veyra_qml_ui WIN32 apps/veyra-qml/main.cpp)+ add_executable(veyra_qml_ui WIN32 apps/veyra-qml/main.cpp src/ui/QmlDataDirectory.cpp)add_custom_command(TARGET veyra_qml_ui POST_BUILDCOMMAND ${CMAKE_COMMAND} -E copy_directory${CMAKE_CURRENT_SOURCE_DIR}/qml $<TARGET_FILE_DIR:veyra_qml_ui>/qml)@@ -774,6 +775,10 @@ if(VEYRA_BUILD_QML_UI AND Qt6_FOUND)# Qt6::CorePrivate only for QUnifiedTimer's slow mode behind --slow-animations.target_link_libraries(veyra_qml_ui PRIVATE veyra_qml_bridge veyra_engine Qt6::CorePrivate)+ add_executable(veyra_qml_data_tests tests/unit/QmlDataDirectoryTests.cpp src/ui/QmlDataDirectory.cpp)+ target_compile_features(veyra_qml_data_tests PRIVATE cxx_std_20)+ target_include_directories(veyra_qml_data_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)+# G0.6: Theme easing curves read back through QML against the design's CSS curves.# Loads qml/ from the source tree; runs offscreen with the Qt bin directory on PATH.add_executable(veyra_qml_easing_tests tests/qml/QmlEasingTests.cpp)@@ -1076,10 +1081,20 @@ if(VEYRA_CLIP_TOOLS_ROOT AND EXISTS "${VEYRA_CLIP_TOOLS_ROOT}/include/libavcodecendif()# Layered child subtitle windows require a modern-Windows compatibility manifest.+set(VEYRA_RESOURCE_FILENAME "Veyra.exe")configure_file(apps/veyra/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/veyra-version.rc @ONLY)+if(TARGET veyra_qml_ui)+ set(VEYRA_RESOURCE_FILENAME "veyra_qml_ui.exe")+ configure_file(apps/veyra/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/veyra-qml-version.rc @ONLY)+ target_sources(veyra_qml_ui PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/veyra-qml-version.rc)+endif()configure_file(apps/veyra/resource.h ${CMAKE_CURRENT_BINARY_DIR}/veyra-resource.h COPYONLY)configure_file(assets/veyra.ico ${CMAKE_CURRENT_BINARY_DIR}/veyra.ico COPYONLY)target_sources(veyra PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/veyra-version.rc)set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/veyra-version.rc PROPERTIESOBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets/veyra.ico;${CMAKE_CURRENT_SOURCE_DIR}/apps/veyra/resource.h")+if(TARGET veyra_qml_ui)+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/veyra-qml-version.rc PROPERTIES+ OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets/veyra.ico;${CMAKE_CURRENT_SOURCE_DIR}/apps/veyra/resource.h")+endif()target_link_options(veyra PRIVATE "/MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/apps/veyra/veyra.manifest")diff --git a/apps/veyra-qml/main.cpp b/apps/veyra-qml/main.cppindex c8539f71..d33b9adf 100644--- a/apps/veyra-qml/main.cpp+++ b/apps/veyra-qml/main.cpp@@ -10,7 +10,7 @@// "videoHost": when that item moves or resizes, this code moves the native// window to match. That keeps the layout in QML (where it belongs) and the// pixels in D3D12 (where the latency budget lives).-#include <QGuiApplication>+#include <QApplication>#include <QQmlApplicationEngine>#include <QQmlContext>#include <QQuickItem>@@ -27,18 +27,62 @@#include <windows.h>#include <cmath>+#include <cstdlib>+#include <cstring>#include <format>#include <memory>#include "veyra/Log.h"#include "veyra/RuntimePaths.h"#include "veyra/engine/EngineController.h"+#include "veyra/engine/ExportJobManager.h"+#include "veyra/ui/QmlDataDirectory.h"#include "veyra/ui/QmlPlayerBridge.h"+#include "veyra/ui/ThumbnailProvider.h"using namespace veyra;namespace {HWND g_video = nullptr;+enum class VideoProbeMode { Normal, Hidden, NoRegion, CoversOnly };+VideoProbeMode g_videoProbe = VideoProbeMode::Normal;+bool g_videoHiddenByProbe = false;++const char* videoProbeName() {+ switch (g_videoProbe) {+ case VideoProbeMode::Hidden: return "hidden";+ case VideoProbeMode::NoRegion: return "no-region";+ case VideoProbeMode::CoversOnly: return "covers-only";+ default: return "normal";+ }+}++void logVideoWindowState(QQuickWindow* window, QQuickItem* host, const char* event) {+ if (!window || !host || !g_video) return;+ const HWND parent = GetParent(g_video);+ RECT parentClient{}, client{}, screen{};+ GetClientRect(parent, &parentClient);+ GetClientRect(g_video, &client);+ GetWindowRect(g_video, &screen);+ HRGN region = CreateRectRgn(0, 0, 0, 0);+ const int regionType = GetWindowRgn(g_video, region);+ RECT regionBox{};+ const int regionBoxType = GetRgnBox(region, ®ionBox);+ DeleteObject(region);+ const QPointF scene = host->mapToScene(QPointF(0, 0));+ veyra::log::info("qml-window", std::format(+ "{} probe={} root={}x{} dpr={:.3f} host=({:.1f},{:.1f}) {:.1f}x{:.1f} "+ "parent={} parentClient={}x{} client={}x{} screen=({},{}) {}x{} "+ "style=0x{:X} visible={} regionType={} regionBoxType={} regionBox=({},{}) {}x{}",+ event, videoProbeName(), window->width(), window->height(), window->devicePixelRatio(),+ scene.x(), scene.y(), host->width(), host->height(), parent != nullptr,+ parentClient.right, parentClient.bottom, client.right, client.bottom,+ screen.left, screen.top, screen.right - screen.left, screen.bottom - screen.top,+ static_cast<unsigned long long>(GetWindowLongPtrW(g_video, GWL_STYLE)),+ IsWindowVisible(g_video) != 0, regionType, regionBoxType,+ regionBox.left, regionBox.top, regionBox.right - regionBox.left,+ regionBox.bottom - regionBox.top));+}LRESULT CALLBACK videoProc(HWND h, UINT m, WPARAM w, LPARAM l) {// The engine owns this window's pixels. Qt must not paint it, or the two@@ -77,10 +121,17 @@ HWND createVideoWindow() {// Places the native video window at the QML item's position. Qt reports the// item's geometry in scene coordinates, which for a child of the window's// content item are already window-relative.-void syncVideoGeometry(QQuickWindow* window, QQuickItem* host) {- if (!window || !host || !g_video) return;+bool syncVideoGeometry(QQuickWindow* window, QQuickItem* host) {+ if (!window || !host || !g_video || GetParent(g_video) != reinterpret_cast<HWND>(window->winId()))+ return false;const QPointF topLeft = host->mapToScene(QPointF(0, 0));const qreal dpr = window->devicePixelRatio();+ if (host->width() < 1 || host->height() < 1 ||+ topLeft.x() + host->width() <= 0 || topLeft.y() + host->height() <= 0 ||+ topLeft.x() >= window->width() || topLeft.y() >= window->height()) {+ if (IsWindowVisible(g_video)) ShowWindow(g_video, SW_HIDE);+ return false;+ }// A fractional size is a resize artifact, not intent: floor it so the// swapchain never alternates between two sizes on alternating frames.const int x = int(std::floor(topLeft.x() * dpr));@@ -90,9 +141,16 @@ void syncVideoGeometry(QQuickWindow* window, QQuickItem* host) {// Called every rendered frame: only a changed rect reaches the window manager,// so a moving popover never makes the presenter see a spurious resize.static RECT last{-1, -1, -1, -1};- if (IsWindowVisible(g_video) && last.left == x && last.top == y && last.right == w && last.bottom == h) return;+ if (IsWindowVisible(g_video) && last.left == x && last.top == y && last.right == w && last.bottom == h) return true;last = RECT{x, y, w, h};- SetWindowPos(g_video, HWND_TOP, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);+ SetLastError(0);+ const BOOL placed = SetWindowPos(g_video, HWND_TOP, x, y, w, h,+ SWP_NOACTIVATE | (g_videoHiddenByProbe ? 0 : SWP_SHOWWINDOW));+ const DWORD error = placed ? 0 : GetLastError();+ veyra::log::info("qml-window", std::format(+ "SetWindowPos rect=({},{}) {}x{} result={} error={}", x, y, w, h, placed != 0, error));+ logVideoWindowState(window, host, "geometry");+ return placed != 0;}struct Cover { QRectF rect; qreal radius = 0; };@@ -144,6 +202,7 @@ void collectCovers(QQuickItem* item, QList<Cover>& out) {// moves or the cineIn inset changes; with neither the window gets its rectangle back.void syncVideoCovers(QQuickWindow* window, QQuickItem* host, qreal inset) {if (!window || !host || !g_video) return;+ if (g_videoProbe == VideoProbeMode::CoversOnly) inset = 0;QList<Cover> covers;collectCovers(window->contentItem()->parentItem() ? window->contentItem()->parentItem(): window->contentItem(), covers);@@ -164,10 +223,18 @@ void syncVideoCovers(QQuickWindow* window, QQuickItem* host, qreal inset) {const int insetBand = int(std::round(inset * h));{QList<QRect> key = holes;- key << QRect(0, 0, insetBand, 0);+ key << QRect(0, 0, insetBand, 0) << QRect(0, 0, w, h);if (key == last) return;last = key;}+ if (g_videoProbe == VideoProbeMode::NoRegion) {+ SetLastError(0);+ const int result = SetWindowRgn(g_video, nullptr, TRUE);+ veyra::log::info("qml-window", std::format(+ "SetWindowRgn no-region result={} error={}", result, result ? 0 : GetLastError()));+ logVideoWindowState(window, host, "region");+ return;+ }// Covers win: a popover over the picture shows the QML beneath it, and the// clip inset only ever runs without one. A cover opening mid-animation simply// takes the whole rectangle back for as long as it is up.@@ -176,14 +243,28 @@ void syncVideoCovers(QQuickWindow* window, QQuickItem* host, qreal inset) {// bottom, corners eased with the band so the last frame has no snap.const int radius = std::max(2, int(std::round(8 * dpr * (inset / 0.12))));HRGN band = CreateRoundRectRgn(0, insetBand, w + 1, h - insetBand + 1, radius, radius);- SetWindowRgn(g_video, band, TRUE);+ SetLastError(0);+ const int result = SetWindowRgn(g_video, band, TRUE);+ const DWORD error = result ? 0 : GetLastError();+ if (!result) DeleteObject(band);+ veyra::log::info("qml-window", std::format(+ "SetWindowRgn inset={}x{} band={} result={} error={}",+ w, h, insetBand, result, error));+ logVideoWindowState(window, host, "region");// The picture is a native window PrintWindow cannot show, so the cineIn// animation is evidenced here rather than in a screenshot.veyra::log::info("qml", std::format("cineIn inset band={}px of {} (frac={:.3f}) radius={}",insetBand, h, inset, radius));return;}- if (holes.isEmpty()) { SetWindowRgn(g_video, nullptr, TRUE); return; }+ if (holes.isEmpty()) {+ SetLastError(0);+ const int result = SetWindowRgn(g_video, nullptr, TRUE);+ veyra::log::info("qml-window", std::format(+ "SetWindowRgn full={}x{} result={} error={}", w, h, result, result ? 0 : GetLastError()));+ logVideoWindowState(window, host, "region");+ return;+ }HRGN region = CreateRectRgn(0, 0, w, h);for (qsizetype i = 0; i + 1 < holes.size(); i += 2) {const QRect& hole = holes[i];@@ -194,11 +275,30 @@ void syncVideoCovers(QQuickWindow* window, QQuickItem* host, qreal inset) {CombineRgn(region, region, cut, RGN_DIFF);DeleteObject(cut);}- SetWindowRgn(g_video, region, TRUE); // the system owns the region from here+ SetLastError(0);+ const int result = SetWindowRgn(g_video, region, TRUE); // the system owns the region on success+ const DWORD error = result ? 0 : GetLastError();+ if (!result) DeleteObject(region);+ veyra::log::info("qml-window", std::format(+ "SetWindowRgn covers={} size={}x{} result={} error={}",+ covers.size(), w, h, result, error));+ logVideoWindowState(window, host, "region");}} // namespaceint main(int argc, char** argv) {+ // ExportJobManager relaunches the owning executable with an inherited mapping.+ // Dispatch before Qt or the video HWND exists, as the Win32 shell does.+ if (argc > 1 && std::strcmp(argv[1], "--export-worker") == 0) {+ if (argc != 3) return 2;+ char* end = nullptr;+ const auto value = std::strtoull(argv[2], &end, 10);+ if (!value || !end || *end != '\0') return 2;+ const HRESULT com = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);+ const int result = engine::runExportWorker(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(value)));+ if (SUCCEEDED(com)) CoUninitialize();+ return result;+ }// A log file has to be opened explicitly; without this the QML app produced// no diagnostics at all, which made every failure look like a silent exit.// Same path and override as the Win32 build, so support instructions do not@@ -213,7 +313,7 @@ int main(int argc, char** argv) {(void)veyra::Logger::instance().openFile(logPath.wstring(), true);}- QGuiApplication app(argc, argv);+ QApplication app(argc, argv);app.setApplicationName(QStringLiteral("Veyra"));app.setOrganizationName(QStringLiteral("Veyra"));veyra::log::info("app", "Veyra QML session started");@@ -224,19 +324,32 @@ int main(int argc, char** argv) {// HWND as soon as the user opens something.g_video = createVideoWindow();- // The data directory mirrors what the Win32 build used, so presets and the- // session file carry over instead of starting empty. `--data-dir <path>` (a- // test switch) points it somewhere else, so a review run can show seeded- // history - recent files, the last capture session - without reading or- // rewriting the user's own.- std::filesystem::path dataDirectory;+ // Keep 2.0.0 settings separate from 1.4.4 so the old executable remains a+ // working rollback. An explicit data directory is for isolated runs and is+ // never populated from the user's old settings.+ std::filesystem::path dataDirectory = veyra::runtime::localDataDirectory() / L"user-data-2.0.0";+ std::filesystem::path legacyDirectory = veyra::runtime::localDataDirectory();+ bool explicitDataDirectory = false;{const QStringList early = QCoreApplication::arguments();const auto at = early.indexOf(QStringLiteral("--data-dir"));if (at > 0 && at + 1 < early.size()) {dataDirectory = std::filesystem::path(early.at(at + 1).toStdWString());+ explicitDataDirectory = true;veyra::log::info("app", "test data directory " + early.at(at + 1).toStdString());}+ const auto importAt = early.indexOf(QStringLiteral("--import-1.4.4-data"));+ if (importAt > 0 && importAt + 1 < early.size())+ legacyDirectory = std::filesystem::path(early.at(importAt + 1).toStdWString());+ }+ if (!explicitDataDirectory) {+ const auto migration = ui::prepareQmlDataDirectory(legacyDirectory, dataDirectory);+ if (!migration.ok) {+ veyra::log::error("app", "2.0.0 data migration failed: " + migration.error);+ return 2;+ }+ veyra::log::info("app", std::format("2.0.0 data directory ready; copied {} legacy files",+ migration.copied));}ui::QmlPlayerBridge bridge(controller, dataDirectory);bridge.attachVideoWindow(reinterpret_cast<qulonglong>(g_video));@@ -253,6 +366,10 @@ int main(int argc, char** argv) {});QQmlApplicationEngine engine;+ auto* thumbnails = new ui::ThumbnailProvider;+ engine.addImageProvider(QStringLiteral("veyra-thumb"), thumbnails);+ QObject::connect(&bridge, &ui::QmlPlayerBridge::thumbnailSourceChanged, &app,+ [thumbnails](const QString& path) { thumbnails->setSource(path); });engine.addImportPath(QCoreApplication::applicationDirPath() + "/qml");engine.rootContext()->setContextProperty(QStringLiteral("veyra"), &bridge);@@ -277,9 +394,11 @@ int main(int argc, char** argv) {// --full-bar <shown|hidden> fullscreen with the control window held shown / hidden// --full-debug log every pointer movement the fullscreen controls see// --data-dir <path> presets and session history from that folder (read before the bridge exists)+ // --import-1.4.4-data <path> read-only legacy settings source for first 2.0.0 launch// --motion-probe <name> dock | page | switch | seg | menu: start that motion, log its value per frame// --exit-after <ms> quit the app by itself after N ms, so a test run ends// through the engine's own teardown instead of a kill+ // --video-probe <normal|hidden|no-region|covers-only> native-window diagnosisconst QStringList args = QCoreApplication::arguments();QString openPath;QVariantMap testOptions;@@ -310,6 +429,8 @@ int main(int argc, char** argv) {testOptions.insert(QStringLiteral("fullDebug"), true);} else if (a == QLatin1String("--data-dir") && hasValue) {++i; // handled before the bridge was created+ } else if (a == QLatin1String("--import-1.4.4-data") && hasValue) {+ ++i; // handled before the bridge was created} else if (a == QLatin1String("--dock-pinned")) {testOptions.insert(QStringLiteral("dockPinned"), true);} else if (a == QLatin1String("--size") && hasValue) {@@ -319,6 +440,16 @@ int main(int argc, char** argv) {testOptions.insert(QStringLiteral("motionProbe"), args.at(++i));} else if (a == QLatin1String("--exit-after") && hasValue) {exitAfterMs = args.at(++i).toInt();+ } else if (a == QLatin1String("--video-probe") && hasValue) {+ const QString mode = args.at(++i);+ if (mode == QLatin1String("hidden")) g_videoProbe = VideoProbeMode::Hidden;+ else if (mode == QLatin1String("no-region")) g_videoProbe = VideoProbeMode::NoRegion;+ else if (mode == QLatin1String("covers-only")) g_videoProbe = VideoProbeMode::CoversOnly;+ else if (mode != QLatin1String("normal")) {+ veyra::log::error("qml-window", "invalid video probe mode " + mode.toStdString());+ return 2;+ }+ g_videoHiddenByProbe = g_videoProbe == VideoProbeMode::Hidden;} else if (a == QLatin1String("--reduced-motion")) {testOptions.insert(QStringLiteral("reducedMotion"), true);} else if (a == QLatin1String("--slow-animations") && hasValue) {@@ -339,6 +470,7 @@ int main(int argc, char** argv) {veyra::log::info("qml", std::format("test switches: {} size={}x{}",QStringList(testOptions.keys()).join(',').toStdString(),testSize.width(), testSize.height()));+ veyra::log::info("qml-window", std::format("probe mode={}", videoProbeName()));engine.rootContext()->setContextProperty(QStringLiteral("vyTest"), testOptions);if (!openPath.isEmpty()) {QTimer::singleShot(600, &bridge, [&bridge, openPath] { bridge.openPath(openPath); });@@ -395,12 +527,19 @@ int main(int argc, char** argv) {// signals alone were not enough: the first layout pass can leave the host at its// default 0x0 with no change to observe, which is how the engine once built a// swapchain from a 1x1 window. The native calls only run when a value changed.- auto follow = [window] {+ auto follow = [window, &bridge] {if (!g_video) return;- // Safety net: the pre-open hook parents the window before the engine reads- // its size, but a resize before any open must also keep it in place.- if (GetParent(g_video) == nullptr)- SetParent(g_video, reinterpret_cast<HWND>(window->winId()));+ // Only the pre-open hook attaches the popup and converts it to WS_CHILD.+ // GetParent() is null for an unattached WS_POPUP, so reparenting here on+ // every animation frame can starve input and timers before any source opens.+ if (!bridge.hasSource()) {+ if (bridge.openingSource()) return;+ if (IsWindowVisible(g_video)) {+ veyra::log::info("qml-window", "follow: hide video because source snapshot is inactive");+ ShowWindow(g_video, SW_HIDE);+ }+ return;+ }static QPointer<QQuickItem> host;if (!host) {host = window->findChild<QQuickItem*>(QStringLiteral("videoHost"));@@ -420,8 +559,8 @@ int main(int argc, char** argv) {veyra::log::info("qml", std::format("video host geometry {}x{} at {},{}",w, h, int(host->x()), int(host->y())));}- syncVideoGeometry(window, host);- syncVideoCovers(window, host, sceneInsetFraction(window));+ if (syncVideoGeometry(window, host))+ syncVideoCovers(window, host, sceneInsetFraction(window));};// V held shows the original picture on the professional page (AppShell: the// OriginalHold key, engine.comparison(1, false) until release). A Shortcut only@@ -450,13 +589,14 @@ int main(int argc, char** argv) {};window->installEventFilter(new HoldOriginalFilter(window, &bridge));QObject::connect(window, &QQuickWindow::afterAnimating, &app, follow);+ QObject::connect(&bridge, &ui::QmlPlayerBridge::snapshotChanged, &app, follow);// The first frame may come before the page layout settles; one pass after the// event loop starts covers a scene that then never animates.QTimer::singleShot(0, &app, follow);// Before every open, place the native window and force the pending layout to// be applied so the client size the presenter reads is the real one.- bridge.setPreOpenHook([window] {+ bridge.setPreOpenHook([window, &bridge] {auto* host = window->findChild<QQuickItem*>(QStringLiteral("videoHost"));veyra::log::info("qml", std::format("pre-open: host={} size={}x{} contentChildren={}",host != nullptr,@@ -475,8 +615,17 @@ int main(int argc, char** argv) {SetWindowLongPtrW(g_video, GWL_STYLE,(style & ~(WS_POPUP)) | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);}- if (host) syncVideoGeometry(window, host);+ const bool validHost = host && syncVideoGeometry(window, host);+ if (!validHost) {+ veyra::log::error("qml-window", "pre-open: video host has no valid client rectangle");+ return;+ }+ const BOOL wasVisible = IsWindowVisible(g_video);ShowWindow(g_video, SW_SHOWNA);+ veyra::log::info("qml-window", std::format(+ "pre-open: show video wasVisible={} nowVisible={} sourceSnapshot={}",+ wasVisible != 0, IsWindowVisible(g_video) != 0, bridge.hasSource()));+ if (g_videoHiddenByProbe) ShowWindow(g_video, SW_HIDE);UpdateWindow(g_video);// Report the native window's own client rect, not the QML item's: the// presenter builds its swapchain from this, and the two sizes can differ.diff --git a/apps/veyra/version.rc.in b/apps/veyra/version.rc.inindex 78fba979..18de45b0 100644--- a/apps/veyra/version.rc.in+++ b/apps/veyra/version.rc.in@@ -17,7 +17,7 @@ BEGINVALUE "FileVersion", "@VEYRA_DISPLAY_VERSION@"VALUE "ProductName", "Veyra"VALUE "ProductVersion", "@VEYRA_DISPLAY_VERSION@"- VALUE "OriginalFilename", "Veyra.exe"+ VALUE "OriginalFilename", "@VEYRA_RESOURCE_FILENAME@"VALUE "LegalCopyright", "Veyra contributors. GPL-3.0."ENDENDdiff --git a/docs/UI_FULL_GOAL_PLAN_2026-09-26.md b/docs/UI_FULL_GOAL_PLAN_2026-09-26.mdindex c19e3d23..3981c8ba 100644--- a/docs/UI_FULL_GOAL_PLAN_2026-09-26.md+++ b/docs/UI_FULL_GOAL_PLAN_2026-09-26.md@@ -8,6 +8,7 @@## 0. 续接指针(当前施工以恢复计划为准)当前入口:`docs/UI_MIGRATION_RECOVERY_PLAN_2026-09-26.md`。+本轮新增交付边界:开发版本为 2.0.0;用户确认完成前保持 1.4.4 程序、配置和源码可独立回退。版本/数据隔离/回退门槛见恢复计划,不以本页旧版“删除 Win32 界面”步骤提前覆盖。旧 G/B 阶段保留作历史记录;在 R0/R1 通过前不得按原线性队列推进 G3.3、G3.4 或 B1-B5。局部问题 R1.1(播放条字幕/音轨菜单遮挡)已在真实片源窗口复查;音轨菜单打开后高度变化的定位缺陷已修。证据在 `goal/r0/menu-*-after.png`,Quick Test 9/9。此项不代表 R0/R1 窗口分层总验收完成,也不代表字幕流已接入。@@ -16,9 +17,9 @@| G0 工具与基线 | 完成 | checkpoint/ui-mig-g0.7 | 设计参考 `design-ref/`、对比 `compare/`、动效曲线 `goal/g0.5/`、缓动测试 `veyra_qml_easing_tests`(构建目录 `build/qt-probe-20260926`)、门槛基线 `goal/g0.7/`(B 阶段性能对比用 `goal/g0.7/perf`) || G1 基础(缓动/背景/字体/图标/组件动效) | 完成 | checkpoint/ui-mig-g1.6 | G1.1–G1.6 完成(Qt 6.8.3:BezierSpline ≤10 段;CurveRenderer 不能用 fillItem;可变字体 600 须设 wght 轴;Popup 无 transform;视频子窗用 videoCover 挖区);动效探针 dock/page/switch/seg/menu/dialog;Quick Test 8/8;M28/M29 曲线未执行;下一步 G2 || G2 外壳 | 完成 | checkpoint/ui-mig-g2.5 | G2.1 dock 热区;G2.2 页面切换 sink/rise(探针同曲线);G2.3 视频窗随渲染帧同步;G2.4 拖放/快捷键/V 看原画/电源/导出徽标/toast;G2.5 全屏独立控制窗(CineBar 抽出共用)、1.6s 自动隐藏、Ctrl+L 锁定——PresentMon 未安装,用引擎 present P95 对比显示/隐藏无退化(D1 保留独立窗);显示器休眠期间截图未执行(拖放后画面、全屏条待亮屏复拍);下一步 G3 |-| G3 四主屏 | 阻塞于 R0/R1 | checkpoint/ui-mig-g3.1 | G3.1 首页代码存在;G3.2 的用户黑面问题未定位,先按恢复计划 R0/R1 处理 |-| B1 小项 + 桥接补齐 | 未开始 | | |-| B2 导出补齐(S2.5) | 未开始 | | |+| G3 四主屏 | 进行中(G3.1 完成;极简页小细节暂缓) | checkpoint/ui-mig-g3.1 | R0/R1 窗口分层尚未做完整总验收;用户要求先继续前后端主线 |+| B1 小项 + 桥接补齐 | 部分完成(按垂直切片) | checkpoint/ui-mig-r5.2-a | 预设隔离、导出状态桥接已落地;B1 其余能力仍未完成 |+| B2 导出补齐(S2.5) | 进行中(R5.2-a/b) | checkpoint/ui-mig-r5.2-b | 已接独立导出预设、分辨率、码率、音轨、剪辑入出点;队列/码率模式/ETA/取消验收仍未完成 || B3 独立调色 pass(S2.2) | 未开始 | | || B4 可排序执行器(S2.3) | 未开始 | | || B5 节点链运行(S2.4) | 未开始 | | |diff --git a/docs/UI_MIGRATION_EXECUTION_2026-09-25.md b/docs/UI_MIGRATION_EXECUTION_2026-09-25.mdindex 64705668..e8910d54 100644--- a/docs/UI_MIGRATION_EXECUTION_2026-09-25.md+++ b/docs/UI_MIGRATION_EXECUTION_2026-09-25.md@@ -272,4 +272,11 @@- 1080p NR:提交 P95 0.92 ms,GPU 就绪 P95 8.09 ms,NR 5.78 ms,60 fps,跳帧 0- 1080p NR + 2X:提交 1.28 ms,GPU 就绪 9.41 ms,120 fps,跳帧 0- 4K NR + 2X:提交 1.38 ms,GPU 就绪 12.46 ms,120 fps,跳帧 0- - 1080p 无增强:提交 0.13 ms,GPU 就绪 1.57 ms+- 1080p 无增强:提交 0.13 ms,GPU 就绪 1.57 ms++### R5.2-b(2026-09-26)导出剪辑入出点+- 在 R5.2-a 的独立导出预设、分辨率、码率和音轨选择上,`PlayerOptions`、导出 worker 共享内存和 `VideoExportJob` 增加入点/出点。视频从入点后的首个完整帧起写,音频丢弃剪辑原点之前的数据并重置时间戳,出点停止写入,进度按剪辑时长计算;换源清空旧范围。+- `ExportPage.qml` 的两个入/出点 slider 与桥接真实属性绑定;`tools/export_probe/main.cpp` 增加 `--trim-start`、`--trim-end`、`--audio-stream`。+- 构建命令:`cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && cmake --build E:\项目\Veyra\build\qt-probe-20260926 --target veyra_qml_ui veyra_qml_quick_tests veyra_export_probe --parallel 4'`,exit 0;产物在 `E:\项目\Veyra\build\qt-probe-20260926\`,探针 staging 在 `E:\项目\Veyra\tests\ui-qml-migration-20260925\app\veyra_export_probe.exe`。+- `audio-tracks-fixture.mkv`:`2→5s` exit 0,91 源帧/91 编码帧,视频约 3.033333s、音频约 3.029s;stream 2 英语音轨同样通过。非法 `5→2s` exit 1,证据 `E:\项目\Veyra\logs\ui-qml-migration-20260926\invalid-range.txt`。`7.9→8.02s` 输出 3 帧、约 0.100333s;`7.98→8.02s` 无入点之后的完整帧而拒绝,符合当前合同。日志显示 RTX 5070 / NVENC / D3D12,未发生 GPU→CPU 视频回读。+- Quick Test:`tools/qt_probe/run-quick-tests.ps1 -Out E:\项目\Veyra\logs\ui-qml-migration-20260925\goal\r5.2-b-trim\quick-tests.txt`,9 passed, 0 failed。slider 目视截图、拖动/点击跳转回归、R0/R1 窗口分层总验收:未执行(用户要求暂缓小 UI 细节)。diff --git a/docs/UI_MIGRATION_RECOVERY_PLAN_2026-09-26.md b/docs/UI_MIGRATION_RECOVERY_PLAN_2026-09-26.mdindex 3be21ed0..9023905b 100644--- a/docs/UI_MIGRATION_RECOVERY_PLAN_2026-09-26.md+++ b/docs/UI_MIGRATION_RECOVERY_PLAN_2026-09-26.md@@ -4,23 +4,31 @@## 目标-交付一个能真实打开视频、正常显示 QML 界面、保留现有播放链路和低延迟特性的 QML 前端。17 屏逐屏对齐、后端升级和旧 Win32 删除都属于后续目标;在视频窗口分层稳定前,不继续扩展页面功能。+交付 Veyra 2.0.0:真实播放的 QML 前端与设计稿 17 屏对齐,完成计划内后端能力,同时保持 1.4.4 的低延迟播放路径。用户确认 2.0.0 完成以前,必须随时能运行未改动的 1.4.4。窗口分层稳定前,不扩展页面功能。++## 2.0.0 与 1.4.4 回退合同++- `v1.4.4` 标签固定在 `6851c277`;本机便携包 `E:\项目\Veyra\releases\1.4.4\final\Veyra-1.4.4-win64-portable.zip` 的 SHA-256 为 `BFF5149B55F8665FEBEAECEEE421956DF72370FA56515A013EE6ABBD45B8878B`,与同目录校验文件一致。禁止覆盖该包、解压目录、标签或 1.4.4 的构建入口。+- 2.0.0 在当前迁移分支和独立构建/测试目录中开发;版本资源、应用内版本和后续包名统一为 `2.0.0`。这不是发布授权。+- 2.0.0 默认用户数据与 1.4.4 分开。首次迁移只读取 1.4.4 配置并复制到 2.0.0 数据目录,不反写旧文件;格式升级须保留原文件和可重试路径。测试继续使用 `--data-dir` 指向隔离目录。+- 每个影响设置、预设或运行组件的阶段都验证 1.4.4 便携版仍可独立启动、旧数据未被 2.0.0 改写。回退是启动原版程序并保留原配置,不是对工作分支执行 `git reset --hard`。+- 用户确认 2.0.0 前保留旧 Win32 入口、1.4.4 便携包和源码标签;删除旧 UI、替换默认入口与发布均需放在最终验收门槛之后,且不自动合并、推送或发布。## 当前判断-- 当前工作区干净,HEAD 为 `73b26ba`,最后有效 UI 标签为 `checkpoint/ui-mig-wip-handoff-2`。-- G0/G1/G2/G3.1 的代码和部分证据存在,但 G3.2 未验收。-- 用户报告的“只有一黑条”是 P0 阻塞问题。它发生在真实视频 HWND 出现后,首要嫌疑是原生 D3D12 子窗口覆盖 Qt Quick 场景,叠加 DPR、child 坐标和 `SetWindowRgn` 区域计算。-- 536e7fe 新增的 `cineIn` region 裁剪没有完成真实画面验收,不能视为已验证功能。-- 现有截图工具不能证明原生视频窗内容;PrintWindow 黑图只能证明采集限制,不能证明 UI 正常或异常。-- B1-B5、G3.3、G3.4、G4、W 尚未开始,不能并行伪装成已完成。+- 当前 HEAD 为 `8a1be6a`,最后 UI 标签为 `checkpoint/ui-mig-r1.1`;工作区包含已授权的 R5.2-a/b 改动。+- G0/G1/G2/G3.1 已有代码和证据;R1.1 只修复字幕/音轨菜单遮挡局部问题,R0/R1 窗口分层尚未做完整总验收。+- 用户已确认先继续前后端主线,进度条缩略图、拖动/点击跳转等小 UI 细节暂缓;未验收项仍必须保留“未执行”口径。+- R5.2-a 已完成:导出预设、分辨率和码率状态与播放设置隔离,真实导出探针通过。+- R5.2-b 已完成主路径:剪辑入出点、音轨选择、音画同步和 NVIDIA 零拷贝导出通过;非法范围拒绝;接近文件尾部若没有“入点之后的完整帧”会按合同拒绝。+- B1/B2 其余能力、G3.3、G3.4、G4、W 尚未完成,不能把垂直切片写成整块 B 阶段完成。## 施工规则1. 一次只改变一个主要变量。每个目标必须有构建、运行、原始 stdout 或日志、截图(如适用)和明确结论。2. 目标模式每次只承诺一个可验收目标,不把“继续做前端”当作目标。3. 未执行的项目必须写“未执行”。不能用 PrintWindow 黑图代替实机画面结论,不能用编译通过代替运行通过。-4. 先保留回退点,再改代码。P0 修复期间不做页面美化、后端新能力或架构大重构。+4. 先保留回退点,再改代码。P0 诊断期间不做页面美化或后端新能力;R0 归因后允许用最小可测的窗口分层调整修复根因。5. 产物写入 `E:\项目\Veyra\`;仅对子进程设置 `TEMP/TMP`。不 push、不合并 main、不发布。6. 任何运行库身份不符、`nvngx_dlssnr.dll` 不符、许可证或第三方来源不清,立即停止该目标。@@ -41,13 +49,13 @@3. 打开片源、视频窗显示、禁用所有 region;4. 打开片源、只启用现有 cover region;`cineIn` 单独关闭。-**通过条件**:能明确指出哪一个状态首次覆盖 QML,且有 stdout/日志原始证据和用户可看的实机截图。若无法区分,R0 不通过,不进入 R1。+**通过条件**:正常用户路径(不带页面/动画测试参数)可复现,并能明确指出哪一个状态首次覆盖 QML;有 stdout/日志原始证据和实际屏幕采集。PrintWindow 仅作 QML 层辅助证据。若无法区分,R0 不通过,不进入 R1。### R1:恢复稳定的视频/QML分层**目的**:修复 R0 指出的单一根因,先让“打开视频后 QML 仍可见”稳定。-**默认策略**:先关闭 `cineIn` region 和不必要的全窗 region,恢复到最后一个能显示 QML 的最小路径;只有证据证明 cover region 必须保留时才逐个恢复。+**策略**:先据 R0 归因做最小修复,验证视频与 QML 同时可见。随后单独比较当前挖区方案与“原生视频 HWND + 单一透明 QML overlay”候选:真实播放、菜单/对话框、全屏、缩放、DPI 与窗口失焦恢复。只有后者的合成、命中测试、Present P95 和提交间隔均通过,才替换当前分层。此前讨论的 overlay 是待验证方案,不把简单探针数据当作产品性能结论。**通过条件**:正常用户路径打开本地视频,首页/极简页/专业页均可见;无视频时原生窗不遮挡 QML;没有用假色块代替视频;至少一次真实屏幕目视确认。未执行 hover、全屏、多显示器必须单独写明。@@ -87,11 +95,11 @@4. 可排序执行器的固定顺序兼容层;5. 节点链最小运行闭环。-每个切片必须单独跑相关单测、hash、性能和交付门槛;固定顺序 hash 不一致时停止,不能继续开放任意顺序。+每个切片必须单独跑相关单测、hash、性能和交付门槛;固定顺序 hash 不一致时停止,不能继续开放任意顺序。UI 状态必须绑定真实引擎能力,不能以静态状态代替运行结果。每片完成后仍要验证 1.4.4 回退合同。### R6:逐屏对齐和收尾-按 `board.js` 的 17 个 `FRAMES` 逐屏建立状态、截图、差异记录。完成前不删除旧 Win32 界面,不改名产品入口,不发布。+按 `board.js` 的 17 个 `FRAMES` 逐屏建立状态、截图、差异记录。完成前不删除旧 Win32 界面,不替换默认产品入口,不发布。最终总验收含文件/采集/PS5/导出中本机实际可执行的路径、功能回归、2.0.0 版本一致性、1.4.4 回退演练和真实播放性能对比;缺失的设备或素材标“未执行”,不能宣布 2.0.0 全部完成。## 每个目标的交付模板@@ -108,5 +116,4 @@## 下一目标-下一次目标模式只启动 **R0:黑面诊断闭环**。完成 R0 前,不修改 CineBar、不做专业页、不做 B1-B5,不把“日志更多”当成修复完成。-+当前目标模式继续 **R5.2-c:导出队列与编码策略**。范围限定为顺序队列、CBR/VBR/CQ 真实映射、ETA 和取消路径;完成后再进入 R5.3 独立调色 pass。R0/R1 窗口分层总验收、G3.3/G3.4 和小 UI 细节保留为未完成项,不在本切片中伪装通过。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex ec042b36..9c40b249 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -6696,3 +6696,5 @@ release. 5090 live acceptance, 15-second hitch and user flicker remain unresolve- 实机 Windows.Graphics.Capture 已看:字幕和音轨菜单完整显示在播放条上方,图在 `goal\r0\menu-subtitle-after.png` 与 `menu-audio-after.png`。修前同一音轨菜单底部压进播放条,修后底部离播放条约 18px。- Qt Quick Test `veyra_qml_quick_tests.exe -input tests\qml\quick -o goal\r0\menu-height-regression-tests.txt,txt`:9 passed, 0 failed,新增动态高度增长时底边不超过 `aboveLimit` 的回归用例。- 未执行:多音轨真实切换、全屏/多显示器/DPI 复查、字幕流选择(后端未接入)。R0/R1 窗口分层总验收未据此宣布通过;进度条缩略图、点击跳转和拖动问题仍需单独验收。++- 2026-09-26 / R5.2-b:完成导出剪辑入出点垂直切片。桥接、worker 共享内存和 `VideoExportJob` 传递剪辑范围;视频从首个完整入点帧开始,音频同步裁剪,出点停止写入;QML 导出页 slider 和导出探针参数已接线。`2→5s` 与英语音轨真实 NVENC/D3D12 导出通过,非法范围拒绝,7.9 秒尾段通过;7.98 秒因无入点后的完整帧拒绝,按合同记录。Quick Test 9/9。证据:`E:\项目\Veyra\logs\ui-qml-migration-20260925\goal\r5.2-b-trim\`、`E:\项目\Veyra\logs\ui-qml-migration-20260926\`。slider 目视、拖动/点击跳转、R0/R1 总验收未执行,按用户要求暂缓。下一目标 R5.2-c:导出队列与编码策略。diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.hindex 9a7151ad..324cfe0a 100644--- a/include/veyra/engine/EngineController.h+++ b/include/veyra/engine/EngineController.h@@ -21,6 +21,8 @@ namespace veyra::engine {class FrameFlowWindow;struct PlayerOptions { bool nr=false,sr=false,fg=false,realtime=true; uint32_t fgMultiplier=2; EnhancementSettings settings;int audioStreamIndex=-1; // export selection; -1 selects the container default+ double exportStartSeconds=0.0; // export-only trim; first complete frame at/after this time+ double exportEndSeconds=0.0; // export-only trim; 0 means source endbool captureReplayForTest=false; // file-backed live scheduler test; never enabled by UIbool captureCpuUnpack=false; // N1 diagnostic: legacy per-pixel CPU unpackEnhancementSettings snapshot()const{auto s=settings;s.nr=nr;s.sr=sr;s.multiplier=fg?fgMultiplier:1;s.nrPolicy=realtime?(settings.nrPolicy==pipeline::NrSizePolicy::Native?pipeline::NrSizePolicy::Realtime:settings.nrPolicy):pipeline::NrSizePolicy::Native;return s;}diff --git a/include/veyra/engine/ExportJobManager.h b/include/veyra/engine/ExportJobManager.hindex ba5a019e..60e86781 100644--- a/include/veyra/engine/ExportJobManager.h+++ b/include/veyra/engine/ExportJobManager.h@@ -17,7 +17,7 @@ struct ExportJobSnapshot {class ExportJobManager {public:ExportJobManager();~ExportJobManager();- bool start(const std::wstring&,const std::wstring&,EnhancementSettings,bool hevc,unsigned maxFrames=0,int audioStreamIndex=-1);+ bool start(const std::wstring&,const std::wstring&,EnhancementSettings,bool hevc,unsigned maxFrames=0,int audioStreamIndex=-1,double trimStartSeconds=0.0,double trimEndSeconds=0.0);void cancel();void pause(bool);void watching(bool);ExportJobSnapshot poll();private:struct Impl;std::unique_ptr<Impl> p_;diff --git a/include/veyra/engine/PresetLibrary.h b/include/veyra/engine/PresetLibrary.hindex 347bb6ad..13f34106 100644--- a/include/veyra/engine/PresetLibrary.h+++ b/include/veyra/engine/PresetLibrary.h@@ -32,7 +32,7 @@ inline constexpr uint32_t kPresetAllContent =// full EnhancementSettings: a preset must never smuggle in capture or export// fields.struct PresetFrameGeneration {- uint32_t multiplier = 2;+ uint32_t multiplier = 1;FrameGenerationBackend backend = FrameGenerationBackend::Dlss;bool operator==(const PresetFrameGeneration&) const = default;};diff --git a/include/veyra/ui/QmlDataDirectory.h b/include/veyra/ui/QmlDataDirectory.hnew file mode 100644index 00000000..4e90d510--- /dev/null+++ b/include/veyra/ui/QmlDataDirectory.h@@ -0,0 +1,19 @@+#pragma once++#include <cstddef>+#include <filesystem>+#include <string>++namespace veyra::ui {++struct QmlDataMigrationResult {+ bool ok = false;+ std::size_t copied = 0;+ std::string error;+};++// Copies known user settings once. The legacy directory is always read-only.+QmlDataMigrationResult prepareQmlDataDirectory(const std::filesystem::path& legacy,+ const std::filesystem::path& current);++} // namespace veyra::uidiff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.hindex 1e8f1985..4184c8ae 100644--- a/include/veyra/ui/QmlPlayerBridge.h+++ b/include/veyra/ui/QmlPlayerBridge.h@@ -133,6 +133,7 @@ class QmlPlayerBridge : public QObject {Q_PROPERTY(QString durationText READ durationText NOTIFY snapshotChanged)// --- source ------------------------------------------------------------+ Q_PROPERTY(int thumbnailGeneration READ thumbnailGeneration NOTIFY thumbnailGenerationChanged)Q_PROPERTY(QString sourceName READ sourceName NOTIFY snapshotChanged)Q_PROPERTY(QString sourceSummary READ sourceSummary NOTIFY snapshotChanged)Q_PROPERTY(int sourceWidth READ sourceWidth NOTIFY snapshotChanged)@@ -225,6 +226,9 @@ class QmlPlayerBridge : public QObject {// The preset the export will use. The design requires export to select a// preset (list or node) rather than assembling effects separately.Q_PROPERTY(QString exportPresetName READ exportPresetName NOTIFY exportChanged)+ Q_PROPERTY(int exportSrTargetIndex READ exportSrTargetIndex WRITE setExportSrTargetIndex NOTIFY exportChanged)+ Q_PROPERTY(double exportTrimStart READ exportTrimStart WRITE setExportTrimStart NOTIFY exportChanged)+ Q_PROPERTY(double exportTrimEnd READ exportTrimEnd WRITE setExportTrimEnd NOTIFY exportChanged)// The super-resolution target, which is what actually decides the export size// in this engine (0 = source, then Qhd/Uhd4K/Uhd8K). A separate "export// resolution" field does not exist, so the UI exposes the real control instead@@ -328,6 +332,7 @@ public:bool isImage() const;bool isCapture() const;bool hasSource() const;+ bool openingSource() const;double position() const;double duration() const;double progress() const;@@ -335,6 +340,7 @@ public:QString durationText() const;QString sourceName() const;+ int thumbnailGeneration() const;QString sourceSummary() const;int sourceWidth() const;int sourceHeight() const;@@ -427,6 +433,12 @@ public:int exportBitrateMbps() const;void setExportBitrateMbps(int value);QString exportPresetName() const;+ int exportSrTargetIndex() const;+ void setExportSrTargetIndex(int index);+ double exportTrimStart() const;+ void setExportTrimStart(double seconds);+ double exportTrimEnd() const;+ void setExportTrimEnd(double seconds);int srTargetIndex() const;QString srTargetLabel() const;void setSrTargetIndex(int index);@@ -502,6 +514,7 @@ public:// Presets. A preset carries selected parts, so there is one preset concept,// not several.Q_INVOKABLE bool applyPresetIndex(int index);+ Q_INVOKABLE bool selectExportPreset(int index);Q_INVOKABLE bool savePresetAs(const QString& name, int contentsMask, bool nodeMode);Q_INVOKABLE bool deletePreset(int index);Q_INVOKABLE bool renamePreset(int index, const QString& name);@@ -522,6 +535,8 @@ signals:// Emitted only when the underlying snapshot actually changed, so QML// bindings do not re-evaluate 60 times a second for nothing.void snapshotChanged();+ void thumbnailGenerationChanged();+ void thumbnailSourceChanged(const QString& path);void settingsChanged();void chainChanged();void recentFilesChanged();diff --git a/include/veyra/ui/ThumbnailProvider.h b/include/veyra/ui/ThumbnailProvider.hnew file mode 100644index 00000000..384c1444--- /dev/null+++ b/include/veyra/ui/ThumbnailProvider.h@@ -0,0 +1,23 @@+#pragma once++#include <QQuickImageProvider>+#include <QString>++#include <mutex>++namespace veyra::ui {++// Image.asynchronous keeps demux and software decode off the QML render thread.+// This decoder owns its own FFmpeg context and never reads the playback swapchain.+class ThumbnailProvider final : public QQuickImageProvider {+public:+ ThumbnailProvider();+ void setSource(const QString& path);+ QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize) override;++private:+ std::mutex mutex_;+ QString source_;+};++} // namespace veyra::uidiff --git a/qml/Veyra/CineBar.qml b/qml/Veyra/CineBar.qmlindex c7844375..412a13f7 100644--- a/qml/Veyra/CineBar.qml+++ b/qml/Veyra/CineBar.qml@@ -22,6 +22,7 @@ Rectangle {readonly property bool menuOpen: presetMenu.visible || ccMenu.visible || audioMenu.visible// The pointer is over the pill.readonly property bool hovered: barHover.hovered+ readonly property bool seekPreviewOpen: seekMouse.containsMouse && seekMouse.enabledHoverHandler { id: barHover }implicitHeight: 92radius: 30@@ -149,17 +150,29 @@ Rectangle {id: seekAreaLayout.fillWidth: trueimplicitHeight: 14+ property bool scrubbing: false+ property real scrubFrac: 0// .seek:hover .thumb { left: 44% } - the thumb tracks the real// progress, not the design's hard-coded 44%.- readonly property real frac: Math.max(0, Math.min(1, veyra.progress))- readonly property real hoverFrac: seekHover.hovered && width > 0- ? Math.max(0, Math.min(1, seekHover.point.position.x / width))- : frac+ readonly property real frac: scrubbing ? scrubFrac : Math.max(0, Math.min(1, veyra.progress))+ readonly property real hoverFrac: scrubbing ? scrubFrac+ : seekMouse.containsMouse && seekArea.width > 0+ ? Math.max(0, Math.min(1, seekMouse.mouseX / seekArea.width))+ : frac+ property int thumbnailBucket: -1+ function fractionAt(x) {+ return seekArea.width > 0 ? Math.max(0, Math.min(1, x / seekArea.width)) : 0+ }+ Timer {+ id: thumbnailDelay+ interval: 120+ onTriggered: seekArea.thumbnailBucket = Math.floor(seekArea.hoverFrac * veyra.duration / 2)+ }Rectangle {id: railanchors.verticalCenter: parent.verticalCenterwidth: parent.width- height: seekHover.hovered ? 6 : 3+ height: seekMouse.containsMouse ? 6 : 3radius: 9color: Qt.rgba(1, 1, 1, 0.14)Behavior on height { NumberAnimation { duration: Theme.d(300); easing.bezierCurve: Theme.spring } }@@ -176,14 +189,11 @@ Rectangle {color: "#FFFFFF"x: seekArea.frac * seekArea.width - width / 2anchors.verticalCenter: parent.verticalCenter- scale: seekHover.hovered ? 1 : 0+ scale: seekMouse.containsMouse || seekArea.scrubbing ? 1 : 0Behavior on scale { NumberAnimation { duration: Theme.d(400); easing.bezierCurve: Theme.spring } }}// .seek .peek: 144x104 above the rail, opacity .15s, scale .85 -> 1- // over .4s --spring from its bottom centre. The design shows a frame- // of the target position; the engine keeps no frame the UI can read- // (only save-to-file), so the scene area is the design's own black- // plate and the time is real. Recorded as 尚未接入 in WORKLOG (B1).+ // over .4s --spring from its bottom centre.Rectangle {visible: opacity > 0.01width: 144@@ -195,11 +205,32 @@ Rectangle {x: Math.max(0, Math.min(parent.width - width,seekArea.hoverFrac * seekArea.width - width / 2))y: -height - 18- opacity: seekHover.hovered ? 1 : 0- scale: seekHover.hovered ? 1 : 0.85+ opacity: seekMouse.containsMouse || seekArea.scrubbing ? 1 : 0+ scale: seekMouse.containsMouse || seekArea.scrubbing ? 1 : 0.85transformOrigin: Item.BottomBehavior on opacity { NumberAnimation { duration: Theme.d(150) } }Behavior on scale { NumberAnimation { duration: Theme.d(400); easing.bezierCurve: Theme.spring } }+ Image {+ id: previewFrame+ anchors.left: parent.left+ anchors.right: parent.right+ anchors.top: parent.top+ height: 81+ asynchronous: true+ cache: true+ fillMode: Image.PreserveAspectFit+ source: (seekMouse.containsMouse || seekArea.scrubbing) && seekArea.thumbnailBucket >= 0+ ? "image://veyra-thumb/" + veyra.thumbnailGeneration + "/" + (seekArea.thumbnailBucket * 2000)+ : ""+ }+ Text {+ anchors.centerIn: previewFrame+ visible: previewFrame.status === Image.Loading || previewFrame.status === Image.Error+ text: previewFrame.status === Image.Loading ? "加载中" : "预览不可用"+ color: Theme.t3+ font.family: Theme.fontUi+ font.pixelSize: 11+ }Text {anchors.left: parent.leftanchors.right: parent.right@@ -219,12 +250,32 @@ Rectangle {}}}- HoverHandler { id: seekHover; cursorShape: Qt.PointingHandCursor }- TapHandler {- onTapped: point => {- const f = Math.max(0, Math.min(1, point.position.x / width))- veyra.seekTo(f * veyra.duration)+ MouseArea {+ id: seekMouse+ anchors.fill: parent+ hoverEnabled: true+ enabled: veyra.duration > 0 && !veyra.isCapture+ cursorShape: Qt.PointingHandCursor+ onEntered: thumbnailDelay.restart()+ onExited: {+ thumbnailDelay.stop()+ seekArea.thumbnailBucket = -1+ }+ onPressed: mouse => {+ seekArea.scrubFrac = seekArea.fractionAt(mouse.x)+ seekArea.scrubbing = true+ }+ onPositionChanged: mouse => {+ if (seekArea.scrubbing) seekArea.scrubFrac = seekArea.fractionAt(mouse.x)+ thumbnailDelay.restart()+ }+ onReleased: mouse => {+ const target = seekArea.fractionAt(mouse.x) * veyra.duration+ seekArea.scrubbing = false+ veyra.logUi("ui-seek", "targetSeconds=" + target.toFixed(3))+ veyra.seekTo(target)}+ onCanceled: seekArea.scrubbing = false}}Text {diff --git a/qml/Veyra/ExportPage.qml b/qml/Veyra/ExportPage.qmlindex 1eb526fd..a244cc97 100644--- a/qml/Veyra/ExportPage.qml+++ b/qml/Veyra/ExportPage.qml@@ -4,9 +4,7 @@// card spans rows 2-3 on the left; the video sits in the middle with the trim range// under it; output settings fill the right column.//-// Scope, stated on the page rather than hidden: this build has no multi-file queue-// and no trim range, because the engine exports one file from the current source-// and has no trim settings. Those two cards say so instead of looking functional.+// Scope, stated on the page rather than hidden: this build has no multi-file queue.// What is real - preset selection, codec, output size, bitrate and progress - is// wired to the engine's export job.import QtQuick@@ -120,16 +118,17 @@ VPage {}VRow {label: "分辨率"- hint: "由超分目标尺寸决定"+ hint: "跟随所选预设,或指定输出尺寸"VSeg {options: [+ { id: "-1", label: "预设" },{ id: "0", label: "源" },{ id: "1", label: "2K" },{ id: "2", label: "4K" },{ id: "3", label: "8K" }]- current: String(veyra.srTargetIndex)- onPicked: id => veyra.srTargetIndex = parseInt(id)+ current: String(veyra.exportSrTargetIndex)+ onPicked: id => veyra.exportSrTargetIndex = parseInt(id)}}VRow {@@ -148,11 +147,11 @@ VPage {VGroup {VRow {label: "增强预设"- hint: "列表预设与节点预设共用一套"+ hint: "节点预设待执行器接入"VSelect {- value: veyra.currentPresetName+ value: veyra.exportPresetNameoptions: veyra.presetChoices- onPicked: id => veyra.applyPresetIndex(parseInt(id))+ onPicked: id => veyra.selectExportPreset(parseInt(id))}}}@@ -305,7 +304,7 @@ VPage {anchors.right: vwrap.rightanchors.bottom: parent.bottomanchors.bottomMargin: 14- height: 72+ height: 92radius: Theme.rCardcolor: Theme.cardborder.width: 1@@ -313,7 +312,7 @@ VPage {RowLayout {anchors.fill: parentanchors.margins: 12- spacing: 10+ spacing: 6Text {text: "导出范围"color: Theme.t2@@ -321,13 +320,29 @@ VPage {font.pixelSize: Theme.fsBody}Text {- Layout.fillWidth: true- text: "整段 · 00:00:00 — " + veyra.durationText+ text: veyra.formatTime(veyra.exportTrimStart) + " — "+ + veyra.formatTime(veyra.exportTrimEnd > 0 ? veyra.exportTrimEnd : veyra.duration)color: Theme.t1font.family: Theme.fontMonofont.pixelSize: Theme.fsSmall}- VTag { text: "片段裁剪尚未实现" }+ Item { Layout.fillWidth: true }+ VSlider {+ Layout.fillWidth: true+ from: 0+ to: Math.max(0.001, veyra.duration)+ value: veyra.exportTrimStart+ enabledControl: veyra.hasSource && !veyra.exportRunning && veyra.duration > 0+ onMoved: veyra.exportTrimStart = value+ }+ VSlider {+ Layout.fillWidth: true+ from: 0+ to: Math.max(0.001, veyra.duration)+ value: veyra.exportTrimEnd > 0 ? veyra.exportTrimEnd : veyra.duration+ enabledControl: veyra.hasSource && !veyra.exportRunning && veyra.duration > 0+ onMoved: veyra.exportTrimEnd = value+ }}}diff --git a/qml/Veyra/FullscreenBar.qml b/qml/Veyra/FullscreenBar.qmlindex cd660c94..c4c3e219 100644--- a/qml/Veyra/FullscreenBar.qml+++ b/qml/Veyra/FullscreenBar.qml@@ -56,9 +56,10 @@ Window {visible: shown || fade > 0.01onVisibleChanged: veyra.logUi("ui-fullscreen", "control window visible=" + visible)- // Only the pill takes the pointer; with the menu open, the whole window does,- // so a click beside the menu closes it instead of falling through to the picture.+ // The seek preview rises above the pill, so its window region must include it.+ // With the menu open, the whole window takes input to allow outside-click close.readonly property rect hitRect: menuOpen ? Qt.rect(0, 0, width, height)+ : bar.seekPreviewOpen ? Qt.rect(0, menuRoom - 122, width, 214): Qt.rect(0, menuRoom, width, 92)onHitRectChanged: veyra.setWindowMask(win, hitRect)Component.onCompleted: veyra.setWindowMask(win, hitRect)diff --git a/qml/Veyra/Main.qml b/qml/Veyra/Main.qmlindex bfbc8f4e..d77f7192 100644--- a/qml/Veyra/Main.qml+++ b/qml/Veyra/Main.qml@@ -7,7 +7,7 @@// * in cinema mode the WINDOW ITSELF snaps to the film's aspect ratio so the// picture has no letterbox bars. The prototype's own technical note says the// window must resize to the film when a file opens (capture cards and games-// are 16:9), and its fitAspect() adds BAR_BELOW = 46 for the control pill.+// are 16:9). The separate control window straddles its lower edge.//// The video is not in this scene graph. It stays the native D3D12 child window// that apps/veyra-qml/main.cpp places over the item named "videoHost"; Qt hosts@@ -36,18 +36,14 @@ Window {readonly property bool cinema: page === "min"Binding { target: Theme; property: "reduced"; value: veyra.reducedMotion || root.test.reducedMotion === true }- // Cinema geometry, straight from the prototype: the picture is width/aspect- // and the window is that plus the lower half of the control pill.+ // Cinema geometry: the main window ends at the picture. The independent pill+ // can extend below it without leaving an opaque strip in this window.property real filmAspect: 2.39- // The design straddles the bar on the picture edge: BAR_BELOW = 46. The pill is- // its own top-level window (FullscreenBar, D1), so it can sit over the native- // video window.- readonly property int barBelow: 46readonly property real pictureHeight: Math.round(width / filmAspect)function fitToFilm(aspect) {if (aspect > 0.2 && aspect < 5.0) filmAspect = aspect- if (cinema && !fullTarget) height = Math.round(pictureHeight + barBelow)+ if (cinema && !fullTarget) height = Math.round(pictureHeight)}// .vy.cine transition: height .7s var(--spring-soft)Behavior on height {@@ -55,7 +51,7 @@ Window {NumberAnimation { duration: Theme.d(700); easing.bezierCurve: Theme.springSoft }}onWidthChanged: {- if (cinema && !fullTarget) height = Math.round(pictureHeight + barBelow)+ if (cinema && !fullTarget) height = Math.round(pictureHeight)videoHost.syncRect()}// The window height animates towards the film's aspect, so the picture area has@@ -68,7 +64,7 @@ Window {// behave differently from home than from the professional page.if (veyra.currentPage !== page) veyra.currentPage = pageif (fullTarget) { /* the screen is the window */ }- else if (cinema) height = Math.round(pictureHeight + barBelow)+ else if (cinema) height = Math.round(pictureHeight)else if (height < 600) height = 800// core.js app.go: the old page sinks (.22s) and the new one shows 150 ms// later with its [data-in] items rising. Reduced motion shows it at once.@@ -110,6 +106,7 @@ Window {VBackdrop {id: backdropanchors.fill: parent+ visible: !root.cinemastrokeColor: root.cinema ? "transparent" : Theme.stroke}@@ -238,7 +235,7 @@ Window {fullTarget = fullscreenif (!fullscreen) {fullLocked = false- if (cinema) height = Math.round(pictureHeight + barBelow)+ if (cinema) height = Math.round(pictureHeight)}fullControls = truefullHide.restart()diff --git a/qml/Veyra/MinimalPage.qml b/qml/Veyra/MinimalPage.qmlindex b6161674..5cf0b220 100644--- a/qml/Veyra/MinimalPage.qml+++ b/qml/Veyra/MinimalPage.qml@@ -43,11 +43,8 @@ VPage {}onEnter: { cineIn.frac = 0.12; cineInAnim.restart() }- // Where the picture ends: Main.qml sets the window height to the picture plus- // BAR_BELOW (46), the lower half of the control pill. The pill itself is a- // separate top-level window (FullscreenBar in cinema mode, D1), because the- // native video window draws above this whole scene.- readonly property real pictureHeight: parent ? parent.height - 46 : 0+ // The independent pill extends below this window; no opaque spacer is needed.+ readonly property real pictureHeight: parent ? parent.height : 0// --- the picture ------------------------------------------------------// .min .stage: full width, the picture height, radius 8 (the window radius),diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qmlindex 4b5d27ed..6854f747 100644--- a/qml/Veyra/ProPage.qml+++ b/qml/Veyra/ProPage.qml@@ -114,6 +114,7 @@ VPage {font.pixelSize: Theme.fsSmall}Item {+ id: proSeekAreaLayout.fillWidth: trueimplicitHeight: 14Rectangle {@@ -131,7 +132,7 @@ VPage {}HoverHandler { cursorShape: Qt.PointingHandCursor }TapHandler {- onTapped: point => veyra.seekTo(Math.max(0, Math.min(1, point.position.x / width)) * veyra.duration)+ onTapped: point => veyra.seekTo(Math.max(0, Math.min(1, point.position.x / proSeekArea.width)) * veyra.duration)}}Text {diff --git a/qml/Veyra/VSelect.qml b/qml/Veyra/VSelect.qmlindex 2e3a2fed..8b29b428 100644--- a/qml/Veyra/VSelect.qml+++ b/qml/Veyra/VSelect.qml@@ -43,7 +43,7 @@ Rectangle {if (p instanceof VRow) return p.labelreturn ""}- items: sel.options.map(o => ({ label: o.label, checked: o.label === sel.value }))+ items: sel.options.map(o => ({ label: o.label, checked: o.label === sel.value, disabled: o.disabled === true }))onPicked: (i, o) => sel.picked(sel.options[i].id)}}diff --git a/src/engine/ExportJobManager.cpp b/src/engine/ExportJobManager.cppindex d0f4586b..c472276f 100644--- a/src/engine/ExportJobManager.cpp+++ b/src/engine/ExportJobManager.cpp@@ -28,6 +28,7 @@ struct Shared {wchar_t input[32768]{},output[32768]{};unsigned hevc=0,maxFrames=0;int audioStreamIndex=-1;+ double trimStartSeconds=0.0,trimEndSeconds=0.0;volatile LONG64 sourceFrames=0,generated=0,holds=0,encoded=0;volatile LONG messageLock=0;wchar_t message[1024]{};volatile LONG cancel=0,pause=0,watching=0,state=LONG(ExportState::Preparing),progress=0;@@ -47,7 +48,7 @@ ExportJobManager::ExportJobManager():p_(std::make_unique<Impl>()){}// draining NVENC is terminated by clear() after a short grace instead of// stalling process exit for up to five seconds.ExportJobManager::~ExportJobManager(){cancel();if(p_->process)WaitForSingleObject(p_->process,1000);p_->clear();}-bool ExportJobManager::start(const std::wstring& input,const std::wstring& output,EnhancementSettings settings,bool hevc,unsigned maxFrames,int audioStreamIndex){+bool ExportJobManager::start(const std::wstring& input,const std::wstring& output,EnhancementSettings settings,bool hevc,unsigned maxFrames,int audioStreamIndex,double trimStartSeconds,double trimEndSeconds){if(poll().active())return false;p_->clear();p_->snapshot={};auto fail=[&](const wchar_t* message){const DWORD error=GetLastError();p_->clear();p_->snapshot.state=ExportState::Failed;p_->snapshot.message=message;log::error("export-worker",std::format("launch failed error={}",error));return false;};if(input.empty()||output.empty()||input.size()>=32768||output.size()>=32768||!settings.validate().empty()||input.starts_with(L"capture:")||input.starts_with(L"capture2:"))return fail(L"请选择本地视频与有效导出设置");@@ -56,8 +57,10 @@ bool ExportJobManager::start(const std::wstring& input,const std::wstring& outpup_->mapping=CreateFileMappingW(INVALID_HANDLE_VALUE,&sa,PAGE_READWRITE,0,sizeof(Shared),nullptr);if(!p_->mapping)return fail(L"无法创建导出通信资源");p_->shared=static_cast<Shared*>(MapViewOfFile(p_->mapping,FILE_MAP_ALL_ACCESS,0,0,sizeof(Shared)));if(!p_->shared)return fail(L"无法映射导出通信资源");+ if(!std::isfinite(trimStartSeconds)||!std::isfinite(trimEndSeconds)||trimStartSeconds<0||trimEndSeconds<0||(trimEndSeconds>0&&trimEndSeconds<=trimStartSeconds))return fail(L"导出剪辑范围无效");new(p_->shared) Shared{};auto& s=*p_->shared;s.settings=settings;s.settings.nrPolicy=pipeline::NrSizePolicy::Native;s.chain=toChain(s.settings);s.hevc=hevc;s.maxFrames=maxFrames;s.audioStreamIndex=audioStreamIndex;+ s.trimStartSeconds=trimStartSeconds;s.trimEndSeconds=trimEndSeconds;wcscpy_s(s.input,input.c_str());wcscpy_s(s.output,output.c_str());p_->job=CreateJobObjectW(nullptr,nullptr);JOBOBJECT_EXTENDED_LIMIT_INFORMATION limits{};limits.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;if(!p_->job||!SetInformationJobObject(p_->job,JobObjectExtendedLimitInformation,&limits,sizeof(limits)))return fail(L"无法建立导出进程生命周期");@@ -96,7 +99,7 @@ ExportJobSnapshot ExportJobManager::poll(){}int runExportWorker(HANDLE mapping){auto s=static_cast<Shared*>(MapViewOfFile(mapping,FILE_MAP_ALL_ACCESS,0,0,sizeof(Shared)));if(!s)return 1;- if(s->signature!=magic||s->version!=3||s->bytes!=sizeof(Shared)||s->audioStreamIndex< -1||!s->settings.validate().empty()||s->input[32767]||s->output[32767]){UnmapViewOfFile(s);CloseHandle(mapping);return 1;}+ if(s->signature!=magic||s->version!=3||s->bytes!=sizeof(Shared)||s->audioStreamIndex< -1||!std::isfinite(s->trimStartSeconds)||!std::isfinite(s->trimEndSeconds)||s->trimStartSeconds<0||s->trimEndSeconds<0||(s->trimEndSeconds>0&&s->trimEndSeconds<=s->trimStartSeconds)||!s->settings.validate().empty()||s->input[32767]||s->output[32767]){UnmapViewOfFile(s);CloseHandle(mapping);return 1;}Logger::instance().openFile((runtime::logsDirectory()/std::format("export-worker-{}.log",GetCurrentProcessId())).wstring());// The chain is the description of record for this job; the settings struct// stays the runtime input until the executor consumes chains directly.@@ -113,7 +116,7 @@ int runExportWorker(HANDLE mapping){if(InterlockedCompareExchange(&s->watching,0,0))for(int i=0;i<5&&!cancel;++i)std::this_thread::sleep_for(std::chrono::milliseconds(10));return !cancel;};- auto options=PlayerOptions::from(settings);options.audioStreamIndex=s->audioStreamIndex;+ auto options=PlayerOptions::from(settings);options.audioStreamIndex=s->audioStreamIndex;options.exportStartSeconds=s->trimStartSeconds;options.exportEndSeconds=s->trimEndSeconds;bool ok=false;try{ok=exportVideo(s->input,s->output,options,s->hevc!=0,cancel,[&](double p,const std::wstring& message){if(InterlockedCompareExchange(&s->messageLock,1,0)==0){wcsncpy_s(s->message,message.c_str(),_TRUNCATE);InterlockedExchange(&s->messageLock,0);}InterlockedExchange(&s->progress,LONG(std::clamp(p,0.0,.999)*10000));if(p>=.99)InterlockedExchange(&s->state,LONG(ExportState::Finishing));},s->maxFrames,frameBoundary,[&](const ExportCounts& count){InterlockedExchange64(&s->sourceFrames,count.source);InterlockedExchange64(&s->generated,count.generated);InterlockedExchange64(&s->holds,count.holds);InterlockedExchange64(&s->encoded,count.encoded);});}catch(...){log::error("export-worker","unhandled job exception");}done=true;monitor.join();InterlockedExchange(&s->state,LONG(ok?ExportState::Succeeded:cancel?ExportState::Cancelled:ExportState::Failed));UnmapViewOfFile(s);CloseHandle(mapping);return ok?0:cancel?3:1;diff --git a/src/engine/PresetLibrary.cpp b/src/engine/PresetLibrary.cppindex 19222039..66b6adbc 100644--- a/src/engine/PresetLibrary.cpp+++ b/src/engine/PresetLibrary.cpp@@ -40,7 +40,7 @@ void PresetLibrary::addBuiltins() {s.videoHdr.enabled = hdr; s.color.enabled = color;entry.chain = toChain(s);entry.color = s.color;- entry.fg = {std::max(2u, s.multiplier), FrameGenerationBackend::Dlss};+ entry.fg = {s.multiplier, FrameGenerationBackend::Dlss};entries_.push_back(std::move(entry));};if (!entries_.empty()) return;diff --git a/src/engine/VideoExportJob.cpp b/src/engine/VideoExportJob.cppindex ac2ea3b4..536bc552 100644--- a/src/engine/VideoExportJob.cpp+++ b/src/engine/VideoExportJob.cpp@@ -22,6 +22,7 @@ extern "C" {namespace veyra::engine {namespace { std::string utf8(const std::wstring& s){const int n=WideCharToMultiByte(CP_UTF8,0,s.data(),int(s.size()),nullptr,0,nullptr,nullptr);std::string r(n,0);WideCharToMultiByte(CP_UTF8,0,s.data(),int(s.size()),r.data(),n,nullptr,nullptr);return r;} }bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptions options,bool hevc,std::atomic<bool>& cancel,const std::function<void(double,const std::wstring&)>& progress,unsigned maxFrames,const std::function<bool()>& frameBoundary,const std::function<void(const ExportCounts&)>& counts){+ if(!std::isfinite(options.exportStartSeconds)||!std::isfinite(options.exportEndSeconds)||options.exportStartSeconds<0||options.exportEndSeconds<0||(options.exportEndSeconds>0&&options.exportEndSeconds<=options.exportStartSeconds)){progress(0,L"导出剪辑范围无效");return false;}if(std::filesystem::exists(output)||std::filesystem::exists(output+L".partial")){progress(0,L"目标或partial文件已存在,请使用其他名称");return false;}// XeSS-FG and AMD FSR-FG interpolate inside the present swapchain: the// provider presents the extra frames itself, so no output texture ever@@ -65,8 +66,18 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptiauto info=source.info();if(!pipeline::Extent{info.width,info.height}.valid()){progress(0,L"输入尺寸超出GPU单纹理能力");break;}// The first decoded frame is authoritative when container headers omit// transfer/range metadata. Retain it instead of scanning and reopening.- pipeline::FramePacket firstPacket;const AVFrame* firstFrame=nullptr;- if(source.read(firstPacket,&firstFrame)!=source::SourceReadStatus::Frame||!firstFrame){failureReason=L"导出预读首帧失败";break;}+ const double requestedStart=options.exportStartSeconds;+ const double requestedEnd=options.exportEndSeconds;+ if(requestedStart>0&& !source.seek(pipeline::Rational{static_cast<int64_t>(std::llround(requestedStart*1000000.0)),1000000})){failureReason=L"导出无法定位到剪辑入点";break;}+ pipeline::FramePacket firstPacket;const AVFrame* firstFrame=nullptr;bool firstReady=false;+ while(!firstReady){+ const auto firstStatus=source.read(firstPacket,&firstFrame);+ if(firstStatus!=source::SourceReadStatus::Frame||!firstFrame){failureReason=firstStatus==source::SourceReadStatus::Eos?L"剪辑入点已超过源视频时长":L"导出预读首帧失败";break;}+ const double firstPts=firstPacket.pts.toDouble();+ firstReady=requestedStart<=0||firstPacket.pts.isUnknown()||!std::isfinite(firstPts)||firstPts>=requestedStart;+ if(!firstReady)firstFrame=nullptr;+ }+ if(!firstReady)break;info=source.info(); // retain this frame for the export, without decoding it againint rateNum=info.nominalRateNum,rateDen=info.nominalRateDen;if(rateNum<=0||rateDen<=0){rateNum=30;rateDen=1;veyra::log::warn("export-timeline","missing nominal rate; encoder configured at 30 fps, source timestamps retained");}@@ -158,7 +169,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOpti}auto writeAudioUntil=[&](double seconds){if(!audioStream)return true;for(;;){if(!audioPending){if(audioEof)return true;av_packet_unref(audioPacket);const int readResult=av_read_frame(audioInput,audioPacket);if(readResult==AVERROR_EOF){audioEof=true;return true;}if(readResult<0)return failAv(L"读取音轨",readResult);if(audioPacket->stream_index!=audioIndex)continue;audioPending=true;}- const auto tb=audioInput->streams[audioIndex]->time_base;const int64_t ts=audioPacket->pts!=AV_NOPTS_VALUE?audioPacket->pts:audioPacket->dts;const double time=ts==AV_NOPTS_VALUE?0:ts*av_q2d(tb)-videoOriginSeconds;if(time>seconds)return true;+ const auto tb=audioInput->streams[audioIndex]->time_base;const int64_t ts=audioPacket->pts!=AV_NOPTS_VALUE?audioPacket->pts:audioPacket->dts;const double time=ts==AV_NOPTS_VALUE?0:ts*av_q2d(tb)-videoOriginSeconds;if(time>seconds)return true;if(time<0){audioPending=false;continue;}const int64_t origin=av_rescale_q(static_cast<int64_t>(videoOriginSeconds*1000000),{1,1000000},tb);if(audioPacket->pts!=AV_NOPTS_VALUE)audioPacket->pts-=origin;if(audioPacket->dts!=AV_NOPTS_VALUE)audioPacket->dts-=origin;av_packet_rescale_ts(audioPacket,tb,audioStream->time_base);audioPacket->stream_index=audioStream->index;audioPacket->pos=-1;audioPending=false;const int rc=av_interleaved_write_frame(mux,audioPacket);if(rc<0)return failAv(L"写入音轨",rc);@@ -221,6 +232,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptidouble sourcePts=packet.pts.toDouble();if(sourceCount==0)videoOriginSeconds=!packet.pts.isUnknown()&&std::isfinite(sourcePts)?sourcePts:0;double pts=sourcePts-videoOriginSeconds;+ if(requestedEnd>0&&pts>requestedEnd-requestedStart)break;const bool repairPts=packet.pts.isUnknown()||!std::isfinite(pts)||(sourceCount&&pts<=previousPts);if(repairPts){pts=sourceCount?previousPts+sourceInterval:0;++repairedTimestamps;@@ -247,7 +259,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptiif(!encodeAt(real.lease->slot,false,pts)){error=true;break;}real.lease->consumerFence=ring.lastSignaledValue();lastReal=real.lease;previousPts=pts;- ++sourceCount;if(counts)counts({sourceCount,generatedCount,holdCount,uint64_t(written)});progress(info.duration.toDouble()>0?std::clamp(pts/info.duration.toDouble(),0.0,.99):0,std::format(L"正在导出:{}张源帧 / {}张编码帧({})",sourceCount,outputIndex,encoderName));+ ++sourceCount;if(counts)counts({sourceCount,generatedCount,holdCount,uint64_t(written)});const double clipDuration=requestedEnd>0?requestedEnd-requestedStart:std::max(0.001,info.duration.toDouble()-videoOriginSeconds);progress(clipDuration>0?std::clamp(pts/clipDuration,0.0,.99):0,std::format(L"正在导出:{}张源帧 / {}张编码帧({})",sourceCount,outputIndex,encoderName));if(maxFrames&&sourceCount>=maxFrames)break;}if(error||cancel)break;diff --git a/src/ui/QmlDataDirectory.cpp b/src/ui/QmlDataDirectory.cppnew file mode 100644index 00000000..dbee864e--- /dev/null+++ b/src/ui/QmlDataDirectory.cpp@@ -0,0 +1,79 @@+#include "veyra/ui/QmlDataDirectory.h"++#include <array>+#include <fstream>+#include <string_view>++namespace veyra::ui {+namespace {++constexpr std::array<std::wstring_view, 9> kLegacyFiles{+ L"presets.v1", L"user-presets.v1", L"nr-presets.v1", L"last-applied.v1",+ L"ui-session.v1", L"ui-preferences.v1", L"capture-preferences.v1",+ L"color-looks.v1", L"veyra.ini"+};++bool copyOnce(const std::filesystem::path& source, const std::filesystem::path& target,+ bool& copied, std::string& error) {+ std::error_code ec;+ copied = false;+ if (!std::filesystem::exists(source, ec)) {+ if (ec) { error = "Cannot inspect legacy setting: " + ec.message(); return false; }+ return true;+ }+ if (!std::filesystem::is_regular_file(source, ec)) {+ error = ec ? "Cannot inspect legacy setting: " + ec.message() : "Legacy setting is not a regular file";+ return false;+ }+ if (std::filesystem::exists(target, ec)) return !ec;+ if (ec) { error = "Cannot inspect new setting: " + ec.message(); return false; }++ auto temporary = target;+ temporary += L".migrating";+ std::filesystem::copy_file(source, temporary, std::filesystem::copy_options::overwrite_existing, ec);+ if (ec) { error = "Cannot copy legacy setting: " + ec.message(); return false; }+ std::filesystem::rename(temporary, target, ec);+ if (ec) { error = "Cannot install migrated setting: " + ec.message(); return false; }+ copied = true;+ return true;+}++} // namespace++QmlDataMigrationResult prepareQmlDataDirectory(const std::filesystem::path& legacy,+ const std::filesystem::path& current) {+ QmlDataMigrationResult result;+ std::error_code ec;+ std::filesystem::create_directories(current, ec);+ if (ec) { result.error = "Cannot create 2.0.0 data directory: " + ec.message(); return result; }+ if (std::filesystem::equivalent(legacy, current, ec) && !ec) {+ result.error = "The legacy and 2.0.0 data directories are identical";+ return result;+ }++ const auto marker = current / L"migration-from-1.4.4.v1";+ if (std::filesystem::exists(marker, ec)) { result.ok = !ec; return result; }+ if (ec) { result.error = "Cannot inspect migration marker: " + ec.message(); return result; }++ for (const auto name : kLegacyFiles) {+ const auto source = legacy / std::filesystem::path(std::wstring(name));+ const auto target = current / std::filesystem::path(std::wstring(name));+ bool copied = false;+ if (!copyOnce(source, target, copied, result.error)) return result;+ if (copied) ++result.copied;+ }++ auto temporary = marker;+ temporary += L".migrating";+ {+ std::ofstream out(temporary, std::ios::binary | std::ios::trunc);+ out << "VEYRA_QML_DATA_MIGRATION 1\n";+ if (!out) { result.error = "Cannot write migration marker"; return result; }+ }+ std::filesystem::rename(temporary, marker, ec);+ if (ec) { result.error = "Cannot install migration marker: " + ec.message(); return result; }+ result.ok = true;+ return result;+}++} // namespace veyra::uidiff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cppindex 1b8b546f..7efff647 100644--- a/src/ui/QmlPlayerBridge.cpp+++ b/src/ui/QmlPlayerBridge.cpp@@ -50,6 +50,8 @@ struct QmlPlayerBridge::Impl {engine::PlayerSnapshot snapshot;uint64_t publishedRevision = 0;bool haveSnapshot = false;+ bool openingSource = false;+ uint64_t openingSessionId = 0;// The chain the UI edits, kept in step with the facade's pending settings.engine::EffectChain chain;@@ -58,6 +60,7 @@ struct QmlPlayerBridge::Impl {// The window the engine presents into, and the last file the UI opened.HWND videoWindow = nullptr;std::wstring sourceLabel;+ int thumbnailGeneration = 0;// Keeps the display and system awake while a video plays (AppShell rule: running,// not failed, not a still image, transport Playing). Acquired and released on@@ -77,6 +80,11 @@ struct QmlPlayerBridge::Impl {engine::ExportJobManager exportJob;engine::ExportJobSnapshot exportSnapshot;bool exportHevc = false;+ uint32_t exportBitrateMbps = 0;+ int exportResolutionIndex = -1;+ double exportTrimStartSeconds = 0.0;+ double exportTrimEndSeconds = 0.0;+ std::wstring exportPresetName;QString initialPageOverride;QString currentPage;std::wstring captureDevice;@@ -98,6 +106,11 @@ struct QmlPlayerBridge::Impl {snapshot = frame.snapshot;publishedRevision = frame.revision;haveSnapshot = true;+ if (openingSource && openingSessionId != 0 && snapshot.sessionId == openingSessionId &&+ (snapshot.running || snapshot.image || snapshot.failed ||+ snapshot.transport == engine::TransportState::Empty ||+ snapshot.transport == engine::TransportState::Stopping))+ openingSource = false;}// The chain is the source of truth for the stage settings; every commit@@ -133,9 +146,20 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesystconnect(impl_->timer, &QTimer::timeout, this, [this] {const bool had = impl_->haveSnapshot;const uint64_t before = impl_->publishedRevision;+ const bool wasRunning = impl_->snapshot.running;+ const bool wasImage = impl_->snapshot.image;+ const bool wasFailed = impl_->snapshot.failed;+ const auto wasTransport = impl_->snapshot.transport;+ const uint64_t wasSession = impl_->snapshot.sessionId;impl_->poll();if (!had || impl_->publishedRevision != before) {const auto& s = impl_->snapshot;+ if (!had || wasSession != s.sessionId || wasTransport != s.transport ||+ wasRunning != s.running || wasImage != s.image || wasFailed != s.failed)+ veyra::log::info("qml-window", std::format(+ "source-state session={} transport={} running={} image={} failed={} opening={} revision={}",+ s.sessionId, int(s.transport), s.running, s.image, s.failed,+ impl_->openingSource, impl_->publishedRevision));impl_->power.update(s.running && !s.failed && !s.image && s.transport == engine::TransportState::Playing);emit snapshotChanged();}@@ -681,6 +705,7 @@ bool QmlPlayerBridge::failed() const { return impl_->snapshot.failed; }bool QmlPlayerBridge::isImage() const { return impl_->snapshot.image; }bool QmlPlayerBridge::isCapture() const { return impl_->snapshot.capture; }bool QmlPlayerBridge::hasSource() const { return impl_->snapshot.running || impl_->snapshot.image; }+bool QmlPlayerBridge::openingSource() const { return impl_->openingSource; }double QmlPlayerBridge::position() const { return impl_->snapshot.position; }double QmlPlayerBridge::duration() const { return impl_->snapshot.duration; }double QmlPlayerBridge::progress() const {@@ -1001,17 +1026,51 @@ void QmlPlayerBridge::setExportHevc(bool value) {// Export bitrate: 0 means the encoder's constant-quality default, which is what// the engine's exportBitrateMbps field documents.-int QmlPlayerBridge::exportBitrateMbps() const { return int(settings().exportBitrateMbps); }+int QmlPlayerBridge::exportBitrateMbps() const { return int(impl_->exportBitrateMbps); }void QmlPlayerBridge::setExportBitrateMbps(int value) {- auto s = settings();const uint32_t want = uint32_t(std::max(0, std::min(2000, value)));- if (s.exportBitrateMbps == want) return;- s.exportBitrateMbps = want;- impl_->commit(std::move(s));- emit settingsChanged();+ if (impl_->exportBitrateMbps == want) return;+ impl_->exportBitrateMbps = want;+ emit exportChanged();}-QString QmlPlayerBridge::exportPresetName() const { return currentPresetName(); }+QString QmlPlayerBridge::exportPresetName() const {+ return impl_->exportPresetName.empty() ? tr("当前播放设置") : utf8Of(impl_->exportPresetName);+}++int QmlPlayerBridge::exportSrTargetIndex() const {+ return impl_->exportResolutionIndex;+}+void QmlPlayerBridge::setExportSrTargetIndex(int index) {+ if (index < -1 || index > 3 || impl_->exportResolutionIndex == index) return;+ impl_->exportResolutionIndex = index;+ emit exportChanged();+}++double QmlPlayerBridge::exportTrimStart() const { return impl_->exportTrimStartSeconds; }+void QmlPlayerBridge::setExportTrimStart(double seconds) {+ if (!std::isfinite(seconds)) return;+ const double duration = impl_->snapshot.duration;+ const double end = impl_->exportTrimEndSeconds > 0.0 ? impl_->exportTrimEndSeconds : duration;+ const double maxStart = end > 0.05 ? end - 0.05 : 0.0;+ const double value = std::clamp(seconds, 0.0, std::max(0.0, maxStart));+ if (std::abs(impl_->exportTrimStartSeconds - value) < 0.0005) return;+ impl_->exportTrimStartSeconds = value;+ emit exportChanged();+}++double QmlPlayerBridge::exportTrimEnd() const { return impl_->exportTrimEndSeconds; }+void QmlPlayerBridge::setExportTrimEnd(double seconds) {+ if (!std::isfinite(seconds)) return;+ const double duration = impl_->snapshot.duration;+ const double sourceEnd = duration > 0.0 ? duration : seconds;+ const double value = std::clamp(seconds, 0.0, std::max(0.0, sourceEnd));+ const double start = impl_->exportTrimStartSeconds;+ if (value > 0.0 && value <= start + 0.05) return;+ if (std::abs(impl_->exportTrimEndSeconds - value) < 0.0005) return;+ impl_->exportTrimEndSeconds = value;+ emit exportChanged();+}QString QmlPlayerBridge::srTargetLabel() const {// The label follows the SR target, because that is what sets the output size.@@ -1051,12 +1110,14 @@ QVariantList QmlPlayerBridge::presetChoices() const {// One list for both kinds; the label carries the distinction so the export page// can offer "any preset" without a second control.QVariantList out;+ out << QVariantMap{{"id", QStringLiteral("-1")}, {"label", tr("当前播放设置")}};const auto& entries = impl_->facade.presets().entries();for (size_t i = 0; i < entries.size(); ++i) {QVariantMap item;item["id"] = QString::number(i);item["label"] = utf8Of(entries[i].name)+ (entries[i].kind == engine::ChainMode::Node ? tr(" · 节点") : QString());+ item["disabled"] = entries[i].kind == engine::ChainMode::Node;out << item;}return out;@@ -1096,16 +1157,27 @@ QString QmlPlayerBridge::diagnosticsReport() const {// --- commands ---------------------------------------------------------------void QmlPlayerBridge::openFileDialog() {+ veyra::log::info("qml-file", "openFileDialog entered");const QString path = QFileDialog::getOpenFileName(nullptr, tr("打开视频或图片"), QString(),tr("媒体文件 (*.mp4 *.mkv *.mov *.avi *.webm *.ts *.m2ts *.jpg *.jpeg *.png *.bmp *.webp);;所有文件 (*)"));+ veyra::log::info("qml-file", path.isEmpty() ? "openFileDialog cancelled" : "openFileDialog selected file");if (!path.isEmpty()) openPath(path);}+int QmlPlayerBridge::thumbnailGeneration() const { return impl_->thumbnailGeneration; }void QmlPlayerBridge::openPath(const QString& path) {if (path.isEmpty()) return;+ impl_->exportTrimStartSeconds = 0.0;+ impl_->exportTrimEndSeconds = 0.0;+ emit exportChanged();+ impl_->openingSource = true;+ impl_->openingSessionId = 0;const std::wstring wide = wideOf(path);impl_->sourceLabel = wide;+ ++impl_->thumbnailGeneration;+ emit thumbnailSourceChanged(path);+ emit thumbnailGenerationChanged();impl_->facade.noteRecentFile(wide);emit recentFilesChanged();// Switch to a page with a video area, then settle the native window's@@ -1119,10 +1191,15 @@ void QmlPlayerBridge::openPath(const QString& path) {emit navigate(QStringLiteral("min"));if (impl_->preOpen) impl_->preOpen();impl_->engine.open(impl_->videoWindow, wide, impl_->options);+ impl_->openingSessionId = impl_->engine.snapshot().sessionId;}void QmlPlayerBridge::togglePlayPause() { impl_->engine.pause(impl_->snapshot.running); }-void QmlPlayerBridge::stopPlayback() { impl_->engine.stop(); }+void QmlPlayerBridge::stopPlayback() {+ impl_->openingSource = false;+ impl_->openingSessionId = 0;+ impl_->engine.stop();+}void QmlPlayerBridge::seekTo(double seconds) { impl_->engine.seek(seconds); }void QmlPlayerBridge::seekBy(double seconds) {impl_->engine.seek(std::max(0.0, impl_->snapshot.position + seconds));@@ -1184,8 +1261,40 @@ void QmlPlayerBridge::startExport() {// export must not change under the user mid-run.auto settings = impl_->facade.pendingSettings();engine::fromChain(impl_->chain, settings);+ if (!impl_->exportPresetName.empty()) {+ const auto& entries = impl_->facade.presets().entries();+ const auto preset = std::find_if(entries.begin(), entries.end(), [this](const auto& entry) {+ return entry.name == impl_->exportPresetName;+ });+ if (preset == entries.end()) { emit notice(tr("导出预设已不存在,请重新选择"), true); return; }+ if (preset->kind == engine::ChainMode::Node) {+ emit notice(tr("节点预设尚未接入导出执行器"), true);+ return;+ }+ engine::PresetLibrary::apply(*preset, settings);+ }+ settings.exportBitrateMbps = impl_->exportBitrateMbps;+ if (impl_->exportResolutionIndex >= 0) {+ settings.sr = impl_->exportResolutionIndex != 0;+ if (settings.sr) {+ switch (impl_->exportResolutionIndex) {+ case 1: settings.srTarget = pipeline::SrTarget::Qhd; break;+ case 2: settings.srTarget = pipeline::SrTarget::Uhd4K; break;+ case 3: settings.srTarget = pipeline::SrTarget::Uhd8K; break;+ default: break;+ }+ }+ }+ if (!settings.validate().empty()) { emit notice(tr("导出设置无效"), true); return; }+ veyra::log::info("qml-export", std::format("preset={} revision={} nr={} sr={} fg={} bitrate={} srTarget={}",+ impl_->exportPresetName.empty() ? "current" : utf8Of(impl_->exportPresetName).toStdString(),+ settings.revision, settings.nr, settings.sr, settings.multiplier,+ settings.exportBitrateMbps, settings.sr ? int(settings.srTarget) : -1));const bool started = impl_->exportJob.start(impl_->sourceLabel, impl_->exportOutput,- settings, impl_->exportHevc);+ settings, impl_->exportHevc, 0,+ impl_->snapshot.selectedAudioTrack,+ impl_->exportTrimStartSeconds,+ impl_->exportTrimEndSeconds);if (!started) { emit notice(tr("导出启动失败;详见诊断"), true); return; }pollExport();emit navigate(QStringLiteral("exp"));@@ -1346,6 +1455,18 @@ bool QmlPlayerBridge::applyPresetIndex(int index) {emit chainChanged();return true;}+bool QmlPlayerBridge::selectExportPreset(int index) {+ if (index == -1) {+ impl_->exportPresetName.clear();+ } else {+ const auto& entries = impl_->facade.presets().entries();+ if (index < 0 || size_t(index) >= entries.size() || entries[size_t(index)].kind == engine::ChainMode::Node)+ return false;+ impl_->exportPresetName = entries[size_t(index)].name;+ }+ emit exportChanged();+ return true;+}bool QmlPlayerBridge::savePresetAs(const QString& name, int contentsMask, bool nodeMode) {if (name.isEmpty()) { emit notice(tr("预设需要一个名字"), true); return false; }@@ -1367,15 +1488,23 @@ bool QmlPlayerBridge::deletePreset(int index) {if (index < 0 || size_t(index) >= impl_->facade.presets().entries().size()) return false;const auto& entry = impl_->facade.presets().entries()[size_t(index)];if (entry.builtin) { emit notice(tr("内置预设不能删除,可以另存一份"), true); return false; }+ const bool selected = impl_->exportPresetName == entry.name;const bool ok = impl_->facade.presets().erase(size_t(index));- if (ok) emit presetsChanged();+ if (ok) {+ if (selected) { impl_->exportPresetName.clear(); emit exportChanged(); }+ emit presetsChanged();+ }return ok;}bool QmlPlayerBridge::renamePreset(int index, const QString& name) {if (index < 0 || size_t(index) >= impl_->facade.presets().entries().size()) return false;+ const bool selected = impl_->exportPresetName == impl_->facade.presets().entries()[size_t(index)].name;const bool ok = impl_->facade.presets().rename(size_t(index), wideOf(name));- if (ok) emit presetsChanged();+ if (ok) {+ if (selected) { impl_->exportPresetName = wideOf(name); emit exportChanged(); }+ emit presetsChanged();+ }return ok;}diff --git a/src/ui/ThumbnailProvider.cpp b/src/ui/ThumbnailProvider.cppnew file mode 100644index 00000000..b579109c--- /dev/null+++ b/src/ui/ThumbnailProvider.cpp@@ -0,0 +1,108 @@+#include "veyra/ui/ThumbnailProvider.h"++#include <QImage>++#include "veyra/engine/PosterFrame.h"++extern "C" {+#include <libavcodec/avcodec.h>+#include <libavformat/avformat.h>+#include <libavutil/avutil.h>+#include <libavutil/pixdesc.h>+}++#include <algorithm>+#include <cstdint>+#include <vector>++namespace veyra::ui {+namespace {+AVPixelFormat softwareFormat(AVCodecContext*, const AVPixelFormat* formats) {+ for (const AVPixelFormat* format = formats; *format != AV_PIX_FMT_NONE; ++format) {+ const AVPixFmtDescriptor* desc = av_pix_fmt_desc_get(*format);+ if (desc && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) return *format;+ }+ return AV_PIX_FMT_NONE;+}+} // namespace++ThumbnailProvider::ThumbnailProvider() : QQuickImageProvider(QQuickImageProvider::Image) {}++void ThumbnailProvider::setSource(const QString& path) {+ std::lock_guard lock(mutex_);+ source_ = path;+}++QImage ThumbnailProvider::requestImage(const QString& id, QSize* size, const QSize&) {+ if (size) *size = {};+ QString path;+ {+ std::lock_guard lock(mutex_);+ path = source_;+ }+ bool validTime = false;+ const int64_t milliseconds = id.section(QLatin1Char('/'), 1, 1).toLongLong(&validTime);+ if (path.isEmpty() || !validTime || milliseconds < 0) return {};++ AVFormatContext* format = nullptr;+ AVCodecContext* decoder = nullptr;+ AVPacket* packet = nullptr;+ AVFrame* frame = nullptr;+ AVFrame* candidate = nullptr;+ QImage result;+ const QByteArray encodedPath = path.toUtf8();+ if (avformat_open_input(&format, encodedPath.constData(), nullptr, nullptr) < 0) goto done;+ if (avformat_find_stream_info(format, nullptr) < 0) goto done;+ {+ const int streamIndex = av_find_best_stream(format, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);+ if (streamIndex < 0) goto done;+ AVStream* stream = format->streams[streamIndex];+ const AVCodec* codec = avcodec_find_decoder(stream->codecpar->codec_id);+ if (!codec) goto done;+ decoder = avcodec_alloc_context3(codec);+ if (!decoder || avcodec_parameters_to_context(decoder, stream->codecpar) < 0) goto done;+ decoder->get_format = softwareFormat;+ if (avcodec_open2(decoder, codec, nullptr) < 0) goto done;+ packet = av_packet_alloc();+ frame = av_frame_alloc();+ candidate = av_frame_alloc();+ if (!packet || !frame || !candidate) goto done;++ const int64_t target = av_rescale_q(milliseconds, AVRational{1, 1000}, stream->time_base) ++ (stream->start_time == AV_NOPTS_VALUE ? 0 : stream->start_time);+ if (av_seek_frame(format, streamIndex, target, AVSEEK_FLAG_BACKWARD) < 0) goto done;+ avcodec_flush_buffers(decoder);++ bool reached = false;+ // Bounded work: a long GOP can be expensive, but never blocks playback.+ for (int n = 0; n < 240 && !reached && av_read_frame(format, packet) >= 0; ++n) {+ if (packet->stream_index == streamIndex && avcodec_send_packet(decoder, packet) >= 0) {+ while (avcodec_receive_frame(decoder, frame) >= 0) {+ av_frame_unref(candidate);+ if (av_frame_ref(candidate, frame) < 0) break;+ const int64_t pts = frame->best_effort_timestamp;+ reached = pts != AV_NOPTS_VALUE && pts >= target;+ av_frame_unref(frame);+ if (reached) break;+ }+ }+ av_packet_unref(packet);+ }+ if (candidate->width > 0 && candidate->height > 0) {+ std::vector<uint8_t> rgba;+ uint32_t width = 0, height = 0;+ if (engine::makePosterFrame(candidate, 144, 81, rgba, width, height))+ result = QImage(rgba.data(), int(width), int(height), int(width * 4), QImage::Format_RGBA8888).copy();+ }+ }+done:+ av_frame_free(&candidate);+ av_frame_free(&frame);+ av_packet_free(&packet);+ avcodec_free_context(&decoder);+ avformat_close_input(&format);+ if (size) *size = result.size();+ return result;+}++} // namespace veyra::uidiff --git a/tests/unit/PresetLibraryTests.cpp b/tests/unit/PresetLibraryTests.cppindex 720100cb..06ecc2a0 100644--- a/tests/unit/PresetLibraryTests.cpp+++ b/tests/unit/PresetLibraryTests.cpp@@ -41,6 +41,10 @@ int main() {bool allBuiltin = true;for (const auto& e : library.entries()) allBuiltin = allBuiltin && e.builtin;check(allBuiltin, "built-ins are flagged read-only");+ auto original = sample();+ PresetLibrary::apply(library.entries().front(), original);+ check(original.multiplier == 1 && !original.nr && !original.sr,+ "original built-in disables frame generation and enhancement");check(!library.erase(0), "a built-in cannot be erased");check(!library.rename(0, L"改个名"), "a built-in cannot be renamed");check(library.duplicate(0), "a built-in can be duplicated");diff --git a/tests/unit/QmlDataDirectoryTests.cpp b/tests/unit/QmlDataDirectoryTests.cppnew file mode 100644index 00000000..88c65a6c--- /dev/null+++ b/tests/unit/QmlDataDirectoryTests.cpp@@ -0,0 +1,49 @@+#include "veyra/ui/QmlDataDirectory.h"++#include <filesystem>+#include <fstream>+#include <iostream>+#include <string>++namespace {+void write(const std::filesystem::path& path, const char* contents) {+ std::ofstream out(path, std::ios::binary);+ out << contents;+}+std::string read(const std::filesystem::path& path) {+ std::ifstream in(path, std::ios::binary);+ return {std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>()};+}+bool check(bool condition, const char* message) {+ if (!condition) std::cerr << "FAIL: " << message << '\n';+ return condition;+}+} // namespace++int main(int argc, char** argv) {+ if (argc != 2) { std::cerr << "usage: veyra_qml_data_tests <new scratch directory>\n"; return 2; }+ const std::filesystem::path root(argv[1]);+ if (std::filesystem::exists(root)) { std::cerr << "scratch directory already exists\n"; return 2; }+ const auto old = root / "legacy";+ const auto current = root / "current";+ std::filesystem::create_directories(old);+ write(old / "user-presets.v1", "original preset");+ write(old / "ui-session.v1", "original session");+ write(old / "private-key.txt", "do not copy");++ const auto first = veyra::ui::prepareQmlDataDirectory(old, current);+ if (!first.ok) std::cerr << "migration error: " << first.error << '\n';+ bool ok = check(first.ok && first.copied == 2, "first migration copies two allowlisted files");+ ok &= check(read(current / "user-presets.v1") == "original preset", "preset copied");+ ok &= check(!std::filesystem::exists(current / "private-key.txt"), "unknown file excluded");+ write(current / "user-presets.v1", "edited in 2.0.0");+ write(old / "ui-session.v1", "edited in 1.4.4");+ const auto second = veyra::ui::prepareQmlDataDirectory(old, current);+ if (!second.ok) std::cerr << "second migration error: " << second.error << '\n';+ ok &= check(second.ok && second.copied == 0, "second launch does not migrate again");+ ok &= check(read(current / "user-presets.v1") == "edited in 2.0.0", "new preset preserved");+ ok &= check(read(current / "ui-session.v1") == "original session", "old edit cannot rewrite 2.0.0");+ ok &= check(read(old / "user-presets.v1") == "original preset", "1.4.4 file untouched");+ std::cout << (ok ? "PASS" : "FAIL") << " qml data migration\n";+ return ok ? 0 : 1;+}diff --git a/tools/export_probe/main.cpp b/tools/export_probe/main.cppindex d0af2e6a..341b3daf 100644--- a/tools/export_probe/main.cpp+++ b/tools/export_probe/main.cpp@@ -4,6 +4,8 @@// the run only exercises decode -> ingress -> encode -> mux -> verify.//// veyra_export_probe <input> <output> [--hevc] [--max-frames N]+// [--trim-start seconds] [--trim-end seconds]+// [--audio-stream index]//// Exit codes: 0 completed, 1 export refused/failed, 2 bad arguments.#include "veyra/engine/VideoExportJob.h"@@ -16,13 +18,15 @@int wmain(int argc, wchar_t** argv){if (argc < 3) {- std::fwprintf(stderr, L"usage: veyra_export_probe <input> <output> [--hevc] [--video-hdr] [--max-frames N]\n");+ std::fwprintf(stderr, L"usage: veyra_export_probe <input> <output> [--hevc] [--video-hdr] [--max-frames N] [--trim-start seconds] [--trim-end seconds] [--audio-stream index]\n");return 2;}const std::wstring input = argv[1];const std::wstring output = argv[2];bool hevc = false, videoHdr = false;unsigned maxFrames = 0;+ double trimStart = 0.0, trimEnd = 0.0;+ int audioStream = -1;for (int i = 3; i < argc; ++i) {const std::wstring arg = argv[i];if (arg == L"--hevc") {@@ -31,6 +35,12 @@ int wmain(int argc, wchar_t** argv)videoHdr = true;} else if (arg == L"--max-frames" && i + 1 < argc) {maxFrames = unsigned(std::wcstoul(argv[++i], nullptr, 10));+ } else if (arg == L"--trim-start" && i + 1 < argc) {+ trimStart = std::wcstod(argv[++i], nullptr);+ } else if (arg == L"--trim-end" && i + 1 < argc) {+ trimEnd = std::wcstod(argv[++i], nullptr);+ } else if (arg == L"--audio-stream" && i + 1 < argc) {+ audioStream = int(std::wcstol(argv[++i], nullptr, 10));} else {std::fwprintf(stderr, L"unknown argument: %ls\n", arg.c_str());return 2;@@ -39,6 +49,9 @@ int wmain(int argc, wchar_t** argv)veyra::engine::PlayerOptions options; // nr/sr/fg all off: decode -> encode onlyoptions.settings.videoHdr.enabled = videoHdr;+ options.exportStartSeconds = trimStart;+ options.exportEndSeconds = trimEnd;+ options.audioStreamIndex = audioStream;std::atomic<bool> cancel{false};const bool ok = veyra::engine::exportVideo(input, output, options, hevc, cancel,[](double progress, const std::wstring& message) {diff --git a/tools/qt_probe/shot-page.ps1 b/tools/qt_probe/shot-page.ps1index 00968ab4..a5471888 100644--- a/tools/qt_probe/shot-page.ps1+++ b/tools/qt_probe/shot-page.ps1@@ -59,6 +59,8 @@ if ($offsets.ContainsKey($Page)) {}[W2]::SetCursorPos($r.Right + 300, $r.Bottom + 300) | Out-NullStart-Sleep -Milliseconds 400+[W2]::SetForegroundWindow($h) | Out-Null+Start-Sleep -Milliseconds 200[W2]::GetWindowRect($h, [ref]$r) | Out-Null$w = $r.Right - $r.Left