Skip to content

NDI Output filter - Performance tweaks#1266

Closed
Trouffman wants to merge 6 commits into
masterfrom
tweak-performance-872
Closed

NDI Output filter - Performance tweaks#1266
Trouffman wants to merge 6 commits into
masterfrom
tweak-performance-872

Conversation

@Trouffman

Copy link
Copy Markdown
Collaborator

Refactor video frame handling in ndi_filter_offscreen_render to be closer to Preview Output

Goal

Update the NDI filer codebase to be updated and more similar to the NDI Preview Output rendering.

Context

  • This was triggered by a discussion posted by @theotherraycole at : Performance issue #872
  • Looked at the code and the only other place where something similar was used was for the NDI Preview output.
  • Then re-used most of the code from Preview output to this.

Disclosure : I do not understand it all for the logic (i am not skilled in anything using gs / drawing textures, etc).

This will stay as a draft until more pairs of eyes can review it.2

@Trouffman

Copy link
Copy Markdown
Collaborator Author

This PR is very similar to #1232

@Trouffman Trouffman added this to the 6.1.1 milestone May 8, 2025
@Trouffman Trouffman self-assigned this May 8, 2025
@Trouffman Trouffman added filter-feature For anything that is tied to an NDI Filter. Output (Program/Preview) relate to NDI Output Progam or Preview performance labels May 8, 2025
@Trouffman Trouffman modified the milestones: 6.1.1, 6.1.2 Jun 12, 2025
@Trouffman
Trouffman requested a review from Copilot June 18, 2025 22:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the NDI offscreen rendering code to align it more closely with the existing NDI Preview Output handling, aiming to improve performance and update the implementation.

  • Replace the direct usage of video_frame with a struct declaration
  • Introduce a conditional check around the mapping process with associated memory copy improvements

Comment thread src/ndi-filter.cpp
uint32_t src_offset = f->video_linesize * i;
memcpy(output_frame.data[0] + dst_offset, f->video_data + src_offset, linesize);
}
if (gs_stagesurface_map(f->stagesurface, &f->video_data, &f->video_linesize)) {

Copilot AI Jun 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle the scenario where gs_stagesurface_map returns false by adding necessary cleanup or logging, to improve the overall robustness and maintainability of the code.

Copilot uses AI. Check for mistakes.
Comment thread src/ndi-filter.cpp
}
if (gs_stagesurface_map(f->stagesurface, &f->video_data, &f->video_linesize)) {
uint32_t linesize = output_frame.linesize[0];
for (uint32_t i = 0; i < f->known_height; i++) {

Copilot AI Jun 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using the pre-increment operator (++i) for consistency with the rest of the code style and any potential minor performance benefits.

Suggested change
for (uint32_t i = 0; i < f->known_height; i++) {
for (uint32_t i = 0; i < f->known_height; ++i) {

Copilot uses AI. Check for mistakes.
@Trouffman

Copy link
Copy Markdown
Collaborator Author

This is superseeded by #1279

@Trouffman Trouffman closed this Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filter-feature For anything that is tied to an NDI Filter. Output (Program/Preview) relate to NDI Output Progam or Preview performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants