supervision 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/depth-preview-probe-DG7McQEN.js +314 -0
  2. package/dist/depth-preview-probe-DG7McQEN.js.map +1 -0
  3. package/dist/depth-preview-track-BvgwNEE9.js +612 -0
  4. package/dist/depth-preview-track-BvgwNEE9.js.map +1 -0
  5. package/dist/detections/chunked-detection-frame-source.d.ts.map +1 -1
  6. package/dist/index.d.ts +4 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +9504 -4719
  9. package/dist/index.js.map +1 -1
  10. package/dist/mask-preparation.worker.js +658 -21
  11. package/dist/mask-preparation.worker.js.map +1 -1
  12. package/dist/media/decoder-deadline.d.ts +18 -0
  13. package/dist/media/decoder-deadline.d.ts.map +1 -0
  14. package/dist/media/depth-preview-probe.d.ts +65 -0
  15. package/dist/media/depth-preview-probe.d.ts.map +1 -0
  16. package/dist/media/depth-preview-track.d.ts +96 -0
  17. package/dist/media/depth-preview-track.d.ts.map +1 -0
  18. package/dist/media/media-normalization.d.ts.map +1 -1
  19. package/dist/media/media-source.d.ts +7 -0
  20. package/dist/media/media-source.d.ts.map +1 -1
  21. package/dist/media/mediabunny-frame-clock.d.ts +7 -0
  22. package/dist/media/mediabunny-frame-clock.d.ts.map +1 -0
  23. package/dist/media/mediabunny-media-source.d.ts +3 -0
  24. package/dist/media/mediabunny-media-source.d.ts.map +1 -1
  25. package/dist/media/track-frame-index.d.ts +14 -0
  26. package/dist/media/track-frame-index.d.ts.map +1 -0
  27. package/dist/media/video-engine-media-source.d.ts.map +1 -1
  28. package/dist/media/video-engine-media-source.js +1 -1
  29. package/dist/render-preparation/depth/clip-preview.d.ts +41 -0
  30. package/dist/render-preparation/depth/clip-preview.d.ts.map +1 -0
  31. package/dist/render-preparation/depth/clip-timing.d.ts +18 -0
  32. package/dist/render-preparation/depth/clip-timing.d.ts.map +1 -0
  33. package/dist/render-preparation/depth/clip.d.ts +14 -0
  34. package/dist/render-preparation/depth/clip.d.ts.map +1 -0
  35. package/dist/render-preparation/depth/exact-at-rest.d.ts +44 -0
  36. package/dist/render-preparation/depth/exact-at-rest.d.ts.map +1 -0
  37. package/dist/render-preparation/depth/exact-playback.d.ts +40 -0
  38. package/dist/render-preparation/depth/exact-playback.d.ts.map +1 -0
  39. package/dist/render-preparation/depth/files.d.ts +55 -0
  40. package/dist/render-preparation/depth/files.d.ts.map +1 -0
  41. package/dist/render-preparation/depth/frame-decode.d.ts +20 -0
  42. package/dist/render-preparation/depth/frame-decode.d.ts.map +1 -0
  43. package/dist/render-preparation/depth/frame-preparer.d.ts +51 -0
  44. package/dist/render-preparation/depth/frame-preparer.d.ts.map +1 -0
  45. package/dist/render-preparation/depth/frame-window.d.ts +146 -0
  46. package/dist/render-preparation/depth/frame-window.d.ts.map +1 -0
  47. package/dist/render-preparation/depth/options.d.ts +37 -0
  48. package/dist/render-preparation/depth/options.d.ts.map +1 -0
  49. package/dist/render-preparation/depth/png16.d.ts +40 -0
  50. package/dist/render-preparation/depth/png16.d.ts.map +1 -0
  51. package/dist/render-preparation/depth/preview-luma-copier.d.ts +12 -0
  52. package/dist/render-preparation/depth/preview-luma-copier.d.ts.map +1 -0
  53. package/dist/render-preparation/depth/preview-luma.d.ts +48 -0
  54. package/dist/render-preparation/depth/preview-luma.d.ts.map +1 -0
  55. package/dist/render-preparation/depth/source.d.ts +123 -0
  56. package/dist/render-preparation/depth/source.d.ts.map +1 -0
  57. package/dist/render-preparation/depth/worker-protocol.d.ts +76 -0
  58. package/dist/render-preparation/depth/worker-protocol.d.ts.map +1 -0
  59. package/dist/render-preparation/playhead-motion.d.ts +67 -0
  60. package/dist/render-preparation/playhead-motion.d.ts.map +1 -0
  61. package/dist/render-preparation/prepared-render-window.d.ts +12 -0
  62. package/dist/render-preparation/prepared-render-window.d.ts.map +1 -1
  63. package/dist/renderers/depth-textures.d.ts +79 -0
  64. package/dist/renderers/depth-textures.d.ts.map +1 -0
  65. package/dist/renderers/id-mask-stroke-coverage.d.ts +3 -0
  66. package/dist/renderers/id-mask-stroke-coverage.d.ts.map +1 -0
  67. package/dist/renderers/media-renderer-core.d.ts.map +1 -1
  68. package/dist/renderers/media-renderer-scene.d.ts +14 -1
  69. package/dist/renderers/media-renderer-scene.d.ts.map +1 -1
  70. package/dist/renderers/pixi-batch-texture-bindings.d.ts +9 -0
  71. package/dist/renderers/pixi-batch-texture-bindings.d.ts.map +1 -0
  72. package/dist/renderers/pixi-depth-layer.d.ts +76 -0
  73. package/dist/renderers/pixi-depth-layer.d.ts.map +1 -0
  74. package/dist/renderers/pixi-depth-shader.d.ts +76 -0
  75. package/dist/renderers/pixi-depth-shader.d.ts.map +1 -0
  76. package/dist/renderers/pixi-focus-layer.d.ts +1 -0
  77. package/dist/renderers/pixi-focus-layer.d.ts.map +1 -1
  78. package/dist/renderers/pixi-frame-present.d.ts +1 -0
  79. package/dist/renderers/pixi-frame-present.d.ts.map +1 -1
  80. package/dist/renderers/pixi-id-mask-shader.d.ts +1 -0
  81. package/dist/renderers/pixi-id-mask-shader.d.ts.map +1 -1
  82. package/dist/renderers/pixi-interaction-layer.d.ts +1 -1
  83. package/dist/renderers/pixi-interaction-layer.d.ts.map +1 -1
  84. package/dist/renderers/pixi-interaction-presentation-layer.d.ts +1 -0
  85. package/dist/renderers/pixi-interaction-presentation-layer.d.ts.map +1 -1
  86. package/dist/renderers/pixi-mask-halo.d.ts +1 -0
  87. package/dist/renderers/pixi-mask-halo.d.ts.map +1 -1
  88. package/dist/renderers/pixi-mask-layer.d.ts +4 -0
  89. package/dist/renderers/pixi-mask-layer.d.ts.map +1 -1
  90. package/dist/renderers/pixi-media-scene.d.ts.map +1 -1
  91. package/dist/renderers/pixi-region-coverage-mask.d.ts +1 -0
  92. package/dist/renderers/pixi-region-coverage-mask.d.ts.map +1 -1
  93. package/dist/renderers/pixi-region-layer.d.ts +1 -0
  94. package/dist/renderers/pixi-region-layer.d.ts.map +1 -1
  95. package/dist/renderers/pixi-scene-layer-slot.d.ts +1 -0
  96. package/dist/renderers/pixi-scene-layer-slot.d.ts.map +1 -1
  97. package/dist/renderers/prepared-annotation-window.d.ts +1 -0
  98. package/dist/renderers/prepared-annotation-window.d.ts.map +1 -1
  99. package/dist/renderers/render-preparation-report.d.ts +23 -0
  100. package/dist/renderers/render-preparation-report.d.ts.map +1 -0
  101. package/dist/sessions/media-session-defaults.d.ts.map +1 -1
  102. package/dist/sessions/media-session-state.d.ts.map +1 -1
  103. package/dist/sessions/media-session.d.ts.map +1 -1
  104. package/dist/tracking.worker.js +64 -0
  105. package/dist/tracking.worker.js.map +1 -1
  106. package/dist/types/media-depth.d.ts +55 -0
  107. package/dist/types/media-depth.d.ts.map +1 -0
  108. package/dist/types/media-renderer.d.ts +19 -0
  109. package/dist/types/media-renderer.d.ts.map +1 -1
  110. package/dist/types/media-session.d.ts +19 -0
  111. package/dist/types/media-session.d.ts.map +1 -1
  112. package/dist/types/render-preparation.d.ts +105 -3
  113. package/dist/types/render-preparation.d.ts.map +1 -1
  114. package/dist/{video-engine-media-source-DR-x1UfK.js → video-engine-media-source-DOFsuGS4.js} +35 -29
  115. package/dist/video-engine-media-source-DOFsuGS4.js.map +1 -0
  116. package/dist/web-video-engine/analysis.js +6 -43
  117. package/dist/web-video-engine/cache-budget.d.ts +4 -7
  118. package/dist/web-video-engine/constants.d.ts +3 -4
  119. package/dist/web-video-engine/create-scrub-cursor.d.ts +1 -0
  120. package/dist/web-video-engine/decode-resolution-fynpRIAG.js +109 -0
  121. package/dist/web-video-engine/decode-scheduler.d.ts +1 -0
  122. package/dist/web-video-engine/engine-core.d.ts +4 -2
  123. package/dist/web-video-engine/engine.js +8 -6
  124. package/dist/web-video-engine/engine.worker.js +164 -66
  125. package/dist/web-video-engine/frame-cache.d.ts +9 -0
  126. package/dist/web-video-engine/frame-index.d.ts +1 -0
  127. package/dist/web-video-engine/frame-index.js +97 -0
  128. package/dist/web-video-engine/{frame-timeline-DreEwsRY.js → frame-timeline-CYgzzmpA.js} +1 -109
  129. package/dist/web-video-engine/frame-timeline-reader.d.ts +21 -0
  130. package/dist/web-video-engine/video-engine.d.ts +9 -4
  131. package/node_modules/supervision-js-core/THIRD_PARTY_NOTICES.md +132 -0
  132. package/node_modules/supervision-js-core/dist/detections/buffered-detection-timeline.d.ts.map +1 -1
  133. package/node_modules/supervision-js-core/dist/index.d.ts +7 -2
  134. package/node_modules/supervision-js-core/dist/index.d.ts.map +1 -1
  135. package/node_modules/supervision-js-core/dist/index.js +1138 -62
  136. package/node_modules/supervision-js-core/dist/index.js.map +1 -1
  137. package/node_modules/supervision-js-core/dist/interactions/annotation-editing-engine.d.ts.map +1 -1
  138. package/node_modules/supervision-js-core/dist/interactions/annotation-handles.d.ts +2 -2
  139. package/node_modules/supervision-js-core/dist/interactions/annotation-handles.d.ts.map +1 -1
  140. package/node_modules/supervision-js-core/dist/styles/annotation-renderer-presentation.d.ts.map +1 -1
  141. package/node_modules/supervision-js-core/dist/styles/annotation-renderer-registry.d.ts.map +1 -1
  142. package/node_modules/supervision-js-core/dist/types/annotation-renderer.d.ts +50 -3
  143. package/node_modules/supervision-js-core/dist/types/annotation-renderer.d.ts.map +1 -1
  144. package/node_modules/supervision-js-core/dist/types/depth-map.d.ts +203 -0
  145. package/node_modules/supervision-js-core/dist/types/depth-map.d.ts.map +1 -0
  146. package/node_modules/supervision-js-core/dist/types/editing.d.ts +4 -0
  147. package/node_modules/supervision-js-core/dist/types/editing.d.ts.map +1 -1
  148. package/node_modules/supervision-js-core/dist/types/media-rendering.d.ts +3 -0
  149. package/node_modules/supervision-js-core/dist/types/media-rendering.d.ts.map +1 -1
  150. package/node_modules/supervision-js-core/dist/utils/depth-color-mapping.d.ts +91 -0
  151. package/node_modules/supervision-js-core/dist/utils/depth-color-mapping.d.ts.map +1 -0
  152. package/node_modules/supervision-js-core/dist/utils/depth-colormap-tables.d.ts +30 -0
  153. package/node_modules/supervision-js-core/dist/utils/depth-colormap-tables.d.ts.map +1 -0
  154. package/node_modules/supervision-js-core/dist/utils/depth-colormaps.d.ts +16 -0
  155. package/node_modules/supervision-js-core/dist/utils/depth-colormaps.d.ts.map +1 -0
  156. package/node_modules/supervision-js-core/dist/utils/depth-manifest.d.ts +23 -0
  157. package/node_modules/supervision-js-core/dist/utils/depth-manifest.d.ts.map +1 -0
  158. package/node_modules/supervision-js-core/dist/utils/depth-readout.d.ts +14 -0
  159. package/node_modules/supervision-js-core/dist/utils/depth-readout.d.ts.map +1 -0
  160. package/node_modules/supervision-js-core/dist/utils/detection-frames.d.ts +21 -0
  161. package/node_modules/supervision-js-core/dist/utils/detection-frames.d.ts.map +1 -1
  162. package/node_modules/supervision-js-core/dist/utils/id-mask-frame.d.ts +3 -7
  163. package/node_modules/supervision-js-core/dist/utils/id-mask-frame.d.ts.map +1 -1
  164. package/node_modules/supervision-js-core/package.json +2 -1
  165. package/package.json +6 -1
  166. package/dist/video-engine-media-source-DR-x1UfK.js.map +0 -1
@@ -165,7 +165,7 @@ export declare const FRAME_TIMELINE: {
165
165
  * session path that is a probe plus a walk from the enclosing sync sample,
166
166
  * measured at 49ms mean / 80ms worst on a 2840x2840 15fps source, flat in how
167
167
  * far the jump travelled. Coverage past the window is worth having, not worth
168
- * having crisp, so it lives in the preview tier at a 79th of the bytes.
168
+ * having crisp, so it lives in the smaller preview tier.
169
169
  *
170
170
  * resolveCacheBudgets turns these into a per-source budget from
171
171
  * navigator.deviceMemory and the decode frame size. A crisp slot costs
@@ -187,9 +187,8 @@ export declare const FRAME_TIMELINE: {
187
187
  * PREVIEW_SLOTS_MAX: the preview slot count is its byte budget over the
188
188
  * downscaled frame size, capped here. No floor pairs with it: raising a starved
189
189
  * count means overspending the byte budget, when the frame width is what a wide
190
- * preview has to give up. At a 79th of a crisp slot the tier carries the
191
- * timeline coverage an 8MP source cannot afford crisply: 163 slots against the
192
- * exact tier's 13, 11s of a 15fps clip.
190
+ * preview has to give up. A 320px square preview costs about a 79th of an
191
+ * 8MP crisp slot, so that source keeps coarse history beyond its exact window.
193
192
  *
194
193
  * SKIP_NEAR_MS: cache lookups that resolve to a frame within this many
195
194
  * milliseconds of what the visible canvas already shows are rejected so the
@@ -16,6 +16,7 @@ export interface ScrubViewport {
16
16
  */
17
17
  export interface ScrubCacheConfig {
18
18
  previewWidth: number;
19
+ fitPreviewToOutput?: boolean;
19
20
  previewCapacity?: number;
20
21
  exactBudgetBytes?: number;
21
22
  }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Decode-resolution strategies. A strategy decides the pixel width each video
3
+ * frame is decoded to, independent of the source's native resolution. Height
4
+ * follows from native aspect, so a strategy only ever returns a width.
5
+ *
6
+ * Decoding below native trades preview sharpness for paint cost and frame-cache
7
+ * memory. It does NOT cut decode cost: the codec decodes the full coded frame
8
+ * regardless of target width, and CanvasSink resizes the result afterward. The
9
+ * win scales with the gap between source resolution and the on-screen box: a 4K
10
+ * source shown in a 640px surface still pays full 4K decode, but the smaller
11
+ * surface cuts the per-frame paint work and the cached blit size.
12
+ *
13
+ * A strategy applies wherever frames decode through this seam: the live scrub
14
+ * surface and the analysis / extraction path alike. AnalysisSession decodes at
15
+ * whatever strategy it is given (native when omitted), so a thumbnail pass can
16
+ * cache a small blit instead of a native-size one.
17
+ */
18
+ /** Decode at native resolution. The conservative default. */
19
+ function nativeResolution() {
20
+ return { kind: "native" };
21
+ }
22
+ /**
23
+ * Decode at the on-screen size: canvas CSS width times devicePixelRatio. Best
24
+ * for fixed-size surfaces fed by a much larger source (frame sampler, inline
25
+ * players). Falls back to native while the box is unmeasured.
26
+ *
27
+ * The box it reads is the one bindCanvas measures, so this strategy resolves to
28
+ * native under presentation "frames", where the engine holds no canvas and
29
+ * nothing ever measures one. A frames-mode consumer passes displayBoxResolution
30
+ * instead.
31
+ */
32
+ function viewportResolution(options = {}) {
33
+ return {
34
+ kind: "viewport",
35
+ maxDevicePixelRatio: options.maxDevicePixelRatio ?? 2,
36
+ };
37
+ }
38
+ /**
39
+ * Decode at no more than maxWidth regardless of display size. For consumers
40
+ * with a hard throughput or memory ceiling (batch surfaces, thumbnail farms).
41
+ */
42
+ function cappedResolution(maxWidth) {
43
+ return { kind: "capped", maxWidth };
44
+ }
45
+ /**
46
+ * Decode at the size the frame will actually occupy inside a box the consumer
47
+ * describes: native aspect fitted into boxWidth x boxHeight, times the clamped
48
+ * device pixel ratio. Letterboxing is why the box is two numbers and not one,
49
+ * since a portrait source in a landscape box paints far narrower than the box.
50
+ *
51
+ * This is the strategy for presentation "frames". There the consumer owns the
52
+ * compositor, so it is the only side that knows the box, and viewportResolution
53
+ * has nothing to read.
54
+ */
55
+ function displayBoxResolution(options) {
56
+ return {
57
+ kind: "displayBox",
58
+ boxWidth: options.boxWidth,
59
+ boxHeight: options.boxHeight,
60
+ devicePixelRatio: options.devicePixelRatio,
61
+ maxDevicePixelRatio: options.maxDevicePixelRatio ?? 2,
62
+ };
63
+ }
64
+ /** Runs the descriptor against a context to produce a target decode width. */
65
+ function strategyWidth(strategy, ctx) {
66
+ switch (strategy.kind) {
67
+ case "native":
68
+ return ctx.nativeWidth;
69
+ case "viewport": {
70
+ if (ctx.displayWidth === null || ctx.displayWidth <= 0)
71
+ return ctx.nativeWidth;
72
+ const dpr = clampDpr(ctx.devicePixelRatio, strategy.maxDevicePixelRatio);
73
+ return Math.ceil(ctx.displayWidth * dpr);
74
+ }
75
+ case "capped":
76
+ return Math.min(strategy.maxWidth, ctx.nativeWidth);
77
+ case "displayBox": {
78
+ const { boxWidth, boxHeight } = strategy;
79
+ if (!(boxWidth > 0) || !(boxHeight > 0))
80
+ return ctx.nativeWidth;
81
+ const fit = Math.min(boxWidth / ctx.nativeWidth, boxHeight / ctx.nativeHeight);
82
+ const dpr = clampDpr(strategy.devicePixelRatio, strategy.maxDevicePixelRatio);
83
+ return Math.ceil(ctx.nativeWidth * fit * dpr);
84
+ }
85
+ }
86
+ }
87
+ /**
88
+ * Runs a strategy and returns native-bounded, aspect-preserving integer
89
+ * dimensions safe to hand to CanvasSink and to size a canvas backing store.
90
+ * A strategy that returns garbage (non-finite, non-positive) falls back to
91
+ * native rather than producing a broken surface.
92
+ */
93
+ function resolveDecodeDimensions(strategy, ctx) {
94
+ const nativeWidth = Math.max(1, Math.round(ctx.nativeWidth));
95
+ const nativeHeight = Math.max(1, Math.round(ctx.nativeHeight));
96
+ const raw = strategyWidth(strategy, ctx);
97
+ const width = Number.isFinite(raw) && raw > 0
98
+ ? Math.min(Math.round(raw), nativeWidth)
99
+ : nativeWidth;
100
+ const height = Math.max(1, Math.round((width * nativeHeight) / nativeWidth));
101
+ return { width, height };
102
+ }
103
+ function clampDpr(dpr, maxDpr) {
104
+ if (!Number.isFinite(dpr) || dpr <= 0)
105
+ return 1;
106
+ return Math.min(dpr, maxDpr);
107
+ }
108
+
109
+ export { cappedResolution as c, displayBoxResolution as d, nativeResolution as n, resolveDecodeDimensions as r, viewportResolution as v };
@@ -324,6 +324,7 @@ export declare class DecodeScheduler implements ScrubCursor {
324
324
  private runPrefetch;
325
325
  private runExactWindow;
326
326
  private runPreviewSweep;
327
+ private residentPreviewAt;
327
328
  private decodeInto;
328
329
  /**
329
330
  * One sweep pull, ended by abandonment rather than by the decode it is
@@ -211,8 +211,10 @@ export declare class EngineCore {
211
211
  *
212
212
  * An exact walk answers at or before the frame it aimed at, and no further
213
213
  * back than the sample next to it, so the target falls inside the answering
214
- * frame's own span. That span is the whole test: a frame decoded for some
215
- * earlier position sits outside it however recently it was painted.
214
+ * frame's own span. That span is the test: a frame decoded for some earlier
215
+ * position sits outside it however recently it was painted. The aimed-at
216
+ * frame answers without it, because a track's last frame has an empty span
217
+ * when its file states no duration for it.
216
218
  */
217
219
  private answersAwaitedSeek;
218
220
  /** The frame table of the loaded source. Reached only from paths that have