Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/darbyjohnston/tlRender into…
Browse files Browse the repository at this point in the history
… darby_main_original
  • Loading branch information
ggarra13 committed Feb 20, 2024
2 parents d65fff5 + e1d8d67 commit 3083cae
Show file tree
Hide file tree
Showing 23 changed files with 197 additions and 178 deletions.
3 changes: 3 additions & 0 deletions examples/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace tl
addWindow(_window);

auto viewport = timelineui::TimelineViewport::create(context, _window);
timeline::BackgroundOptions backgroundOptions;
backgroundOptions.type = timeline::Background::Checkers;
viewport->setBackgroundOptions(backgroundOptions);
viewport->setPlayers({ _player });

_window->show();
Expand Down
28 changes: 15 additions & 13 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
add_subdirectory(tlBaseApp)
add_subdirectory(tlCore)
add_subdirectory(tlGL)
add_subdirectory(tlDevice)
add_subdirectory(tlIO)
add_subdirectory(tlPlay)
add_subdirectory(tlResourceApp)
add_subdirectory(tlTimeline)
add_subdirectory(tlTimelineUI)
add_subdirectory(tlUI)
if(TLRENDER_GLFW)
add_subdirectory(tlTimelineGL)
if(TLRENDER_PROGRAMS OR TLRENDER_EXAMPLES)
add_subdirectory(tlUIApp)
endif()
if(TLRENDER_PROGRAMS)
add_subdirectory(tlBakeApp)
add_subdirectory(tlPlayApp)
endif()
add_subdirectory(tlTimelineGL)
if(TLRENDER_PROGRAMS OR TLRENDER_EXAMPLES OR TLRENDER_TESTS)
add_subdirectory(tlBaseApp)
endif()
if(TLRENDER_PROGRAMS OR TLRENDER_EXAMPLES)
add_subdirectory(tlUIApp)
endif()
if(TLRENDER_PROGRAMS)
add_subdirectory(tlBakeApp)
add_subdirectory(tlPlayApp)
add_subdirectory(tlResourceApp)
endif()
endif()
if(TLRENDER_QT6 OR TLRENDER_QT5 AND NOT "${TLRENDER_API}" STREQUAL "GLES_2")
add_subdirectory(tlQt)
add_subdirectory(tlQtQuick)
add_subdirectory(tlQtWidget)
if(TLRENDER_PROGRAMS)
add_subdirectory(tlPlayQtApp)
endif()
if(TLRENDER_PROGRAMS)
add_subdirectory(tlPlayQtApp)
endif()
endif()
1 change: 1 addition & 0 deletions lib/tlCore/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace tl
for (; i > 0 && value[i - 1] >= '0' && value[i - 1] <= '9'; --i)
;
if (value[i] >= '0' && value[i] <= '9' &&
options.maxNumberDigits > 0 &&
(j - i) <= options.maxNumberDigits)
{
_number = value.substr(i, j - i);
Expand Down
62 changes: 32 additions & 30 deletions lib/tlIO/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,38 @@ namespace tl
{
namespace io
{
std::string getCacheKey(
const file::Path& path,
const otime::RationalTime& time,
const Options& options)
{
std::vector<std::string> s;
s.push_back(path.get());
s.push_back(path.getNumber());
s.push_back(string::Format("{0}").arg(time));
for (const auto& i : options)
{
s.push_back(string::Format("{0}:{1}").arg(i.first).arg(i.second));
}
return string::join(s, ';');
}

std::string getCacheKey(
const file::Path& path,
const otime::TimeRange& timeRange,
const Options& options)
{
std::vector<std::string> s;
s.push_back(path.get());
s.push_back(path.getNumber());
s.push_back(string::Format("{0}").arg(timeRange));
for (const auto& i : options)
{
s.push_back(string::Format("{0}:{1}").arg(i.first).arg(i.second));
}
return string::join(s, ';');
}

struct Cache::Private
{
size_t max = memory::gigabyte;
Expand Down Expand Up @@ -71,21 +103,6 @@ namespace tl
static_cast<float>(p.video.getMax() + p.audio.getMax()) * 100.F;
}

std::string Cache::getVideoKey(
const std::string& fileName,
const otime::RationalTime& time,
const Options& options)
{
std::vector<std::string> s;
s.push_back(fileName);
s.push_back(string::Format("{0}").arg(time));
for (const auto& i : options)
{
s.push_back(string::Format("{0}:{1}").arg(i.first).arg(i.second));
}
return string::join(s, ';');
}

void Cache::addVideo(const std::string& key, const VideoData& videoData)
{
TLRENDER_P();
Expand All @@ -110,21 +127,6 @@ namespace tl
return p.video.get(key, videoData);
}

std::string Cache::getAudioKey(
const std::string& fileName,
const otime::TimeRange& timeRange,
const Options& options)
{
std::vector<std::string> s;
s.push_back(fileName);
s.push_back(string::Format("{0}").arg(timeRange));
for (const auto& i : options)
{
s.push_back(string::Format("{0}:{1}").arg(i.first).arg(i.second));
}
return string::join(s, ';');
}

void Cache::addAudio(const std::string& key, const AudioData& audioData)
{
TLRENDER_P();
Expand Down
26 changes: 14 additions & 12 deletions lib/tlIO/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@

#include <tlIO/IO.h>

#include <tlCore/Path.h>

namespace tl
{
namespace io
{
//! Get a cache key.
std::string getCacheKey(
const file::Path&,
const otime::RationalTime&,
const Options& = Options());

//! Get a cache key.
std::string getCacheKey(
const file::Path&,
const otime::TimeRange&,
const Options& = Options());

//! I/O cache.
class Cache : public std::enable_shared_from_this<Cache>
{
Expand Down Expand Up @@ -38,12 +52,6 @@ namespace tl
//! Get the current cache size as a percentage.
float getPercentage() const;

//! Get a video cache key.
static std::string getVideoKey(
const std::string& fileName,
const otime::RationalTime&,
const Options&);

//! Add video to the cache.
void addVideo(const std::string& key, const VideoData&);

Expand All @@ -53,12 +61,6 @@ namespace tl
//! Get video from the cache.
bool getVideo(const std::string& key, VideoData&) const;

//! Get an audio cache key.
static std::string getAudioKey(
const std::string& fileName,
const otime::TimeRange&,
const Options&);

//! Add audio to the cache.
void addAudio(const std::string& key, const AudioData&);

Expand Down
16 changes: 8 additions & 8 deletions lib/tlIO/FFmpegRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ namespace tl
io::VideoData videoData;
if (videoRequest && _cache)
{
const std::string cacheKey = io::Cache::getVideoKey(
_path.get(),
const std::string cacheKey = io::getCacheKey(
_path,
videoRequest->time,
videoRequest->options);
if (_cache->getVideo(cacheKey, videoData))
Expand Down Expand Up @@ -421,8 +421,8 @@ namespace tl

if (_cache)
{
const std::string cacheKey = io::Cache::getVideoKey(
_path.get(),
const std::string cacheKey = io::getCacheKey(
_path,
videoRequest->time,
videoRequest->options);
_cache->addVideo(cacheKey, data);
Expand Down Expand Up @@ -500,8 +500,8 @@ namespace tl
io::AudioData audioData;
if (request && _cache)
{
const std::string cacheKey = io::Cache::getAudioKey(
_path.get(),
const std::string cacheKey = io::getCacheKey(
_path,
request->timeRange,
request->options);
if (_cache->getAudio(cacheKey, audioData))
Expand Down Expand Up @@ -557,8 +557,8 @@ namespace tl

if (_cache)
{
const std::string cacheKey = io::Cache::getAudioKey(
_path.get(),
const std::string cacheKey = io::getCacheKey(
_path,
request->timeRange,
request->options);
_cache->addAudio(cacheKey, audioData);
Expand Down
1 change: 0 additions & 1 deletion lib/tlIO/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <tlIO/Cache.h>

#include <tlCore/FileIO.h>
#include <tlCore/Path.h>

#include <future>
#include <set>
Expand Down
19 changes: 7 additions & 12 deletions lib/tlIO/SequenceIORead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ namespace tl
{
TLRENDER_P();
auto request = std::make_shared<Private::VideoRequest>();
request->fileName = _path.get(-1, file::PathType::Path);
request->time = time;
request->options = merge(options, _options);
auto future = request->promise.get_future();
Expand Down Expand Up @@ -214,33 +213,29 @@ namespace tl
videoRequests.pop_front();

VideoData videoData;
const std::string cacheKey = Cache::getVideoKey(
request->fileName,
const std::string cacheKey = getCacheKey(
_path,
request->time,
request->options);
if (_cache && _cache->getVideo(cacheKey, videoData))
{
//std::cout << "cache: " << request->fileName << " " <<
// request->time << std::endl;
request->promise.set_value(videoData);
}
else
{
//std::cout << "request: " << request->fileName << " " <<
// request->time << std::endl;
bool seq = false;
std::string fileName;
if (!_path.getNumber().empty())
{
seq = true;
request->fileName = _path.get(
fileName = _path.get(
static_cast<int>(request->time.value()),
file::PathType::Path);
}
else
{
request->fileName = _path.get(-1, file::PathType::Path);
fileName = _path.get(-1, file::PathType::Path);
}
const std::string fileName = request->fileName;
const otime::RationalTime time = request->time;
const Options options = request->options;
request->future = std::async(
Expand Down Expand Up @@ -285,8 +280,8 @@ namespace tl

if (_cache)
{
const std::string cacheKey = Cache::getVideoKey(
(*requestIt)->fileName,
const std::string cacheKey = getCacheKey(
_path,
(*requestIt)->time,
(*requestIt)->options);
_cache->addVideo(cacheKey, videoData);
Expand Down
2 changes: 0 additions & 2 deletions lib/tlIO/SequenceIOReadPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ namespace tl
otime::RationalTime time = time::invalidTime;
Options options;
std::promise<VideoData> promise;

std::string fileName;
std::future<VideoData> future;
};

Expand Down
Loading

0 comments on commit 3083cae

Please sign in to comment.