()
| 606 | } |
| 607 | |
| 608 | function renderPendingFrameCanvas2D() { |
| 609 | if (!pendingNv12Frame || !directCanvas || !directCtx) return; |
| 610 | |
| 611 | const { buffer, receivedAt } = pendingNv12Frame; |
| 612 | pendingNv12Frame = null; |
| 613 | |
| 614 | const metadata = readNv12Metadata(buffer); |
| 615 | if (!metadata) return; |
| 616 | |
| 617 | const { yStride, height, width, fullRange } = metadata; |
| 618 | |
| 619 | if (width > 0 && height > 0) { |
| 620 | const ySize = yStride * height; |
| 621 | const uvSize = yStride * (height / 2); |
| 622 | const totalSize = ySize + uvSize; |
| 623 | |
| 624 | const frameData = new Uint8ClampedArray(buffer, 0, totalSize); |
| 625 | renderNv12FrameCanvas2D( |
| 626 | frameData, |
| 627 | width, |
| 628 | height, |
| 629 | yStride, |
| 630 | fullRange, |
| 631 | receivedAt, |
| 632 | ); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | function schedulePendingNv12FrameCanvas2D( |
| 637 | buffer: ArrayBuffer, |
no test coverage detected