From 0cc1bf197f4dca1ebb8f8f97f427cbe14ceb54f2 Mon Sep 17 00:00:00 2001 From: Joose Sainio Date: Fri, 23 Apr 2021 12:24:00 +0300 Subject: [PATCH] Add monochrome tests and fix monochrome --- src/filter.c | 4 ++-- src/search.c | 2 +- tests/Makefile.am | 4 +++- tests/test_intra.sh | 2 +- tests/test_invalid_input.sh | 2 +- tests/test_monochrome.sh | 12 ++++++++++++ tests/test_tools.sh | 2 +- tests/test_weird_shapes.sh | 6 +++--- tests/util.sh | 10 +++++++--- 9 files changed, 31 insertions(+), 13 deletions(-) create mode 100755 tests/test_monochrome.sh diff --git a/src/filter.c b/src/filter.c index 70cc2fda..3e4baa5a 100644 --- a/src/filter.c +++ b/src/filter.c @@ -1149,8 +1149,8 @@ static void filter_deblock_unit(encoder_state_t * const state, // Chroma pixel coordinates. const int32_t x_c = x >> 1; const int32_t y_c = y >> 1; - if ((state->encoder_control->chroma_format != KVZ_CSP_400 && is_on_8x8_grid(x_c, y_c, dir) && (x_c + 4) % 32) - || (x == state->tile->frame->width - 8 && dir == 1 && y_c % 8 == 0)) { + if (state->encoder_control->chroma_format != KVZ_CSP_400 && (is_on_8x8_grid(x_c, y_c, dir && (x_c + 4) % 32) + || (x == state->tile->frame->width - 8 && dir == 1 && y_c % 8 == 0))) { filter_deblock_edge_chroma(state, x_c, y_c, length, dir, tu_boundary); } } diff --git a/src/search.c b/src/search.c index 9179c9b8..cedebdff 100644 --- a/src/search.c +++ b/src/search.c @@ -639,7 +639,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth, NULL, lcu); // TODO: This heavily relies to square CUs - if (depth != 4 || (x % 8 && y % 8) && state->encoder_control->chroma_format != KVZ_CSP_400) { + if ((depth != 4 || (x % 8 && y % 8)) && state->encoder_control->chroma_format != KVZ_CSP_400) { // There is almost no benefit to doing the chroma mode search for // rd2. Possibly because the luma mode search already takes chroma // into account, so there is less of a chanse of luma mode being diff --git a/tests/Makefile.am b/tests/Makefile.am index 386573d7..cf2ce1db 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,7 +2,8 @@ TESTS = $(check_PROGRAMS) \ test_external_symbols.sh \ test_intra.sh \ - test_invalid_input.sh + test_invalid_input.sh \ + test_monochrome.sh #test_tools.sh #test_weird_shapes.sh @@ -10,6 +11,7 @@ EXTRA_DIST = \ test_external_symbols.sh \ test_intra.sh \ test_invalid_input.sh \ + test_monochrome.sh \ #test_tools.sh \ #test_weird_shapes.sh \ util.sh diff --git a/tests/test_intra.sh b/tests/test_intra.sh index aaad7525..039b0497 100755 --- a/tests/test_intra.sh +++ b/tests/test_intra.sh @@ -6,7 +6,7 @@ set -eu . "${0%/*}/util.sh" -common_args='256x128 10 -p1 --preset=ultrafast --threads=0 --no-wpp --no-tmvp --no-deblock --sao=0 --alf=full --cpuid=0 --pu-depth-intra 0-4' +common_args='256x128 10 yuv420p -p1 --preset=ultrafast --threads=0 --no-wpp --no-tmvp --no-deblock --sao=0 --alf=full --cpuid=0 --pu-depth-intra 0-4' valgrind_test $common_args --rd=1 valgrind_test $common_args --rd=2 --no-transform-skip --qp 37 valgrind_test $common_args --rd=2 --no-transform-skip --qp 37 --rdoq diff --git a/tests/test_invalid_input.sh b/tests/test_invalid_input.sh index b7cf7369..c33f0dae 100755 --- a/tests/test_invalid_input.sh +++ b/tests/test_invalid_input.sh @@ -5,4 +5,4 @@ set -eu . "${0%/*}/util.sh" -encode_test 1x65 1 1 +encode_test 1x65 1 yuv420p 1 diff --git a/tests/test_monochrome.sh b/tests/test_monochrome.sh new file mode 100755 index 00000000..928228d4 --- /dev/null +++ b/tests/test_monochrome.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Test all-intra coding. + +set -eu + +. "${0%/*}/util.sh" + +common_args='256x128 10 gray --hash none --preset=ultrafast --input-format P400 --threads=0 --no-wpp --no-tmvp --no-deblock --sao=0 --cpuid=0 --pu-depth-intra 0-4' +valgrind_test $common_args --rd=1 -p1 +valgrind_test $common_args --rd=2 -p1 +valgrind_test $common_args --rd=2 -p1 --deblock 0:0 diff --git a/tests/test_tools.sh b/tests/test_tools.sh index ff2a14f3..ca80123a 100755 --- a/tests/test_tools.sh +++ b/tests/test_tools.sh @@ -5,7 +5,7 @@ set -eu . "${0%/*}/util.sh" -common_args='264x130 10 -p0 -r1 --threads=2 --wpp --owf=1 --rd=0' +common_args='264x130 10 yuv420p -p0 -r1 --threads=2 --wpp --owf=1 --rd=0' valgrind_test $common_args --no-rdoq --no-deblock --no-sao --no-signhide --subme=1 --pu-depth-intra=2-3 valgrind_test $common_args --no-rdoq --no-signhide --subme=0 diff --git a/tests/test_weird_shapes.sh b/tests/test_weird_shapes.sh index d6782008..025b7794 100755 --- a/tests/test_weird_shapes.sh +++ b/tests/test_weird_shapes.sh @@ -3,6 +3,6 @@ set -eu . "${0%/*}/util.sh" -valgrind_test 16x16 10 --threads=0 --no-wpp --preset=veryslow -valgrind_test 256x16 10 --threads=0 --no-wpp --preset=veryslow -valgrind_test 16x256 10 --threads=0 --no-wpp --preset=veryslow +valgrind_test 16x16 10 yuv420p --threads=0 --no-wpp --preset=veryslow +valgrind_test 256x16 10 yuv420p --threads=0 --no-wpp --preset=veryslow +valgrind_test 16x256 10 yuv420p --threads=0 --no-wpp --preset=veryslow diff --git a/tests/util.sh b/tests/util.sh index f6d956d6..9658837a 100644 --- a/tests/util.sh +++ b/tests/util.sh @@ -22,7 +22,7 @@ prepare() { cleanup print_and_run \ ffmpeg -f lavfi -i "mandelbrot=size=${1}" \ - -vframes "${2}" -pix_fmt yuv420p -f yuv4mpegpipe \ + -vframes "${2}" -pix_fmt "${3}" -f yuv4mpegpipe \ "${yuvfile}" } @@ -31,8 +31,10 @@ valgrind_test() { shift frames="$1" shift + format="$1" + shift - prepare "${dimensions}" "${frames}" + prepare "${dimensions}" "${frames}" "${format}" # If $KVZ_TEST_VALGRIND is defined and equal to "1", run the test with # valgrind. Otherwise, run without valgrind. @@ -59,10 +61,12 @@ encode_test() { shift frames="$1" shift + format="$1" + shift expected_status="$1" shift - prepare "${dimensions}" "${frames}" + prepare "${dimensions}" "${frames}" "${format}" set +e print_and_run \