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