MCPcopy
hub / github.com/nikopueringer/CorridorKey / _prefetch_frames

Method _prefetch_frames

backend/service.py:582–612  ·  view source on GitHub ↗

Read frames ahead of GPU processing in a background thread.

(
        self,
        clip: ClipEntry,
        frame_indices,
        input_files: list[str],
        alpha_files: list[str],
        input_cap,
        alpha_cap,
        input_is_linear: bool,
        prefetch_queue: Queue,
        job: GPUJob | None,
    )

Source from the content-addressed store, hash-verified

580 # --- Processing ---
581
582 def _prefetch_frames(
583 self,
584 clip: ClipEntry,
585 frame_indices,
586 input_files: list[str],
587 alpha_files: list[str],
588 input_cap,
589 alpha_cap,
590 input_is_linear: bool,
591 prefetch_queue: Queue,
592 job: GPUJob | None,
593 ) -> None:
594 """Read frames ahead of GPU processing in a background thread."""
595 for i in frame_indices:
596 if job and job.is_cancelled:
597 break
598 try:
599 img, stem, is_linear = self._read_input_frame(
600 clip,
601 i,
602 input_files,
603 input_cap,
604 input_is_linear,
605 )
606 mask = self._read_alpha_frame(clip, i, alpha_files, alpha_cap)
607 except Exception as e:
608 prefetch_queue.put((i, None, None, f"{i:05d}", input_is_linear, str(e)))
609 continue
610 prefetch_queue.put((i, img, mask, stem, is_linear, None))
611
612 prefetch_queue.put(None)
613
614 def run_inference(
615 self,

Callers

nothing calls this directly

Calls 2

_read_input_frameMethod · 0.95
_read_alpha_frameMethod · 0.95

Tested by

no test coverage detected