Skip to content

Commit

Permalink
obs-nvenc: Migrate to obs_encoder_video_tex_active()
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaedtler authored and derrod committed Oct 5, 2024
1 parent f7b37aa commit 033130d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/obs-nvenc/nvenc-cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion plugins/obs-nvenc/nvenc-d3d11.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion plugins/obs-nvenc/nvenc-opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 7 additions & 4 deletions plugins/obs-nvenc/nvenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -869,7 +870,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;
Expand Down Expand Up @@ -1179,8 +1181,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 */
Expand Down

0 comments on commit 033130d

Please sign in to comment.