perf: reuse guide images and drag selections
This commit is contained in:
@@ -8189,13 +8189,13 @@ class TimelineEditor {
|
||||
return s;
|
||||
}),
|
||||
motion: this._multiDragInitialSegments.motion.map(s => {
|
||||
if (selectedIds.includes(s.id)) {
|
||||
if (selectedIdSet.has(s.id)) {
|
||||
return { ...s, start: s.start + clampedDragDelta };
|
||||
}
|
||||
return s;
|
||||
}),
|
||||
audio: this._multiDragInitialSegments.audio.map(s => {
|
||||
if (selectedIds.includes(s.id)) {
|
||||
if (selectedIdSet.has(s.id)) {
|
||||
return { ...s, start: s.start + clampedDragDelta };
|
||||
}
|
||||
return s;
|
||||
@@ -8206,7 +8206,7 @@ class TimelineEditor {
|
||||
for (const track of ["image", "motion"]) {
|
||||
const prevSegs = this._multiDragPreviewTimelines[track];
|
||||
for (const s of prevSegs) {
|
||||
if (selectedIds.includes(s.id) && (s.type === "video" || s.type === "motion_video")) {
|
||||
if (selectedIdSet.has(s.id) && (s.type === "video" || s.type === "motion_video")) {
|
||||
this._liveScrubVideo(s, "start");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,6 +1207,7 @@ def _build_guide_data_from_timeline(
|
||||
):
|
||||
guide_data = {"images": [], "insert_frames": [], "strengths": [], "frame_rate": frame_rate_f}
|
||||
derived_w, derived_h = custom_width, custom_height
|
||||
processed_still_cache = {}
|
||||
|
||||
try:
|
||||
img_segs = [
|
||||
@@ -1234,9 +1235,24 @@ def _build_guide_data_from_timeline(
|
||||
seg_for_load["trimStart"] = float(seg.get("trimStart", 0)) + offset
|
||||
seg_for_load["length"] = max(1, seg_length - offset)
|
||||
tensor = _load_video_tensor(seg_for_load, frame_rate_f, input_dir=input_dir)
|
||||
cache_key = None
|
||||
else:
|
||||
cache_key = (
|
||||
seg.get("imageFile") or "",
|
||||
seg.get("imageB64") or "",
|
||||
custom_width,
|
||||
custom_height,
|
||||
resize_method,
|
||||
divisible_by,
|
||||
img_compression,
|
||||
)
|
||||
cached_tensor = processed_still_cache.get(cache_key)
|
||||
if cached_tensor is not None:
|
||||
tensor = cached_tensor
|
||||
else:
|
||||
tensor = _load_image_tensor(seg, cache=image_cache, input_dir=input_dir)
|
||||
|
||||
if cache_key is None or cached_tensor is None:
|
||||
src_h, src_w = tensor.shape[1], tensor.shape[2]
|
||||
tgt_w, tgt_h, resize_override = _target_resize_dims(
|
||||
src_w, src_h, custom_width, custom_height, divisible_by
|
||||
@@ -1252,6 +1268,9 @@ def _build_guide_data_from_timeline(
|
||||
if img_compression > 0:
|
||||
tensor = _compress_image(tensor, img_compression)
|
||||
|
||||
if cache_key is not None:
|
||||
processed_still_cache[cache_key] = tensor
|
||||
|
||||
if idx == 0:
|
||||
derived_h = tensor.shape[1]
|
||||
derived_w = tensor.shape[2]
|
||||
|
||||
Reference in New Issue
Block a user