Skip to content

Optimize memory management and frame conversions#143

Merged
sundermann merged 8 commits into
webosbrew:mainfrom
sundermann:optimize
Jul 6, 2026
Merged

Optimize memory management and frame conversions#143
sundermann merged 8 commits into
webosbrew:mainfrom
sundermann:optimize

Conversation

@sundermann

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and bug fixes across the build system, memory management, and frame handling logic. The most significant changes enhance buffer management to prevent memory leaks and overflows, optimize frame acquisition and conversion, and update third-party dependencies for improved reliability.

Memory Management Improvements

  • Introduced a converter_reserve helper to safely manage buffer allocations, replacing repeated realloc calls and reducing the risk of memory leaks or overflows. All buffer allocations in the converter now use this function.
  • Fixed incorrect argument order in calloc calls, ensuring correct memory allocation for buffer pointers.

Frame Handling and Performance

  • Improved frame acquisition in unicapture/backends/libvtcapture.cpp by introducing a buff_valid flag to avoid redundant buffer queries and ensure the buffer is only refreshed when needed.
  • Optimized frame conversion in unicapture/unicapture.c by adding a borrow_frame helper, allowing direct reuse of frames when the pixel format already matches the target, thus avoiding unnecessary conversions.
  • Added an optimized path for NV12 blending using libyuv

Networking and Communication

  • Refactored message sending in to use writev for atomic header and payload transmission, improving reliability and simplifying the code.

@satgit62

satgit62 commented Jul 5, 2026

Copy link
Copy Markdown

Hi, I've thoroughly tested this on my devices, and the improvements are clearly noticeable. HyperHDR benefits from this as well. Even on my old webOS 3.9 device, when the “Continuous output” option under “Smoothing” in HyperHDR is disabled, no frames are discarded or skipped—in other words, there are no glitches. Before this PR, you had to keep “Continuous output” enabled at all times, which would have consumed resources.
This is a real improvement and should be released so that @TBSniller can release a new version of PicCap.

@TBSniller

Copy link
Copy Markdown
Collaborator

Thanks guys!
Will take a look during the day

@TBSniller

Copy link
Copy Markdown
Collaborator

@sundermann is it already mergeable? I could do release for piccap today

@sundermann sundermann merged commit 00c932f into webosbrew:main Jul 6, 2026
2 checks passed
@satgit62

satgit62 commented Jul 6, 2026

Copy link
Copy Markdown

@sundermann is it already mergeable? I could do release for piccap today

The PR has been merged, so nothing stands in the way of releasing a new version of PicCap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants