Conversation
Capture RGBA from vtkWindowToImageFilter and flip it into a new buffer, returning its RGB channels as a view. Pillow and PyTurboJPEG can then read the 4-byte pixels in place (Image.frombuffer "RGBX" / TJPF_RGBX) instead of Pillow copying the frame via Image.fromarray. The returned array is still a top-down RGB array, so other RCAs, the non-JPEG formats and the multiprocessing path are unchanged: VTK's alpha (0 on the background) never reaches the encoders, and output is byte-identical to before for jpeg, turbo-jpeg, png, webp and avif. The flip no longer writes back into the VTK-owned buffer.
PyTurboJPEG defaults to 4:2:2 while Pillow uses 4:2:0, so turbo-jpeg frames were larger and slower to encode than jpeg ones. With 4:2:0 both encoders produce frames of the same size. The test is skipped unless PyTurboJPEG can load libjpeg-turbo >= 3.0.
user27182
marked this pull request as ready for review
October 5, 2026 20:48
This branch has not been deployed
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.
Two speedups for JPEG image streaming, one commit each:
VtkRemoteControlledAreacaptures RGBA and returns the RGB channels as a view over that buffer. The Pillow and PyTurboJPEG encoders detect the view and read the pixels in place, instead of Pillow copying every frame throughImage.fromarray.img_cols_rowsstill returns a top-down RGB array, and output is byte-identical tomasterfor all formats.turbo-jpegframes about 16% smaller and faster to encode.Benchmark
Capture + encode per 1920x1080 frame (Apple Silicon, rendering excluded):
jpeg(Pillow)turbo-jpegturbo-jpegframemasterTo reproduce (from a trame-rca checkout):
bench_rca.py
For real
turbo-jpegnumbers, alsopip install PyTurboJPEGwith libjpeg-turbo >= 3.0 on the system; otherwise it falls back to Pillow (the script prints which one it used).🤖 Generated with Claude Code