Commit d8fe8f14 authored by garykac@chromium.org's avatar garykac@chromium.org

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
parent 16cb745a
......@@ -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);
......
......@@ -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
......
......@@ -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;
......
// 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.
......
......@@ -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);
......
......@@ -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);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment