]> git.sesse.net Git - movit/commitdiff
Merge branch 'master' into epoxy
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Mar 2014 00:25:39 +0000 (01:25 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Mar 2014 00:25:39 +0000 (01:25 +0100)
Conflicts:
Makefile.in

.gitignore
Makefile.in
configure.ac
fp16_test.cpp

index 3da5e6cadaebf859695ec7890c34e1dd0655c16b..547ccdb86de3885dba6e2432762dcd893b605b8d 100644 (file)
@@ -1,6 +1,7 @@
 *.o
 *.lo
 *.la
+*.ld
 *.a
 *.d
 *.jpg
@@ -31,6 +32,12 @@ glow_effect_test
 padding_effect_test
 flat_input_test
 ycbcr_input_test
+complex_modulate_effect_test
+fft_pass_effect_test
+fp16_test
+luma_mix_effect_test
+slice_effect_test
+vignette_effect_test
 chain-*.frag
 movit.info
 coverage/
@@ -40,6 +47,13 @@ autom4te.cache/
 config.h.in
 config.log
 config.status
+.libs
+config.guess
+config.sub
+install-sh
+libtool
+ltmain.sh
+m4
 configure
 Makefile
 movit.pc
index 0c2e9eed6f9f6bfa31c42b53f81440486c4fe81c..3a2461f41edf6a55d0d106aed69767b5a3a79b37 100644 (file)
@@ -9,6 +9,7 @@ datadir = @datadir@
 top_builddir = @top_builddir@
 with_demo_app = @with_demo_app@
 with_SDL2 = @with_SDL2@
+with_coverage = @with_coverage@
 
 CC=@CC@
 CXX=@CXX@
@@ -24,7 +25,7 @@ RANLIB=ranlib
 INSTALL=install
 MKDIR=mkdir
 
-ifeq ($(COVERAGE),1)
+ifeq ($(with_coverage),yes)
 CXXFLAGS += -fprofile-arcs -ftest-coverage --coverage
 LDFLAGS += -fprofile-arcs -ftest-coverage
 LDLIBS += -lgcov
@@ -131,11 +132,16 @@ check: $(TESTS)
                exit 1; \
        fi
 
-# You need to build with COVERAGE=1 to use this target.
+ifeq ($(with_coverage),yes)
 coverage: check
        lcov -d . -c -o movit.info
        lcov --remove movit.info '*_test.cpp' 'test_util.*' 'sandbox_effect.*' widgets.cpp -o movit.info
        genhtml -o coverage movit.info
+else
+coverage:
+       @echo You need to compile with --enable-coverage to use this target.
+       @exit 1
+endif
 
 HDRS = effect_chain.h effect_util.h effect.h input.h image_format.h init.h util.h defs.h resource_pool.h
 HDRS += $(INPUTS:=.h)
index 79e99cadbaf0162dba9c83cf17968339ebed5261..f9117465aa9625ba7adb09bf8ca16d32783a4421 100644 (file)
@@ -28,5 +28,9 @@ PKG_CHECK_MODULES([libpng], [libpng12], [], [with_demo_app=no; AC_MSG_WARN([libp
 AC_SUBST([with_demo_app])
 AC_SUBST([with_SDL2])
 
+with_coverage=no
+AC_ARG_ENABLE([coverage], [  --enable-coverage       build with information needed to compute test coverage], [with_coverage=yes])
+AC_SUBST([with_coverage])
+
 AC_CONFIG_FILES([Makefile movit.pc])
 AC_OUTPUT
index d5d7fc04c22396a48fc7bbf73b239629f6fd39e6..3deb74b32a9f3e3c5dec92807cec8aa08a01eea9 100644 (file)
@@ -16,9 +16,19 @@ TEST(FP16Test, Simple) {
        EXPECT_DOUBLE_EQ(0.333251953125, fp16_to_fp64(0x3555));
 }
 
-TEST(FP16Test, NaN) {
-       EXPECT_EQ(0xfe00, fp64_to_fp16(0.0 / 0.0));
-       EXPECT_TRUE(isnan(fp16_to_fp64(0xfe00)));
+TEST(FP16Test, RoundToNearestEven) {
+       ASSERT_DOUBLE_EQ(1.0, fp16_to_fp64(0x3c00));
+
+       double x0 = fp16_to_fp64(0x3c00);
+       double x1 = fp16_to_fp64(0x3c01);
+       double x2 = fp16_to_fp64(0x3c02);
+       double x3 = fp16_to_fp64(0x3c03);
+       double x4 = fp16_to_fp64(0x3c04);
+
+       EXPECT_EQ(0x3c00, fp64_to_fp16(0.5 * (x0 + x1)));
+       EXPECT_EQ(0x3c02, fp64_to_fp16(0.5 * (x1 + x2)));
+       EXPECT_EQ(0x3c02, fp64_to_fp16(0.5 * (x2 + x3)));
+       EXPECT_EQ(0x3c04, fp64_to_fp16(0.5 * (x3 + x4)));
 }
 
 union fp64 {
@@ -30,6 +40,44 @@ union fp32 {
        unsigned int u;
 };
 
+TEST(FP16Test, NaN) {
+       EXPECT_EQ(0xfe00, fp64_to_fp16(0.0 / 0.0));
+       EXPECT_TRUE(isnan(fp16_to_fp64(0xfe00)));
+
+       fp64 borderline_inf;
+       borderline_inf.ll = 0x7ff0000000000000ull;
+       fp64 borderline_nan;
+       borderline_nan.ll = 0x7ff0000000000001ull;
+
+       ASSERT_FALSE(isfinite(borderline_inf.f));
+       ASSERT_FALSE(isnan(borderline_inf.f));
+
+       ASSERT_FALSE(isfinite(borderline_nan.f));
+       ASSERT_TRUE(isnan(borderline_nan.f));
+
+       double borderline_inf_roundtrip = fp16_to_fp64(fp64_to_fp16(borderline_inf.f));
+       double borderline_nan_roundtrip = fp16_to_fp64(fp64_to_fp16(borderline_nan.f));
+
+       EXPECT_FALSE(isfinite(borderline_inf_roundtrip));
+       EXPECT_FALSE(isnan(borderline_inf_roundtrip));
+
+       EXPECT_FALSE(isfinite(borderline_nan_roundtrip));
+       EXPECT_TRUE(isnan(borderline_nan_roundtrip));
+}
+
+TEST(FP16Test, Denormals) {
+       const double smallest_fp16_denormal = 5.9604644775390625e-08;
+       EXPECT_EQ(0x0001, fp64_to_fp16(smallest_fp16_denormal));
+       EXPECT_EQ(0x0000, fp64_to_fp16(0.5 * smallest_fp16_denormal));  // Round-to-even.
+       EXPECT_EQ(0x0001, fp64_to_fp16(0.51 * smallest_fp16_denormal));
+       EXPECT_EQ(0x0002, fp64_to_fp16(1.5 * smallest_fp16_denormal));
+
+       const double smallest_fp16_non_denormal = 6.103515625e-05;
+       EXPECT_EQ(0x0400, fp64_to_fp16(smallest_fp16_non_denormal));
+       EXPECT_EQ(0x0400, fp64_to_fp16(smallest_fp16_non_denormal - 0.5 * smallest_fp16_denormal));  // Round-to-even.
+       EXPECT_EQ(0x03ff, fp64_to_fp16(smallest_fp16_non_denormal - smallest_fp16_denormal));
+}
+
 // Randomly test a large number of fp64 -> fp32 conversions, comparing
 // against the FPU.
 TEST(FP16Test, FP32ReferenceDownconvert) {