Преглед на файлове

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.
Dennis Sädtler преди 1 година
родител
ревизия
e6edfe5229
променени са 4 файла, в които са добавени 10 реда и са изтрити 7 реда
  1. 1 1
      plugins/obs-nvenc/nvenc-cuda.c
  2. 1 1
      plugins/obs-nvenc/nvenc-d3d11.c
  3. 1 1
      plugins/obs-nvenc/nvenc-opengl.c
  4. 7 4
      plugins/obs-nvenc/nvenc.c

+ 1 - 1
plugins/obs-nvenc/nvenc-cuda.c

@@ -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)
 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;
 	CUDA_ARRAY3D_DESCRIPTOR desc;
 	desc.Width = enc->cx;
 	desc.Width = enc->cx;
 	desc.Height = enc->cy;
 	desc.Height = enc->cy;

+ 1 - 1
plugins/obs-nvenc/nvenc-d3d11.c

@@ -93,7 +93,7 @@ void d3d11_free(struct nvenc_data *enc)
 
 
 static bool d3d11_texture_init(struct nvenc_data *enc, struct nv_texture *nvtex)
 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};
 	D3D11_TEXTURE2D_DESC desc = {0};
 	desc.Width = enc->cx;
 	desc.Width = enc->cx;

+ 1 - 1
plugins/obs-nvenc/nvenc-opengl.c

@@ -96,7 +96,7 @@ bool cuda_opengl_encode(void *data, struct encoder_texture *tex, int64_t pts, ui
 	struct nvenc_data *enc = data;
 	struct nvenc_data *enc = data;
 	struct nv_cuda_surface *surf;
 	struct nv_cuda_surface *surf;
 	struct nv_bitstream *bs;
 	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];
 	GLuint input_tex[2];
 
 
 	if (tex == NULL || tex->tex[0] == NULL) {
 	if (tex == NULL || tex->tex[0] == NULL) {

+ 7 - 4
plugins/obs-nvenc/nvenc.c

@@ -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)
 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)
 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 "
 		blog(LOG_INFO, "[obs-nvenc] nv12/p010 not active, falling back to "
 			       "non-texture encoder");
 			       "non-texture encoder");
 		goto reroute;
 		goto reroute;
@@ -1196,8 +1198,9 @@ bool nvenc_encode_base(struct nvenc_data *enc, struct nv_bitstream *bs, void *pi
 	if (enc->non_texture) {
 	if (enc->non_texture) {
 		params.bufferFmt = enc->surface_format;
 		params.bufferFmt = enc->surface_format;
 	} else {
 	} 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 */
 	/* Add ROI map if enabled */