OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/differ_block.h" | 5 #include "remoting/host/differ_block.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "media/base/cpu_features.h" | 8 #include "media/base/cpu_features.h" |
9 #include "remoting/host/differ_block_internal.h" | 9 #include "remoting/host/differ_block_internal.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 int BlockDifference_C(const uint8* image1, const uint8* image2, int stride) { | 13 int BlockDifference_C(const uint8* image1, const uint8* image2, int stride) { |
14 int width_bytes = kBlockWidth * kBytesPerPixel; | 14 int width_bytes = kBlockSize * kBytesPerPixel; |
15 | 15 |
16 for (int y = 0; y < kBlockHeight; y++) { | 16 for (int y = 0; y < kBlockSize; y++) { |
17 if (memcmp(image1, image2, width_bytes) != 0) | 17 if (memcmp(image1, image2, width_bytes) != 0) |
18 return 1; | 18 return 1; |
19 image1 += stride; | 19 image1 += stride; |
20 image2 += stride; | 20 image2 += stride; |
21 } | 21 } |
22 return 0; | 22 return 0; |
23 } | 23 } |
24 | 24 |
25 int BlockDifference(const uint8* image1, const uint8* image2, int stride) { | 25 int BlockDifference(const uint8* image1, const uint8* image2, int stride) { |
26 static int (*diff_proc)(const uint8*, const uint8*, int) = NULL; | 26 static int (*diff_proc)(const uint8*, const uint8*, int) = NULL; |
27 | 27 |
28 if (!diff_proc) { | 28 if (!diff_proc) { |
29 #if defined(ARCH_CPU_ARM_FAMILY) | 29 #if defined(ARCH_CPU_ARM_FAMILY) |
30 // For ARM processors, always use C version. | 30 // For ARM processors, always use C version. |
31 // TODO(hclam): Implement a NEON version. | 31 // TODO(hclam): Implement a NEON version. |
32 diff_proc = &BlockDifference_C; | 32 diff_proc = &BlockDifference_C; |
33 #else | 33 #else |
34 // For x86 processors, check if SSE2 is supported. | 34 // For x86 processors, check if SSE2 is supported. |
35 if (media::hasSSE2() && kBlockWidth == 32) | 35 if (media::hasSSE2() && kBlockSize == 32) |
36 diff_proc = &BlockDifference_SSE2_W32; | 36 diff_proc = &BlockDifference_SSE2_W32; |
37 else if (media::hasSSE2() && kBlockWidth == 16) | 37 else if (media::hasSSE2() && kBlockSize == 16) |
38 diff_proc = &BlockDifference_SSE2_W16; | 38 diff_proc = &BlockDifference_SSE2_W16; |
39 else | 39 else |
40 diff_proc = &BlockDifference_C; | 40 diff_proc = &BlockDifference_C; |
41 #endif | 41 #endif |
42 } | 42 } |
43 | 43 |
44 return diff_proc(image1, image2, stride); | 44 return diff_proc(image1, image2, stride); |
45 } | 45 } |
46 | 46 |
47 } // namespace remoting | 47 } // namespace remoting |
OLD | NEW |