Repository navigation
feat: run on Windows with the app's own WebM decoder - #13
Merged
Merged
Conversation
NSGo's Windows player refuses video that declares alpha (internal/platform/windows/video.go), as whether Media Foundation keeps it was never checked, so the pet showed nothing there. On Windows each slot now plays its clip in clipPlayer: the WebM is demuxed with ebml-go, its VP9 color stream and the alpha stream in the blocks' additions are decoded with libvpx, bound through purego without cgo, and the frames are shown premultiplied in a core.Image through ImageSource.Pixels at their timestamps. The player gives the slot what core.Video gives it elsewhere: the load once the first picture is up, progress every 33 ms, the end, pausing and restarting from the start. macOS and Linux keep core.Video. libvpx 1.16.0 and the winpthreads library it links ship unchanged from MSYS2's signed mingw64 packages in resources/windows, with their licenses; tools/fetch-libvpx.sh fetches them again by SHA-256. The decoder's tests run against the bundled DLL on Windows and the system's libvpx elsewhere, and are skipped without one.
nsgo.yaml builds windows_x64, and the release workflow gets a Windows row that makes the NSIS installer on Ubuntu, as NSGo's desktop builds need no cgo. The installer is not signed yet, for which SmartScreen warns. Only x64: the bundled libvpx is an x64 DLL.
…sh frame on Windows A BlockMore that leaves out BlockAddID holds the alpha picture, as the element defaults to 1, so packs from muxers that skip default values no longer play opaque on Windows. Replaying the clip the hidden slot already holds now waits for the Windows player's first new frame before showing the slot, instead of showing its stale frame while the clip is read and decoded again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The pet now runs on Windows x64. NSGo's Windows player refuses any clip that declares alpha (
internal/platform/windows/video.go,VideoErrorAlphaUnsupported), so until now the pet's window stayed empty there.clip.go: demuxes a WebM clip withgithub.com/at-wat/ebml-gov0.19.4 into its VP9 frames, each with the alpha picture from the block's additions (BlockAddID 1), and converts a decoded I420 picture plus the alpha stream's luma to premultiplied RGBA (BT.601/BT.709, limited/full range as libvpx reports).vpx.go,vpx_windows.go,vpx_other.go: libvpx's VP9 decoder bound withgithub.com/ebitengine/purego(now a direct dependency), no cgo. On Windows it loads the bundledresources/windows/libvpx-1.dllwithLoadLibraryExWrestricted to the DLL's own folder and System32; elsewhere only the tests use it, against the system's libvpx.clipplayer.go: on Windows each slot plays its clip in acore.ImagethroughImageSource.Pixels, decoding on a goroutine of its own into three reused buffers and showing each frame at its timestamp on the graph clock. It keeps the contract the pet relies on fromcore.Video: the load once the first picture is up (which drives the two-slot swap), progress every 33 ms, the end, pausing, restarting from the start, and the same style (Contain, mirroring, opacity). macOS and Linux keepcore.Videounchanged.resources/windows: libvpx 1.16.0 and the winpthreads DLL it links, unchanged from MSYS2's signed mingw64 packages (mingw-w64-x86_64-libvpx-1.16.0-1,mingw-w64-x86_64-libwinpthread-14.0.0.r92.g818fa6510-1), with their licenses and a NOTICE.tools/fetch-libvpx.shfetches them again and checks their SHA-256.nsgo.yamlbuildswindows_x64, and the release workflow gets a Windows row that makes the NSIS installer on Ubuntu, unsigned for now.Tests
go tool nsgo test .passes on macOS (libvpx from Homebrew): 18 passed.go testpasses with the bundled DLL (all butTestEveryClipShips, which needs the MOV clips the sparse checkout there left out).BenchmarkDecodeFrame: 1.74 ms per 640x360 frame with its alpha on an i5-14600KF.Checked on Windows
The app built with
go tool nsgo build -target windows_x64ran in a logged-on but disconnected desktop session of the VM:PrintWindowcaptures the window black, while the clips go on playing; from a fresh start every pet captures fine, and switching between pets of the same size does too. Whether the window really draws nothing after the resize needs a connected display to tell.Screenshots
Captured with
PrintWindow, which draws the window's transparent area black; the pet itself is what the window shows. Before this change the window showed nothing on Windows.