From d2c42cb303980152906dbb4ed0c18483d809b74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Wed, 15 Jul 2015 11:00:45 +0300 Subject: [PATCH 1/3] Fix making tests. Commit 9cfbd55e removed "./" prefix of the TESTS variable in the Makefile but the recipe of target tests was expecting it. Fixed by prepending "./" to the tests recipe. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index ca58aa7b..0c6dcb7f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -210,7 +210,7 @@ debug: CFLAGS := $(filter-out -O3 -O2 -flto, $(CFLAGS)) debug: $(DEBUG) tests: build_tests - $(TESTS) + ./$(TESTS) build_tests: CFLAGS := $(filter-out -Werror, $(CFLAGS)) build_tests: init_submodules $(TESTS) From c51323b0def0f0e596d5bdd0c250ff784f6cb2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Fri, 17 Jul 2015 10:03:51 +0300 Subject: [PATCH 2/3] Add a travis test for invalid input resolution. Checks that kvazaar exits with code 1 when given an input resolution that is not a power of two. --- .travis-script.sh | 18 +++++++++++++----- .travis.yml | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.travis-script.sh b/.travis-script.sh index 7b6efc47..8c22b025 100755 --- a/.travis-script.sh +++ b/.travis-script.sh @@ -1,12 +1,20 @@ #!/bin/sh set -ev -if [ -z "$VALGRIND_TEST" ]; then - cd src - make - make tests -else +if [ -n "$VALGRIND_TEST" ]; then cd src make debug valgrind --leak-check=full --error-exitcode=1 ./kvazaar_debug -i ../mandelbrot_${TEST_DIM}.yuv --input-res=${TEST_DIM} -o /dev/null $VALGRIND_TEST +elif [ -n "$EXPECTED_STATUS" ]; then + cd src + make + set +e + ./kvazaar $PARAMS + EXIT_STATUS=$? + set -e + [ "$EXIT_STATUS" = "$EXPECTED_STATUS" ] +else + cd src + make + make tests fi diff --git a/.travis.yml b/.travis.yml index 79635207..edc50287 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,9 @@ matrix: - env: TEST_FRAMES=20 VALGRIND_TEST="--gop=8 -p0 --threads=2 --wpp --owf=1 --rd=0 --no-rdoq --no-deblock --no-sao --no-signhide --subme=0 --pu-depth-inter=1-3 --pu-depth-intra=2-3" - env: TEST_FRAMES=20 VALGRIND_TEST="--gop=8 -p0 --threads=2 --wpp --owf=0 --rd=0 --no-rdoq --no-deblock --no-sao --no-signhide --subme=0 --pu-depth-inter=1-3 --pu-depth-intra=2-3" + # Tests trying to use invalid input dimensions + - env: EXPECTED_STATUS=1 PARAMS="-i kvazaar --input-res=1x65 -o /dev/null" + before_install: # Work around a weird bug in Travis-ci, where compiler is set wrong. - if [ "$CC" = "[gcc]" ]; then export CC=gcc; gcc --version; fi From e307b7cec47d0619c7d7a7f3ffdb71206e0bf982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Wed, 15 Jul 2015 11:37:37 +0300 Subject: [PATCH 3/3] Check that input dimensions are multiples of two. Fixes wrongly accepting non-multiple of two resolutions and a segfault when one of the input dimensions is one. --- src/config.c | 22 ++++++++++++++++------ src/yuv_io.c | 3 +++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/config.c b/src/config.c index a1b03e8e..11636875 100644 --- a/src/config.c +++ b/src/config.c @@ -460,7 +460,22 @@ int config_validate(const kvz_config *const cfg) int error = 0; if (cfg->width <= 0) { - fprintf(stderr, "Input error: width is not positive\n"); + fprintf(stderr, "Input error: width must be positive\n"); + error = 1; + } + + if (cfg->height <= 0) { + fprintf(stderr, "Input error: height must be positive\n"); + error = 1; + } + + if (cfg->width % 2 != 0) { + fprintf(stderr, "Input error: width must be a multiple of two\n"); + error = 1; + } + + if (cfg->height % 2 != 0) { + fprintf(stderr, "Input error: height must be a multiple of two\n"); error = 1; } @@ -469,11 +484,6 @@ int config_validate(const kvz_config *const cfg) error = 1; } - if (cfg->height <= 0) { - fprintf(stderr, "Input error: height is not positive\n"); - error = 1; - } - if (cfg->gop_len && cfg->intra_period && cfg->intra_period % cfg->gop_len != 0) { diff --git a/src/yuv_io.c b/src/yuv_io.c index 0e0fce30..ec1689e5 100644 --- a/src/yuv_io.c +++ b/src/yuv_io.c @@ -85,6 +85,9 @@ int yuv_io_read(FILE* file, unsigned input_width, unsigned input_height, kvz_picture *img_out) { + assert(input_width % 2 == 0); + assert(input_height % 2 == 0); + const unsigned y_size = input_width * input_height; const unsigned uv_input_width = input_width / 2; const unsigned uv_input_height = input_height / 2;