9
9
#include " TimeWarp.h"
10
10
#include " Util.h"
11
11
12
+ #include < opentimelineio/clip.h>
12
13
#include < opentimelineio/externalReference.h>
13
14
#include < opentimelineio/gap.h>
14
15
#include < opentimelineio/generatorReference.h>
@@ -24,27 +25,28 @@ namespace toucan
24
25
25
26
ImageGraph::ImageGraph (
26
27
const std::filesystem::path& path,
27
- const std::shared_ptr<Timeline >& timeline ,
28
+ const std::shared_ptr<TimelineWrapper >& timelineWrapper ,
28
29
const ImageGraphOptions& options) :
29
30
_path (path),
30
- _timeline (timeline ),
31
- _timeRange (timeline ->getTimeRange ()),
31
+ _timelineWrapper (timelineWrapper ),
32
+ _timeRange (timelineWrapper ->getTimeRange ()),
32
33
_options(options)
33
34
{
34
35
_loadCache.setMax (10 );
35
36
36
37
// Get the image size from the first video clip.
37
- for (auto track : _timeline-> otio ()->find_children <OTIO_NS::Track>())
38
+ for (auto track : _timelineWrapper-> getTimeline ()->find_children <OTIO_NS::Track>())
38
39
{
39
40
if (OTIO_NS::Track::Kind::video == track->kind ())
40
41
{
41
42
for (auto clip : track->find_clips ())
42
43
{
43
44
if (auto externalRef = dynamic_cast <OTIO_NS::ExternalReference*>(clip->media_reference ()))
44
45
{
45
- const std::filesystem::path path = _timeline->getMediaPath (externalRef->target_url ());
46
- const OIIO::ImageBuf buf (path.string ());
47
- const auto & spec = buf.spec ();
46
+ auto read = std::make_shared<ReadNode>(
47
+ _timelineWrapper->getMediaPath (externalRef->target_url ()),
48
+ _timelineWrapper->getMemoryReference (externalRef->target_url ()));
49
+ const auto & spec = read->getSpec ();
48
50
if (spec.width > 0 )
49
51
{
50
52
_imageSize.x = spec.width ;
@@ -54,14 +56,16 @@ namespace toucan
54
56
}
55
57
else if (auto sequenceRef = dynamic_cast <OTIO_NS::ImageSequenceReference*>(clip->media_reference ()))
56
58
{
57
- const std::filesystem::path path = getSequenceFrame (
58
- _timeline ->getMediaPath (sequenceRef->target_url_base ()),
59
+ auto read = std::make_shared<SequenceReadNode> (
60
+ _timelineWrapper ->getMediaPath (sequenceRef->target_url_base ()),
59
61
sequenceRef->name_prefix (),
62
+ sequenceRef->name_suffix (),
60
63
sequenceRef->start_frame (),
64
+ sequenceRef->frame_step (),
65
+ sequenceRef->rate (),
61
66
sequenceRef->frame_zero_padding (),
62
- sequenceRef->name_suffix ());
63
- const OIIO::ImageBuf buf (path.string ());
64
- const auto & spec = buf.spec ();
67
+ _timelineWrapper->getMemoryReferences ());
68
+ const auto & spec = read->getSpec ();
65
69
if (spec.width > 0 )
66
70
{
67
71
_imageSize.x = spec.width ;
@@ -102,7 +106,7 @@ namespace toucan
102
106
std::shared_ptr<IImageNode> node = host->createNode (" toucan:Fill" , metaData);
103
107
104
108
// Loop over the tracks.
105
- auto stack = _timeline-> otio ()->tracks ();
109
+ auto stack = _timelineWrapper-> getTimeline ()->tracks ();
106
110
for (const auto & i : stack->children ())
107
111
{
108
112
if (auto track = OTIO_NS::dynamic_retainer_cast<OTIO_NS::Track>(i))
@@ -294,8 +298,9 @@ namespace toucan
294
298
std::shared_ptr<ReadNode> read;
295
299
if (!_loadCache.get (externalRef, read))
296
300
{
297
- const std::filesystem::path path = _timeline->getMediaPath (externalRef->target_url ());
298
- read = std::make_shared<ReadNode>(path);
301
+ read = std::make_shared<ReadNode>(
302
+ _timelineWrapper->getMediaPath (externalRef->target_url ()),
303
+ _timelineWrapper->getMemoryReference (externalRef->target_url ()));
299
304
_loadCache.add (externalRef, read);
300
305
}
301
306
out = read;
@@ -312,15 +317,15 @@ namespace toucan
312
317
}
313
318
else if (auto sequenceRef = dynamic_cast <OTIO_NS::ImageSequenceReference*>(clip->media_reference ()))
314
319
{
315
- const std::filesystem::path path = _timeline->getMediaPath (sequenceRef->target_url_base ());
316
320
auto read = std::make_shared<SequenceReadNode>(
317
- path ,
321
+ _timelineWrapper-> getMediaPath (sequenceRef-> target_url_base ()) ,
318
322
sequenceRef->name_prefix (),
319
323
sequenceRef->name_suffix (),
320
324
sequenceRef->start_frame (),
321
325
sequenceRef->frame_step (),
322
326
sequenceRef->rate (),
323
- sequenceRef->frame_zero_padding ());
327
+ sequenceRef->frame_zero_padding (),
328
+ _timelineWrapper->getMemoryReferences ());
324
329
out = read;
325
330
}
326
331
else if (auto generatorRef = dynamic_cast <OTIO_NS::GeneratorReference*>(clip->media_reference ()))
0 commit comments