(frames: SwitchFrameSample[])
| 378 | } |
| 379 | |
| 380 | async function detectVisualInstability(frames: SwitchFrameSample[]) { |
| 381 | const anchorIndex = frames.findIndex((frame) => frame.containsTargetMarker); |
| 382 | if (anchorIndex === -1) return []; |
| 383 | const diffs = [] as Array<{ fromFrame: number; toFrame: number; ratio: number }>; |
| 384 | for (let index = anchorIndex; index < frames.length - 1; index++) { |
| 385 | const current = frames[index]; |
| 386 | const next = frames[index + 1]; |
| 387 | if (!current.containsTargetMarker || !next.containsTargetMarker) continue; |
| 388 | diffs.push({ |
| 389 | fromFrame: current.frame, |
| 390 | toFrame: next.frame, |
| 391 | ratio: await computeDiffRatio(current.png, next.png), |
| 392 | }); |
| 393 | } |
| 394 | return diffs.filter((diff) => diff.ratio > 0.01); |
| 395 | } |
| 396 | |
| 397 | function stripPng(frames: SwitchFrameSample[]) { |
| 398 | return frames.map(({ png, ...rest }) => rest); |
no test coverage detected