This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via de06f184c1474e76daba31543187ad4b0205c5c3 (commit) via 0de9265c1f8dbd2860ccea964a7d22507f845657 (commit) via b8f76479c697120adbb7468aff93a98315dd3dba (commit) from fa2fab96f4932dece35de36740e2f1e4af38afd2 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/de06f184c1474e76daba31543187ad4b0205c...
commit de06f184c1474e76daba31543187ad4b0205c5c3 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 2 14:20:53 2012 +0100
filters: Add header + minor cleanup.
diff --git a/include/filters/GP_Convolution.h b/include/filters/GP_Convolution.h index 8c158ff..0cd9089 100644 --- a/include/filters/GP_Convolution.h +++ b/include/filters/GP_Convolution.h @@ -30,6 +30,7 @@ #define FILTERS_GP_CONVOLUTION_H
#include "GP_Filter.h" +#include "GP_Linear.h"
/* * 2D convolution kernel. diff --git a/libs/filters/GP_Convolution.c b/libs/filters/GP_Convolution.c index 7ee3b62..0b81e55 100644 --- a/libs/filters/GP_Convolution.c +++ b/libs/filters/GP_Convolution.c @@ -21,10 +21,9 @@ *****************************************************************************/
#include "core/GP_Debug.h" - #include "GP_Linear.h" - #include "GP_Convolution.h" + int GP_FilterConvolutionEx(const GP_Context *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Coord h_src,
http://repo.or.cz/w/gfxprim.git/commit/0de9265c1f8dbd2860ccea964a7d22507f845...
commit 0de9265c1f8dbd2860ccea964a7d22507f845657 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 2 14:19:41 2012 +0100
tests: framework: Copy only content of resource dir.
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index 8a0789b..1266f9b 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -29,6 +29,7 @@ #include <string.h> #include <sys/types.h> #include <sys/wait.h> +#include <sys/stat.h> #include <stdarg.h> #include <math.h>
@@ -185,22 +186,40 @@ static void prepare_tmpdir(const char *name, const char *res_path, }
/* Create template from test name */ - snprintf(template, size, "/tmp/ctest_%s_XXXXXX", tmp); + snprintf(template, size, "/tmp/test_%s_XXXXXX", tmp);
if (mkdtemp(template) == NULL) { tst_warn("mkdtemp(%s) failed: %s", template, strerror(errno)); exit(TST_INTERR); }
- /* Copy resources if needed */ + /* + * Copy resources if needed + * + * If resource is directory, copy only it's content. + */ if (res_path != NULL) { - snprintf(tmp, sizeof(tmp), "cp -r '%s' '%s'", - res_path, template); + struct stat st; + char *p = ""; + + if (stat(res_path, &st)) { + tst_warn("failed to stat resource '%s': %s", + res_path, strerror(errno)); + rmdir(template); + exit(TST_INTERR); + } + + if (S_ISDIR(st.st_mode)) + p = "/*"; + + snprintf(tmp, sizeof(tmp), "cp -r '%s'%s '%s'", + res_path, p, template);
ret = system(tmp);
if (ret) { tst_warn("failed to copy resource '%s'", res_path); + rmdir(template); exit(TST_INTERR); } }
http://repo.or.cz/w/gfxprim.git/commit/b8f76479c697120adbb7468aff93a98315dd3...
commit b8f76479c697120adbb7468aff93a98315dd3dba Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 2 14:16:24 2012 +0100
tests, filters: Convolution tests, not yet working.
diff --git a/tests/filters/LinearConvolution.c b/tests/filters/LinearConvolution.c new file mode 100644 index 0000000..cbad724 --- /dev/null +++ b/tests/filters/LinearConvolution.c @@ -0,0 +1,142 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include <core/GP_Context.h> +#include <loaders/GP_Loaders.h> +#include <filters/GP_Convolution.h> + +#include "tst_test.h" + +static int load_resources(const char *path1, const char *path2, + GP_Context **c1, GP_Context **c2) +{ + *c1 = GP_LoadImage(path1, NULL); + *c2 = GP_LoadImage(path2, NULL); + + if (*c1 == NULL || *c2 == NULL) { + tst_report(0, "Failed to load resource"); + return TST_INTERR; + } + + return TST_SUCCESS; +} + +static int test_lin_conv_box_3x3(void) +{ + GP_Context *in, *out; + int ret; + + ret = load_resources("in.pgm", "out.pgm", &in, &out); + + if (ret != TST_SUCCESS) + return ret; + + /* Apply the convolution */ + float box_3x3[] = { + 1, 1, 1, + 1, 1, 1, + 1, 1, 1, + }; + + GP_FilterKernel2D box_3x3_kernel = { + .w = 3, + .h = 3, + .div = 9, + .kernel = box_3x3, + }; + + GP_FilterConvolution(in, in, &box_3x3_kernel, NULL); + + /* Check result */ + //TODO + + return TST_SUCCESS; +} + +static int test_h_lin_conv_box_3_raw(void) +{ + GP_Context *in, *out; + int ret; + + ret = load_resources("in.pgm", "out.pgm", &in, &out); + + if (ret != TST_SUCCESS) + return ret; + + /* Apply the convolution */ + float kernel[] = {1, 1, 1}; + + GP_FilterHLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0, + kernel, 3, 3, NULL); + + /* Check result */ + //TODO + + return TST_SUCCESS; +} + +static int test_v_lin_conv_box_3_raw(void) +{ + GP_Context *in, *out; + int ret; + + ret = load_resources("in.pgm", "out.pgm", &in, &out); + + if (ret != TST_SUCCESS) + return ret; + + GP_SetDebugLevel(10); + + /* Apply the convolution */ + float kernel[] = {1, 1, 1}; + + GP_FilterVLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0, + kernel, 3, 3, NULL); + + /* Check result */ + //TODO + + return TST_SUCCESS; +} + +const struct tst_suite tst_suite = { + .suite_name = "Linear Convolution Testsuite", + .tests = { + {.name = "LinearConvolution Box 3x3", + .tst_fn = test_lin_conv_box_3x3, + .res_path = "data/conv/box_3x3/", + .flags = TST_TMPDIR}, + {.name = "HLinearConvolution_Raw Kern 3", + .tst_fn = test_h_lin_conv_box_3_raw, + .res_path = "data/conv/box_3x3/", + .flags = TST_TMPDIR}, + {.name = "VLinearConvolution_Raw Kern 3", + .tst_fn = test_v_lin_conv_box_3_raw, + .res_path = "data/conv/box_3x3/", + .flags = TST_TMPDIR}, + {.name = NULL} + } +}; diff --git a/tests/filters/Makefile b/tests/filters/Makefile new file mode 100644 index 0000000..aaa6125 --- /dev/null +++ b/tests/filters/Makefile @@ -0,0 +1,11 @@ +TOPDIR=../.. +include $(TOPDIR)/pre.mk + +CSOURCES=$(shell echo *.c) + +APPS=LinearConvolution + +include ../tests.mk + +include $(TOPDIR)/app.mk +include $(TOPDIR)/post.mk diff --git a/tests/filters/data/conv/box_3x3/in.pgm b/tests/filters/data/conv/box_3x3/in.pgm new file mode 100644 index 0000000..2adeee4 --- /dev/null +++ b/tests/filters/data/conv/box_3x3/in.pgm @@ -0,0 +1,14 @@ +P2 +# This is white square in the middle of an image +10 10 +255 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 255 255 255 255 0 0 0 + 0 0 0 255 255 255 255 0 0 0 + 0 0 0 255 255 255 255 0 0 0 + 0 0 0 255 255 255 255 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 diff --git a/tests/filters/data/conv/box_3x3/out.pgm b/tests/filters/data/conv/box_3x3/out.pgm new file mode 100644 index 0000000..6eae0df --- /dev/null +++ b/tests/filters/data/conv/box_3x3/out.pgm @@ -0,0 +1,15 @@ +P2 +# This is white square in the middle of an image +# after applying 3x3 box linear convolution +10 10 +255 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 28 57 85 85 57 28 0 0 + 0 0 57 113 170 170 113 57 0 0 + 0 0 85 170 255 255 170 85 0 0 + 0 0 85 170 255 255 170 85 0 0 + 0 0 57 113 170 170 113 57 0 0 + 0 0 28 57 85 85 57 28 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 diff --git a/tests/filters/runtest.sh b/tests/filters/runtest.sh new file mode 100755 index 0000000..9efe909 --- /dev/null +++ b/tests/filters/runtest.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# +# By default the glibc __libc_message() writes to /dev/tty before calling +# the abort(). Exporting this macro makes it to use stderr instead. +# +# The main usage of the function are malloc assertions, so this makes us catch +# the malloc error message by catching stderr output. +# +export LIBC_FATAL_STDERR_=1 + +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./LinearConvolution "$@"
-----------------------------------------------------------------------
Summary of changes: include/filters/GP_Convolution.h | 1 + libs/filters/GP_Convolution.c | 3 +- tests/filters/LinearConvolution.c | 142 +++++++++++++++++++++++++++++++ tests/{loaders => filters}/Makefile | 2 +- tests/filters/data/conv/box_3x3/in.pgm | 14 +++ tests/filters/data/conv/box_3x3/out.pgm | 15 +++ tests/{loaders => filters}/runtest.sh | 2 +- tests/framework/tst_job.c | 27 +++++- 8 files changed, 198 insertions(+), 8 deletions(-) create mode 100644 tests/filters/LinearConvolution.c copy tests/{loaders => filters}/Makefile (85%) create mode 100644 tests/filters/data/conv/box_3x3/in.pgm create mode 100644 tests/filters/data/conv/box_3x3/out.pgm copy tests/{loaders => filters}/runtest.sh (91%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.