Skip to content

Fix source ranges in the edit algorithms - #2079

Open
darbyjohnston wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
darbyjohnston:edit-algorithm-fixes
Open

darbyjohnston wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
darbyjohnston:edit-algorithm-fixes

Conversation

@darbyjohnston

@darbyjohnston darbyjohnston commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

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 <[email protected]>
@codecov-commenter

codecov-commenter commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.58%. Comparing base (eee67fd) to head (dc4bde7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/opentimelineio/algo/editAlgorithm.cpp 0.00% 42 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2079      +/-   ##
==========================================
- Coverage   83.61%   83.58%   -0.03%     
==========================================
  Files         183      183              
  Lines       13579    13585       +6     
  Branches     1261     1260       -1     
==========================================
+ Hits        11354    11355       +1     
- Misses       2052     2057       +5     
  Partials      173      173              
Flag Coverage Δ
py-unittests 83.58% <0.00%> (-0.03%) ⬇️

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 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes


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 eee67fd...dc4bde7. Read the comment docs.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants