Skip to content

Fix source ranges in the edit algorithms - #2079

Merged
darbyjohnston merged 3 commits into
AcademySoftwareFoundation:mainfrom
darbyjohnston:edit-algorithm-fixes
Nov 27, 2026
Merged

darbyjohnston merged 3 commits into
AcademySoftwareFoundation:mainfrom
darbyjohnston:edit-algorithm-fixes

Conversation

@darbyjohnston

@darbyjohnston darbyjohnston commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

This PR has various fixes for the editing functions, found when testing with clips whose source ranges did not start at zero:

  • overwrite: a partly overwritten last item kept the wrong part, and an item longer than the range was given the overwritten item's start
  • insert: the second half of the split item skipped the inserted item's duration in the source
  • roll: moving the end did not change the next item's duration, so the end of the next item moved; the clamp for the start was wrong
  • ripple: the clamp for the start compared the delta to the start time
  • trim: trimming the start extended a previous clip instead of filling the hole, and trimming the end did not shrink or grow a following gap

Assisted-by: Claude Code / Claude Opus 5.5

Note from Claude:

The source range bugs were found by probing each edit with clips whose source ranges don’t start at zero, which none of the existing tests did.

Before and after diagrams of the fixes, made with the OTIO SVG adapter.

Each diagram has three tracks: the track before the edit, the result on main ("Current"), and the result with this PR ("Fixed").

Clips A and B use frames 10-19 of 30 frame media, so the source ranges don't start at zero. The bar under each clip shows which part of its media is used.

overwrite: frames 8-11 with C, across the cut between A and B

B should keep frames 12-19, but kept 18-19, and the track got shorter.

overwrite_partial
overwrite: frames 3-6 inside A, with a C that is longer than the range

C should start at its own frame 5, but was given A's start, frame 10.

overwrite_longer
insert: C at frame 3, splitting A

The second part of A should continue at frame 13, but started at 17, skipping frames 13-16.

insert
roll: the end of A by +3 frames

B should get 3 frames shorter, but kept its duration, so the track got longer.

roll_out
roll: the start of B by -10 frames, the whole length of A

A should be left with one frame, but was left with none.

roll_in_clamp
ripple: the start of A by +3 frames

A should start at frame 13, but the clamp moved it to frame 0.

ripple_in
trim: the start of B by +3 frames

The hole should be filled with a gap, but A was extended into it.

trim_in
trim: the end of A by +3 frames, into the gap

The gap should get 3 frames shorter, but kept its duration, so the track got longer.

trim_out_into_gap
trim: the end of A by -3 frames, away from the gap

The gap should get 3 frames longer, but got 3 frames shorter, so the track lost 6 frames.

trim_out_from_gap

@codecov-commenter

codecov-commenter commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.33%. Comparing base (a501b17) to head (fd81a27).

Files with missing lines Patch % Lines
src/opentimelineio/algo/editAlgorithm.cpp 66.66% 14 Missing ⚠️

❌ Your changes status has failed because you have indirect coverage changes. Learn more about Unexpected Coverage Changes and reasons for indirect coverage changes.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2079      +/-   ##
==========================================
- Coverage   87.33%   87.33%   -0.01%     
==========================================
  Files         189      189              
  Lines       13925    13930       +5     
  Branches     1273     1273              
==========================================
+ Hits        12162    12166       +4     
- Misses       1592     1593       +1     
  Partials      171      171              
Flag Coverage Δ
cpp-unittests 64.79% <100.00%> (+0.11%) ⬆️
py-unittests 85.64% <23.80%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/opentimelineio/algo/editAlgorithm.cpp 69.72% <66.66%> (+0.11%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a501b17...fd81a27. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@darbyjohnston darbyjohnston added the bug A problem, flaw, or broken functionality. label Nov 20, 2026

@camkerr camkerr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you @darbyjohnston.

I tested all of these edit functions, wrote out their otio files and then brought each one into Resolve for a visual check. Everything is behaving as expected. I tried to follow the examples you showed in the SVGs. I've attached my test files here.

camkerr-otio-pr2079-tests.zip

The bugs show with clips whose source ranges do not start at zero, which
the tests did not use:

- overwrite: a partly overwritten last item kept the wrong part, and an
  item longer than the range was given the overwritten item's start
- insert: the second half of the split item skipped the inserted
  item's duration in the source
- roll: moving the end did not change the next item's duration, so the
  end of the next item moved; the clamp for the start was wrong
- ripple: the clamp for the start compared the delta to the start time
- trim: trimming the start extended a previous clip instead of filling
  the hole, and trimming the end did not shrink or grow a following gap

test_edit_insert_8, test_edit_roll_3, test_edit_roll_4 and
test_edit_fill_2 expected the old results.

Signed-off-by: Darby Johnston <darbyjohnston@yahoo.com>
Signed-off-by: Darby Johnston <darbyjohnston@yahoo.com>
@timlehr
timlehr force-pushed the edit-algorithm-fixes branch from d24b281 to c8f9eff Compare November 27, 2026 21:45

@timlehr timlehr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @camkerr for testing the changes. I had a look at the code and it looks fine. Go ahead @darbyjohnston.

@darbyjohnston

Copy link
Copy Markdown
Collaborator Author

Great, thanks for the reviews, I'll go ahead and merge...

@darbyjohnston darbyjohnston added this to the 1.0 Release milestone Nov 27, 2026
@darbyjohnston
darbyjohnston merged commit 363d71e into AcademySoftwareFoundation:main Nov 27, 2026
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A problem, flaw, or broken functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants