Skip to content

Commit

Permalink
libobs: Add obs_encoder_scaling_enabled()
Browse files Browse the repository at this point in the history
Returns whether rescaling is enabled for an encoder.  This will be used
with texture-based encoders to determine whether to fall back to
RAM-based encoding instead.
  • Loading branch information
jp9000 committed Feb 19, 2020
1 parent 4d0b3ef commit de363d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/sphinx/reference-encoders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ General Encoder Functions

---------------------

.. function:: bool obs_encoder_scaling_enabled(const obs_encoder_t *encoder)

:return: *true* if pre-encode (CPU) scaling enabled, *false*
otherwise.

---------------------

.. function:: uint32_t obs_encoder_get_width(const obs_encoder_t *encoder)
uint32_t obs_encoder_get_height(const obs_encoder_t *encoder)
Expand Down
8 changes: 8 additions & 0 deletions libobs/obs-encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,14 @@ void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
encoder->scaled_height = height;
}

bool obs_encoder_scaling_enabled(const obs_encoder_t *encoder)
{
if (!obs_encoder_valid(encoder, "obs_encoder_scaling_enabled"))
return false;

return encoder->scaled_width || encoder->scaled_height;
}

uint32_t obs_encoder_get_width(const obs_encoder_t *encoder)
{
if (!obs_encoder_valid(encoder, "obs_encoder_get_width"))
Expand Down
3 changes: 3 additions & 0 deletions libobs/obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,9 @@ EXPORT enum obs_encoder_type obs_encoder_get_type(const obs_encoder_t *encoder);
EXPORT void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
uint32_t height);

/** For video encoders, returns true if pre-encode scaling is enabled */
EXPORT bool obs_encoder_scaling_enabled(const obs_encoder_t *encoder);

/** For video encoders, returns the width of the encoded image */
EXPORT uint32_t obs_encoder_get_width(const obs_encoder_t *encoder);

Expand Down

0 comments on commit de363d3

Please sign in to comment.