Skip to content

Commit 4b7143e

Browse files
Merge pull request #35 from darbyjohnston/refactor10
Add context menus
2 parents ae5f29b + 970244c commit 4b7143e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1638
-383
lines changed

bin/toucan-render/App.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "App.h"
55

66
#include <toucanRender/FFmpegWrite.h>
7+
#include <toucanRender/Read.h>
78
#include <toucanRender/Util.h>
89

910
#include <dtk/core/CmdLine.h>
@@ -209,7 +210,7 @@ namespace toucan
209210

210211
// Open the movie file.
211212
std::shared_ptr<ffmpeg::Write> ffWrite;
212-
if (ffmpeg::hasVideoExtension(outputPath.extension().string()))
213+
if (MovieReadNode::hasExtension(outputPath.extension().string()))
213214
{
214215
ffmpeg::VideoCodec videoCodec = ffmpeg::VideoCodec::First;
215216
ffmpeg::fromString(_options.videoCodec, videoCodec);

cmake/SuperBuild/Builddtk-deps.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include(ExternalProject)
22

33
set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git")
4-
set(dtk_GIT_TAG "f9bb41e9e45ce50c34e02dafe2b88f01985eed61")
4+
set(dtk_GIT_TAG "24600e0d096205733c2adceb3ffc7b330c5402f9")
55

66
set(dtk-deps_ARGS
77
${toucan_EXTERNAL_PROJECT_ARGS}

cmake/SuperBuild/Builddtk.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include(ExternalProject)
22

33
set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git")
4-
set(dtk_GIT_TAG "f9bb41e9e45ce50c34e02dafe2b88f01985eed61")
4+
set(dtk_GIT_TAG "24600e0d096205733c2adceb3ffc7b330c5402f9")
55

66
set(dtk_DEPS dtk-deps)
77
set(dtk_ARGS

lib/toucanRender/FFmpeg.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "FFmpeg.h"
55

6+
#include "Util.h"
7+
68
extern "C"
79
{
810
#include <libavcodec/avcodec.h>
@@ -21,18 +23,6 @@ namespace toucan
2123
return AVRational({ value.den, value.num });
2224
}
2325

24-
std::vector<std::string> getVideoExtensions()
25-
{
26-
return std::vector<std::string>({ ".mov", ".mp4", ".m4v", ".y4m" });
27-
}
28-
29-
bool hasVideoExtension(const std::string& value)
30-
{
31-
const std::vector<std::string> extensions = getVideoExtensions();
32-
const auto i = std::find(extensions.begin(), extensions.end(), value);
33-
return i != extensions.end();
34-
}
35-
3626
namespace
3727
{
3828
std::vector<std::pair<int, std::string> > _getVideoCodecs()

lib/toucanRender/FFmpeg.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ namespace toucan
2020
//! Swap the numerator and denominator.
2121
AVRational swap(AVRational);
2222

23-
//! Get a list of supported video extensions.
24-
std::vector<std::string> getVideoExtensions();
25-
26-
//! Check if the given extension is supported.
27-
bool hasVideoExtension(const std::string&);
28-
2923
//! Video codecs.
3024
enum class VideoCodec
3125
{

lib/toucanRender/ImageGraph.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,17 @@ namespace toucan
5757
{
5858
try
5959
{
60-
auto read = std::make_shared<ReadNode>(
61-
_timelineWrapper->getMediaPath(externalRef->target_url()),
62-
_timelineWrapper->getMemoryReference(externalRef->target_url()));
60+
const std::filesystem::path path = _timelineWrapper->getMediaPath(externalRef->target_url());
61+
const MemoryReference mem = _timelineWrapper->getMemoryReference(externalRef->target_url());
62+
std::shared_ptr<IReadNode> read;
63+
if (MovieReadNode::hasExtension(path.extension().string()))
64+
{
65+
read = std::make_shared<MovieReadNode>(path, mem);
66+
}
67+
else
68+
{
69+
read = std::make_shared<ImageReadNode>(path, mem);
70+
}
6371
const auto& spec = read->getSpec();
6472
if (spec.width > 0)
6573
{
@@ -338,14 +346,21 @@ namespace toucan
338346
// Get the media reference.
339347
if (auto externalRef = dynamic_cast<OTIO_NS::ExternalReference*>(clip->media_reference()))
340348
{
341-
std::shared_ptr<ReadNode> read;
349+
std::shared_ptr<IReadNode> read;
342350
if (!_loadCache.get(externalRef, read))
343351
{
344352
try
345353
{
346-
read = std::make_shared<ReadNode>(
347-
_timelineWrapper->getMediaPath(externalRef->target_url()),
348-
_timelineWrapper->getMemoryReference(externalRef->target_url()));
354+
const std::filesystem::path path = _timelineWrapper->getMediaPath(externalRef->target_url());
355+
const MemoryReference mem = _timelineWrapper->getMemoryReference(externalRef->target_url());
356+
if (MovieReadNode::hasExtension(path.extension().string()))
357+
{
358+
read = std::make_shared<MovieReadNode>(path, mem);
359+
}
360+
else
361+
{
362+
read = std::make_shared<ImageReadNode>(path, mem);
363+
}
349364
}
350365
catch (const std::exception& e)
351366
{

lib/toucanRender/ImageGraph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace toucan
2020
{
21-
class ReadNode;
21+
class IReadNode;
2222

2323
//! Create image graphs from a timeline.
2424
class ImageGraph : public std::enable_shared_from_this<ImageGraph>
@@ -70,6 +70,6 @@ namespace toucan
7070
IMATH_NAMESPACE::V2i _imageSize = IMATH_NAMESPACE::V2i(0, 0);
7171
int _imageChannels = 0;
7272
std::string _imageDataType;
73-
dtk::LRUCache<OTIO_NS::MediaReference*, std::shared_ptr<ReadNode> > _loadCache;
73+
dtk::LRUCache<OTIO_NS::MediaReference*, std::shared_ptr<IReadNode> > _loadCache;
7474
};
7575
}

0 commit comments

Comments
 (0)