Procházet zdrojové kódy

win-mf: Do not register encoder if it can't create

It seems that certain encoders (quicksync) do not have proper back-end
support in the windows media foundation libraries for certain CPUs.
Quicksync doesn't appear to support CPUs that are not haswell (4xxx) or
above.  It's really annoying, but there's not much we can do about it
until we implement our own custom quicksync implementation.

This check simply makes it attempt to spawn an encoder to check to see
whether the encoder can actually be created before registering an
encoder.
jp9000 před 10 roky
rodič
revize
8280dbc596
1 změnil soubory, kde provedl 15 přidání a 0 odebrání
  1. 15 0
      plugins/win-mf/mf-h264.cpp

+ 15 - 0
plugins/win-mf/mf-h264.cpp

@@ -504,6 +504,16 @@ static bool MFH264_Update(void *data, obs_data_t *settings)
 	return true;
 	return true;
 }
 }
 
 
+static bool CanSpawnEncoder(std::shared_ptr<EncoderDescriptor> descriptor)
+{
+	HRESULT hr;
+	ComPtr<IMFTransform> transform;
+
+	hr = CoCreateInstance(descriptor->Guid(), nullptr,
+			CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&transform));
+	return hr == S_OK;
+}
+
 void RegisterMFH264Encoders()
 void RegisterMFH264Encoders()
 {
 {
 	obs_encoder_info info = { 0 };
 	obs_encoder_info info = { 0 };
@@ -527,6 +537,11 @@ void RegisterMFH264Encoders()
 		if (e->Type() == EncoderType::H264_SOFTWARE)
 		if (e->Type() == EncoderType::H264_SOFTWARE)
 			continue;
 			continue;
 
 
+		/* certain encoders such as quicksync will be "available" but
+		 * not usable with certain processors */
+		if (!CanSpawnEncoder(e))
+			continue;
+
 		info.id = e->Id();
 		info.id = e->Id();
 		info.type_data = new TypeData(e);
 		info.type_data = new TypeData(e);
 		info.free_type_data = [] (void *type_data) {
 		info.free_type_data = [] (void *type_data) {