2015-02-23 11:18:48 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* This file is part of Kvazaar HEVC encoder.
|
|
|
|
*
|
2021-10-07 08:32:59 +00:00
|
|
|
* Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer in the documentation and/or
|
|
|
|
* other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON
|
|
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
* INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
2015-02-23 11:18:48 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
#include "greatest/greatest.h"
|
2013-10-09 12:31:27 +00:00
|
|
|
|
2014-07-28 12:49:51 +00:00
|
|
|
#include "test_strategies.h"
|
|
|
|
|
2014-06-12 12:04:48 +00:00
|
|
|
#include "src/image.h"
|
2013-10-09 12:31:27 +00:00
|
|
|
|
2014-06-16 14:05:29 +00:00
|
|
|
#include <string.h>
|
2014-06-13 07:34:08 +00:00
|
|
|
|
|
|
|
|
2013-10-09 12:31:27 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// EXTERNAL FUNCTIONS
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// DEFINES
|
2019-01-21 17:25:54 +00:00
|
|
|
#define TEST_SAD(X, Y) kvz_image_calc_sad(g_pic, g_ref, 0, 0, (X), (Y), 8, 8, NULL)
|
2013-10-09 12:31:27 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// GLOBALS
|
2015-08-11 14:21:39 +00:00
|
|
|
static const kvz_pixel ref_data[64] = {
|
2013-10-09 12:31:27 +00:00
|
|
|
1,2,2,2,2,2,2,3,
|
|
|
|
4,5,5,5,5,5,5,6,
|
|
|
|
4,5,5,5,5,5,5,6,
|
|
|
|
4,5,5,5,5,5,5,6,
|
|
|
|
4,5,5,5,5,5,5,6,
|
|
|
|
4,5,5,5,5,5,5,6,
|
|
|
|
4,5,5,5,5,5,5,6,
|
|
|
|
7,8,8,8,8,8,8,9
|
|
|
|
};
|
|
|
|
|
2015-08-11 14:21:39 +00:00
|
|
|
static const kvz_pixel pic_data[64] = {
|
2013-10-09 12:31:27 +00:00
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1
|
|
|
|
};
|
|
|
|
|
2015-07-01 06:52:39 +00:00
|
|
|
static kvz_picture *g_pic = 0;
|
|
|
|
static kvz_picture *g_ref = 0;
|
2016-08-26 11:16:25 +00:00
|
|
|
static kvz_picture *g_big_pic = 0;
|
|
|
|
static kvz_picture *g_big_ref = 0;
|
|
|
|
static kvz_picture *g_64x64_zero = 0;
|
|
|
|
static kvz_picture *g_64x64_max = 0;
|
|
|
|
|
|
|
|
static struct sad_test_env_t {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
void * tested_func;
|
|
|
|
const strategy_t * strategy;
|
|
|
|
char msg[255];
|
|
|
|
} sad_test_env;
|
2013-10-09 12:31:27 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// SETUP, TEARDOWN AND HELPER FUNCTIONS
|
2014-06-13 07:34:08 +00:00
|
|
|
static void setup_tests()
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2016-08-16 16:03:21 +00:00
|
|
|
g_pic = kvz_image_alloc(KVZ_CSP_420, 8, 8);
|
2021-01-14 12:30:50 +00:00
|
|
|
for (int y = 0; y < 8; ++y) {
|
|
|
|
for (int x = 0; x < 8; ++x) {
|
|
|
|
g_pic->y[y*g_pic->stride + x] = pic_data[8*y + x] + 48;
|
|
|
|
}
|
2013-10-10 16:09:44 +00:00
|
|
|
}
|
2013-10-09 12:31:27 +00:00
|
|
|
|
2016-08-16 16:03:21 +00:00
|
|
|
g_ref = kvz_image_alloc(KVZ_CSP_420, 8, 8);
|
2021-01-14 12:30:50 +00:00
|
|
|
for (int y = 0; y < 8; ++y) {
|
|
|
|
for (int x = 0; x < 8; ++x) {
|
|
|
|
g_ref->y[y*g_ref->stride + x] = ref_data[8*y + x] + 48;
|
|
|
|
}
|
2013-10-10 16:09:44 +00:00
|
|
|
}
|
2016-08-26 11:16:25 +00:00
|
|
|
|
2021-01-14 12:30:50 +00:00
|
|
|
int i = 0;
|
2016-08-26 11:16:25 +00:00
|
|
|
g_big_pic = kvz_image_alloc(KVZ_CSP_420, 64, 64);
|
2021-01-14 12:30:50 +00:00
|
|
|
for (int y = 0; y < 64; ++y) {
|
|
|
|
for (int x = 0; x < 64; ++x) {
|
|
|
|
i = ((64 * y) + x);
|
|
|
|
g_big_pic->y[y*g_big_pic->stride + x] = (i*i / 32 + i) % 255;
|
|
|
|
}
|
2016-08-26 11:16:25 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 12:30:50 +00:00
|
|
|
i = 0;
|
2016-08-26 11:16:25 +00:00
|
|
|
g_big_ref = kvz_image_alloc(KVZ_CSP_420, 64, 64);
|
2021-01-14 12:30:50 +00:00
|
|
|
for (int y = 0; y < 64; ++y) {
|
|
|
|
for (int x = 0; x < 64; ++x) {
|
|
|
|
i = ((64 * y) + x);
|
|
|
|
g_big_ref->y[y*g_big_ref->stride + x] = (i*i / 16 + i) % 255;
|
|
|
|
}
|
2016-08-26 11:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_64x64_zero = kvz_image_alloc(KVZ_CSP_420, 64, 64);
|
|
|
|
memset(g_64x64_zero->y, 0, 64 * 64 * sizeof(kvz_pixel));
|
|
|
|
|
|
|
|
g_64x64_max = kvz_image_alloc(KVZ_CSP_420, 64, 64);
|
|
|
|
memset(g_64x64_max->y, PIXEL_MAX, 64 * 64 * sizeof(kvz_pixel));
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
static void tear_down_tests()
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2015-08-26 08:50:27 +00:00
|
|
|
kvz_image_free(g_pic);
|
|
|
|
kvz_image_free(g_ref);
|
2016-08-26 11:16:25 +00:00
|
|
|
kvz_image_free(g_big_pic);
|
|
|
|
kvz_image_free(g_big_ref);
|
|
|
|
kvz_image_free(g_64x64_zero);
|
|
|
|
kvz_image_free(g_64x64_max);
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
|
2013-10-09 12:31:27 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2013-10-11 11:08:56 +00:00
|
|
|
// OVERLAPPING BOUNDARY TESTS
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_topleft(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
1*(4*4) + (2+4)*(4*4) + 5*(4*4) - 64,
|
|
|
|
TEST_SAD(-3, -3));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_top(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
(1+3)*4 + 2*(6*4) + (4+6)*4 + 5*(6*4) - 64,
|
|
|
|
TEST_SAD(0, -3));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_topright(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
3*(4*4) + (2+6)*(4*4) + 5*(4*4) - 64,
|
|
|
|
TEST_SAD(3, -3));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_left(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
(1+7)*4 + 4*(6*4) + (2+8)*4 + 5*(6*4) - 64,
|
|
|
|
TEST_SAD(-3, 0));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_no_offset(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
(1+3+7+9) + (2+4+6+8)*6 + 5*(6*6) - 64,
|
2013-10-09 12:31:27 +00:00
|
|
|
TEST_SAD(0, 0));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_right(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
(3+9)*4 + 6*(4*6) + (2+8)*4 + 5*(6*4) - 64,
|
|
|
|
TEST_SAD(3, 0));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_bottomleft(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
7*(4*4) + (4+8)*(4*4) + 5*(4*4) - 64,
|
|
|
|
TEST_SAD(-3, 3));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_bottom(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
(7+9)*4 + 8*(6*4) + (4+6)*4 + 5*(6*4) - 64,
|
|
|
|
TEST_SAD(0, 3));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_bottomright(void)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-10 12:16:14 +00:00
|
|
|
9*(4*4) + (6+8)*(4*4) + 5*(4*4) - 64,
|
2013-10-11 09:38:14 +00:00
|
|
|
TEST_SAD(3, 3));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 11:08:56 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// OUT OF FRAME TESTS
|
|
|
|
|
2014-02-07 11:06:17 +00:00
|
|
|
#define DIST 10
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_topleft_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
1*(8*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(-DIST, -DIST));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_top_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
(1+3)*8 + 2*(6*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(0, -DIST));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_topright_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
3*(8*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(DIST, -DIST));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_left_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
(1+7)*8 + 4*(6*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(-DIST, 0));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_right_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
(3+9)*8 + 6*(6*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(DIST, 0));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_bottomleft_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
7*(8*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(-DIST, DIST));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_bottom_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
(7+9)*8 + 8*(6*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(0, DIST));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_bottomright_out(void)
|
2013-10-11 11:08:56 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT_EQ(
|
2013-10-11 11:08:56 +00:00
|
|
|
9*(8*8) - 64,
|
2014-02-07 11:06:17 +00:00
|
|
|
TEST_SAD(DIST, DIST));
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-10-11 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 11:16:25 +00:00
|
|
|
static unsigned simple_sad(const kvz_pixel* buf1, const kvz_pixel* buf2, unsigned stride,
|
|
|
|
unsigned width, unsigned height)
|
|
|
|
{
|
|
|
|
unsigned sum = 0;
|
|
|
|
for (unsigned y = 0; y < height; ++y) {
|
|
|
|
for (unsigned x = 0; x < width; ++x) {
|
|
|
|
sum += abs((int)buf1[y * stride + x] - (int)buf2[y * stride + x]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
2014-06-12 12:04:48 +00:00
|
|
|
|
2016-08-26 11:16:25 +00:00
|
|
|
TEST test_reg_sad(void)
|
|
|
|
{
|
|
|
|
unsigned width = sad_test_env.width;
|
|
|
|
unsigned height = sad_test_env.height;
|
|
|
|
unsigned stride = 64;
|
|
|
|
|
|
|
|
unsigned correct_result = simple_sad(g_big_pic->y, g_big_ref->y, stride, width, height);
|
|
|
|
|
|
|
|
unsigned(*tested_func)(const kvz_pixel *, const kvz_pixel *, int, int, unsigned, unsigned) = sad_test_env.tested_func;
|
|
|
|
unsigned result = tested_func(g_big_pic->y, g_big_ref->y, width, height, stride, stride);
|
|
|
|
|
|
|
|
sprintf(sad_test_env.msg, "%s(%ux%u):%s",
|
|
|
|
sad_test_env.strategy->type,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
sad_test_env.strategy->strategy_name);
|
|
|
|
|
|
|
|
if (result != correct_result) {
|
|
|
|
FAILm(sad_test_env.msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
PASSm(sad_test_env.msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST test_reg_sad_overflow(void)
|
|
|
|
{
|
|
|
|
unsigned width = sad_test_env.width;
|
|
|
|
unsigned height = sad_test_env.height;
|
|
|
|
unsigned stride = 64;
|
|
|
|
|
|
|
|
unsigned correct_result = simple_sad(g_64x64_zero->y, g_64x64_max->y, stride, width, height);
|
|
|
|
|
|
|
|
unsigned(*tested_func)(const kvz_pixel *, const kvz_pixel *, int, int, unsigned, unsigned) = sad_test_env.tested_func;
|
|
|
|
unsigned result = tested_func(g_64x64_zero->y, g_64x64_max->y, width, height, stride, stride);
|
|
|
|
|
|
|
|
sprintf(sad_test_env.msg, "overflow %s(%ux%u):%s",
|
|
|
|
sad_test_env.strategy->type,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
sad_test_env.strategy->strategy_name);
|
|
|
|
|
|
|
|
if (result != correct_result) {
|
|
|
|
FAILm(sad_test_env.msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
PASSm(sad_test_env.msg);
|
|
|
|
}
|
2014-06-13 07:34:08 +00:00
|
|
|
|
|
|
|
|
2013-10-09 12:31:27 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TEST FIXTURES
|
2014-01-31 12:35:37 +00:00
|
|
|
SUITE(sad_tests)
|
2013-10-09 12:31:27 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
//SET_SETUP(sad_setup);
|
|
|
|
//SET_TEARDOWN(sad_teardown);
|
2013-10-11 11:08:56 +00:00
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
setup_tests();
|
|
|
|
|
2018-06-12 10:57:07 +00:00
|
|
|
for (volatile unsigned i = 0; i < strategies.count; ++i) {
|
2014-06-16 14:05:29 +00:00
|
|
|
if (strcmp(strategies.strategies[i].type, "reg_sad") != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
// Change the global reg_sad function pointer.
|
2015-08-26 08:50:27 +00:00
|
|
|
kvz_reg_sad = strategies.strategies[i].fptr;
|
2013-10-09 12:31:27 +00:00
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
// Tests for movement vectors that overlap frame.
|
|
|
|
RUN_TEST(test_topleft);
|
|
|
|
RUN_TEST(test_top);
|
|
|
|
RUN_TEST(test_topright);
|
2013-10-09 12:31:27 +00:00
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
RUN_TEST(test_left);
|
|
|
|
RUN_TEST(test_no_offset);
|
|
|
|
RUN_TEST(test_right);
|
2013-10-09 12:31:27 +00:00
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
RUN_TEST(test_bottomleft);
|
|
|
|
RUN_TEST(test_bottom);
|
|
|
|
RUN_TEST(test_bottomright);
|
2013-10-11 11:08:56 +00:00
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
// Tests for movement vectors that are outside the frame.
|
|
|
|
RUN_TEST(test_topleft_out);
|
|
|
|
RUN_TEST(test_top_out);
|
|
|
|
RUN_TEST(test_topright_out);
|
2013-10-11 11:08:56 +00:00
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
RUN_TEST(test_left_out);
|
|
|
|
RUN_TEST(test_right_out);
|
2013-10-11 11:08:56 +00:00
|
|
|
|
2014-06-13 07:34:08 +00:00
|
|
|
RUN_TEST(test_bottomleft_out);
|
|
|
|
RUN_TEST(test_bottom_out);
|
|
|
|
RUN_TEST(test_bottomright_out);
|
2016-08-26 11:16:25 +00:00
|
|
|
|
|
|
|
struct dimension {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
};
|
|
|
|
static const struct dimension tested_dims[] = {
|
|
|
|
// Square motion partitions
|
|
|
|
{64, 64}, {32, 32}, {16, 16}, {8, 8},
|
|
|
|
// Symmetric motion partitions
|
|
|
|
{64, 32}, {32, 64}, {32, 16}, {16, 32}, {16, 8}, {8, 16}, {8, 4}, {4, 8},
|
|
|
|
// Asymmetric motion partitions
|
|
|
|
{48, 16}, {16, 48}, {24, 16}, {16, 24}, {12, 4}, {4, 12}
|
|
|
|
};
|
|
|
|
|
|
|
|
sad_test_env.tested_func = strategies.strategies[i].fptr;
|
|
|
|
sad_test_env.strategy = &strategies.strategies[i];
|
|
|
|
int num_dim_tests = sizeof(tested_dims) / sizeof(tested_dims[0]);
|
2017-07-24 09:15:17 +00:00
|
|
|
for (volatile int dim_test = 0; dim_test < num_dim_tests; ++dim_test) {
|
2016-08-26 11:16:25 +00:00
|
|
|
sad_test_env.width = tested_dims[dim_test].width;
|
|
|
|
sad_test_env.height = tested_dims[dim_test].height;
|
|
|
|
RUN_TEST(test_reg_sad);
|
|
|
|
RUN_TEST(test_reg_sad_overflow);
|
|
|
|
}
|
2014-06-13 07:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tear_down_tests();
|
2013-10-09 12:31:27 +00:00
|
|
|
}
|