diff --git a/docs/sphinx/reference-encoders.rst b/docs/sphinx/reference-encoders.rst index b35a2f30c..5c267382e 100644 --- a/docs/sphinx/reference-encoders.rst +++ b/docs/sphinx/reference-encoders.rst @@ -164,8 +164,9 @@ Encoder Definition Structure (obs_encoder_info) - **OBS_ENCODER_CAP_DEPRECATED** - Encoder is deprecated - **OBS_ENCODER_CAP_ROI** - Encoder supports region of interest feature + - **OBS_ENCODER_CAP_SCALING** - Encoder implements its own scaling logic, + desiring to receive unscaled frames - .. versionadded:: 30.1 Encoder Packet Structure (encoder_packet) ----------------------------------------- diff --git a/libobs/obs-encoder.c b/libobs/obs-encoder.c index c0f53d061..e8916c6cf 100644 --- a/libobs/obs-encoder.c +++ b/libobs/obs-encoder.c @@ -186,6 +186,16 @@ static inline void get_video_info(struct obs_encoder *encoder, if (encoder->info.get_video_info) encoder->info.get_video_info(encoder->context.data, info); + + /** + * Prevent video output from performing an actual scale. If GPU scaling is + * enabled, the voi will contain the scaled size. Therefore, GPU scaling + * takes priority over self-scaling functionality. + */ + if ((encoder->info.caps & OBS_ENCODER_CAP_SCALING) != 0) { + info->width = voi->width; + info->height = voi->height; + } } static inline bool gpu_encode_available(const struct obs_encoder *encoder) diff --git a/libobs/obs-encoder.h b/libobs/obs-encoder.h index 26d35a872..5c7859b8e 100644 --- a/libobs/obs-encoder.h +++ b/libobs/obs-encoder.h @@ -37,6 +37,7 @@ typedef struct obs_encoder obs_encoder_t; #define OBS_ENCODER_CAP_DYN_BITRATE (1 << 2) #define OBS_ENCODER_CAP_INTERNAL (1 << 3) #define OBS_ENCODER_CAP_ROI (1 << 4) +#define OBS_ENCODER_CAP_SCALING (1 << 5) /** Specifies the encoder type */ enum obs_encoder_type { diff --git a/libobs/obs-module.c b/libobs/obs-module.c index e79847955..02c12bf00 100644 --- a/libobs/obs-module.c +++ b/libobs/obs-module.c @@ -934,6 +934,14 @@ void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size) goto error; } + if (((info->caps & OBS_ENCODER_CAP_PASS_TEXTURE) != 0 && + info->caps & OBS_ENCODER_CAP_SCALING) != 0) { + encoder_warn( + "Texture encoders cannot self-scale. Encoder id '%s' not registered.", + info->id); + goto error; + } + #define CHECK_REQUIRED_VAL_(info, val, func) \ CHECK_REQUIRED_VAL(struct obs_encoder_info, info, val, func) CHECK_REQUIRED_VAL_(info, get_name, obs_register_encoder);