Commit a6025e8b authored by fbarchard@google.com's avatar fbarchard@google.com

ARGBDetect do 2 pixels at a time for improved performance.

BUG=375
TESTED=libyuvTest.BenchmarkARGBDetect_Opt
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/26049004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1155 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent b661b3ee
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1152
Version: 1155
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1152
#define LIBYUV_VERSION 1155
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -81,14 +81,28 @@ uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed) {
static uint32 ARGBDetectRow_C(const uint8* argb, int width) {
int x;
for (x = 0; x < width; ++x) {
for (x = 0; x < width - 1; x += 2) {
if (argb[0] != 255) { // First byte is not Alpha of 255, so not ARGB.
return FOURCC_BGRA;
}
if (argb[3] != 255) { // 4th byte is not Alpha of 255, so not BGRA.
return FOURCC_ARGB;
}
if (argb[4] != 255) { // Second pixel first byte is not Alpha of 255.
return FOURCC_BGRA;
}
if (argb[7] != 255) { // Second pixel 4th byte is not Alpha of 255.
return FOURCC_ARGB;
}
argb += 8;
}
if (width & 1) {
if (argb[0] != 255) { // First byte is not Alpha of 255, so not ARGB.
return FOURCC_BGRA;
}
if (argb[3] != 255) { // 4th byte is not Alpha of 255, so not BGRA.
return FOURCC_ARGB;
}
argb += 4;
}
return 0;
}
......
......@@ -175,6 +175,33 @@ TEST_F(libyuvTest, BenchmarkARGBDetect_Opt) {
free_aligned_buffer_64(src_a);
}
TEST_F(libyuvTest, BenchmarkARGBDetect_Unaligned) {
uint32 fourcc;
const int kMaxTest = benchmark_width_ * benchmark_height_ * 4 + 1;
align_buffer_64(src_a, kMaxTest);
for (int i = 0; i < kMaxTest; ++i) {
src_a[i + 1] = 255;
}
src_a[0 + 1] = 0;
fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4,
benchmark_width_, benchmark_height_);
EXPECT_EQ(libyuv::FOURCC_BGRA, fourcc);
src_a[0 + 1] = 255;
src_a[3 + 1] = 0;
fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4,
benchmark_width_, benchmark_height_);
EXPECT_EQ(libyuv::FOURCC_ARGB, fourcc);
src_a[3 + 1] = 255;
for (int i = 0; i < benchmark_iterations_; ++i) {
fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4,
benchmark_width_, benchmark_height_);
}
EXPECT_EQ(0, fourcc);
free_aligned_buffer_64(src_a);
}
TEST_F(libyuvTest, BenchmarkSumSquareError_Opt) {
const int kMaxWidth = 4096 * 3;
align_buffer_64(src_a, kMaxWidth);
......@@ -273,7 +300,6 @@ TEST_F(libyuvTest, BenchmarkPsnr_Opt) {
free_aligned_buffer_64(src_b);
}
TEST_F(libyuvTest, BenchmarkPsnr_Unaligned) {
align_buffer_64(src_a, benchmark_width_ * benchmark_height_ + 1);
align_buffer_64(src_b, benchmark_width_ * benchmark_height_);
......
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