summaryrefslogtreecommitdiff
path: root/test/add_noise_test.cc
diff options
context:
space:
mode:
authorJim Bankoski <jimbankoski@google.com>2016-07-15 08:27:34 -0700
committerJim Bankoski <jimbankoski@google.com>2016-07-15 08:27:34 -0700
commit0dc69c70f70bb320101064fa0dc0643e3d266f57 (patch)
tree0e809b8bb0bbdb227fd2a4cad3954e3730f25590 /test/add_noise_test.cc
parent7eec1f31b50e05f6fe06bccda8db08d75a6ff0f2 (diff)
downloadlibvpx-0dc69c70f70bb320101064fa0dc0643e3d266f57.tar
libvpx-0dc69c70f70bb320101064fa0dc0643e3d266f57.tar.gz
libvpx-0dc69c70f70bb320101064fa0dc0643e3d266f57.tar.bz2
libvpx-0dc69c70f70bb320101064fa0dc0643e3d266f57.zip
postproc : fix function parameters for noise functions.
Change-Id: I582b6307f28bfc987dcf8910379a52c6f679173c
Diffstat (limited to 'test/add_noise_test.cc')
-rw-r--r--test/add_noise_test.cc66
1 files changed, 25 insertions, 41 deletions
diff --git a/test/add_noise_test.cc b/test/add_noise_test.cc
index 35aaadfa7..271ce340e 100644
--- a/test/add_noise_test.cc
+++ b/test/add_noise_test.cc
@@ -18,11 +18,12 @@
namespace {
+static const int kNoiseSize = 3072;
+
// TODO(jimbankoski): make width and height integers not unsigned.
-typedef void (*AddNoiseFunc)(unsigned char *start, char *noise,
- char blackclamp[16], char whiteclamp[16],
- char bothclamp[16], unsigned int width,
- unsigned int height, int pitch);
+typedef void (*AddNoiseFunc)(uint8_t *start, const int8_t *noise,
+ int blackclamp, int whiteclamp,
+ int width, int height, int pitch);
class AddNoiseTest
: public ::testing::TestWithParam<AddNoiseFunc> {
@@ -42,26 +43,18 @@ double stddev6(char a, char b, char c, char d, char e, char f) {
}
TEST_P(AddNoiseTest, CheckNoiseAdded) {
- DECLARE_ALIGNED(16, char, blackclamp[16]);
- DECLARE_ALIGNED(16, char, whiteclamp[16]);
- DECLARE_ALIGNED(16, char, bothclamp[16]);
const int width = 64;
const int height = 64;
const int image_size = width * height;
- char noise[3072];
- const int clamp = vpx_setup_noise(4.4, sizeof(noise), noise);
-
- for (int i = 0; i < 16; i++) {
- blackclamp[i] = clamp;
- whiteclamp[i] = clamp;
- bothclamp[i] = 2 * clamp;
- }
+ int8_t noise[kNoiseSize];
+ const int clamp = vpx_setup_noise(4.4, noise, kNoiseSize);
+ uint8_t *const s = reinterpret_cast<uint8_t *>(vpx_calloc(image_size,
+ sizeof(*s)));
+ ASSERT_TRUE(s != NULL);
+ memset(s, 99, image_size * sizeof(*s));
- uint8_t *const s = reinterpret_cast<uint8_t *>(vpx_calloc(image_size, 1));
- memset(s, 99, image_size);
-
- ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, blackclamp, whiteclamp,
- bothclamp, width, height, width));
+ ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, clamp, clamp,
+ width, height, width));
// Check to make sure we don't end up having either the same or no added
// noise either vertically or horizontally.
@@ -79,8 +72,8 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
// Initialize pixels in the image to 255 and check for roll over.
memset(s, 255, image_size);
- ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, blackclamp, whiteclamp,
- bothclamp, width, height, width));
+ ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, clamp, clamp,
+ width, height, width));
// Check to make sure don't roll over.
for (int i = 0; i < image_size; ++i) {
@@ -90,8 +83,8 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
// Initialize pixels in the image to 0 and check for roll under.
memset(s, 0, image_size);
- ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, blackclamp, whiteclamp,
- bothclamp, width, height, width));
+ ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, clamp, clamp,
+ width, height, width));
// Check to make sure don't roll under.
for (int i = 0; i < image_size; ++i) {
@@ -102,35 +95,26 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
}
TEST_P(AddNoiseTest, CheckCvsAssembly) {
- DECLARE_ALIGNED(16, char, blackclamp[16]);
- DECLARE_ALIGNED(16, char, whiteclamp[16]);
- DECLARE_ALIGNED(16, char, bothclamp[16]);
const int width = 64;
const int height = 64;
const int image_size = width * height;
- char noise[3072];
-
- const int clamp = vpx_setup_noise(4.4, sizeof(noise), noise);
-
- for (int i = 0; i < 16; i++) {
- blackclamp[i] = clamp;
- whiteclamp[i] = clamp;
- bothclamp[i] = 2 * clamp;
- }
+ int8_t noise[kNoiseSize];
+ const int clamp = vpx_setup_noise(4.4, noise, kNoiseSize);
uint8_t *const s = reinterpret_cast<uint8_t *>(vpx_calloc(image_size, 1));
uint8_t *const d = reinterpret_cast<uint8_t *>(vpx_calloc(image_size, 1));
+ ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(d != NULL);
memset(s, 99, image_size);
memset(d, 99, image_size);
srand(0);
- ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, blackclamp, whiteclamp,
- bothclamp, width, height, width));
+ ASM_REGISTER_STATE_CHECK(
+ GetParam()(s, noise, clamp, clamp, width, height, width));
srand(0);
- ASM_REGISTER_STATE_CHECK(vpx_plane_add_noise_c(d, noise, blackclamp,
- whiteclamp, bothclamp,
- width, height, width));
+ ASM_REGISTER_STATE_CHECK(
+ vpx_plane_add_noise_c(d, noise, clamp, clamp, width, height, width));
for (int i = 0; i < image_size; ++i) {
EXPECT_EQ(static_cast<int>(s[i]), static_cast<int>(d[i])) << "i = " << i;