2014-01-31 12:35:37 +00:00
|
|
|
#include "greatest/greatest.h"
|
2013-09-24 15:36:33 +00:00
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
#include "src/picture.h"
|
2013-09-24 15:36:33 +00:00
|
|
|
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
typedef struct {
|
|
|
|
picture_list *list; // picturelist used by all tests.
|
|
|
|
} picture_list_env;
|
2013-09-24 15:36:33 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// SETUP, TEARDOWN AND HELPER FUNCTIONS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alloc and initialize picture. Initialize yuv-data with parameter init.
|
|
|
|
*/
|
|
|
|
picture * make_pic(unsigned lcu_width, unsigned lcu_height, char init) {
|
|
|
|
picture *pic = picture_init(LCU_WIDTH * lcu_width, LCU_WIDTH * lcu_height,
|
|
|
|
lcu_width, lcu_height);
|
|
|
|
unsigned luma_size = pic->width * pic->height;
|
|
|
|
unsigned chroma_size = luma_size >> 2;
|
|
|
|
|
|
|
|
memset(pic->y_data, init, luma_size);
|
|
|
|
memset(pic->u_data, init, chroma_size);
|
|
|
|
memset(pic->v_data, init, chroma_size);
|
|
|
|
|
|
|
|
return pic;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup initial conditions for all tests.
|
|
|
|
*
|
|
|
|
* The conditions are that g_pl is a picture list of size 10 with 10 pictures.
|
|
|
|
* The pictures have their yuv-data initialized with their index in the list,
|
|
|
|
* meaning that the first picture is filled with 0 values and the second with
|
|
|
|
* 1 values.
|
|
|
|
*/
|
2014-01-31 12:35:37 +00:00
|
|
|
void picture_list_setup(picture_list_env *env)
|
2013-09-24 15:36:33 +00:00
|
|
|
{
|
|
|
|
unsigned lcu_width = 2;
|
|
|
|
unsigned lcu_height = 2;
|
|
|
|
unsigned i;
|
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
env->list = picture_list_init(10);
|
|
|
|
//ASSERT(g_pl->size == 10);
|
|
|
|
//ASSERT(g_pl->used_size == 0);
|
2013-09-24 15:36:33 +00:00
|
|
|
|
2014-01-31 12:35:37 +00:00
|
|
|
for (i = 0; i < env->list->size; ++i) {
|
2013-09-24 15:36:33 +00:00
|
|
|
picture *pic = make_pic(lcu_width, lcu_height, i);
|
2014-01-31 12:35:37 +00:00
|
|
|
picture_list_add(env->list, pic);
|
2013-09-24 15:36:33 +00:00
|
|
|
}
|
2014-01-31 12:35:37 +00:00
|
|
|
//ASSERT(g_pl->used_size == 10);
|
2013-09-24 15:36:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deallocate all memory allocated by picturelist_setup.
|
|
|
|
*/
|
2014-01-31 12:35:37 +00:00
|
|
|
void picture_list_teardown(picture_list_env *env)
|
2013-09-24 15:36:33 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
picture_list_destroy(env->list);
|
2013-09-24 15:36:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TEST FUNCTIONS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check that pictures have been added to the list in the correct order and
|
|
|
|
* that they can be retrieved.
|
|
|
|
*/
|
2014-01-31 12:35:37 +00:00
|
|
|
TEST test_add(picture_list_env *env)
|
2013-09-24 15:36:33 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
2014-01-31 12:35:37 +00:00
|
|
|
for (i = 0; i < env->list->used_size; ++i) {
|
|
|
|
picture *pic = env->list->pics[i];
|
2013-09-24 15:36:33 +00:00
|
|
|
unsigned luma_size = pic->width * pic->height;
|
|
|
|
unsigned chroma_size = luma_size >> 2;
|
|
|
|
|
|
|
|
// Identify that the correct picture is in the correct place by checking
|
|
|
|
// that the data values are the same as the index.
|
2014-01-31 12:35:37 +00:00
|
|
|
ASSERT(pic->y_data[0] == i);
|
|
|
|
ASSERT(pic->u_data[0] == i);
|
|
|
|
ASSERT(pic->v_data[0] == i);
|
|
|
|
ASSERT(pic->y_data[luma_size - 1] == i);
|
|
|
|
ASSERT(pic->u_data[chroma_size - 1] == i);
|
|
|
|
ASSERT(pic->v_data[chroma_size - 1] == i);
|
2013-09-24 15:36:33 +00:00
|
|
|
}
|
2014-01-31 12:35:37 +00:00
|
|
|
PASS();
|
2013-09-24 15:36:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TEST FIXTURES
|
2014-01-31 12:35:37 +00:00
|
|
|
SUITE(picture_list_tests)
|
2013-09-24 15:36:33 +00:00
|
|
|
{
|
2014-01-31 12:35:37 +00:00
|
|
|
picture_list_env env;
|
|
|
|
SET_SETUP(picture_list_setup, &env);
|
|
|
|
SET_TEARDOWN(picture_list_teardown, &env);
|
|
|
|
|
|
|
|
RUN_TEST1(test_add, &env);
|
2013-09-24 15:36:33 +00:00
|
|
|
}
|