Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Oct 23, 2023
1 parent c226bf2 commit c84f6ca
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 63 deletions.
3 changes: 3 additions & 0 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ v0.8.2
digits.
- Fixed Auto Playback working only for the first clip loaded.
- Fixed playback buttons when switching clips not showing playback.
- Fixed a random OpenGL error when creating the color texture in the main
viewport.
- Fixed EDL creation for movies that did not have audio.


v0.8.1
Expand Down
70 changes: 19 additions & 51 deletions mrv2/lib/mrvEdit/mrvEditCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1613,53 +1613,16 @@ namespace mrv
}
auto sourceRange = sourceItem->inOutRange;
videoDuration = sourceRange.duration();
if (videoDuration.rate() > videoRate)
videoRate = videoDuration.rate();
clip->set_source_range(sourceRange);
track->append_child(clip, &errorStatus);
if (otio::is_error(errorStatus))
{
throw std::runtime_error("Cannot append child");
}

// If audio is longer than video, append a video gap.
// It seems this should *not* be done.
// #if 0
// if (audioInfo.audio.isValid())
// {
// const auto audioRate =
// audioInfo.audioTime.duration().rate();
// const auto videoRate =
// sourceRange.duration().rate();
// const auto audio_duration =
// audioInfo.audioTime.duration().rescaled_to(videoRate);
// const auto clip_duration =
// sourceRange.duration(); const
// auto gap_duration =
// audio_duration -
// clip_duration;
// if (gap_duration.value() > 0.0)
// {
// const auto gapRange =
// TimeRange(
// RationalTime(0.0,
// videoRate),
// gap_duration);

// auto gap = new
// otio::Gap(gapRange);
// track->append_child(gap,
// &errorStatus); if
// (otio::is_error(errorStatus))
// {
// throw std::runtime_error(
// _("Cannot append
// video gap"));
// }
// }
// }
// #endif
}

auto audioInfoDuration = audioInfo.audioTime.duration();
if (!audioInfo.audio.isValid() && audioTrackIndex >= 0)
{
auto audioTrack = otio::dynamic_retainer_cast<Track>(
Expand All @@ -1673,15 +1636,19 @@ namespace mrv
}
}

if (audioInfoDuration.rate() > sampleRate)
sampleRate = audioInfoDuration.rate();
auto audioDuration = RationalTime(0.0, sampleRate);
if (audioInfo.audio.isValid())
{
audioDuration = audioInfo.audioTime.duration();
}

if (audioDuration.rate() > sampleRate)
sampleRate = audioDuration.rate();
else
audioInfoDuration =
audioInfoDuration.rescaled_to(sampleRate);
audioDuration = audioDuration.rescaled_to(sampleRate);

if (sampleRate > 0)
{

// If no audio track, create one and fill it with a gap
// until new video clip.
// If no audio (a sequence), we also fill it with a gap.
Expand Down Expand Up @@ -1733,10 +1700,11 @@ namespace mrv
audioTrack = otio::dynamic_retainer_cast<Track>(
tracks[audioTrackIndex]);
}
audioDuration = RationalTime(
videoRange.duration().rescaled_to(sampleRate));
auto gapRange = TimeRange(
RationalTime(0.0, sampleRate),
RationalTime(videoRange.start_time().rescaled_to(
sampleRate)));
RationalTime(0.0, sampleRate), audioDuration);

auto gap = new otio::Gap(gapRange);
audioTrack->append_child(gap);
}
Expand All @@ -1754,8 +1722,8 @@ namespace mrv
auto media = new otio::ExternalReference(
audioPath.get(), audioInfo.audioTime);
clip->set_media_reference(media);
if (sourceDuration > audioInfoDuration)
sourceDuration = audioInfoDuration;
if (sourceDuration > audioDuration)
sourceDuration = audioDuration;
const TimeRange sourceRange(start, sourceDuration);
clip->set_source_range(sourceRange);
audioTrack->append_child(clip, &errorStatus);
Expand All @@ -1766,10 +1734,10 @@ namespace mrv
}
}
auto gap_duration = RationalTime(0.0, sampleRate);
if (videoDuration > audioInfoDuration)
if (videoDuration > audioDuration)
{
if (audioInfo.audio.isValid())
gap_duration = videoDuration - audioInfoDuration;
gap_duration = videoDuration - audioDuration;
else
gap_duration = videoDuration;
}
Expand Down
51 changes: 39 additions & 12 deletions mrv2/lib/mrvGL/mrvGLViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,28 @@ namespace mrv
bool transparent =
p.backgroundOptions.type == timeline::Background::Transparent;

try
if (renderSize.isValid())
{
if (renderSize.isValid())
gl::OffscreenBufferOptions offscreenBufferOptions;
try
{
gl::OffscreenBufferOptions offscreenBufferOptions;
offscreenBufferOptions.colorType = image::PixelType::RGBA_F32;
if (gl::doCreate(
gl.background, renderSize, offscreenBufferOptions))
{
gl.background = gl::OffscreenBuffer::create(
renderSize, offscreenBufferOptions);
}
}
catch (const std::exception& e)
{
LOG_ERROR("Creating background: " << e.what());
gl.buffer.reset();
gl.stereoBuffer.reset();
}

try
{
if (!p.displayOptions.empty())
{
offscreenBufferOptions.colorFilters =
Expand Down Expand Up @@ -241,8 +250,16 @@ namespace mrv
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
CHECK_GL;
}
}
catch (const std::exception& e)
{
LOG_ERROR("Creating buffer: " << e.what());
gl.buffer.reset();
}

if (can_do(FL_STEREO))
if (can_do(FL_STEREO))
{
try
{
if (gl::doCreate(
gl.stereoBuffer, renderSize,
Expand All @@ -253,15 +270,23 @@ namespace mrv
CHECK_GL;
}
}
catch (const std::exception& e)
{
LOG_ERROR("Creating stereo buffer: " << e.what());
gl.stereoBuffer.reset();
}
}
else
{
gl.background.reset();
gl.buffer.reset();
gl.stereoBuffer.reset();
}
}
else
{
gl.background.reset();
gl.buffer.reset();
gl.stereoBuffer.reset();
}

if (gl.background && !transparent)
try
{
if (gl.background && gl.render && !transparent)
{
gl::OffscreenBufferBinding binding(gl.background);

Expand Down Expand Up @@ -329,9 +354,11 @@ namespace mrv
}
catch (const std::exception& e)
{
LOG_ERROR(e.what());
LOG_ERROR("tlRender internal error: " << e.what());
gl.background.reset();
gl.buffer.reset();
gl.stereoBuffer.reset();
valid(0);
}

glViewport(0, 0, GLsizei(viewportSize.w), GLsizei(viewportSize.h));
Expand Down

0 comments on commit c84f6ca

Please sign in to comment.