Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Oct 26, 2023
2 parents 6546f43 + 70b176f commit 0ac1992
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 153 deletions.
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set( mrv2_VERSION_MAJOR 0 )
set( mrv2_VERSION_MINOR 8 )
set( mrv2_VERSION_PATCH 2 )
set( mrv2_VERSION_PATCH 3 )
set( mrv2_VERSION
"${mrv2_VERSION_MAJOR}.${mrv2_VERSION_MINOR}.${mrv2_VERSION_PATCH}"
)
11 changes: 11 additions & 0 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
v0.8.3
======

- Fixed adding a movie with no audio, which created an audio gap of sample
rate of 1, leading to precision issues.
- Fixed creation of an empty timeline.
- Fixed Annotations shifting when moving clips around in the Timeline Viewport
(feature of v0.9.0 not yet finished by Darby).
- Added support for HDR Radiance (.hdr) format.


v0.8.2
======

Expand Down
150 changes: 63 additions & 87 deletions mrv2/lib/mrvEdit/mrvEditCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace fs = std::filesystem;
#include "mrvDraw/Annotation.h"

#include "mrvNetwork/mrvTCP.h"
#include "mrvNetwork/mrvMoveData.h"

#include "mrvPanels/mrvPanelsCallbacks.h"

Expand Down Expand Up @@ -166,6 +165,7 @@ namespace mrv
return true;
}

// Routine to verify a clip is available and it is not an .otio file.
bool verifySourceItem(int index, ViewerUI* ui)
{
auto model = ui->app->filesModel();
Expand Down Expand Up @@ -939,7 +939,7 @@ namespace mrv
edit_store_undo(player, ui);

double videoRate = 0.F, sampleRate = 0.F;
;

for (const auto& frame : copiedFrames)
{
if (frame.kind == Track::Kind::video)
Expand Down Expand Up @@ -1273,27 +1273,40 @@ namespace mrv
const auto& originalAnnotations = player->getAllAnnotations();
auto annotations = deepCopyAnnotations(originalAnnotations);

// Then, adjust the annotations within the range.
// Then, adjust the annotations within the range and store the
// annotations that are out of range and should be skipped.
std::set<std::shared_ptr<draw::Annotation>> skipAnnotations;
const auto& startTime = range.start_time();
const auto& rangeDuration = range.duration();
for (auto& annotation : annotations)
{
if (annotation->allFrames)
continue;

if (range.contains(annotation->time))
if (previous)
{
auto offset = annotation->time - range.start_time();
annotation->time = insertTime + offset;
skipAnnotations.insert(annotation);
if (annotation->time <= range.start_time() ||
annotation->time >= insertTime)
skipAnnotations.insert(annotation);
else if (range.contains(annotation->time))
{
const auto offset = annotation->time - startTime;
annotation->time = insertTime + offset - rangeDuration;
skipAnnotations.insert(annotation);
}
}
else if (previous)
else
{
if (annotation->time < range.start_time())
if (range.contains(annotation->time))
{
const auto offset = annotation->time - startTime;
annotation->time = insertTime + offset;
skipAnnotations.insert(annotation);
}
}
}

// Finally, move the annotations.
// Finally, shift the other annotations.
if (previous)
{
for (auto& annotation : annotations)
Expand All @@ -1304,10 +1317,7 @@ namespace mrv
if (skipAnnotations.find(annotation) != skipAnnotations.end())
continue;

if (annotation->time < insertTime)
{
annotation->time -= range.duration();
}
annotation->time -= rangeDuration;
}
}
else
Expand Down Expand Up @@ -1337,13 +1347,16 @@ namespace mrv
{
otio::SerializableObject::Retainer<otio::Timeline> otioTimeline =
new otio::Timeline("EDL");

auto videoTrack =
new otio::Track("Video", otio::nullopt, otio::Track::Kind::video);
auto audioTrack =
new otio::Track("Audio", otio::nullopt, otio::Track::Kind::audio);

auto stack = new otio::Stack;
stack->append_child(videoTrack);
stack->append_child(audioTrack);

otioTimeline->set_tracks(stack);

return otioTimeline;
Expand Down Expand Up @@ -1399,7 +1412,6 @@ namespace mrv
throw std::runtime_error(error);
}
ui->app->open(file);
add_clip_to_timeline(Aindex, ui);
tcp->unlock();
}

Expand Down Expand Up @@ -1550,11 +1562,6 @@ namespace mrv
sampleRate = track->trimmed_range().duration().rate();
}
}
if (videoTrackIndex == -1 && audioTrackIndex == -1)
{
throw std::runtime_error(
_("Neither video nor audio tracks found."));
}

TimeRange timeRange;
auto sourceDuration = sourceItem->inOutRange.duration();
Expand Down Expand Up @@ -1594,10 +1601,8 @@ namespace mrv

RationalTime videoDuration(0.F, videoRate);

if (!info.video.empty() && videoTrackIndex != -1)
if (!info.video.empty())
{
auto track = otio::dynamic_retainer_cast<Track>(
tracks[videoTrackIndex]);
auto clip = new otio::Clip;
TimeRange mediaRange(info.videoTime);
if (isSequence)
Expand All @@ -1622,23 +1627,31 @@ namespace mrv
if (videoDuration.rate() > videoRate)
videoRate = videoDuration.rate();
clip->set_source_range(sourceRange);
track->append_child(clip, &errorStatus);
if (otio::is_error(errorStatus))

otio::Track* videoTrack;
if (videoTrackIndex < 0)
{
throw std::runtime_error("Cannot append child");
videoTrack = new otio::Track(
"Video", otio::nullopt, otio::Track::Kind::video);
stack->append_child(videoTrack, &errorStatus);
if (otio::is_error(errorStatus))
{
throw std::runtime_error(
_("Cannot append video track."));
}
tracks = stack->children();
videoTrackIndex = tracks.size() - 1;
videoRate = mediaRange.duration().rate();
}
}

if (!audioInfo.audio.isValid() && audioTrackIndex >= 0)
{
auto audioTrack = otio::dynamic_retainer_cast<Track>(
tracks[audioTrackIndex]);
if (audioTrack)
else
{
auto trackSampleRate =
audioTrack->trimmed_range().duration().rate();
if (trackSampleRate > sampleRate)
sampleRate = trackSampleRate;
videoTrack = otio::dynamic_retainer_cast<Track>(
tracks[videoTrackIndex]);
}
videoTrack->append_child(clip, &errorStatus);
if (otio::is_error(errorStatus))
{
throw std::runtime_error("Cannot append child");
}
}

Expand All @@ -1653,7 +1666,12 @@ namespace mrv
else
audioDuration = audioDuration.rescaled_to(sampleRate);

if (sampleRate > 0)
if (videoRate > sampleRate)
{
sampleRate = videoRate;
}

if (sampleRate > 0.F)
{
// If no audio track, create one and fill it with a gap
// until new video clip.
Expand Down Expand Up @@ -1800,8 +1818,8 @@ namespace mrv
tcp->unlock();
}

void edit_insert_clip_annotations(
const std::vector<mrv::MoveData>& moves, ViewerUI* ui)
void edit_move_clip_annotations(
const std::vector<tl::timeline::MoveData>& moves, ViewerUI* ui)
{
auto player = ui->uiView->getTimelinePlayer();
if (!player)
Expand Down Expand Up @@ -1869,6 +1887,11 @@ namespace mrv
insertTime = insertRange.start_time();
}

// std::cerr << "previous =" << previous << std::endl;
// std::cerr << "fromIndex=" << move.fromIndex << std::endl;
// std::cerr << " toIndex=" << toIndex << std::endl;
// std::cerr << " oldRange=" << oldRange << std::endl;
// std::cerr << " insert=" << insertTime << std::endl;
//
// Shift annotations
//
Expand All @@ -1880,53 +1903,6 @@ namespace mrv
ui->uiTimeline->redraw();
}

void edit_move_clip(const std::vector<mrv::MoveData>& moves, ViewerUI* ui)
{
auto player = ui->uiView->getTimelinePlayer();
if (!player)
return;

std::vector<tl::timeline::MoveData> moveData;
const auto& timeline = player->getTimeline();
const auto& stack = timeline->tracks();
const auto& tracks = stack->children();
for (const auto& move : moves)
{
if (auto track = otio::dynamic_retainer_cast<otio::Track>(
tracks[move.fromTrack]))
{
if (auto child = track->children()[move.fromIndex])
{
auto item = otio::dynamic_retainer_cast<otio::Item>(child);
if (!item)
continue;

timeline::MoveData data;
data.fromTrack = move.fromTrack;
data.fromIndex = move.fromIndex;
data.toTrack = move.toTrack;
data.toIndex = move.toIndex;
moveData.push_back(data);
}
}
}

auto otioTimeline = tl::timeline::move(timeline, moveData);
player->player()->getTimeline()->setTimeline(otioTimeline);

edit_move_clip_annotations(moveData, ui);
}

void edit_move_clip_annotations(
const std::vector<tl::timeline::MoveData>& moves, ViewerUI* ui)
{
auto player = ui->uiView->getTimelinePlayer();
if (!player)
return;

edit_move_clip_annotations(moves, ui);
}

EditMode editMode = EditMode::kTimeline;
int editModeH = 30;
const int kMinEditModeH = 30;
Expand Down
5 changes: 0 additions & 5 deletions mrv2/lib/mrvEdit/mrvEditCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ namespace mrv
class TimelinePlayer;
using otio::Timeline;

struct MoveData;

//@{
//! Store timeline in undo queue.

Expand All @@ -43,9 +41,6 @@ namespace mrv
void edit_move_clip_annotations(
const std::vector<tl::timeline::MoveData>& moves, ViewerUI* ui);

//! Handle move of clip annotations from network.
void edit_move_clip(const std::vector<mrv::MoveData>& moves, ViewerUI* ui);

//! Set the temporary EDL for a drag item callback.
void toOtioFile(TimelinePlayer*, ViewerUI* ui);

Expand Down
6 changes: 5 additions & 1 deletion mrv2/lib/mrvGL/mrvTimelineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,10 @@ namespace mrv
TLRENDER_P();
const math::Size2i renderSize(pixel_w(), pixel_h());

DBG2;
make_current();

DBG2;
if (!valid())
{
_initializeGL();
Expand Down Expand Up @@ -593,6 +595,7 @@ namespace mrv
glClear(GL_COLOR_BUFFER_BIT);
CHECK_GL;

DBG2;
if (p.buffer)
{
p.shader->bind();
Expand Down Expand Up @@ -627,6 +630,7 @@ namespace mrv
p.vao->draw(GL_TRIANGLES, 0, p.vbo->getSize());
}
}
DBG2;
}

int TimelineWidget::enterEvent()
Expand Down Expand Up @@ -1197,7 +1201,7 @@ namespace mrv
{
TLRENDER_P();
p.eventLoop->tick();
if (p.eventLoop->hasDrawUpdate())
if (visible_r() && p.eventLoop->hasDrawUpdate())
{
redraw();
}
Expand Down
2 changes: 0 additions & 2 deletions mrv2/lib/mrvNetwork/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set(HEADERS
mrvFilesModelItem.h
mrvFilePath.h
mrvImageOptions.h
mrvMoveData.h
mrvLUTOptions.h
mrvTCP.h
mrvTimelineItemOptions.h
Expand All @@ -24,7 +23,6 @@ set(SOURCES
mrvFilesModelItem.cpp
mrvFilePath.cpp
mrvImageOptions.cpp
mrvMoveData.cpp
mrvLUTOptions.cpp
mrvTCP.cpp
mrvTimelineItemOptions.cpp
Expand Down
1 change: 0 additions & 1 deletion mrv2/lib/mrvNetwork/mrvCommandInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "mrvNetwork/mrvCommandInterpreter.h"
#include "mrvNetwork/mrvCompareOptions.h"
#include "mrvNetwork/mrvDisplayOptions.h"
#include "mrvNetwork/mrvMoveData.h"
#include "mrvNetwork/mrvImageOptions.h"
#include "mrvNetwork/mrvLUTOptions.h"
#include "mrvNetwork/mrvTimelineItemOptions.h"
Expand Down

0 comments on commit 0ac1992

Please sign in to comment.