From 775569473d2cd2a90d06816fcb75f424a46f0f93 Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 17 Mar 2017 13:19:45 -0700 Subject: [PATCH] temporal filter test: update types Use 'int' for w/h since it is that way everywhere else. Pass Buffer pointers Change-Id: I9eef6890af657baba171c6bcfcc85fc976173399 --- test/temporal_filter_test.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/temporal_filter_test.cc b/test/temporal_filter_test.cc index cb86b728f..a7bc436bc 100644 --- a/test/temporal_filter_test.cc +++ b/test/temporal_filter_test.cc @@ -29,10 +29,10 @@ typedef void (*TemporalFilterFunc)(uint8_t *a, unsigned int stride, uint8_t *b, // Calculate the difference between 'a' and 'b', sum in blocks of 9, and apply // filter based on strength and weight. Store the resulting filter amount in // 'count' and apply it to 'b' and store it in 'accumulator'. -void reference_filter(const Buffer &a, const Buffer &b, - unsigned int w, unsigned int h, int filter_strength, - int filter_weight, Buffer &accumulator, - Buffer &count) { +void reference_filter(const Buffer &a, const Buffer &b, int w, + int h, int filter_strength, int filter_weight, + Buffer *accumulator, + Buffer *count) { Buffer diff_sq = Buffer(w, h, 0); diff_sq.Set(0); @@ -43,8 +43,8 @@ void reference_filter(const Buffer &a, const Buffer &b, // Calculate all the differences. Avoids re-calculating a bunch of extra // values. - for (int height = 0; height < (int)h; ++height) { - for (int width = 0; width < (int)w; ++width) { + for (int height = 0; height < h; ++height) { + for (int width = 0; width < w; ++width) { int diff = a.TopLeftPixel()[height * a.stride() + width] - b.TopLeftPixel()[height * b.stride() + width]; diff_sq.TopLeftPixel()[height * diff_sq.stride() + width] = diff * diff; @@ -53,16 +53,16 @@ void reference_filter(const Buffer &a, const Buffer &b, // For any given point, sum the neighboring values and calculate the // modifier. - for (int height = 0; height < (int)h; ++height) { - for (int width = 0; width < (int)w; ++width) { + for (int height = 0; height < h; ++height) { + for (int width = 0; width < w; ++width) { // Determine how many values are being summed. int summed_values = 9; - if (height == 0 || height == ((int)h - 1)) { + if (height == 0 || height == (h - 1)) { summed_values -= 3; } - if (width == 0 || width == ((int)w - 1)) { + if (width == 0 || width == (w - 1)) { if (summed_values == 6) { // corner summed_values -= 2; } else { @@ -78,7 +78,7 @@ void reference_filter(const Buffer &a, const Buffer &b, const int x = width + idx; // If inside the border. - if (y >= 0 && y < (int)h && x >= 0 && x < (int)w) { + if (y >= 0 && y < h && x >= 0 && x < w) { sum += diff_sq.TopLeftPixel()[y * diff_sq.stride() + x]; } } @@ -95,8 +95,8 @@ void reference_filter(const Buffer &a, const Buffer &b, sum *= filter_weight; - count.TopLeftPixel()[height * count.stride() + width] += sum; - accumulator.TopLeftPixel()[height * accumulator.stride() + width] += + count->TopLeftPixel()[height * count->stride() + width] += sum; + accumulator->TopLeftPixel()[height * accumulator->stride() + width] += sum * b.TopLeftPixel()[height * b.stride() + width]; } } @@ -135,7 +135,7 @@ TEST_P(TemporalFilterTest, CompareReferenceRandom) { count_ref.Set(rnd_.Rand8()); count_chk.CopyFrom(count_ref); reference_filter(a, b, width, height, filter_strength, filter_weight, - accum_ref, count_ref); + &accum_ref, &count_ref); filter_func_(a.TopLeftPixel(), a.stride(), b.TopLeftPixel(), width, height, filter_strength, filter_weight, accum_chk.TopLeftPixel(), count_chk.TopLeftPixel()); -- 2.40.0