Commit 92e51c7a authored by fbarchard@google.com's avatar fbarchard@google.com

ARGBAffineRow_C for non-SSE2 machine.

BUG=62
TEST=TestAffine unittest added to planar_test
Review URL: https://webrtc-codereview.appspot.com/731004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@315 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent b0c97975
......@@ -228,6 +228,13 @@ int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0,
uint8* dst_argb, int dst_stride_argb,
int width, int height, int interpolation);
// Row functions for copying a pixels from a source with a slope to a row
// of destination. Useful for scaling, rotation, mirror, texture mapping.
void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride,
uint8* dst_argb, const float* uv_dudv, int width);
void ARGBAffineRow_SSE2(const uint8* src_argb, int src_argb_stride,
uint8* dst_argb, const float* uv_dudv, int width);
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
......
......@@ -523,6 +523,9 @@ void ARGBShadeRow_C(const uint8* src_argb, uint8* dst_argb, int width,
uint32 value);
void ARGBShadeRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width,
uint32 value);
void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride,
uint8* dst_argb, const float* uv_dudv, int width);
void ARGBAffineRow_SSE2(const uint8* src_argb, int src_argb_stride,
uint8* dst_argb, const float* uv_dudv, int width);
......
......@@ -984,6 +984,25 @@ void ARGBShadeRow_C(const uint8* src_argb, uint8* dst_argb, int width,
#undef REPEAT8
#undef SHADE
// Copy pixels from rotated source to destination row with a slope.
void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride,
uint8* dst_argb, const float* uv_dudv, int width) {
// Render a row of pixels from source into a buffer.
float uv[2];
uv[0] = uv_dudv[0];
uv[1] = uv_dudv[1];
for (int i = 0; i < width; ++i) {
int x = static_cast<int>(uv[0]);
int y = static_cast<int>(uv[1]);
*reinterpret_cast<uint32*>(dst_argb) =
*reinterpret_cast<const uint32*>(src_argb + y * src_argb_stride +
x * 4);
dst_argb += 4;
uv[0] += uv_dudv[2];
uv[1] += uv_dudv[3];
}
}
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
......
......@@ -899,4 +899,44 @@ TEST_F(libyuvTest, TestInterpolate) {
}
}
TEST_F(libyuvTest, TestAffine) {
SIMD_ALIGNED(uint8 orig_pixels_0[256][4]);
SIMD_ALIGNED(uint8 interpolate_pixels_Opt[256][4]);
SIMD_ALIGNED(uint8 interpolate_pixels_C[256][4]);
for (int i = 0; i < 256; ++i) {
for (int j = 0; j < 4; ++j) {
orig_pixels_0[i][j] = i;
}
}
float uv_step[4] = { 0.f, 0.f, 0.75f, 0.f };
ARGBAffineRow_C(&orig_pixels_0[0][0], 0, &interpolate_pixels_C[0][0],
uv_step, 256);
EXPECT_EQ(0u, interpolate_pixels_C[0][0]);
EXPECT_EQ(96u, interpolate_pixels_C[128][0]);
EXPECT_EQ(191u, interpolate_pixels_C[255][3]);
#if defined(_MSC_VER)
ARGBAffineRow_SSE2(&orig_pixels_0[0][0], 0, &interpolate_pixels_Opt[0][0],
uv_step, 256);
EXPECT_EQ(0, memcmp(interpolate_pixels_Opt, interpolate_pixels_C, 256 * 4));
#endif
#if defined(_MSC_VER)
int has_sse2 = TestCpuFlag(kCpuHasSSE2);
if (has_sse2) {
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) {
ARGBAffineRow_SSE2(&orig_pixels_0[0][0], 0, &interpolate_pixels_Opt[0][0],
uv_step, 256);
}
} else
#endif
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) {
ARGBAffineRow_C(&orig_pixels_0[0][0], 0, &interpolate_pixels_C[0][0],
uv_step, 256);
}
}
} // 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