From 01129bd465ab819de3c28ee9178cddf340b1fb24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Fri, 13 Oct 2023 05:24:41 -0300 Subject: [PATCH] Fixed missing frame and refresh cache. --- mrv2/docs/HISTORY.md | 11 ++++++---- mrv2/lib/mrvCore/mrvUtil.cpp | 28 +++++++++++++++++++++----- mrv2/lib/mrvCore/mrvUtil.h | 7 +++++++ mrv2/lib/mrvFl/mrvCallbacks.cpp | 3 ++- mrv2/lib/mrvGL/mrvTimelineViewport.cpp | 14 ++++++++++--- 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/mrv2/docs/HISTORY.md b/mrv2/docs/HISTORY.md index 5ee39da7a..e4d83d6e4 100644 --- a/mrv2/docs/HISTORY.md +++ b/mrv2/docs/HISTORY.md @@ -16,12 +16,12 @@ v0.8.0 ones. - Added a cmd.getVersion() to get the version of mrv2 from Python. - Made playback play with audio when changing frame rate (slower or faster). -- Made audio play when stepping through frames. It is currently a hack and not - a proper fix yet. Also, the stepping buttons are not updated properly. +- Made audio play when stepping through frames. It is currently a hack and + not a proper fix yet. Also, the stepping buttons are not updated properly. - Fixed a locale change when using the FPS pull-down and there were thumbnails present. -- Fixed macOS menu bar font size when switching from macOS menus back to normal - ones. +- Fixed macOS menu bar font size when switching from macOS menus back to + normal ones. - Made saving of .otio files also work from File/Save/Movie or Sequence if the extension given is .otio. - Added user metadata to save in the session file as "metadata". This can be @@ -48,6 +48,9 @@ v0.8.0 - Creating a timeline in the Playlist Panel is also done in seconds. - Fixed a crash when creating an empty timeline or a timeline from a clip in the Playlist Panel. +- Fixed missing frames (Repeat Last and Repeat Scratched) when the user was + reading a different layer and he was playing backwards or stepping through + the frames. - Some UI fixes: * The Zoom factor in the Pixel Toolbar keeps its value when selecting it from the pulldown. diff --git a/mrv2/lib/mrvCore/mrvUtil.cpp b/mrv2/lib/mrvCore/mrvUtil.cpp index 1b0199da7..bf8c723fa 100644 --- a/mrv2/lib/mrvCore/mrvUtil.cpp +++ b/mrv2/lib/mrvCore/mrvUtil.cpp @@ -3,6 +3,7 @@ // Copyright Contributors to the mrv2 Project. All rights reserved. #include +#include #include namespace fs = std::filesystem; @@ -16,6 +17,23 @@ namespace fs = std::filesystem; namespace mrv { + std::string randomString() + { + static const std::string charset = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + std::string out; + + const int length = 16; + std::random_device rd; + std::default_random_engine generator(rd()); + std::uniform_int_distribution distribution(0, charset.size() - 1); + + for (int i = 0; i < length; ++i) + { + out += charset[distribution(generator)]; + } + return out; + } int padded_digits(const std::string& frame) { @@ -34,22 +52,22 @@ namespace mrv std::string commentCharacter(const std::string& input, const char match) { - std::string result; + std::string out; for (char c : input) { if (c == match) { - result += "\\"; - result += match; + out += "\\"; + out += match; } else { - result += c; + out += c; } } - return result; + return out; } void parse_directory( diff --git a/mrv2/lib/mrvCore/mrvUtil.h b/mrv2/lib/mrvCore/mrvUtil.h index 11396f510..99ccfe4cc 100644 --- a/mrv2/lib/mrvCore/mrvUtil.h +++ b/mrv2/lib/mrvCore/mrvUtil.h @@ -18,6 +18,13 @@ namespace otime = opentime::OPENTIME_VERSION; namespace mrv { + /** + * Returns a random string (useful to refresh cache). + * + * + * @return random string + */ + std::string randomString(); /** * Given a frame string like "0020", return the number of diff --git a/mrv2/lib/mrvFl/mrvCallbacks.cpp b/mrv2/lib/mrvFl/mrvCallbacks.cpp index a246c8815..4e220b60c 100644 --- a/mrv2/lib/mrvFl/mrvCallbacks.cpp +++ b/mrv2/lib/mrvFl/mrvCallbacks.cpp @@ -1913,7 +1913,8 @@ namespace mrv auto player = ui->uiView->getTimelinePlayer(); if (!player) return; - const io::Options& options = player->getIOOptions(); + io::Options options = player->getIOOptions(); + options["refresh"] = randomString(); player->setIOOptions(options); } diff --git a/mrv2/lib/mrvGL/mrvTimelineViewport.cpp b/mrv2/lib/mrvGL/mrvTimelineViewport.cpp index 2c58eb6f5..aeb3effe8 100644 --- a/mrv2/lib/mrvGL/mrvTimelineViewport.cpp +++ b/mrv2/lib/mrvGL/mrvTimelineViewport.cpp @@ -794,6 +794,7 @@ namespace mrv p.videoData[index] = value; if (index == 0) { + int layerId = sender->videoLayer(); p.missingFrame = false; if (p.missingFrameType != MissingFrameType::kBlackFrame && !value.layers.empty()) @@ -806,17 +807,24 @@ namespace mrv p.missingFrame = true; if (sender->playback() != timeline::Playback::Forward) { + io::Options ioOptions; + { + std::stringstream s; + s << layerId; + ioOptions["Layer"] = s.str(); + } const auto& timeline = sender->timeline(); const auto& inOutRange = sender->inOutRange(); auto currentTime = value.time; - // Seek until we find a previous frame or reach the - // beginning of the inOutRange. + // Seek until we find a previous frame or reach + // the beginning of the inOutRange. while (1) { currentTime -= otio::RationalTime(1, currentTime.rate()); const auto& videoData = - timeline->getVideo(currentTime).get(); + timeline->getVideo(currentTime, ioOptions) + .get(); if (videoData.layers.empty()) continue; const auto& image = videoData.layers[0].image;