From: Geza Lore Date: Wed, 1 Jun 2016 12:54:54 +0000 (+0100) Subject: Move template specializations into .cc from .h X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a69ee0e11cccdeefcd5c7655144c8a978f5c46a;p=libvpx Move template specializations into .cc from .h Change-Id: I6d8775c1fa228fde25016a401e3c22a8e3da42f9 --- diff --git a/test/randomise.cc b/test/randomise.cc new file mode 100644 index 000000000..679ee724a --- /dev/null +++ b/test/randomise.cc @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "test/randomise.h" + +namespace libvpx_test { + +// Add further specialisations as necessary + +template<> +bool Randomise::uniform() { + return rnd_.Rand8() & 1 ? true : false; +} + +template<> +uint8_t Randomise::uniform() { + return rnd_.Rand8(); +} + +template<> +uint16_t Randomise::uniform() { + return rnd_.Rand16(); +} + +template<> +uint32_t Randomise::uniform() { + const uint32_t l = uniform(); + const uint32_t h = uniform(); + return h << 16 | l; +} + +template<> +uint64_t Randomise::uniform() { + const uint64_t l = uniform(); + const uint64_t h = uniform(); + return h << 32 | l; +} + +template<> +int8_t Randomise::uniform() { return uniform(); } + +template<> +int16_t Randomise::uniform() { return uniform(); } + +template<> +int32_t Randomise::uniform() { return uniform(); } + +template<> +int64_t Randomise::uniform() { return uniform(); } + +} // namespace libvpx_test diff --git a/test/randomise.h b/test/randomise.h index fbf419c68..c263f84d8 100644 --- a/test/randomise.h +++ b/test/randomise.h @@ -162,45 +162,31 @@ class Randomise { // Add further specialisations as necessary template<> -bool Randomise::uniform() { - return rnd_.Rand8() & 1 ? true : false; -} +bool Randomise::uniform(); template<> -uint8_t Randomise::uniform() { - return rnd_.Rand8(); -} +uint8_t Randomise::uniform(); template<> -uint16_t Randomise::uniform() { - return rnd_.Rand16(); -} +uint16_t Randomise::uniform(); template<> -uint32_t Randomise::uniform() { - const uint32_t l = uniform(); - const uint32_t h = uniform(); - return h << 16 | l; -} +uint32_t Randomise::uniform(); template<> -uint64_t Randomise::uniform() { - const uint64_t l = uniform(); - const uint64_t h = uniform(); - return h << 32 | l; -} +uint64_t Randomise::uniform(); template<> -int8_t Randomise::uniform() { return uniform(); } +int8_t Randomise::uniform(); template<> -int16_t Randomise::uniform() { return uniform(); } +int16_t Randomise::uniform(); template<> -int32_t Randomise::uniform() { return uniform(); } +int32_t Randomise::uniform(); template<> -int64_t Randomise::uniform() { return uniform(); } +int64_t Randomise::uniform(); } // namespace libvpx_test diff --git a/test/test.mk b/test/test.mk index 8eda2dd26..9a87a809d 100644 --- a/test/test.mk +++ b/test/test.mk @@ -49,6 +49,8 @@ LIBVPX_TEST_SRCS-yes += decode_test_driver.cc LIBVPX_TEST_SRCS-yes += decode_test_driver.h LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += encode_test_driver.cc LIBVPX_TEST_SRCS-yes += encode_test_driver.h +LIBVPX_TEST_SRCS-yes += randomise.h +LIBVPX_TEST_SRCS-yes += randomise.cc ## IVF writing. LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += ../ivfenc.c ../ivfenc.h