MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / VerifyRectOffsetAlignment

Function VerifyRectOffsetAlignment

src/video_frame.ts:719–741  ·  view source on GitHub ↗
(format: VideoPixelFormat | null, rect: DOMRectInit)

Source from the content-addressed store, hash-verified

717};
718
719const VerifyRectOffsetAlignment = (format: VideoPixelFormat | null, rect: DOMRectInit): boolean => {
720 // 1. If format is null, return true.
721 if (format === null) return true;
722
723 const info = getPixelFormatInfo(format);
724 if (!info) return false;
725
726 // 2. Let planeIndex be 0.
727 // 3. Let numPlanes be the number of planes as defined by format.
728 // 4. While planeIndex is less than numPlanes:
729 for (let planeIndex = 0; planeIndex < info.planes.length; planeIndex++) {
730 const plane = info.planes[planeIndex];
731 const sampleWidth = plane.sampleWidth;
732 const sampleHeight = plane.sampleHeight;
733
734 // If rect.x is not a multiple of sampleWidth, return false.
735 if ((rect.x || 0) % sampleWidth !== 0) return false;
736 // If rect.y is not a multiple of sampleHeight, return false.
737 if ((rect.y || 0) % sampleHeight !== 0) return false;
738 }
739
740 return true;
741};
742
743const ComputeLayoutAndAllocationSize = (
744 parsedRect: DOMRectInit,

Callers 2

ParseVisibleRectFunction · 0.85
ValidateVideoFrameInitFunction · 0.85

Calls 1

getPixelFormatInfoFunction · 0.85

Tested by

no test coverage detected