diff options
author | David Bremner <bremner@debian.org> | 2018-12-25 22:44:44 +0900 |
---|---|---|
committer | David Bremner <bremner@debian.org> | 2018-12-25 22:44:44 +0900 |
commit | 33cc53ba511843ac9857470e74e043013d3620fe (patch) | |
tree | ebc0e94b5486710fc2f381d92fab9a594f1dc62c /src/external/rawspeed/test/librawspeed/io | |
parent | 1fddb41abdd4ca3be5bfdfe019e126b188879e15 (diff) |
Importing darktable_2.6.0.orig.tar.xz
Diffstat (limited to 'src/external/rawspeed/test/librawspeed/io')
9 files changed, 590 insertions, 5 deletions
diff --git a/src/external/rawspeed/test/librawspeed/io/BitPumpJPEGTest.cpp b/src/external/rawspeed/test/librawspeed/io/BitPumpJPEGTest.cpp new file mode 100644 index 000000000..1936e2fd0 --- /dev/null +++ b/src/external/rawspeed/test/librawspeed/io/BitPumpJPEGTest.cpp @@ -0,0 +1,110 @@ +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2018 Roman Lebedev + + This library 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 of the License, or (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "io/BitPumpJPEG.h" // for BitPumpJPEG, BitStream<>::fillCache +#include "common/Common.h" // for uchar8, uint32 +#include "io/BitPumpTest.h" // for Endianness, Pattern, (anonymous), Buffer +#include "io/Buffer.h" // for Buffer, DataBuffer +#include "io/ByteStream.h" // for ByteStream +#include "io/Endianness.h" // for Endianness, Endianness::big, Endianness:... +#include <array> // for array +#include <gtest/gtest.h> // for Test, Message, TestInfo (ptr only), ASSE... +#include <initializer_list> // for initializer_list + +using rawspeed::BitPumpJPEG; +using rawspeed::Buffer; +using rawspeed::ByteStream; +using rawspeed::DataBuffer; +using rawspeed::Endianness; + +namespace rawspeed_test { + +struct InvOnesTag; +struct OnesTag; +struct SaturatedTag; + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpJPEG, OnesTag>::Data = { + {/* [Byte0 Byte1 Byte2 Byte3] */ + /* Byte: [Bit0 .. Bit7] */ + 0b10100100, 0b01000010, 0b00001000, 0b00011111}}; +template <> rawspeed::uint32 Pattern<BitPumpJPEG, OnesTag>::data(int index) { + const auto set = GenOnesBE(1, 0); + return set[index]; +} + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpJPEG, InvOnesTag>::Data = { + {0b11010010, 0b00100001, 0b00000100, 0b00001111}}; +template <> rawspeed::uint32 Pattern<BitPumpJPEG, InvOnesTag>::data(int index) { + const auto set = GenOnesBE(0, -1); + return set[index]; +} + +// If 0xFF0x00 byte sequence is found, it is just 0xFF, i.e. 0x00 is ignored. +// So if we want 0xFF, we need to append 0x00 byte +template <> +const std::array<rawspeed::uchar8, 8> Pattern<BitPumpJPEG, SaturatedTag>::Data{ + {rawspeed::uchar8(~0U), 0, rawspeed::uchar8(~0U), 0, rawspeed::uchar8(~0U), + 0, rawspeed::uchar8(~0U), 0}}; + +INSTANTIATE_TYPED_TEST_CASE_P(JPEG, BitPumpTest, Patterns<BitPumpJPEG>); + +TEST(BitPumpJPEGTest, 0xFF0x00Is0xFFTest) { + // If 0xFF0x00 byte sequence is found, it is just 0xFF, i.e. 0x00 is ignored. + static const std::array<rawspeed::uchar8, 2 + 4> data{ + {0xFF, 0x00, 0b10100100, 0b01000010, 0b00001000, 0b00011111}}; + + const Buffer b(data.data(), data.size()); + + for (auto e : {Endianness::little, Endianness::big}) { + const DataBuffer db(b, e); + const ByteStream bs(db); + + BitPumpJPEG p(bs); + + ASSERT_EQ(p.getBits(8), 0xFF); + + for (int len = 1; len <= 7; len++) + ASSERT_EQ(p.getBits(len), 1) << " Where len: " << len; + } +} + +TEST(BitPumpJPEGTest, 0xFF0xXXIsTheEndTest) { + // If 0xFF0xXX byte sequence is found, where XX != 0, then it is the end. + for (rawspeed::uchar8 end = 0x01; end < 0xFF; end++) { + static const std::array<rawspeed::uchar8, 2 + 4> data{ + {0xFF, end, 0xFF, 0xFF, 0xFF, 0xFF}}; + + const Buffer b(data.data(), data.size()); + + for (auto e : {Endianness::little, Endianness::big}) { + const DataBuffer db(b, e); + const ByteStream bs(db); + + BitPumpJPEG p(bs); + + for (int cnt = 0; cnt <= 64 + 32 - 1; cnt++) + ASSERT_EQ(p.getBits(1), 0); + } + } +} + +} // namespace rawspeed_test diff --git a/src/external/rawspeed/test/librawspeed/io/BitPumpLSBTest.cpp b/src/external/rawspeed/test/librawspeed/io/BitPumpLSBTest.cpp new file mode 100644 index 000000000..703146147 --- /dev/null +++ b/src/external/rawspeed/test/librawspeed/io/BitPumpLSBTest.cpp @@ -0,0 +1,54 @@ +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2018 Roman Lebedev + + This library 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 of the License, or (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "io/BitPumpLSB.h" // for BitPumpLSB +#include "common/Common.h" // for uchar8, uint32 +#include "io/BitPumpTest.h" // for Pattern, (anonymous), GenOnesLE, BitPump... +#include <array> // for array +#include <gtest/gtest.h> // for INSTANTIATE_TYPED_TEST_CASE_P, Types + +using rawspeed::BitPumpLSB; + +namespace rawspeed_test { + +struct InvOnesTag; +struct OnesTag; + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpLSB, OnesTag>::Data = { + {/* [Byte0 Byte1 Byte2 Byte3] */ + /* Byte: [Bit7 .. Bit0] */ + 0b01001011, 0b10000100, 0b00100000, 0b11110000}}; +template <> rawspeed::uint32 Pattern<BitPumpLSB, OnesTag>::data(int index) { + const auto set = GenOnesLE(0, -1); + return set[index]; +} + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpLSB, InvOnesTag>::Data = { + {0b00100101, 0b01000010, 0b00010000, 0b11111000}}; +template <> rawspeed::uint32 Pattern<BitPumpLSB, InvOnesTag>::data(int index) { + const auto set = GenOnesLE(1, 0); + return set[index]; +} + +INSTANTIATE_TYPED_TEST_CASE_P(LSB, BitPumpTest, Patterns<BitPumpLSB>); + +} // namespace rawspeed_test diff --git a/src/external/rawspeed/test/librawspeed/io/BitPumpMSB16Test.cpp b/src/external/rawspeed/test/librawspeed/io/BitPumpMSB16Test.cpp new file mode 100644 index 000000000..18ea4e52b --- /dev/null +++ b/src/external/rawspeed/test/librawspeed/io/BitPumpMSB16Test.cpp @@ -0,0 +1,55 @@ +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2018 Roman Lebedev + + This library 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 of the License, or (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "io/BitPumpMSB16.h" // for BitPumpMSB16 +#include "common/Common.h" // for uchar8, uint32 +#include "io/BitPumpTest.h" // for Pattern, (anonymous), GenOnesBE, BitPum... +#include <array> // for array +#include <gtest/gtest.h> // for INSTANTIATE_TYPED_TEST_CASE_P, Types + +using rawspeed::BitPumpMSB16; + +namespace rawspeed_test { + +struct InvOnesTag; +struct OnesTag; + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpMSB16, OnesTag>::Data = { + {/* [Byte1 Byte0 Byte3 Byte2] */ + /* Byte: [Bit0 .. Bit7] */ + 0b01000010, 0b10100100, 0b00011111, 0b00001000}}; +template <> rawspeed::uint32 Pattern<BitPumpMSB16, OnesTag>::data(int index) { + const auto set = GenOnesBE(1, 0); + return set[index]; +} + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpMSB16, InvOnesTag>::Data = + {{0b00100001, 0b11010010, 0b00001111, 0b00000100}}; +template <> +rawspeed::uint32 Pattern<BitPumpMSB16, InvOnesTag>::data(int index) { + const auto set = GenOnesBE(0, -1); + return set[index]; +} + +INSTANTIATE_TYPED_TEST_CASE_P(MSB16, BitPumpTest, Patterns<BitPumpMSB16>); + +} // namespace rawspeed_test diff --git a/src/external/rawspeed/test/librawspeed/io/BitPumpMSB32Test.cpp b/src/external/rawspeed/test/librawspeed/io/BitPumpMSB32Test.cpp new file mode 100644 index 000000000..5685c9851 --- /dev/null +++ b/src/external/rawspeed/test/librawspeed/io/BitPumpMSB32Test.cpp @@ -0,0 +1,55 @@ +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2018 Roman Lebedev + + This library 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 of the License, or (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "io/BitPumpMSB32.h" // for BitPumpMSB32 +#include "common/Common.h" // for uchar8, uint32 +#include "io/BitPumpTest.h" // for Pattern, (anonymous), GenOnesBE, BitPum... +#include <array> // for array +#include <gtest/gtest.h> // for INSTANTIATE_TYPED_TEST_CASE_P, Types + +using rawspeed::BitPumpMSB32; + +namespace rawspeed_test { + +struct InvOnesTag; +struct OnesTag; + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpMSB32, OnesTag>::Data = { + {/* [Byte3 Byte2 Byte1 Byte0] */ + /* Byte: [Bit0 .. Bit7] */ + 0b00011111, 0b00001000, 0b01000010, 0b10100100}}; +template <> rawspeed::uint32 Pattern<BitPumpMSB32, OnesTag>::data(int index) { + const auto set = GenOnesBE(1, 0); + return set[index]; +} + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpMSB32, InvOnesTag>::Data = + {{0b00001111, 0b00000100, 0b00100001, 0b11010010}}; +template <> +rawspeed::uint32 Pattern<BitPumpMSB32, InvOnesTag>::data(int index) { + const auto set = GenOnesBE(0, -1); + return set[index]; +} + +INSTANTIATE_TYPED_TEST_CASE_P(MSB32, BitPumpTest, Patterns<BitPumpMSB32>); + +} // namespace rawspeed_test diff --git a/src/external/rawspeed/test/librawspeed/io/BitPumpMSBTest.cpp b/src/external/rawspeed/test/librawspeed/io/BitPumpMSBTest.cpp new file mode 100644 index 000000000..dd266470e --- /dev/null +++ b/src/external/rawspeed/test/librawspeed/io/BitPumpMSBTest.cpp @@ -0,0 +1,54 @@ +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2018 Roman Lebedev + + This library 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 of the License, or (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "io/BitPumpMSB.h" // for BitPumpMSB +#include "common/Common.h" // for uchar8, uint32 +#include "io/BitPumpTest.h" // for Pattern, (anonymous), GenOnesBE, BitPump... +#include <array> // for array +#include <gtest/gtest.h> // for INSTANTIATE_TYPED_TEST_CASE_P, Types + +using rawspeed::BitPumpMSB; + +namespace rawspeed_test { + +struct InvOnesTag; +struct OnesTag; + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpMSB, OnesTag>::Data = { + {/* [Byte0 Byte1 Byte2 Byte3] */ + /* Byte: [Bit0 .. Bit7] */ + 0b10100100, 0b01000010, 0b00001000, 0b00011111}}; +template <> rawspeed::uint32 Pattern<BitPumpMSB, OnesTag>::data(int index) { + const auto set = GenOnesBE(1, 0); + return set[index]; +} + +template <> +const std::array<rawspeed::uchar8, 4> Pattern<BitPumpMSB, InvOnesTag>::Data = { + {0b11010010, 0b00100001, 0b00000100, 0b00001111}}; +template <> rawspeed::uint32 Pattern<BitPumpMSB, InvOnesTag>::data(int index) { + const auto set = GenOnesBE(0, -1); + return set[index]; +} + +INSTANTIATE_TYPED_TEST_CASE_P(MSB, BitPumpTest, Patterns<BitPumpMSB>); + +} // namespace rawspeed_test diff --git a/src/external/rawspeed/test/librawspeed/io/BitPumpTest.h b/src/external/rawspeed/test/librawspeed/io/BitPumpTest.h new file mode 100644 index 000000000..143eea31c --- /dev/null +++ b/src/external/rawspeed/test/librawspeed/io/BitPumpTest.h @@ -0,0 +1,252 @@ +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2018 Roman Lebedev + + This library 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 of the License, or (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "common/Common.h" // for uchar8 +#include "io/Buffer.h" // for Buffer +#include "io/ByteStream.h" // for ByteStream +#include "io/Endianness.h" // for getHostEndianness, Endianness::big, Endia... +#include <array> // for array +#include <gtest/gtest.h> // for Message, AssertionResult, ASSERT_PRED_FOR... + +using rawspeed::Buffer; +using rawspeed::ByteStream; +using rawspeed::DataBuffer; +using rawspeed::Endianness; + +namespace rawspeed_test { + +template <typename T, typename Tag> struct BitPumpPatternTest {}; + +struct TestGetBitsTag; +template <typename T> struct BitPumpPatternTest<T, TestGetBitsTag> { + using PumpT = typename T::PumpT; + using PatternT = typename T::PatternT; + + template <typename L> static void Test(PumpT* pump, L gen) { + for (int len = 1; len <= 7; len++) + ASSERT_EQ(pump->getBits(len), gen(len)) << " Where len: " << len; + } +}; + +struct TestGetBitsNoFillTag; +template <typename T> struct BitPumpPatternTest<T, TestGetBitsNoFillTag> { + using PumpT = typename T::PumpT; + using PatternT = typename T::PatternT; + + template <typename L> static void Test(PumpT* pump, L gen) { + pump->fill(32); // Actually fills 32 bits + for (int len = 1; len <= 7; len++) + ASSERT_EQ(pump->getBitsNoFill(len), gen(len)) + << " Where len: " << len; + } +}; + +struct TestPeekBitsTag; +template <typename T> struct BitPumpPatternTest<T, TestPeekBitsTag> { + using PumpT = typename T::PumpT; + using PatternT = typename T::PatternT; + + template <typename L> static void Test(PumpT* pump, L gen) { + for (int len = 1; len <= 7; len++) { + ASSERT_EQ(pump->peekBits(len), gen(len)) << " Where len: " << len; + pump->skipBits(len); + } + } +}; + +struct TestPeekBitsNoFillTag; +template <typename T> struct BitPumpPatternTest<T, TestPeekBitsNoFillTag> { + using PumpT = typename T::PumpT; + using PatternT = typename T::PatternT; + + template <typename L> static void Test(PumpT* pump, L gen) { + pump->fill(32); // Actually fills 32 bits + for (int len = 1; len <= 7; len++) { + ASSERT_EQ(pump->peekBitsNoFill(len), gen(len)) + << " Where len: " << len; + pump->skipBitsNoFill(len); + } + } +}; + +struct TestIncreasingPeekLengthTag; +template <typename T> +struct BitPumpPatternTest<T, TestIncreasingPeekLengthTag> { + using PumpT = typename T::PumpT; + using PatternT = typename T::PatternT; + + template <typename L> static void Test(PumpT* pump, L data) { + static const auto MaxLen = 28; + for (int len = 1; len <= MaxLen; len++) + ASSERT_EQ(pump->peekBits(len), data(len)) << " Where len: " << len; + } +}; + +struct TestIncreasingPeekLengthNoFillTag; +template <typename T> +struct BitPumpPatternTest<T, TestIncreasingPeekLengthNoFillTag> { + using PumpT = typename T::PumpT; + using PatternT = typename T::PatternT; + + template <typename L> static void Test(PumpT* pump, L data) { + static const auto MaxLen = 28; + pump->fill(MaxLen); // Actually fills 32 bits + for (int len = 1; len <= MaxLen; len++) + ASSERT_EQ(pump->peekBitsNoFill(len), data(len)) + << " Where len: " << len; + } +}; + +template <typename T> class BitPumpTest : public ::testing::Test { +public: + using PumpT = typename T::PumpT; + using PatternT = typename T::PatternT; + +protected: + template <typename Tag, typename TestDataType, typename L> + void runTest(const TestDataType& data, L gen) { + const Buffer b(data.data(), data.size()); + + for (auto e : {Endianness::little, Endianness::big}) { + const DataBuffer db(b, e); + const ByteStream bs(db); + + PumpT pump(bs); + BitPumpPatternTest<T, Tag>::Test(&pump, gen); + } + } +}; + +TYPED_TEST_CASE_P(BitPumpTest); + +TYPED_TEST_P(BitPumpTest, GetTest) { + this->template runTest<TestGetBitsTag>(TypeParam::PatternT::Data, + TypeParam::PatternT::element); +} +TYPED_TEST_P(BitPumpTest, GetNoFillTest) { + this->template runTest<TestGetBitsNoFillTag>(TypeParam::PatternT::Data, + TypeParam::PatternT::element); +} +TYPED_TEST_P(BitPumpTest, PeekTest) { + this->template runTest<TestPeekBitsTag>(TypeParam::PatternT::Data, + TypeParam::PatternT::element); +} +TYPED_TEST_P(BitPumpTest, PeekNoFillTest) { + this->template runTest<TestPeekBitsNoFillTag>(TypeParam::PatternT::Data, + TypeParam::PatternT::element); +} +TYPED_TEST_P(BitPumpTest, IncreasingPeekLengthTest) { + this->template runTest<TestIncreasingPeekLengthTag>( + TypeParam::PatternT::Data, TypeParam::PatternT::data); +} +TYPED_TEST_P(BitPumpTest, IncreasingPeekLengthNoFillTest) { + this->template runTest<TestIncreasingPeekLengthNoFillTag>( + TypeParam::PatternT::Data, TypeParam::PatternT::data); +} + +REGISTER_TYPED_TEST_CASE_P(BitPumpTest, GetTest, GetNoFillTest, PeekTest, + PeekNoFillTest, IncreasingPeekLengthTest, + IncreasingPeekLengthNoFillTest); + +template <typename Pump, typename PatternTag> struct Pattern {}; + +struct ZerosTag; +template <typename Pump> struct Pattern<Pump, ZerosTag> { + static const std::array<rawspeed::uchar8, 4> Data; + static rawspeed::uint32 element(int index) { return 0U; } + static rawspeed::uint32 data(int len) { return 0U; } +}; +template <typename Pump> +const std::array<rawspeed::uchar8, 4> Pattern<Pump, ZerosTag>::Data{ + {/* zero-init */}}; + +struct OnesTag; +template <typename Pump> struct Pattern<Pump, OnesTag> { + static const std::array<rawspeed::uchar8, 4> Data; + static rawspeed::uint32 element(int index) { return 1U; } + static rawspeed::uint32 data(int len); +}; + +struct InvOnesTag; +template <typename Pump> struct Pattern<Pump, InvOnesTag> { + static const std::array<rawspeed::uchar8, 4> Data; + static rawspeed::uint32 element(int index) { return 1U << (index - 1U); } + static rawspeed::uint32 data(int len); +}; + +struct SaturatedTag; +template <typename Pump> struct Pattern<Pump, SaturatedTag> { + static const std::array<rawspeed::uchar8, 8> Data; + static rawspeed::uint32 element(int index) { return (1U << index) - 1U; } + static rawspeed::uint32 data(int len) { return (1U << len) - 1U; } +}; +template <typename Pump> +const std::array<rawspeed::uchar8, 8> Pattern<Pump, SaturatedTag>::Data{ + {rawspeed::uchar8(~0U), rawspeed::uchar8(~0U), rawspeed::uchar8(~0U), + rawspeed::uchar8(~0U)}}; + +auto GenOnesLE = [](int zerosToOutput, + int zerosOutputted) -> std::array<rawspeed::uint32, 29> { + std::array<rawspeed::uint32, 29> v; + rawspeed::uint32 bits = 0; + int currBit = -1; + for (auto& value : v) { + if (zerosToOutput == zerosOutputted) { + assert(currBit < 32); + bits |= 0b1 << currBit; + zerosToOutput++; + zerosOutputted = 0; + } + value = bits; + zerosOutputted++; + currBit++; + } + return v; +}; +auto GenOnesBE = [](int zerosToOutput, + int zerosOutputted) -> std::array<rawspeed::uint32, 29> { + std::array<rawspeed::uint32, 29> v; + rawspeed::uint32 bits = 0; + for (auto& value : v) { + if (zerosToOutput == zerosOutputted) { + bits |= 0b1; + zerosToOutput++; + zerosOutputted = 0; + } + value = bits; + zerosOutputted++; + bits <<= 1; + } + return v; +}; + +template <typename Pump, typename Pattern> struct PumpAndPattern { + using PumpT = Pump; + using PatternT = Pattern; +}; + +template <typename Pump> +using Patterns = + ::testing::Types<PumpAndPattern<Pump, Pattern<Pump, ZerosTag>>, + PumpAndPattern<Pump, Pattern<Pump, OnesTag>>, + PumpAndPattern<Pump, Pattern<Pump, InvOnesTag>>, + PumpAndPattern<Pump, Pattern<Pump, SaturatedTag>>>; + +} // namespace rawspeed_test diff --git a/src/external/rawspeed/test/librawspeed/io/CMakeLists.txt b/src/external/rawspeed/test/librawspeed/io/CMakeLists.txt index cc6ccfea9..480ddc4ec 100644 --- a/src/external/rawspeed/test/librawspeed/io/CMakeLists.txt +++ b/src/external/rawspeed/test/librawspeed/io/CMakeLists.txt @@ -1,4 +1,9 @@ FILE(GLOB RAWSPEED_TEST_SOURCES + "BitPumpJPEGTest.cpp" + "BitPumpLSBTest.cpp" + "BitPumpMSB16Test.cpp" + "BitPumpMSB32Test.cpp" + "BitPumpMSBTest.cpp" "EndiannessTest.cpp" ) diff --git a/src/external/rawspeed/test/librawspeed/io/EndiannessTest.cpp b/src/external/rawspeed/test/librawspeed/io/EndiannessTest.cpp index 94302e1d9..affb956f3 100644 --- a/src/external/rawspeed/test/librawspeed/io/EndiannessTest.cpp +++ b/src/external/rawspeed/test/librawspeed/io/EndiannessTest.cpp @@ -111,10 +111,10 @@ protected: AbstractGetByteSwappedTest() = default; virtual void SetUp() { auto p = this->GetParam(); - auto v = std::tr1::get<0>(p); + auto v = std::get<0>(p); // swap them around? the test is symmetrical - if (std::tr1::get<1>(p)) { + if (std::get<1>(p)) { memcpy(&in, &(v.first), sizeof(T2)); memcpy(&expected, &(v.second), sizeof(T2)); } else { diff --git a/src/external/rawspeed/test/librawspeed/io/EndiannessTest.h b/src/external/rawspeed/test/librawspeed/io/EndiannessTest.h index 9a47ba949..441f6d96a 100644 --- a/src/external/rawspeed/test/librawspeed/io/EndiannessTest.h +++ b/src/external/rawspeed/test/librawspeed/io/EndiannessTest.h @@ -35,7 +35,7 @@ template <typename T> struct intPair { }; using ushort16Type = intPair<ushort16>; -using ushort16TType = std::tr1::tuple<ushort16Type, bool>; +using ushort16TType = std::tuple<ushort16Type, bool>; static const ushort16Type ushort16Values[] = { {0x01cd, 0xcd01}, {0x024e, 0x4e02}, {0x0726, 0x2607}, {0x07e3, 0xe307}, {0x0857, 0x5708}, {0x0a0c, 0x0c0a}, {0x0a3c, 0x3c0a}, {0x0a5a, 0x5a0a}, @@ -104,7 +104,7 @@ static const ushort16Type ushort16Values[] = { }; using uint32Type = intPair<uint32>; -using uint32TType = std::tr1::tuple<uint32Type, bool>; +using uint32TType = std::tuple<uint32Type, bool>; static const uint32Type uint32Values[] = { {0x017c2230, 0x30227c01}, {0x03b26f3a, 0x3a6fb203}, {0x03e67a66, 0x667ae603}, {0x073bac8d, 0x8dac3b07}, @@ -237,7 +237,7 @@ static const uint32Type uint32Values[] = { }; using uint64Type = intPair<uint64>; -using uint64TType = std::tr1::tuple<uint64Type, bool>; +using uint64TType = std::tuple<uint64Type, bool>; static const uint64Type uint64Values[] = { {0x01a4f185910d9936, 0x36990d9185f1a401}, {0x030d4fdc9f4011b5, 0xb511409fdc4f0d03}, |