Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: webrtc/modules/desktop_capture/differ_block.cc

Issue 2202443002: [WebRTC] Add ScreenCapturerDifferWrapper to share Differ across ScreenCapturers (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Resolve review comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/desktop_capture/differ_block.cc
diff --git a/webrtc/modules/desktop_capture/differ_block.cc b/webrtc/modules/desktop_capture/differ_block.cc
index d4cbda3601f44b4e5c65d3352fec816df2f84c03..bcdaa91246c04f9dce6b8fd04b20493930e14223 100644
--- a/webrtc/modules/desktop_capture/differ_block.cc
+++ b/webrtc/modules/desktop_capture/differ_block.cc
@@ -13,49 +13,62 @@
#include <string.h>
#include "webrtc/typedefs.h"
-#include "webrtc/modules/desktop_capture/differ_block_sse2.h"
+#include "webrtc/modules/desktop_capture/differ_vector_sse2.h"
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
namespace webrtc {
-bool BlockDifference_C(const uint8_t* image1,
- const uint8_t* image2,
- int stride) {
- int width_bytes = kBlockSize * kBytesPerPixel;
+namespace {
- for (int y = 0; y < kBlockSize; y++) {
- if (memcmp(image1, image2, width_bytes) != 0)
- return true;
- image1 += stride;
- image2 += stride;
- }
- return false;
+bool VectorDifference_C(const uint8_t* image1,
+ const uint8_t* image2) {
+ return memcmp(image1, image2, kBlockSize * kBytesPerPixel) != 0;
}
-bool BlockDifference(const uint8_t* image1,
- const uint8_t* image2,
- int stride) {
- static bool (*diff_proc)(const uint8_t*, const uint8_t*, int) = NULL;
+} // namespace
+
+bool VectorDifference(const uint8_t* image1, const uint8_t* image2) {
+ static bool (*diff_proc)(const uint8_t*, const uint8_t*) = nullptr;
if (!diff_proc) {
#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY)
// For ARM and MIPS processors, always use C version.
// TODO(hclam): Implement a NEON version.
- diff_proc = &BlockDifference_C;
+ diff_proc = &VectorDifference_C;
#else
bool have_sse2 = WebRtc_GetCPUInfo(kSSE2) != 0;
// For x86 processors, check if SSE2 is supported.
if (have_sse2 && kBlockSize == 32) {
- diff_proc = &BlockDifference_SSE2_W32;
+ diff_proc = &VectorDifference_SSE2_W32;
} else if (have_sse2 && kBlockSize == 16) {
- diff_proc = &BlockDifference_SSE2_W16;
+ diff_proc = &VectorDifference_SSE2_W16;
} else {
- diff_proc = &BlockDifference_C;
+ diff_proc = &VectorDifference_C;
}
#endif
}
- return diff_proc(image1, image2, stride);
+ return diff_proc(image1, image2);
+}
+
+bool BlockDifference(const uint8_t* image1,
+ const uint8_t* image2,
+ int height,
+ int stride) {
+ for (int i = 0; i < height; i++) {
+ if (VectorDifference(image1, image2)) {
+ return true;
+ }
+ image1 += stride;
+ image2 += stride;
+ }
+ return false;
+}
+
+bool BlockDifference(const uint8_t* image1,
+ const uint8_t* image2,
+ int stride) {
+ return BlockDifference(image1, image2, kBlockSize, stride);
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698