Просмотр исходного кода

win-dshow: Use FFmpeg for MJPEG decompression

Measured lower CPU usage and latency than default DirectShow filter.
Tested with Logitech BRIO camera at 4K, 30 FPS.
James Park 6 лет назад
Родитель
Сommit
0e7eec8f2d
1 измененных файлов с 6 добавлено и 17 удалено
  1. 6 17
      plugins/win-dshow/win-dshow.cpp

+ 6 - 17
plugins/win-dshow/win-dshow.cpp

@@ -418,8 +418,6 @@ static inline video_format ConvertVideoFormat(VideoFormat format)
 		return VIDEO_FORMAT_UYVY;
 	case VideoFormat::HDYC:
 		return VIDEO_FORMAT_UYVY;
-	case VideoFormat::MJPEG:
-		return VIDEO_FORMAT_YUY2;
 	default:
 		return VIDEO_FORMAT_NONE;
 	}
@@ -502,6 +500,11 @@ void DShowInput::OnVideoData(const VideoConfig &config, unsigned char *data,
 		return;
 	}
 
+	if (videoConfig.format == VideoFormat::MJPEG) {
+		OnEncodedVideoData(AV_CODEC_ID_MJPEG, data, size, startTime);
+		return;
+	}
+
 	const int cx = config.cx;
 	const int cy = config.cy;
 
@@ -905,8 +908,7 @@ bool DShowInput::UpdateVideoConfig(obs_data_t *settings)
 					 placeholders::_3, placeholders::_4,
 					 placeholders::_5);
 
-	if (videoConfig.internalFormat != VideoFormat::MJPEG)
-		videoConfig.format = videoConfig.internalFormat;
+	videoConfig.format = videoConfig.internalFormat;
 
 	if (!device.SetVideoConfig(&videoConfig)) {
 		blog(LOG_WARNING, "%s: device.SetVideoConfig failed",
@@ -914,19 +916,6 @@ bool DShowInput::UpdateVideoConfig(obs_data_t *settings)
 		return false;
 	}
 
-	if (videoConfig.internalFormat == VideoFormat::MJPEG) {
-		videoConfig.format = VideoFormat::XRGB;
-		videoConfig.useDefaultConfig = false;
-
-		if (!device.SetVideoConfig(&videoConfig)) {
-			blog(LOG_WARNING,
-			     "%s: device.SetVideoConfig (XRGB) "
-			     "failed",
-			     obs_source_get_name(source));
-			return false;
-		}
-	}
-
 	DStr formatName = GetVideoFormatName(videoConfig.internalFormat);
 
 	double fps = 0.0;