فهرست منبع

libobs: Use one copy for RGBA output when possible

A minor optimization: in copy_rgbx_frame (used when libobs is set to
output RGBA frames instead of YUV frames), if the line sizes for the
source and destination match, just use a single memcpy call for all of
the data instead of multiple memcpy calls.
Anthony Catel 10 سال پیش
والد
کامیت
ffb3ca4595
1فایلهای تغییر یافته به همراه9 افزوده شده و 4 حذف شده
  1. 9 4
      libobs/obs-video.c

+ 9 - 4
libobs/obs-video.c

@@ -473,10 +473,15 @@ static inline void copy_rgbx_frame(
 	uint8_t *in_ptr = input->data[0];
 	uint8_t *out_ptr = output->data[0];
 
-	for (size_t y = 0; y < info->height; y++) {
-		memcpy(out_ptr, in_ptr, info->width * 4);
-		in_ptr += input->linesize[0];
-		out_ptr += output->linesize[0];
+	/* if the line sizes match, do a single copy */
+	if (input->linesize[0] == output->linesize[0]) {
+		memcpy(out_ptr, in_ptr, input->linesize[0] * info->height);
+	} else {
+		for (size_t y = 0; y < info->height; y++) {
+			memcpy(out_ptr, in_ptr, info->width * 4);
+			in_ptr += input->linesize[0];
+			out_ptr += output->linesize[0];
+		}
 	}
 }