( init: VideoFrameInit, frame: VideoFramePolyfill, otherFrame: VideoFramePolyfill, )
| 880 | }; |
| 881 | |
| 882 | const InitializeFrameFromOtherFrame = ( |
| 883 | init: VideoFrameInit, |
| 884 | frame: VideoFramePolyfill, |
| 885 | otherFrame: VideoFramePolyfill, |
| 886 | ) => { |
| 887 | // 1. Let format be otherFrame.format. |
| 888 | let format = otherFrame.format; |
| 889 | |
| 890 | // 2. If init.alpha is discard, assign otherFrame.format’s equivalent opaque format format. |
| 891 | if (init.alpha === 'discard' && format) { |
| 892 | format = getEquivalentOpaqueFormat(format) as VideoPixelFormat; |
| 893 | } |
| 894 | |
| 895 | // 3. Let validInit be the result of running the Validate VideoFrameInit algorithm... |
| 896 | if (!ValidateVideoFrameInit(init, format, otherFrame.codedWidth, otherFrame.codedHeight)) { |
| 897 | throw new TypeError('Invalid VideoFrameInit'); |
| 898 | } |
| 899 | |
| 900 | // 4. Let resource be the media resource referenced by otherFrame... |
| 901 | frame.data = otherFrame.data; |
| 902 | |
| 903 | // 5. Assign the following attributes from otherFrame to frame: codedWidth, codedHeight, colorSpace. |
| 904 | // @ts-expect-error Write to readonly |
| 905 | frame.codedWidth = otherFrame.codedWidth; |
| 906 | // @ts-expect-error Write to readonly |
| 907 | frame.codedHeight = otherFrame.codedHeight; |
| 908 | // @ts-expect-error Write to readonly |
| 909 | frame.colorSpace = new VideoColorSpacePolyfill(otherFrame.colorSpace); |
| 910 | |
| 911 | // 6. Let defaultVisibleRect be the result of performing the getter steps for visibleRect on otherFrame. |
| 912 | const defaultVisibleRect = otherFrame.visibleRect!; |
| 913 | |
| 914 | // 7. Let baseRotation and baseFlip be otherFrame’s [[rotation]] and [[flip]]. |
| 915 | const baseRotation = otherFrame.rotation; |
| 916 | const baseFlip = otherFrame.flip; |
| 917 | |
| 918 | // 8. Let defaultDisplayWidth and defaultDisplayHeight... |
| 919 | const defaultDisplayWidth = otherFrame.displayWidth; |
| 920 | const defaultDisplayHeight = otherFrame.displayHeight; |
| 921 | |
| 922 | // 9. Run the Initialize Visible Rect, Orientation, and Display Size algorithm. |
| 923 | InitializeVisibleRectOrientationAndDisplaySize( |
| 924 | init, frame, defaultVisibleRect, baseRotation, baseFlip, defaultDisplayWidth, defaultDisplayHeight, |
| 925 | ); |
| 926 | |
| 927 | // 10. If duration exists in init... |
| 928 | // @ts-expect-error Write to readonly |
| 929 | frame.duration = init.duration != null |
| 930 | ? Math.trunc(init.duration) |
| 931 | : otherFrame.duration; |
| 932 | |
| 933 | // 11. If timestamp exists in init... |
| 934 | // @ts-expect-error Write to readonly |
| 935 | frame.timestamp = init.timestamp != null |
| 936 | ? Math.trunc(init.timestamp) |
| 937 | : otherFrame.timestamp; |
| 938 | |
| 939 | // 12. Assign format to frame.[[format]]. |
no test coverage detected