diff --git a/README.chromium b/README.chromium index 353eb7ade..4fb2628e5 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1152 +Version: 1155 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index a24a59520..0f3a3cd36 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -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 diff --git a/source/compare.cc b/source/compare.cc index 759223a87..f84a08ee6 100644 --- a/source/compare.cc +++ b/source/compare.cc @@ -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; } diff --git a/unit_test/compare_test.cc b/unit_test/compare_test.cc index 15215fe7c..4d76050f0 100644 --- a/unit_test/compare_test.cc +++ b/unit_test/compare_test.cc @@ -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_);