Commit 69df6223 authored by fbarchard@google.com's avatar fbarchard@google.com

Test J420 conversion to and from ARGB has low absolute difference.

BUG=none
TESTED=TestJ420
R=tpsiaki@google.com

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

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1225 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent cb96f37a
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1224
Version: 1225
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1224
#define LIBYUV_VERSION 1225
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -1330,4 +1330,92 @@ TEST_F(libyuvTest, TestI420) {
free_aligned_buffer_64(dst_pixels_c);
}
TEST_F(libyuvTest, TestJ420) {
const int kPixels = benchmark_width_ * benchmark_height_;
const int kHalfPixels = ((benchmark_width_ + 1) / 2) *
((benchmark_height_ + 1) / 2);
align_buffer_64(orig_y, kPixels);
align_buffer_64(orig_u, kHalfPixels);
align_buffer_64(orig_v, kHalfPixels);
align_buffer_64(orig_pixels, kPixels * 4);
align_buffer_64(temp_y, kPixels);
align_buffer_64(temp_u, kHalfPixels);
align_buffer_64(temp_v, kHalfPixels);
align_buffer_64(dst_pixels_opt, kPixels * 4);
align_buffer_64(dst_pixels_c, kPixels * 4);
MemRandomize(orig_pixels, kPixels * 4);
MemRandomize(orig_y, kPixels);
MemRandomize(orig_u, kHalfPixels);
MemRandomize(orig_v, kHalfPixels);
MemRandomize(temp_y, kPixels);
MemRandomize(temp_u, kHalfPixels);
MemRandomize(temp_v, kHalfPixels);
MemRandomize(dst_pixels_opt, kPixels * 4);
MemRandomize(dst_pixels_c, kPixels * 4);
// The test is overall for color conversion matrix being reversible, so
// this initializes the pixel with 2x2 blocks to eliminate subsampling.
uint8* p = orig_y;
for (int y = 0; y < benchmark_height_ - 1; y += 2) {
for (int x = 0; x < benchmark_width_ - 1; x += 2) {
uint8 r = static_cast<uint8>(random());
p[0] = r;
p[1] = r;
p[benchmark_width_] = r;
p[benchmark_width_ + 1] = r;
p += 2;
}
p += benchmark_width_;
}
// Start with YUV converted to ARGB.
J420ToARGB(orig_y, benchmark_width_,
orig_u, (benchmark_width_ + 1) / 2,
orig_v, (benchmark_width_ + 1) / 2,
orig_pixels, benchmark_width_ * 4,
benchmark_width_, benchmark_height_);
ARGBToJ420(orig_pixels, benchmark_width_ * 4,
temp_y, benchmark_width_,
temp_u, (benchmark_width_ + 1) / 2,
temp_v, (benchmark_width_ + 1) / 2,
benchmark_width_, benchmark_height_);
MaskCpuFlags(0);
J420ToARGB(temp_y, benchmark_width_,
temp_u, (benchmark_width_ + 1) / 2,
temp_v, (benchmark_width_ + 1) / 2,
dst_pixels_c, benchmark_width_ * 4,
benchmark_width_, benchmark_height_);
MaskCpuFlags(-1);
for (int i = 0; i < benchmark_iterations_; ++i) {
J420ToARGB(temp_y, benchmark_width_,
temp_u, (benchmark_width_ + 1) / 2,
temp_v, (benchmark_width_ + 1) / 2,
dst_pixels_opt, benchmark_width_ * 4,
benchmark_width_, benchmark_height_);
}
// Test C and SIMD match.
for (int i = 0; i < kPixels * 4; ++i) {
EXPECT_EQ(dst_pixels_c[i], dst_pixels_opt[i]);
}
// Test SIMD is close to original.
for (int i = 0; i < kPixels * 4; ++i) {
EXPECT_NEAR(static_cast<int>(orig_pixels[i]),
static_cast<int>(dst_pixels_opt[i]), 3);
}
free_aligned_buffer_64(orig_pixels);
free_aligned_buffer_64(orig_y);
free_aligned_buffer_64(orig_u);
free_aligned_buffer_64(orig_v);
free_aligned_buffer_64(temp_y);
free_aligned_buffer_64(temp_u);
free_aligned_buffer_64(temp_v);
free_aligned_buffer_64(dst_pixels_opt);
free_aligned_buffer_64(dst_pixels_c);
}
} // namespace libyuv
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