From: Johann Date: Sat, 10 Dec 2016 00:51:01 +0000 (-0800) Subject: Use Buffer class for post proc tests X-Git-Tag: v1.7.0~767^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f380a1658d5d3fd085db33c0ee2a5fa9a2ae36d4;p=libvpx Use Buffer class for post proc tests Add Buffer features for: Setting the buffer to the output of an ACMRandom function. Copying a buffer. Comparing two buffers. Printing two buffers. Change-Id: Ib53fb602451a3abdcee279ea2b65b51fbc02d3df --- diff --git a/test/buffer.h b/test/buffer.h index 7819bc494..75016c91e 100644 --- a/test/buffer.h +++ b/test/buffer.h @@ -17,6 +17,7 @@ #include "third_party/googletest/src/include/gtest/gtest.h" +#include "test/acm_random.h" #include "vpx/vpx_integer.h" namespace libvpx_test { @@ -48,19 +49,32 @@ class Buffer { // Set the buffer (excluding padding) to 'value'. void Set(const int value); + // Set the buffer (excluding padding) to the output of ACMRandom function 'b'. + void Set(ACMRandom *rand_class, T (ACMRandom::*rand_func)()); + + // Copy the contents of Buffer 'a' (excluding padding). + void CopyFrom(const Buffer &a); + void DumpBuffer() const; + // Highlight the differences between two buffers if they are the same size. + void PrintDifference(const Buffer &a) const; + bool HasPadding() const; // Sets all the values in the buffer to 'padding_value'. void SetPadding(const int padding_value); - // Checks if all the values (excluding padding) are equal to 'value'. + // Checks if all the values (excluding padding) are equal to 'value' if the + // Buffers are the same size. bool CheckValues(const int value) const; // Check that padding matches the expected value or there is no padding. bool CheckPadding() const; + // Compare the non-padding portion of two buffers if they are the same size. + bool CheckValues(const Buffer &a) const; + private: void Init() { ASSERT_GT(width_, 0); @@ -76,6 +90,8 @@ class Buffer { SetPadding(std::numeric_limits::max()); } + bool BufferSizesMatch(const Buffer &a) const; + const int width_; const int height_; const int top_padding_; @@ -104,6 +120,34 @@ void Buffer::Set(const int value) { } } +template +void Buffer::Set(ACMRandom *rand_class, T (ACMRandom::*rand_func)()) { + T *src = TopLeftPixel(); + for (int height = 0; height < height_; ++height) { + for (int width = 0; width < width_; ++width) { + src[width] = (*rand_class.*rand_func)(); + } + src += stride(); + } +} + +template +void Buffer::CopyFrom(const Buffer &a) { + if (!BufferSizesMatch(a)) { + return; + } + + T *a_src = a.TopLeftPixel(); + T *b_src = this->TopLeftPixel(); + for (int height = 0; height < height_; ++height) { + for (int width = 0; width < width_; ++width) { + b_src[width] = a_src[width]; + } + a_src += a.stride(); + b_src += this->stride(); + } +} + template void Buffer::DumpBuffer() const { for (int height = 0; height < height_ + top_padding_ + bottom_padding_; @@ -120,6 +164,47 @@ bool Buffer::HasPadding() const { return top_padding_ || left_padding_ || right_padding_ || bottom_padding_; } +template +void Buffer::PrintDifference(const Buffer &a) const { + if (!BufferSizesMatch(a)) { + return; + } + + T *a_src = a.TopLeftPixel(); + T *b_src = TopLeftPixel(); + + printf("This buffer:\n"); + for (int height = 0; height < height_; ++height) { + for (int width = 0; width < width_; ++width) { + if (a_src[width] != b_src[width]) { + printf("*%3d", b_src[width]); + } else { + printf("%4d", b_src[width]); + } + } + printf("\n"); + a_src += a.stride(); + b_src += this->stride(); + } + + a_src = a.TopLeftPixel(); + b_src = TopLeftPixel(); + + printf("Reference buffer:\n"); + for (int height = 0; height < height_; ++height) { + for (int width = 0; width < width_; ++width) { + if (a_src[width] != b_src[width]) { + printf("*%3d", a_src[width]); + } else { + printf("%4d", a_src[width]); + } + } + printf("\n"); + a_src += a.stride(); + b_src += this->stride(); + } +} + template void Buffer::SetPadding(const int padding_value) { padding_value_ = padding_value; @@ -190,5 +275,38 @@ bool Buffer::CheckPadding() const { return true; } + +template +bool Buffer::CheckValues(const Buffer &a) const { + if (!BufferSizesMatch(a)) { + return false; + } + + T *a_src = a.TopLeftPixel(); + T *b_src = this->TopLeftPixel(); + for (int height = 0; height < height_; ++height) { + for (int width = 0; width < width_; ++width) { + if (a_src[width] != b_src[width]) { + return false; + } + } + a_src += a.stride(); + b_src += this->stride(); + } + return true; +} + +template +bool Buffer::BufferSizesMatch(const Buffer &a) const { + if (a.width_ != this->width_ || a.height_ != this->height_) { + printf( + "Reference buffer of size %dx%d does not match this buffer which is " + "size %dx%d\n", + a.width_, a.height_, this->width_, this->height_); + return false; + } + + return true; +} } // namespace libvpx_test #endif // TEST_BUFFER_H_ diff --git a/test/pp_filter_test.cc b/test/pp_filter_test.cc index 7061c9159..95da09c31 100644 --- a/test/pp_filter_test.cc +++ b/test/pp_filter_test.cc @@ -11,6 +11,7 @@ #include "./vpx_config.h" #include "./vpx_dsp_rtcd.h" #include "test/acm_random.h" +#include "test/buffer.h" #include "test/clear_system_state.h" #include "test/register_state_check.h" #include "third_party/googletest/src/include/gtest/gtest.h" @@ -18,6 +19,7 @@ #include "vpx_mem/vpx_mem.h" using libvpx_test::ACMRandom; +using libvpx_test::Buffer; typedef void (*VpxPostProcDownAndAcrossMbRowFunc)( unsigned char *src_ptr, unsigned char *dst_ptr, int src_pixels_per_line, @@ -54,31 +56,14 @@ TEST_P(VpxPostProcDownAndAcrossMbRowTest, CheckFilterOutput) { const int block_height = 16; // 5-tap filter needs 2 padding rows above and below the block in the input. - const int input_width = block_width; - const int input_height = block_height + 4; - const int input_stride = input_width; - const int input_size = input_width * input_height; + Buffer src_image = Buffer(block_width, block_height, 2); // Filter extends output block by 8 samples at left and right edges. - const int output_width = block_width + 16; - const int output_height = block_height; - const int output_stride = output_width; - const int output_size = output_width * output_height; - - uint8_t *const src_image = new uint8_t[input_size]; - ASSERT_TRUE(src_image != NULL); - // Though the left padding is only 8 bytes, the assembly code tries to // read 16 bytes before the pointer. - uint8_t *const dst_image = new uint8_t[output_size + 8]; - ASSERT_TRUE(dst_image != NULL); + Buffer dst_image = + Buffer(block_width, block_height, 8, 16, 8, 8); - // Pointers to top-left pixel of block in the input and output images. - uint8_t *const src_image_ptr = src_image + (input_stride << 1); - - // The assembly works in increments of 16. The first read may be offset by - // this amount. - uint8_t *const dst_image_ptr = dst_image + 16; uint8_t *const flimits = reinterpret_cast(vpx_memalign(16, block_width)); (void)memset(flimits, 255, block_width); @@ -86,37 +71,29 @@ TEST_P(VpxPostProcDownAndAcrossMbRowTest, CheckFilterOutput) { // Initialize pixels in the input: // block pixels to value 1, // border pixels to value 10. - (void)memset(src_image, 10, input_size); - uint8_t *pixel_ptr = src_image_ptr; - for (int i = 0; i < block_height; ++i) { - for (int j = 0; j < block_width; ++j) { - pixel_ptr[j] = 1; - } - pixel_ptr += input_stride; - } + src_image.SetPadding(10); + src_image.Set(1); // Initialize pixels in the output to 99. - (void)memset(dst_image, 99, output_size); + dst_image.Set(99); - ASM_REGISTER_STATE_CHECK(GetParam()(src_image_ptr, dst_image_ptr, - input_stride, output_stride, block_width, - flimits, 16)); + ASM_REGISTER_STATE_CHECK(GetParam()( + src_image.TopLeftPixel(), dst_image.TopLeftPixel(), src_image.stride(), + dst_image.stride(), block_width, flimits, 16)); static const uint8_t kExpectedOutput[block_height] = { 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4 }; - pixel_ptr = dst_image_ptr; + uint8_t *pixel_ptr = dst_image.TopLeftPixel(); for (int i = 0; i < block_height; ++i) { for (int j = 0; j < block_width; ++j) { ASSERT_EQ(kExpectedOutput[i], pixel_ptr[j]) << "at (" << i << ", " << j << ")"; } - pixel_ptr += output_stride; + pixel_ptr += dst_image.stride(); } - delete[] src_image; - delete[] dst_image; vpx_free(flimits); }; @@ -129,35 +106,17 @@ TEST_P(VpxPostProcDownAndAcrossMbRowTest, CheckCvsAssembly) { // 5-tap filter needs 2 padding rows above and below the block in the input. // SSE2 reads in blocks of 16. Pad an extra 8 in case the width is not %16. - const int input_width = block_width; - const int input_height = block_height + 4 + 8; - const int input_stride = input_width; - const int input_size = input_stride * input_height; + Buffer src_image = + Buffer(block_width, block_height, 2, 2, 10, 2); // Filter extends output block by 8 samples at left and right edges. + // Though the left padding is only 8 bytes, there is 'above' padding as well + // so when the assembly code tries to read 16 bytes before the pointer it is + // not a problem. // SSE2 reads in blocks of 16. Pad an extra 8 in case the width is not %16. - const int output_width = block_width + 24; - const int output_height = block_height; - const int output_stride = output_width; - const int output_size = output_stride * output_height; - - uint8_t *const src_image = new uint8_t[input_size]; - ASSERT_TRUE(src_image != NULL); - - // Though the left padding is only 8 bytes, the assembly code tries to - // read 16 bytes before the pointer. - uint8_t *const dst_image = new uint8_t[output_size + 8]; - ASSERT_TRUE(dst_image != NULL); - uint8_t *const dst_image_ref = new uint8_t[output_size + 8]; - ASSERT_TRUE(dst_image_ref != NULL); - - // Pointers to top-left pixel of block in the input and output images. - uint8_t *const src_image_ptr = src_image + (input_stride << 1); - - // The assembly works in increments of 16. The first read may be offset by - // this amount. - uint8_t *const dst_image_ptr = dst_image + 16; - uint8_t *const dst_image_ref_ptr = dst_image + 16; + Buffer dst_image = + Buffer(block_width, block_height, 8, 8, 16, 8); + Buffer dst_image_ref = Buffer(block_width, block_height, 8); // Filter values are set in blocks of 16 for Y and 8 for U/V. Each macroblock // can have a different filter. SSE2 assembly reads flimits in blocks of 16 so @@ -171,14 +130,8 @@ TEST_P(VpxPostProcDownAndAcrossMbRowTest, CheckCvsAssembly) { // Initialize pixels in the input: // block pixels to random values. // border pixels to value 10. - (void)memset(src_image, 10, input_size); - uint8_t *pixel_ptr = src_image_ptr; - for (int i = 0; i < block_height; ++i) { - for (int j = 0; j < block_width; ++j) { - pixel_ptr[j] = rnd.Rand8(); - } - pixel_ptr += input_stride; - } + src_image.SetPadding(10); + src_image.Set(&rnd, &ACMRandom::Rand8); for (int blocks = 0; blocks < block_width; blocks += 8) { (void)memset(flimits, 0, sizeof(*flimits) * flimits_width); @@ -186,29 +139,22 @@ TEST_P(VpxPostProcDownAndAcrossMbRowTest, CheckCvsAssembly) { for (int f = 0; f < 255; f++) { (void)memset(flimits + blocks, f, sizeof(*flimits) * 8); - (void)memset(dst_image, 0, output_size); - (void)memset(dst_image_ref, 0, output_size); + dst_image.Set(0); + dst_image_ref.Set(0); vpx_post_proc_down_and_across_mb_row_c( - src_image_ptr, dst_image_ref_ptr, input_stride, output_stride, - block_width, flimits, block_height); - ASM_REGISTER_STATE_CHECK(GetParam()(src_image_ptr, dst_image_ptr, - input_stride, output_stride, - block_width, flimits, 16)); - - for (int i = 0; i < block_height; ++i) { - for (int j = 0; j < block_width; ++j) { - ASSERT_EQ(dst_image_ref_ptr[j + i * output_stride], - dst_image_ptr[j + i * output_stride]) - << "at (" << i << ", " << j << ")"; - } - } + src_image.TopLeftPixel(), dst_image_ref.TopLeftPixel(), + src_image.stride(), dst_image_ref.stride(), block_width, flimits, + block_height); + ASM_REGISTER_STATE_CHECK( + GetParam()(src_image.TopLeftPixel(), dst_image.TopLeftPixel(), + src_image.stride(), dst_image.stride(), block_width, + flimits, block_height)); + + ASSERT_TRUE(dst_image.CheckValues(dst_image_ref)); } } - delete[] src_image; - delete[] dst_image; - delete[] dst_image_ref; vpx_free(flimits); } @@ -249,108 +195,77 @@ class VpxMbPostProcAcrossIpTest TEST_P(VpxMbPostProcAcrossIpTest, CheckLowFilterOutput) { const int rows = 16; const int cols = 16; - const int src_left_padding = 8; - const int src_right_padding = 17; - const int src_width = cols + src_left_padding + src_right_padding; - const int src_size = rows * src_width; - unsigned char *const src = new unsigned char[src_size]; - ASSERT_TRUE(src != NULL); - memset(src, 10, src_size); - unsigned char *const s = src + src_left_padding; - SetCols(s, rows, cols, src_width); + Buffer src = Buffer(cols, rows, 8, 8, 17, 8); + src.SetPadding(10); + SetCols(src.TopLeftPixel(), rows, cols, src.stride()); - unsigned char *expected_output = new unsigned char[rows * cols]; - ASSERT_TRUE(expected_output != NULL); - SetCols(expected_output, rows, cols, cols); + Buffer expected_output = Buffer(cols, rows, 0); + SetCols(expected_output.TopLeftPixel(), rows, cols, expected_output.stride()); - RunFilterLevel(s, rows, cols, src_width, q2mbl(0), expected_output); - delete[] src; - delete[] expected_output; + RunFilterLevel(src.TopLeftPixel(), rows, cols, src.stride(), q2mbl(0), + expected_output.TopLeftPixel()); } TEST_P(VpxMbPostProcAcrossIpTest, CheckMediumFilterOutput) { const int rows = 16; const int cols = 16; - const int src_left_padding = 8; - const int src_right_padding = 17; - const int src_width = cols + src_left_padding + src_right_padding; - const int src_size = rows * src_width; - unsigned char *const src = new unsigned char[src_size]; - ASSERT_TRUE(src != NULL); - memset(src, 10, src_size); - unsigned char *const s = src + src_left_padding; + Buffer src = Buffer(cols, rows, 8, 8, 17, 8); + src.SetPadding(10); + SetCols(src.TopLeftPixel(), rows, cols, src.stride()); - SetCols(s, rows, cols, src_width); static const unsigned char kExpectedOutput[cols] = { 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13 }; - RunFilterLevel(s, rows, cols, src_width, q2mbl(70), kExpectedOutput); - - delete[] src; + RunFilterLevel(src.TopLeftPixel(), rows, cols, src.stride(), q2mbl(70), + kExpectedOutput); } TEST_P(VpxMbPostProcAcrossIpTest, CheckHighFilterOutput) { const int rows = 16; const int cols = 16; - const int src_left_padding = 8; - const int src_right_padding = 17; - const int src_width = cols + src_left_padding + src_right_padding; - const int src_size = rows * src_width; - unsigned char *const src = new unsigned char[src_size]; - ASSERT_TRUE(src != NULL); - unsigned char *const s = src + src_left_padding; + Buffer src = Buffer(cols, rows, 8, 8, 17, 8); + src.SetPadding(10); + SetCols(src.TopLeftPixel(), rows, cols, src.stride()); - memset(src, 10, src_size); - SetCols(s, rows, cols, src_width); static const unsigned char kExpectedOutput[cols] = { 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 13 }; - RunFilterLevel(s, rows, cols, src_width, INT_MAX, kExpectedOutput); + RunFilterLevel(src.TopLeftPixel(), rows, cols, src.stride(), INT_MAX, + kExpectedOutput); - memset(src, 10, src_size); - SetCols(s, rows, cols, src_width); - RunFilterLevel(s, rows, cols, src_width, q2mbl(100), kExpectedOutput); + SetCols(src.TopLeftPixel(), rows, cols, src.stride()); - delete[] src; + RunFilterLevel(src.TopLeftPixel(), rows, cols, src.stride(), q2mbl(100), + kExpectedOutput); } TEST_P(VpxMbPostProcAcrossIpTest, CheckCvsAssembly) { const int rows = 16; const int cols = 16; - const int src_left_padding = 8; - const int src_right_padding = 17; - const int src_width = cols + src_left_padding + src_right_padding; - const int src_size = rows * src_width; - - unsigned char *const c_mem = new unsigned char[src_size]; - unsigned char *const asm_mem = new unsigned char[src_size]; - ASSERT_TRUE(c_mem != NULL); - ASSERT_TRUE(asm_mem != NULL); - unsigned char *const src_c = c_mem + src_left_padding; - unsigned char *const src_asm = asm_mem + src_left_padding; + + Buffer c_mem = Buffer(cols, rows, 8, 8, 17, 8); + Buffer asm_mem = Buffer(cols, rows, 8, 8, 17, 8); // When level >= 100, the filter behaves the same as the level = INT_MAX // When level < 20, it behaves the same as the level = 0 for (int level = 0; level < 100; level++) { - memset(c_mem, 10, src_size); - memset(asm_mem, 10, src_size); - SetCols(src_c, rows, cols, src_width); - SetCols(src_asm, rows, cols, src_width); + c_mem.SetPadding(10); + asm_mem.SetPadding(10); + SetCols(c_mem.TopLeftPixel(), rows, cols, c_mem.stride()); + SetCols(asm_mem.TopLeftPixel(), rows, cols, asm_mem.stride()); - vpx_mbpost_proc_across_ip_c(src_c, src_width, rows, cols, q2mbl(level)); - ASM_REGISTER_STATE_CHECK( - GetParam()(src_asm, src_width, rows, cols, q2mbl(level))); + vpx_mbpost_proc_across_ip_c(c_mem.TopLeftPixel(), c_mem.stride(), rows, + cols, q2mbl(level)); + ASM_REGISTER_STATE_CHECK(GetParam()( + asm_mem.TopLeftPixel(), asm_mem.stride(), rows, cols, q2mbl(level))); - RunComparison(src_c, src_asm, rows, cols, src_width); + ASSERT_TRUE(asm_mem.CheckValues(c_mem)); } - - delete[] c_mem; - delete[] asm_mem; } class VpxMbPostProcDownTest @@ -359,44 +274,10 @@ class VpxMbPostProcDownTest virtual void TearDown() { libvpx_test::ClearSystemState(); } protected: - void SetRows(unsigned char *src_c, int rows, int cols) { + void SetRows(unsigned char *src_c, int rows, int cols, int src_width) { for (int r = 0; r < rows; r++) { memset(src_c, r, cols); - src_c += cols; - } - } - - void SetRandom(unsigned char *src_c, unsigned char *src_asm, int rows, - int cols, int src_pitch) { - ACMRandom rnd; - rnd.Reset(ACMRandom::DeterministicSeed()); - - // Add some random noise to the input - for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - const int noise = rnd(4); - src_c[c] = r + noise; - src_asm[c] = r + noise; - } - src_c += src_pitch; - src_asm += src_pitch; - } - } - - void SetRandomSaturation(unsigned char *src_c, unsigned char *src_asm, - int rows, int cols, int src_pitch) { - ACMRandom rnd; - rnd.Reset(ACMRandom::DeterministicSeed()); - - // Add some random noise to the input - for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - const int noise = 3 * rnd(2); - src_c[c] = r + noise; - src_asm[c] = r + noise; - } - src_c += src_pitch; - src_asm += src_pitch; + src_c += src_width; } } @@ -411,17 +292,6 @@ class VpxMbPostProcDownTest } } - void RunComparison(unsigned char *src_c, unsigned char *src_asm, int rows, - int cols, int src_pitch) { - for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - ASSERT_EQ(src_c[c], src_asm[c]) << "at (" << r << ", " << c << ")"; - } - src_c += src_pitch; - src_asm += src_pitch; - } - } - void RunFilterLevel(unsigned char *s, int rows, int cols, int src_width, int filter_level, const unsigned char *expected_output) { ASM_REGISTER_STATE_CHECK( @@ -433,17 +303,11 @@ class VpxMbPostProcDownTest TEST_P(VpxMbPostProcDownTest, CheckHighFilterOutput) { const int rows = 16; const int cols = 16; - const int src_pitch = cols; - const int src_top_padding = 8; - const int src_bottom_padding = 17; - const int src_size = cols * (rows + src_top_padding + src_bottom_padding); - unsigned char *const c_mem = new unsigned char[src_size]; - ASSERT_TRUE(c_mem != NULL); - memset(c_mem, 10, src_size); - unsigned char *const src_c = c_mem + src_top_padding * src_pitch; + Buffer src_c = Buffer(cols, rows, 8, 8, 8, 17); + src_c.SetPadding(10); - SetRows(src_c, rows, cols); + SetRows(src_c.TopLeftPixel(), rows, cols, src_c.stride()); static const unsigned char kExpectedOutput[rows * cols] = { 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, @@ -462,29 +326,23 @@ TEST_P(VpxMbPostProcDownTest, CheckHighFilterOutput) { 13, 13, 13, 13, 14, 13, 13, 13, 13 }; - RunFilterLevel(src_c, rows, cols, src_pitch, INT_MAX, kExpectedOutput); + RunFilterLevel(src_c.TopLeftPixel(), rows, cols, src_c.stride(), INT_MAX, + kExpectedOutput); - memset(c_mem, 10, src_size); - SetRows(src_c, rows, cols); - RunFilterLevel(src_c, rows, cols, src_pitch, q2mbl(100), kExpectedOutput); - - delete[] c_mem; + src_c.SetPadding(10); + SetRows(src_c.TopLeftPixel(), rows, cols, src_c.stride()); + RunFilterLevel(src_c.TopLeftPixel(), rows, cols, src_c.stride(), q2mbl(100), + kExpectedOutput); } TEST_P(VpxMbPostProcDownTest, CheckMediumFilterOutput) { const int rows = 16; const int cols = 16; - const int src_pitch = cols; - const int src_top_padding = 8; - const int src_bottom_padding = 17; - const int src_size = cols * (rows + src_top_padding + src_bottom_padding); - unsigned char *const c_mem = new unsigned char[src_size]; - ASSERT_TRUE(c_mem != NULL); - memset(c_mem, 10, src_size); - unsigned char *const src_c = c_mem + src_top_padding * src_pitch; + Buffer src_c = Buffer(cols, rows, 8, 8, 8, 17); + src_c.SetPadding(10); - SetRows(src_c, rows, cols); + SetRows(src_c.TopLeftPixel(), rows, cols, src_c.stride()); static const unsigned char kExpectedOutput[rows * cols] = { 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, @@ -503,70 +361,62 @@ TEST_P(VpxMbPostProcDownTest, CheckMediumFilterOutput) { 13, 13, 13, 13, 14, 13, 13, 13, 13 }; - RunFilterLevel(src_c, rows, cols, src_pitch, q2mbl(70), kExpectedOutput); - - delete[] c_mem; + RunFilterLevel(src_c.TopLeftPixel(), rows, cols, src_c.stride(), q2mbl(70), + kExpectedOutput); } TEST_P(VpxMbPostProcDownTest, CheckLowFilterOutput) { const int rows = 16; const int cols = 16; - const int src_pitch = cols; - const int src_top_padding = 8; - const int src_bottom_padding = 17; - const int src_size = cols * (rows + src_top_padding + src_bottom_padding); - unsigned char *const c_mem = new unsigned char[src_size]; - ASSERT_TRUE(c_mem != NULL); - memset(c_mem, 10, src_size); - unsigned char *const src_c = c_mem + src_top_padding * src_pitch; + Buffer src_c = Buffer(cols, rows, 8, 8, 8, 17); + src_c.SetPadding(10); - SetRows(src_c, rows, cols); + SetRows(src_c.TopLeftPixel(), rows, cols, src_c.stride()); unsigned char *expected_output = new unsigned char[rows * cols]; ASSERT_TRUE(expected_output != NULL); - SetRows(expected_output, rows, cols); + SetRows(expected_output, rows, cols, cols); - RunFilterLevel(src_c, rows, cols, src_pitch, q2mbl(0), expected_output); + RunFilterLevel(src_c.TopLeftPixel(), rows, cols, src_c.stride(), q2mbl(0), + expected_output); - delete[] c_mem; delete[] expected_output; } TEST_P(VpxMbPostProcDownTest, CheckCvsAssembly) { const int rows = 16; const int cols = 16; - const int src_pitch = cols; - const int src_top_padding = 8; - const int src_bottom_padding = 17; - const int src_size = cols * (rows + src_top_padding + src_bottom_padding); - unsigned char *const c_mem = new unsigned char[src_size]; - unsigned char *const asm_mem = new unsigned char[src_size]; - ASSERT_TRUE(c_mem != NULL); - ASSERT_TRUE(asm_mem != NULL); - unsigned char *const src_c = c_mem + src_top_padding * src_pitch; - unsigned char *const src_asm = asm_mem + src_top_padding * src_pitch; - for (int level = 0; level < 100; level++) { - memset(c_mem, 10, src_size); - memset(asm_mem, 10, src_size); - SetRandom(src_c, src_asm, rows, cols, src_pitch); - vpx_mbpost_proc_down_c(src_c, src_pitch, rows, cols, q2mbl(level)); - ASM_REGISTER_STATE_CHECK( - GetParam()(src_asm, src_pitch, rows, cols, q2mbl(level))); - RunComparison(src_c, src_asm, rows, cols, src_pitch); + ACMRandom rnd; + rnd.Reset(ACMRandom::DeterministicSeed()); - memset(c_mem, 10, src_size); - memset(asm_mem, 10, src_size); - SetRandomSaturation(src_c, src_asm, rows, cols, src_pitch); - vpx_mbpost_proc_down_c(src_c, src_pitch, rows, cols, q2mbl(level)); - ASM_REGISTER_STATE_CHECK( - GetParam()(src_asm, src_pitch, rows, cols, q2mbl(level))); - RunComparison(src_c, src_asm, rows, cols, src_pitch); - } + Buffer src_c = Buffer(cols, rows, 8, 8, 8, 17); + Buffer src_asm = Buffer(cols, rows, 8, 8, 8, 17); - delete[] c_mem; - delete[] asm_mem; + for (int level = 0; level < 100; level++) { + src_c.SetPadding(10); + src_asm.SetPadding(10); + src_c.Set(&rnd, &ACMRandom::Rand8); + src_asm.CopyFrom(src_c); + + vpx_mbpost_proc_down_c(src_c.TopLeftPixel(), src_c.stride(), rows, cols, + q2mbl(level)); + ASM_REGISTER_STATE_CHECK(GetParam()( + src_asm.TopLeftPixel(), src_asm.stride(), rows, cols, q2mbl(level))); + ASSERT_TRUE(src_asm.CheckValues(src_c)); + + src_c.SetPadding(10); + src_asm.SetPadding(10); + src_c.Set(&rnd, &ACMRandom::Rand8Extremes); + src_asm.CopyFrom(src_c); + + vpx_mbpost_proc_down_c(src_c.TopLeftPixel(), src_c.stride(), rows, cols, + q2mbl(level)); + ASM_REGISTER_STATE_CHECK(GetParam()( + src_asm.TopLeftPixel(), src_asm.stride(), rows, cols, q2mbl(level))); + ASSERT_TRUE(src_asm.CheckValues(src_c)); + } } INSTANTIATE_TEST_CASE_P(