( init: VideoFrameInit, format: VideoPixelFormat | null, codedWidth: number, codedHeight: number, )
| 1091 | }; |
| 1092 | |
| 1093 | const ValidateVideoFrameInit = ( |
| 1094 | init: VideoFrameInit, |
| 1095 | format: VideoPixelFormat | null, |
| 1096 | codedWidth: number, |
| 1097 | codedHeight: number, |
| 1098 | ): boolean => { |
| 1099 | // 1. If visibleRect exists: |
| 1100 | if (init.visibleRect) { |
| 1101 | // Let validAlignment be the result of running the Verify Rect Offset Alignment... |
| 1102 | if (!VerifyRectOffsetAlignment(format, init.visibleRect)) return false; |
| 1103 | // If any attribute of visibleRect is negative or not finite, return false. |
| 1104 | const r = init.visibleRect; |
| 1105 | if ((r.x || 0) < 0 || (r.y || 0) < 0 || (r.width || 0) < 0 || (r.height || 0) < 0) return false; |
| 1106 | // If visibleRect.width == 0 or visibleRect.height == 0 return false. |
| 1107 | if (r.width === 0 || r.height === 0) return false; |
| 1108 | // If visibleRect.y + visibleRect.height > codedHeight, return false. |
| 1109 | if ((r.y || 0) + (r.height || 0) > codedHeight) return false; |
| 1110 | // If visibleRect.x + visibleRect.width > codedWidth, return false. |
| 1111 | if ((r.x || 0) + (r.width || 0) > codedWidth) return false; |
| 1112 | } |
| 1113 | |
| 1114 | // 2. If codedWidth = 0 or codedHeight = 0, return false. |
| 1115 | if (codedWidth === 0 || codedHeight === 0) return false; |
| 1116 | |
| 1117 | // 3. If only one of displayWidth or displayHeight exists, return false. |
| 1118 | if ((init.displayWidth !== undefined && init.displayHeight === undefined) |
| 1119 | || (init.displayWidth === undefined && init.displayHeight !== undefined)) { |
| 1120 | return false; |
| 1121 | } |
| 1122 | |
| 1123 | // 4. If displayWidth == 0 or displayHeight == 0, return false. |
| 1124 | if (init.displayWidth === 0 || init.displayHeight === 0) return false; |
| 1125 | |
| 1126 | return true; |
| 1127 | }; |
| 1128 | |
| 1129 | const isValidVideoFrameBufferInit = (init: VideoFrameBufferInit): boolean => { |
| 1130 | // Check for required fields (WebIDL 'required') |
no test coverage detected