obs-nvenc: Migrate to obs_encoder_video_tex_active()

Unlike obs_nv12/p010_tex_active() this accurately reflects the texture
availability in the mix associated with the encoder.
This commit is contained in:
Dennis Sädtler
2024-10-01 15:14:35 +02:00
committed by Ryan Foster
parent 3b1a66f632
commit e6edfe5229
4 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ void cuda_ctx_free(struct nvenc_data *enc)
static bool cuda_surface_init(struct nvenc_data *enc, struct nv_cuda_surface *nvsurf)
{
const bool p010 = obs_p010_tex_active();
const bool p010 = obs_encoder_video_tex_active(enc->encoder, VIDEO_FORMAT_P010);
CUDA_ARRAY3D_DESCRIPTOR desc;
desc.Width = enc->cx;
desc.Height = enc->cy;
+1 -1
View File
@@ -93,7 +93,7 @@ void d3d11_free(struct nvenc_data *enc)
static bool d3d11_texture_init(struct nvenc_data *enc, struct nv_texture *nvtex)
{
const bool p010 = obs_p010_tex_active();
const bool p010 = obs_encoder_video_tex_active(enc->encoder, VIDEO_FORMAT_P010);
D3D11_TEXTURE2D_DESC desc = {0};
desc.Width = enc->cx;
+1 -1
View File
@@ -96,7 +96,7 @@ bool cuda_opengl_encode(void *data, struct encoder_texture *tex, int64_t pts, ui
struct nvenc_data *enc = data;
struct nv_cuda_surface *surf;
struct nv_bitstream *bs;
const bool p010 = obs_p010_tex_active();
const bool p010 = obs_encoder_video_tex_active(enc->encoder, VIDEO_FORMAT_P010);
GLuint input_tex[2];
if (tex == NULL || tex->tex[0] == NULL) {
+7 -4
View File
@@ -209,7 +209,8 @@ static inline NV_ENC_MULTI_PASS get_nv_multipass(const char *multipass)
static bool is_10_bit(const struct nvenc_data *enc)
{
return enc->non_texture ? enc->in_format == VIDEO_FORMAT_P010 : obs_p010_tex_active();
return enc->non_texture ? enc->in_format == VIDEO_FORMAT_P010
: obs_encoder_video_tex_active(enc->encoder, VIDEO_FORMAT_P010);
}
static bool init_encoder_base(struct nvenc_data *enc, obs_data_t *settings)
@@ -886,7 +887,8 @@ static void *nvenc_create_base(enum codec_type codec, obs_data_t *settings, obs_
}
}
if (texture && !obs_p010_tex_active() && !obs_nv12_tex_active()) {
if (texture && !obs_encoder_video_tex_active(encoder, VIDEO_FORMAT_NV12) &&
!obs_encoder_video_tex_active(encoder, VIDEO_FORMAT_P010)) {
blog(LOG_INFO, "[obs-nvenc] nv12/p010 not active, falling back to "
"non-texture encoder");
goto reroute;
@@ -1196,8 +1198,9 @@ bool nvenc_encode_base(struct nvenc_data *enc, struct nv_bitstream *bs, void *pi
if (enc->non_texture) {
params.bufferFmt = enc->surface_format;
} else {
params.bufferFmt = obs_p010_tex_active() ? NV_ENC_BUFFER_FORMAT_YUV420_10BIT
: NV_ENC_BUFFER_FORMAT_NV12;
params.bufferFmt = obs_encoder_video_tex_active(enc->encoder, VIDEO_FORMAT_P010)
? NV_ENC_BUFFER_FORMAT_YUV420_10BIT
: NV_ENC_BUFFER_FORMAT_NV12;
}
/* Add ROI map if enabled */