Skip to content

Commit

Permalink
Fix lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-ynput committed Jan 22, 2025
1 parent 66da9fa commit 133bb32
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
30 changes: 22 additions & 8 deletions client/ayon_core/pipeline/editorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end):
if is_input_sequence:

src_in = conformed_source_range.start_time
src_duration = math.ceil(otio_clip.source_range.duration.value * abs(time_scalar))
src_duration = math.ceil(
otio_clip.source_range.duration.value
* abs(time_scalar)
)
retimed_duration = otio.opentime.RationalTime(
src_duration,
otio_clip.source_range.duration.rate
Expand All @@ -422,9 +425,15 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end):
# compute retimed range
media_in_trimmed = conformed_source_range.start_time.value + offset_in

offset_duration = conformed_source_range.duration.value * abs(time_scalar)
offset_duration -= 1 # duration 1 frame -> freeze frame -> end = start + 0
offset_duration = max(0, offset_duration) # negative duration = frozen frame
offset_duration = (
conformed_source_range.duration.value
* abs(time_scalar)
)

# duration 1 frame -> freeze frame -> end = start + 0
offset_duration -= 1
# negative duration = frozen frame
offset_duration = max(0, offset_duration)
media_out_trimmed = media_in_trimmed + offset_duration

media_in = available_range.start_time.value
Expand All @@ -443,17 +452,22 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end):
for idx, frame_number in enumerate(frame_range):
# First timewarp, apply on media range
if tw_idx == 0:
frame_range[idx] = round(frame_number + tw["lookup"][idx] * time_scalar)
frame_range[idx] = round(
frame_number +
(tw["lookup"][idx] * time_scalar)
)
# Consecutive timewarp, apply on the previous result
else:
new_idx = round(idx + tw["lookup"][idx])

if not 0 <= new_idx < len(frame_range):
# TODO: implementing this would need to actually have
# retiming engine resolve process within AYON, resolving wraps
# as curves, then projecting those into the previous media_range.
# retiming engine resolve process within AYON,
# resolving wraps as curves, then projecting
# those into the previous media_range.
raise NotImplementedError(
"Unsupported consecutive timewarps (out of computed range)"
"Unsupported consecutive timewarps "
"(out of computed range)"
)

frame_range[idx] = frame_range[new_idx]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def test_img_sequence_2x_speed_resolve():
"""
Img sequence clip
available files = 0-99 24fps
source_range = 38-49 24fps
source_range = 38-49 24fps
speed = 2.0
"""
expected_data = {
Expand Down Expand Up @@ -531,7 +531,7 @@ def test_img_sequence_frozen_frame():
"""
Img sequence clip
available files = 948674-948974 25fps
source_range = 909990.8339241028
source_range = 909990.8339241028
- 909995.8339241028 23.976fps
speed = 0.0
"""
Expand Down Expand Up @@ -562,7 +562,7 @@ def test_img_sequence_timewarp_beyond_range():
"""
Img sequence clip
available files = 948674-948974 25fps
source_range = 909990.8339241028
source_range = 909990.8339241028
- 909995.8339241028 23.976fps
timewarp to get from 948845 to 948870
"""
Expand Down Expand Up @@ -611,7 +611,7 @@ def test_img_sequence_2X_speed_timewarp():
"""
Img sequence clip
available files = 948674-948974 25fps
source_range = 909990.8339241028
source_range = 909990.8339241028
- 909995.8339241028 23.976fps
speed: 200%
timewarp to get from 948854 to 948874
Expand Down Expand Up @@ -662,7 +662,7 @@ def test_img_sequence_multiple_timewarps():
"""
Img sequence clip
available files = 948674-948974 25fps
source_range = 909990.8339241028
source_range = 909990.8339241028
- 909995.8339241028 23.976fps
multiple timewarps to get from 948842 to 948864
"""
Expand Down

0 comments on commit 133bb32

Please sign in to comment.