Move reservoir window clipping into core
This commit is contained in:
parent
c7429760d5
commit
472515943b
5 changed files with 39 additions and 25 deletions
|
|
@ -49,12 +49,14 @@ from localcast.diagnostics.visual_cache import (
|
|||
from localcast.diagnostics.lod_json import write_lod_cache_json
|
||||
from localcast.sensor_fusion.camera_control import AdaptiveCameraController, OpenCvCameraSettingPort
|
||||
from localcast.sensor_fusion.adapters import LatestFramePump, OpenCvCaptureConfig, OpenCvFrameSource
|
||||
from localcast.sensor_fusion.reservoir_window import (
|
||||
DEFAULT_RESERVOIR_NS,
|
||||
evidence_in_reservoir,
|
||||
render_points_in_reservoir,
|
||||
)
|
||||
from audio_field.cultcache_audio import frame_to_numpy, get_live_audio_phase_field, get_live_spatial_audio_frame
|
||||
|
||||
|
||||
DEFAULT_RESERVOIR_NS = 5_000_000_000
|
||||
|
||||
|
||||
def acquire_runtime_lock(path: Path) -> BinaryIO | None:
|
||||
import msvcrt
|
||||
|
||||
|
|
@ -72,21 +74,6 @@ def acquire_runtime_lock(path: Path) -> BinaryIO | None:
|
|||
return handle
|
||||
|
||||
|
||||
def reservoir_window_ns(latest_timestamp_ns: int, reservoir_ns: int) -> tuple[int, int]:
|
||||
end_ns = int(latest_timestamp_ns)
|
||||
return end_ns - int(reservoir_ns), end_ns
|
||||
|
||||
|
||||
def evidence_in_reservoir(evidence: tuple, *, latest_timestamp_ns: int, reservoir_ns: int) -> tuple:
|
||||
start_ns, end_ns = reservoir_window_ns(latest_timestamp_ns, reservoir_ns)
|
||||
return tuple(item for item in evidence if start_ns <= int(item.timestamp_ns) <= end_ns)
|
||||
|
||||
|
||||
def render_points_in_reservoir(points: tuple[RenderPointPacket, ...], *, latest_timestamp_ns: int, reservoir_ns: int) -> tuple[RenderPointPacket, ...]:
|
||||
start_ns, end_ns = reservoir_window_ns(latest_timestamp_ns, reservoir_ns)
|
||||
return tuple(point for point in points if start_ns <= int(point.source_timestamp_ns) <= end_ns)
|
||||
|
||||
|
||||
def latest_audio_time_ns(audio_cache: Path) -> int | None:
|
||||
if not audio_cache.exists():
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import numpy as np
|
|||
|
||||
from .render_bridge import RenderFramePacket, RenderPointPacket
|
||||
from .media_artifacts import RemoteVideoArtifact
|
||||
from .reservoir_window import DEFAULT_RESERVOIR_NS, render_points_in_reservoir
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
|
@ -17,9 +18,6 @@ if str(ROOT) not in sys.path:
|
|||
from audio_field.cultcache_audio import CultAudioSourceEvents, CultSpatialAudioFrame # noqa: E402
|
||||
|
||||
|
||||
DEFAULT_RESERVOIR_NS = 5_000_000_000
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AudioVisualSyncStatus:
|
||||
visual_frame_id: int
|
||||
|
|
@ -90,7 +88,11 @@ def clamp_frame_to_audio_reservoir(
|
|||
return frame
|
||||
edge_ns = max(int(frame.source_time_max_ns), int(audio_frame.audio_time_ns))
|
||||
start_ns = edge_ns - int(reservoir_ns)
|
||||
points = tuple(point for point in frame.points if start_ns <= int(point.source_timestamp_ns) <= edge_ns)
|
||||
points = render_points_in_reservoir(
|
||||
frame.points,
|
||||
latest_timestamp_ns=edge_ns,
|
||||
reservoir_ns=reservoir_ns,
|
||||
)
|
||||
return RenderFramePacket(
|
||||
schema=frame.schema,
|
||||
frame_id=frame.frame_id,
|
||||
|
|
|
|||
26
localcast/sensor_fusion/reservoir_window.py
Normal file
26
localcast/sensor_fusion/reservoir_window.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""Shared reservoir-window clipping rules for visual evidence."""
|
||||
|
||||
from .render_bridge import RenderPointPacket
|
||||
|
||||
|
||||
DEFAULT_RESERVOIR_NS = 5_000_000_000
|
||||
|
||||
|
||||
def reservoir_window_ns(latest_timestamp_ns: int, reservoir_ns: int) -> tuple[int, int]:
|
||||
end_ns = int(latest_timestamp_ns)
|
||||
return end_ns - int(reservoir_ns), end_ns
|
||||
|
||||
|
||||
def evidence_in_reservoir(evidence: tuple, *, latest_timestamp_ns: int, reservoir_ns: int) -> tuple:
|
||||
start_ns, end_ns = reservoir_window_ns(latest_timestamp_ns, reservoir_ns)
|
||||
return tuple(item for item in evidence if start_ns <= int(item.timestamp_ns) <= end_ns)
|
||||
|
||||
|
||||
def render_points_in_reservoir(
|
||||
points: tuple[RenderPointPacket, ...],
|
||||
*,
|
||||
latest_timestamp_ns: int,
|
||||
reservoir_ns: int,
|
||||
) -> tuple[RenderPointPacket, ...]:
|
||||
start_ns, end_ns = reservoir_window_ns(latest_timestamp_ns, reservoir_ns)
|
||||
return tuple(point for point in points if start_ns <= int(point.source_timestamp_ns) <= end_ns)
|
||||
|
|
@ -74,3 +74,4 @@
|
|||
{"ts": "2026-05-19T10:00:32+00:00", "type": "implementation", "status": "ok", "note": "AmbiX spatial-audio Python publisher moved from scripts into localcast.diagnostics.spatial_audio; docs and handoff now treat it as replay smoke-test code while live spatial/stem production remains native/Faust through LocalcastProducer."}
|
||||
{"ts": "2026-05-19T10:03:37+00:00", "type": "implementation", "status": "ok", "note": "Native reservoir ABI now includes LocalcastAudioBlockDescriptor and localcast_producer_push_audio_block: audio producers pass caller-owned float32 interleaved block descriptors as payload handles while the reservoir keeps timing/retention ownership only."}
|
||||
{"ts": "2026-05-19T10:05:55+00:00", "type": "implementation", "status": "ok", "note": "Aquarium-Engine commit 34694e6 adds the C# LocalCast audio block descriptor binding and layout tests for the native LocalcastAudioBlockDescriptor/localcast_producer_push_audio_block ABI."}
|
||||
{"ts": "2026-05-19T10:07:55+00:00", "type": "implementation", "status": "ok", "note": "Reservoir-window clipping moved out of localcast.diagnostics.visual_producer into localcast.sensor_fusion.reservoir_window; audio overlay and tests now use the shared core invariant instead of importing diagnostic launcher code."}
|
||||
|
|
|
|||
|
|
@ -64,16 +64,14 @@ from localcast.diagnostics.render_math import (
|
|||
rasterize_frame_rgba,
|
||||
)
|
||||
from localcast.diagnostics.visual_producer import (
|
||||
DEFAULT_RESERVOIR_NS,
|
||||
LiveClapCalibrator,
|
||||
evidence_in_reservoir,
|
||||
leap_channel_motion_points,
|
||||
render_points_in_reservoir,
|
||||
rgb_dense_camera,
|
||||
rgb_dense_stereo_splats,
|
||||
rgb_room_splats,
|
||||
unpack_leap_packed_channels,
|
||||
)
|
||||
from localcast.sensor_fusion.reservoir_window import DEFAULT_RESERVOIR_NS, evidence_in_reservoir, render_points_in_reservoir
|
||||
from localcast.sensor_fusion.active_illumination import ActiveIlluminationController, IlluminationPulsePlan
|
||||
from audio_field.cultcache_audio import make_audio_source_events, make_spatial_audio_frame, put_live_spatial_audio_frame
|
||||
from localcast.sensor_fusion.adapters import read_raw_bgr_frames
|
||||
|
|
|
|||
Loading…
Reference in a new issue