diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-04 20:09:12 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-04 20:09:12 +0000 |
commit | d8fe8f140c0a8faeee309bf1b1d97f8a33f75dcc (patch) | |
tree | 0de6302339955c66fb620fb3c4780ad8b35b77fc /remoting | |
parent | 16cb745a833a6e86012ee7dab0878941cdf7f7f0 (diff) | |
download | chromium_src-d8fe8f140c0a8faeee309bf1b1d97f8a33f75dcc.zip chromium_src-d8fe8f140c0a8faeee309bf1b1d97f8a33f75dcc.tar.gz chromium_src-d8fe8f140c0a8faeee309bf1b1d97f8a33f75dcc.tar.bz2 |
Define Chromoting's differ block size in one (and only one) place.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7511014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/differ.cc | 2 | ||||
-rw-r--r-- | remoting/host/differ.h | 4 | ||||
-rw-r--r-- | remoting/host/differ_block.cc | 8 | ||||
-rw-r--r-- | remoting/host/differ_block.h | 10 | ||||
-rw-r--r-- | remoting/host/differ_block_sse2.cc | 4 | ||||
-rw-r--r-- | remoting/host/differ_block_unittest.cc | 10 |
6 files changed, 18 insertions, 20 deletions
diff --git a/remoting/host/differ.cc b/remoting/host/differ.cc index 397bd43..d5e618a 100644 --- a/remoting/host/differ.cc +++ b/remoting/host/differ.cc @@ -105,7 +105,7 @@ void Differ::MarkDirtyBlocks(const void* prev_buffer, const void* curr_buffer) { for (int x = 0; x < x_full_blocks; x++) { *diff_info = DiffPartialBlock(prev_block, curr_block, bytes_per_row_, - kBlockWidth, partial_row_height); + kBlockSize, partial_row_height); prev_block += block_x_offset; curr_block += block_x_offset; diff_info += sizeof(DiffInfo); diff --git a/remoting/host/differ.h b/remoting/host/differ.h index b36d055..9903680 100644 --- a/remoting/host/differ.h +++ b/remoting/host/differ.h @@ -16,10 +16,6 @@ namespace remoting { typedef uint8 DiffInfo; -// Size (in pixels) of each square block used for diffing. -// This must be a multiple of sizeof(uint64). -static const int kBlockSize = 32; - class Differ { public: // Create a differ that operates on bitmaps with the specified width, height diff --git a/remoting/host/differ_block.cc b/remoting/host/differ_block.cc index 40c0c79..a8da5b9 100644 --- a/remoting/host/differ_block.cc +++ b/remoting/host/differ_block.cc @@ -11,9 +11,9 @@ namespace remoting { int BlockDifference_C(const uint8* image1, const uint8* image2, int stride) { - int width_bytes = kBlockWidth * kBytesPerPixel; + int width_bytes = kBlockSize * kBytesPerPixel; - for (int y = 0; y < kBlockHeight; y++) { + for (int y = 0; y < kBlockSize; y++) { if (memcmp(image1, image2, width_bytes) != 0) return 1; image1 += stride; @@ -32,9 +32,9 @@ int BlockDifference(const uint8* image1, const uint8* image2, int stride) { diff_proc = &BlockDifference_C; #else // For x86 processors, check if SSE2 is supported. - if (media::hasSSE2() && kBlockWidth == 32) + if (media::hasSSE2() && kBlockSize == 32) diff_proc = &BlockDifference_SSE2_W32; - else if (media::hasSSE2() && kBlockWidth == 16) + else if (media::hasSSE2() && kBlockSize == 16) diff_proc = &BlockDifference_SSE2_W16; else diff_proc = &BlockDifference_C; diff --git a/remoting/host/differ_block.h b/remoting/host/differ_block.h index 9c03814..4f78960 100644 --- a/remoting/host/differ_block.h +++ b/remoting/host/differ_block.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,9 +9,11 @@ namespace remoting { -// Block size and format (BGRA 32 bit) are fixed. -static const int kBlockWidth = 32; -static const int kBlockHeight = 32; +// Size (in pixels) of each square block used for diffing. +// This must be a multiple of sizeof(uint64)/8. +static const int kBlockSize = 32; + +// Format: BGRA 32 bit. static const int kBytesPerPixel = 4; // Low level functions to compare 2 blocks of pixels. diff --git a/remoting/host/differ_block_sse2.cc b/remoting/host/differ_block_sse2.cc index c0cc3b6..67e571c 100644 --- a/remoting/host/differ_block_sse2.cc +++ b/remoting/host/differ_block_sse2.cc @@ -20,7 +20,7 @@ extern int BlockDifference_SSE2_W16(const uint8* image1, const uint8* image2, __m128i v0; __m128i v1; __m128i sad; - for (int y = 0; y < kBlockHeight; ++y) { + for (int y = 0; y < kBlockSize; ++y) { const __m128i* i1 = reinterpret_cast<const __m128i*>(image1); const __m128i* i2 = reinterpret_cast<const __m128i*>(image2); v0 = _mm_loadu_si128(i1); @@ -59,7 +59,7 @@ extern int BlockDifference_SSE2_W32(const uint8* image1, const uint8* image2, __m128i v0; __m128i v1; __m128i sad; - for (int y = 0; y < kBlockHeight; ++y) { + for (int y = 0; y < kBlockSize; ++y) { const __m128i* i1 = reinterpret_cast<const __m128i*>(image1); const __m128i* i2 = reinterpret_cast<const __m128i*>(image2); v0 = _mm_loadu_si128(i1); diff --git a/remoting/host/differ_block_unittest.cc b/remoting/host/differ_block_unittest.cc index ad91a87..1bfdb19 100644 --- a/remoting/host/differ_block_unittest.cc +++ b/remoting/host/differ_block_unittest.cc @@ -25,7 +25,7 @@ class EncodeDoneHandler }; // Memory buffer large enough for 2 blocks aligned to 16 bytes. -static const int kSizeOfBlock = kBlockHeight * kBlockWidth * kBytesPerPixel; +static const int kSizeOfBlock = kBlockSize * kBlockSize * kBytesPerPixel; uint8 block_buffer[kSizeOfBlock * 2 + 16]; void PrepareBuffers(uint8* &block1, uint8* &block2) { @@ -43,7 +43,7 @@ TEST(BlockDifferenceTestSame, BlockDifference) { // These blocks should match. for (int i = 0; i < kTimesToRun; ++i) { - int result = BlockDifference(block1, block2, kBlockWidth * kBytesPerPixel); + int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); EXPECT_EQ(0, result); } } @@ -55,7 +55,7 @@ TEST(BlockDifferenceTestLast, BlockDifference) { block2[kSizeOfBlock-2] += 1; for (int i = 0; i < kTimesToRun; ++i) { - int result = BlockDifference(block1, block2, kBlockWidth * kBytesPerPixel); + int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); EXPECT_EQ(1, result); } } @@ -67,7 +67,7 @@ TEST(BlockDifferenceTestMid, BlockDifference) { block2[kSizeOfBlock/2+1] += 1; for (int i = 0; i < kTimesToRun; ++i) { - int result = BlockDifference(block1, block2, kBlockWidth * kBytesPerPixel); + int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); EXPECT_EQ(1, result); } } @@ -79,7 +79,7 @@ TEST(BlockDifferenceTestFirst, BlockDifference) { block2[0] += 1; for (int i = 0; i < kTimesToRun; ++i) { - int result = BlockDifference(block1, block2, kBlockWidth * kBytesPerPixel); + int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); EXPECT_EQ(1, result); } } |