Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libobs: Add obs_encoder_get_group() #10952

Closed
wants to merge 1 commit into from

Conversation

tt2468
Copy link
Member

@tt2468 tt2468 commented Jul 6, 2024

Description

Allows getting of the current encoder group of an encoder. Not useful for too much on its own, but allows encoder implementations to know if they are in a group or not.

Motivation and Context

Needed in my case for enabling some performance optimizations in an encoder plugin. I can rely on encoder groups in my plugin to create a shared scaler object for encoders within the group, rather than always one scaler per encoder always. This gives me a >30% efficiency boost in my scaler utilization.

How Has This Been Tested?

Compiles on Ubuntu 22.04

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Allows getting of the current encoder group of an encoder. Needed in
my case for enabling some performance optimizations in an encoder
plugin.
@tt2468 tt2468 added the Enhancement Improvement to existing functionality label Jul 6, 2024
@RytoEX RytoEX added this to the OBS Studio 31 milestone Jul 8, 2024
Comment on lines +2049 to +2054
obs_encoder_group_t *obs_encoder_get_group(obs_encoder_t *encoder)
{
return obs_encoder_valid(encoder, "obs_encoder_get_group")
? encoder->encoder_group
: NULL;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

given the intricacies around the lifetime of groups I'd suggest going with a design that doesn't expose the pointer to code that doesn't own the group, e.g.

bool obs_encoder_is_grouped_with(obs_encoder_t *encoder, obs_encoder_t *other_encoder)

or maybe add a comment to the function along the lines of

this pointer is only safe to use before encoders have been started or while encoders are active; the pointer might get invalidated as soon as encoders become inactive

@tt2468 tt2468 removed this from the OBS Studio 31 milestone Sep 7, 2024
@tt2468 tt2468 closed this Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants