summaryrefslogtreecommitdiff
path: root/liboil/ref
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2005-12-18 05:13:26 +0000
committerDavid Schleef <ds@schleef.org>2005-12-18 05:13:26 +0000
commiteb82d8fb7d4d2a14b03fb33eb2edbae112cae235 (patch)
treec412125f982aeb64815d8b3015803ad75df15db1 /liboil/ref
parent4c5004c8d6912b15bb0330ad1d32945c99167909 (diff)
downloadliboil-eb82d8fb7d4d2a14b03fb33eb2edbae112cae235.tar.gz
* liboil/liboilparameter.h:
* liboil/liboilprototype.c: (oil_param_get_source_data): * liboil/liboiltest.c: (oil_test_get_value): * liboil/liboiltest.h: New functions for getting values common in test setup functions. * liboil/dct/idct8x8theora_ref.c: * liboil/ref/clip_ref.c: * liboil/ref/composite.c: * liboil/ref/permute.c: * liboil/ref/resample.c: * liboil/utf8/utf8.c: Use new functions.
Diffstat (limited to 'liboil/ref')
-rw-r--r--liboil/ref/clip_ref.c6
-rw-r--r--liboil/ref/composite.c51
-rw-r--r--liboil/ref/permute.c5
-rw-r--r--liboil/ref/resample.c9
4 files changed, 27 insertions, 44 deletions
diff --git a/liboil/ref/clip_ref.c b/liboil/ref/clip_ref.c
index 7f109b3..c0afec4 100644
--- a/liboil/ref/clip_ref.c
+++ b/liboil/ref/clip_ref.c
@@ -57,11 +57,9 @@ static void clip_ ## type ## _ref ( \
static void clip_ ## type ## _test (OilTest *test) \
{ \
oil_type_ ## type *lo = (oil_type_ ## type *) \
- (test->params[OIL_ARG_SRC2].src_data + \
- test->params[OIL_ARG_SRC2].test_header); \
+ oil_test_get_source_data (test, OIL_ARG_SRC2); \
oil_type_ ## type *hi = (oil_type_ ## type *) \
- (test->params[OIL_ARG_SRC3].src_data + \
- test->params[OIL_ARG_SRC3].test_header); \
+ oil_test_get_source_data (test, OIL_ARG_SRC3); \
if (*lo > *hi) { \
oil_type_ ## type tmp; \
tmp = *lo; \
diff --git a/liboil/ref/composite.c b/liboil/ref/composite.c
index 4db98d3..ff2610d 100644
--- a/liboil/ref/composite.c
+++ b/liboil/ref/composite.c
@@ -31,6 +31,7 @@
#include <liboil/liboil.h>
#include <liboil/liboilfunction.h>
+#include <liboil/liboilrandom.h>
#include <liboil/liboilcolorspace.h>
#include <liboil/liboiltest.h>
#include <liboil/liboildebug.h>
@@ -55,44 +56,32 @@
*
*/
static void
-composite_test (OilTest *test)
+handle_param (OilParameter *p)
{
- int i;
int n;
- uint32_t *ptr;
- int a;
- OilParameter *p;
-
- p = &test->params[OIL_ARG_SRC1];
- if (p->src_data && p->type == OIL_TYPE_u32p) {
- ptr = (uint32_t *)(p->src_data + p->test_header);
- n = p->post_n;
- for(i=0;i<n;i++){
- a = oil_rand_u8();
- ptr[i] = oil_rand_rgba(a);
- }
- }
- p = &test->params[OIL_ARG_SRC2];
- if (p->src_data && p->type == OIL_TYPE_u32p) {
- ptr = (uint32_t *)(p->src_data + p->test_header);
- n = p->post_n;
- for(i=0;i<n;i++){
- a = oil_rand_u8();
- ptr[i] = oil_rand_rgba(a);
+ if (p->src_data) {
+ if (p->type == OIL_TYPE_u32p) {
+ uint32_t *ptr;
+ ptr = (uint32_t *)oil_param_get_source_data (p);
+ n = p->post_n;
+ oil_random_argb (ptr, n);
}
- }
-
- p = &test->params[OIL_ARG_INPLACE1];
- if (p->src_data && p->type == OIL_TYPE_u32p) {
- ptr = (uint32_t *)(p->src_data + p->test_header);
- n = p->post_n;
- for(i=0;i<n;i++){
- a = oil_rand_u8();
- ptr[i] = oil_rand_rgba(a);
+ if (p->type == OIL_TYPE_u8p) {
+ uint8_t *ptr;
+ ptr = (uint8_t *)oil_param_get_source_data (p);
+ n = p->post_n;
+ oil_random_alpha (ptr, n);
}
}
+}
+static void
+composite_test (OilTest *test)
+{
+ handle_param(&test->params[OIL_ARG_SRC1]);
+ handle_param(&test->params[OIL_ARG_SRC2]);
+ handle_param(&test->params[OIL_ARG_INPLACE1]);
}
/**
diff --git a/liboil/ref/permute.c b/liboil/ref/permute.c
index e1c14f0..55d3f29 100644
--- a/liboil/ref/permute.c
+++ b/liboil/ref/permute.c
@@ -39,9 +39,8 @@ permute_test (OilTest *test)
{
int i;
int n = test->n;
- int stride = test->params[OIL_ARG_SSTR2].value;
- uint8_t *ptr = (uint8_t *)test->params[OIL_ARG_SRC2].src_data +
- test->params[OIL_ARG_SRC2].test_header;
+ int stride = oil_test_get_value (test, OIL_ARG_SSTR2);
+ uint8_t *ptr = (uint8_t *) oil_test_get_source_data (test, OIL_ARG_SRC2);
for(i=0;i<n;i++){
/* FIXME */
diff --git a/liboil/ref/resample.c b/liboil/ref/resample.c
index 876aec9..686c500 100644
--- a/liboil/ref/resample.c
+++ b/liboil/ref/resample.c
@@ -47,8 +47,7 @@
static void
resample_linear_u8_test (OilTest *test)
{
- uint32_t *in = (uint32_t *)(test->params[OIL_ARG_INPLACE1].src_data +
- test->params[OIL_ARG_INPLACE1].test_header);
+ uint32_t *in = (uint32_t *) oil_test_get_source_data (test, OIL_ARG_INPLACE1);
in[0] = 0;
in[1] = 65536;
@@ -69,8 +68,7 @@ OIL_DEFINE_CLASS_FULL (resample_linear_u8,
static void
resample_linear_argb_test (OilTest *test)
{
- uint32_t *in = (uint32_t *)(test->params[OIL_ARG_INPLACE1].src_data +
- test->params[OIL_ARG_INPLACE1].test_header);
+ uint32_t *in = (uint32_t *) oil_test_get_source_data (test, OIL_ARG_INPLACE1);
in[0] = 0;
in[1] = 65536;
@@ -148,8 +146,7 @@ OIL_DEFINE_IMPL_REF (resample_linear_argb_ref, resample_linear_argb);
static void
merge_linear_argb_test (OilTest *test)
{
- uint32_t *src3 = (uint32_t *)(test->params[OIL_ARG_SRC3].src_data +
- test->params[OIL_ARG_SRC3].test_header);
+ uint32_t *src3 = (uint32_t *) oil_test_get_source_data (test, OIL_ARG_SRC3);
src3[0] = oil_rand_u8();
}