瀏覽代碼

libobs: Disable encoder scaling request if it matches output size

It was possible to set the encoder to scale the video to the same size
as the output, resulting in unnecessary passes through swscale and
skipping hardware encoders. This was a common user error in Advanced
Output mode where they would tick the rescale box but leave it at the
same resolution as their main output.
Richard Stanway 2 年之前
父節點
當前提交
01786a3f11
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      libobs/obs-encoder.c

+ 12 - 0
libobs/obs-encoder.c

@@ -694,6 +694,18 @@ void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
 		return;
 	}
 
+	const struct video_output_info *voi;
+	voi = video_output_get_info(encoder->media);
+	if (voi && voi->width == width && voi->height == height) {
+		blog(LOG_WARNING,
+		     "encoder '%s': Scaled resolution "
+		     "matches output resolution, scaling "
+		     "disabled",
+		     obs_encoder_get_name(encoder));
+		encoder->scaled_width = encoder->scaled_height = 0;
+		return;
+	}
+
 	encoder->scaled_width = width;
 	encoder->scaled_height = height;
 }