diff --git a/examples/render/render.cpp b/examples/render/render.cpp index bcc9fa35..c7c1b5ef 100644 --- a/examples/render/render.cpp +++ b/examples/render/render.cpp @@ -135,7 +135,6 @@ namespace tl compare.push_back(timeline::Timeline::create(_options.compareFileName, _context)); } _player->setCompare(compare); - _videoSizes = _player->getSizes(); _videoDataObserver = observer::ListObserver::create( _player->observeCurrentVideo(), [this](const std::vector& value) @@ -404,7 +403,7 @@ namespace tl const float viewportAspect = viewportSize.getAspect(); const math::Size2i renderSize = timeline::getRenderSize( compareOptions.mode, - _videoSizes); + _videoData); const float renderSizeAspect = renderSize.getAspect(); image::Size transformSize; math::Vector2f transformOffset; @@ -440,7 +439,7 @@ namespace tl math::translate(math::Vector3f(-renderSize.w / 2, -renderSize.h / 2, 0.F))); _render->drawVideo( _videoData, - timeline::getBoxes(compareOptions.mode, _videoSizes), + timeline::getBoxes(compareOptions.mode, _videoData), {}, {}, compareOptions); diff --git a/examples/render/render.h b/examples/render/render.h index b7dfe42a..b7fd5756 100644 --- a/examples/render/render.h +++ b/examples/render/render.h @@ -81,7 +81,6 @@ namespace tl Options _options; std::shared_ptr _player; - std::vector _videoSizes; std::shared_ptr _window; math::Size2i _frameBufferSize; diff --git a/lib/tlDevice/BMDOutputDevice.cpp b/lib/tlDevice/BMDOutputDevice.cpp index 7cf06133..46c8dd3f 100644 --- a/lib/tlDevice/BMDOutputDevice.cpp +++ b/lib/tlDevice/BMDOutputDevice.cpp @@ -75,7 +75,6 @@ namespace tl otime::TimeRange timeRange = time::invalidTimeRange; timeline::Playback playback = timeline::Playback::Stop; otime::RationalTime currentTime = time::invalidTime; - std::vector sizes; std::vector videoData; std::shared_ptr overlay; float volume = 1.F; @@ -98,7 +97,6 @@ namespace tl double viewZoom = 1.0; bool frameView = true; otime::TimeRange timeRange = time::invalidTimeRange; - std::vector sizes; std::vector videoData; std::shared_ptr overlay; @@ -466,12 +464,10 @@ namespace tl p.mutex.playback = timeline::Playback::Stop; p.mutex.currentTime = time::invalidTime; } - p.mutex.sizes.clear(); p.mutex.videoData.clear(); p.mutex.audioData.clear(); if (p.player) { - p.mutex.sizes = p.player->getSizes(); p.mutex.videoData = p.player->getCurrentVideo(); p.mutex.audioData = p.player->getCurrentAudio(); } @@ -554,7 +550,6 @@ namespace tl _p->thread.timeRange != _p->mutex.timeRange || playback != _p->mutex.playback || currentTime != _p->mutex.currentTime || - _p->thread.sizes != _p->mutex.sizes || _p->thread.videoData != _p->mutex.videoData || _p->thread.overlay != _p->mutex.overlay || volume != _p->mutex.volume || @@ -586,7 +581,6 @@ namespace tl p.thread.viewPos != p.mutex.viewPos || p.thread.viewZoom != p.mutex.viewZoom || p.thread.frameView != p.mutex.frameView || - p.thread.sizes != p.mutex.sizes || p.thread.videoData != p.mutex.videoData || p.thread.overlay != p.mutex.overlay; ocioOptions = p.mutex.ocioOptions; @@ -600,7 +594,6 @@ namespace tl p.thread.viewPos = p.mutex.viewPos; p.thread.viewZoom = p.mutex.viewZoom; p.thread.frameView = p.mutex.frameView; - p.thread.sizes = p.mutex.sizes; p.thread.videoData = p.mutex.videoData; p.thread.overlay = p.mutex.overlay; @@ -925,7 +918,7 @@ namespace tl // Create the offscreen buffer. const math::Size2i renderSize = timeline::getRenderSize( compareOptions.mode, - p.thread.sizes); + p.thread.videoData); gl::OffscreenBufferOptions offscreenBufferOptions; offscreenBufferOptions.colorType = getOffscreenType(p.thread.outputPixelType); if (!displayOptions.empty()) @@ -977,7 +970,7 @@ namespace tl { p.thread.render->drawVideo( p.thread.videoData, - timeline::getBoxes(compareOptions.mode, p.thread.sizes), + timeline::getBoxes(compareOptions.mode, p.thread.videoData), imageOptions, displayOptions, compareOptions, diff --git a/lib/tlQt/TimelinePlayer.cpp b/lib/tlQt/TimelinePlayer.cpp index c623dee1..18e670aa 100644 --- a/lib/tlQt/TimelinePlayer.cpp +++ b/lib/tlQt/TimelinePlayer.cpp @@ -237,11 +237,6 @@ namespace tl return _p->player->getIOInfo(); } - std::vector TimelinePlayer::sizes() const - { - return _p->player->getSizes(); - } - double TimelinePlayer::defaultSpeed() const { return _p->player->getDefaultSpeed(); diff --git a/lib/tlQt/TimelinePlayer.h b/lib/tlQt/TimelinePlayer.h index 3fa2214a..9715a392 100644 --- a/lib/tlQt/TimelinePlayer.h +++ b/lib/tlQt/TimelinePlayer.h @@ -150,9 +150,6 @@ namespace tl //! the first clip in the timeline. const io::Info& ioInfo() const; - //! Get the timeline sizes. - std::vector sizes() const; - ///@} //! \name Playback diff --git a/lib/tlQtWidget/TimelineViewport.cpp b/lib/tlQtWidget/TimelineViewport.cpp index 58837531..446f4576 100644 --- a/lib/tlQtWidget/TimelineViewport.cpp +++ b/lib/tlQtWidget/TimelineViewport.cpp @@ -379,7 +379,7 @@ namespace tl p.render->begin(viewportSize); p.render->setOCIOOptions(p.ocioOptions); p.render->setLUTOptions(p.lutOptions); - if (p.player && !p.videoData.empty()) + if (!p.videoData.empty()) { math::Matrix4x4f vm; vm = vm * math::translate(math::Vector3f(p.viewPos.x, p.viewPos.y, 0.F)); @@ -394,7 +394,7 @@ namespace tl p.render->setTransform(pm * vm); p.render->drawVideo( p.videoData, - timeline::getBoxes(p.compareOptions.mode, p.player->sizes()), + timeline::getBoxes(p.compareOptions.mode, p.videoData), p.imageOptions, p.displayOptions, p.compareOptions, @@ -615,12 +615,7 @@ namespace tl math::Size2i TimelineViewport::_renderSize() const { TLRENDER_P(); - math::Size2i out; - if (p.player) - { - out = timeline::getRenderSize(p.compareOptions.mode, p.player->sizes()); - } - return out; + return timeline::getRenderSize(p.compareOptions.mode, p.videoData); } void TimelineViewport::_frameView() diff --git a/lib/tlTimeline/CompareOptions.cpp b/lib/tlTimeline/CompareOptions.cpp index 572f90a0..11c7e473 100644 --- a/lib/tlTimeline/CompareOptions.cpp +++ b/lib/tlTimeline/CompareOptions.cpp @@ -31,10 +31,10 @@ namespace tl TLRENDER_ENUM_IMPL(CompareTimeMode, "Relative", "Absolute"); TLRENDER_ENUM_SERIALIZE_IMPL(CompareTimeMode); - std::vector getBoxes(CompareMode mode, const std::vector& sizes) + std::vector getBoxes(CompareMode mode, const std::vector& videoData) { std::vector out; - const size_t count = sizes.size(); + const size_t count = videoData.size(); switch (mode) { case CompareMode::Horizontal: @@ -42,7 +42,7 @@ namespace tl image::Size size; if (count > 0) { - size = sizes[0]; + size = videoData[0].size; } if (count > 0) { @@ -67,7 +67,7 @@ namespace tl image::Size size; if (count > 0) { - size = sizes[0]; + size = videoData[0].size; } if (count > 0) { @@ -91,9 +91,9 @@ namespace tl if (count > 0) { image::Size tileSize; - for (const auto& i : sizes) + for (const auto& i : videoData) { - tileSize = std::max(tileSize, i); + tileSize = std::max(tileSize, i.size); } int columns = 0; @@ -119,7 +119,7 @@ namespace tl { if (i < count) { - const auto& s = sizes[i]; + const auto& s = videoData[i].size; const math::Box2i box( x, y, @@ -139,19 +139,19 @@ namespace tl out.push_back(math::Box2i( 0, 0, - sizes[0].w * sizes[0].pixelAspectRatio, - sizes[0].h)); + videoData[0].size.w * videoData[0].size.pixelAspectRatio, + videoData[0].size.h)); } break; } return out; } - math::Size2i getRenderSize(CompareMode mode, const std::vector& sizes) + math::Size2i getRenderSize(CompareMode mode, const std::vector& videoData) { math::Size2i out; math::Box2i box; - const auto boxes = getBoxes(mode, sizes); + const auto boxes = getBoxes(mode, videoData); if (!boxes.empty()) { box = boxes[0]; diff --git a/lib/tlTimeline/CompareOptions.h b/lib/tlTimeline/CompareOptions.h index d67e2113..b40b0d57 100644 --- a/lib/tlTimeline/CompareOptions.h +++ b/lib/tlTimeline/CompareOptions.h @@ -4,9 +4,7 @@ #pragma once -#include -#include -#include +#include namespace tl { @@ -55,10 +53,10 @@ namespace tl }; //! Get the boxes for the given compare mode and sizes. - std::vector getBoxes(CompareMode, const std::vector&); + std::vector getBoxes(CompareMode, const std::vector&); //! Get the render size for the given compare mode and sizes. - math::Size2i getRenderSize(CompareMode, const std::vector&); + math::Size2i getRenderSize(CompareMode, const std::vector&); //! Get a compare time. otime::RationalTime getCompareTime( diff --git a/lib/tlTimeline/Player.cpp b/lib/tlTimeline/Player.cpp index 3b52d482..2f070661 100644 --- a/lib/tlTimeline/Player.cpp +++ b/lib/tlTimeline/Player.cpp @@ -393,22 +393,6 @@ namespace tl return _p->ioInfo; } - std::vector Player::getSizes() const - { - TLRENDER_P(); - std::vector out; - out.push_back(!_p->ioInfo.video.empty() ? - _p->ioInfo.video.front().size : - image::Size()); - for (const auto& compare : p.compare->get()) - { - out.push_back(compare && !compare->getIOInfo().video.empty() ? - compare->getIOInfo().video.front().size : - image::Size()); - } - return out; - } - double Player::getDefaultSpeed() const { return _p->timeline->getTimeRange().duration().rate(); diff --git a/lib/tlTimeline/Player.h b/lib/tlTimeline/Player.h index 3695dc3a..303dda83 100644 --- a/lib/tlTimeline/Player.h +++ b/lib/tlTimeline/Player.h @@ -128,9 +128,6 @@ namespace tl //! the first clip in the timeline. const io::Info& getIOInfo() const; - //! Get the timeline sizes. - std::vector getSizes() const; - ///@} //! \name Playback diff --git a/lib/tlTimeline/TimelinePrivate.cpp b/lib/tlTimeline/TimelinePrivate.cpp index 1b1cb49f..05f2495c 100644 --- a/lib/tlTimeline/TimelinePrivate.cpp +++ b/lib/tlTimeline/TimelinePrivate.cpp @@ -311,6 +311,10 @@ namespace tl if (valid) { VideoData data; + if (!ioInfo.video.empty()) + { + data.size = ioInfo.video.front().size; + } data.time = (*videoRequestIt)->time; try { diff --git a/lib/tlTimeline/Video.h b/lib/tlTimeline/Video.h index a0fe9d4b..b92f5d14 100644 --- a/lib/tlTimeline/Video.h +++ b/lib/tlTimeline/Video.h @@ -33,6 +33,7 @@ namespace tl //! Video data. struct VideoData { + image::Size size; otime::RationalTime time = time::invalidTime; std::vector layers; diff --git a/lib/tlTimeline/VideoInline.h b/lib/tlTimeline/VideoInline.h index 7d2dbc4c..e2afe930 100644 --- a/lib/tlTimeline/VideoInline.h +++ b/lib/tlTimeline/VideoInline.h @@ -25,6 +25,7 @@ namespace tl inline bool VideoData::operator == (const VideoData& other) const { return + size == other.size && time::compareExact(time, other.time) && layers == other.layers; } diff --git a/lib/tlTimelineGL/RenderVideo.cpp b/lib/tlTimelineGL/RenderVideo.cpp index 7b2221fd..c64a4505 100644 --- a/lib/tlTimelineGL/RenderVideo.cpp +++ b/lib/tlTimelineGL/RenderVideo.cpp @@ -415,7 +415,7 @@ namespace tl boxes[0].h()); gl::OffscreenBufferOptions offscreenBufferOptions; offscreenBufferOptions.colorType = gl::offscreenColorDefault; - if (!imageOptions.empty()) + if (!displayOptions.empty()) { offscreenBufferOptions.colorFilters = displayOptions[0].imageFilters; } @@ -467,7 +467,7 @@ namespace tl { offscreenBufferOptions = gl::OffscreenBufferOptions(); offscreenBufferOptions.colorType = gl::offscreenColorDefault; - if (imageOptions.size() > 1) + if (displayOptions.size() > 1) { offscreenBufferOptions.colorFilters = displayOptions[1].imageFilters; } @@ -625,10 +625,7 @@ namespace tl const math::Size2i& offscreenBufferSize = box.getSize(); gl::OffscreenBufferOptions offscreenBufferOptions; offscreenBufferOptions.colorType = gl::offscreenColorDefault; - if (imageOptions.get()) - { - offscreenBufferOptions.colorFilters = displayOptions.imageFilters; - } + offscreenBufferOptions.colorFilters = displayOptions.imageFilters; if (doCreate( p.buffers["video"], offscreenBufferSize, diff --git a/lib/tlTimelineUI/TimelineViewport.cpp b/lib/tlTimelineUI/TimelineViewport.cpp index c4636aa4..1ab1c9dd 100644 --- a/lib/tlTimelineUI/TimelineViewport.cpp +++ b/lib/tlTimelineUI/TimelineViewport.cpp @@ -358,7 +358,7 @@ namespace tl event.render->clearViewport(image::Color4f(0.F, 0.F, 0.F)); event.render->setOCIOOptions(p.ocioOptions); event.render->setLUTOptions(p.lutOptions); - if (p.player && !p.videoData.empty()) + if (!p.videoData.empty()) { math::Matrix4x4f vm; vm = vm * math::translate(math::Vector3f(p.viewPos.x, p.viewPos.y, 0.F)); @@ -373,7 +373,7 @@ namespace tl event.render->setTransform(pm * vm); event.render->drawVideo( p.videoData, - timeline::getBoxes(p.compareOptions.mode, p.player->getSizes()), + timeline::getBoxes(p.compareOptions.mode, p.videoData), p.imageOptions, p.displayOptions, p.compareOptions, @@ -526,12 +526,7 @@ namespace tl math::Size2i TimelineViewport::_getRenderSize() const { TLRENDER_P(); - math::Size2i out; - if (p.player) - { - out = timeline::getRenderSize(p.compareOptions.mode, p.player->getSizes()); - } - return out; + return timeline::getRenderSize(p.compareOptions.mode, p.videoData); } math::Vector2i TimelineViewport::_getViewportCenter() const diff --git a/tests/tlTimelineTest/CompareOptionsTest.cpp b/tests/tlTimelineTest/CompareOptionsTest.cpp index bae5d407..c4e5d8b4 100644 --- a/tests/tlTimelineTest/CompareOptionsTest.cpp +++ b/tests/tlTimelineTest/CompareOptionsTest.cpp @@ -37,12 +37,12 @@ namespace tl TLRENDER_ASSERT(options != CompareOptions()); } { - const std::vector sizes = + const std::vector videoData = { - image::Size(1920, 1080), - image::Size(1920 / 2, 1080 / 2), - image::Size(1920 / 2, 1080 / 2), - image::Size(1920 / 2, 1080 / 2) + { image::Size(1920, 1080) }, + { image::Size(1920 / 2, 1080 / 2) }, + { image::Size(1920 / 2, 1080 / 2) }, + { image::Size(1920 / 2, 1080 / 2) } }; for (auto mode : @@ -54,35 +54,35 @@ namespace tl CompareMode::Difference }) { - auto boxes = getBoxes(mode, sizes); + auto boxes = getBoxes(mode, videoData); TLRENDER_ASSERT(2 == boxes.size()); TLRENDER_ASSERT(math::Box2i(0, 0, 1920, 1080) == boxes[0]); TLRENDER_ASSERT(math::Box2i(0, 0, 1920, 1080) == boxes[1]); - auto renderSize = getRenderSize(mode, sizes); + auto renderSize = getRenderSize(mode, videoData); TLRENDER_ASSERT(math::Size2i(1920, 1080) == renderSize); } - auto boxes = getBoxes(CompareMode::Horizontal, sizes); + auto boxes = getBoxes(CompareMode::Horizontal, videoData); TLRENDER_ASSERT(2 == boxes.size()); TLRENDER_ASSERT(math::Box2i(0, 0, 1920, 1080) == boxes[0]); TLRENDER_ASSERT(math::Box2i(1920, 0, 1920, 1080) == boxes[1]); - auto renderSize = getRenderSize(CompareMode::Horizontal, sizes); + auto renderSize = getRenderSize(CompareMode::Horizontal, videoData); TLRENDER_ASSERT(math::Size2i(1920 * 2, 1080) == renderSize); - boxes = getBoxes(CompareMode::Vertical, sizes); + boxes = getBoxes(CompareMode::Vertical, videoData); TLRENDER_ASSERT(2 == boxes.size()); TLRENDER_ASSERT(math::Box2i(0, 0, 1920, 1080) == boxes[0]); TLRENDER_ASSERT(math::Box2i(0, 1080, 1920, 1080) == boxes[1]); - renderSize = getRenderSize(CompareMode::Vertical, sizes); + renderSize = getRenderSize(CompareMode::Vertical, videoData); TLRENDER_ASSERT(math::Size2i(1920, 1080 * 2) == renderSize); - boxes = getBoxes(CompareMode::Tile, sizes); + boxes = getBoxes(CompareMode::Tile, videoData); TLRENDER_ASSERT(4 == boxes.size()); TLRENDER_ASSERT(math::Box2i(0, 0, 1920, 1080) == boxes[0]); TLRENDER_ASSERT(math::Box2i(1920, 0, 1920, 1080) == boxes[1]); TLRENDER_ASSERT(math::Box2i(0, 1080, 1920, 1080) == boxes[2]); TLRENDER_ASSERT(math::Box2i(1920, 1080, 1920, 1080) == boxes[3]); - renderSize = getRenderSize(CompareMode::Tile, sizes); + renderSize = getRenderSize(CompareMode::Tile, videoData); TLRENDER_ASSERT(math::Size2i(1920 * 2, 1080 * 2) == renderSize); } {