diff --git a/ricepp/include/ricepp/bitstream_reader.h b/ricepp/include/ricepp/bitstream_reader.h index 7fb85f3d..386a0f48 100644 --- a/ricepp/include/ricepp/bitstream_reader.h +++ b/ricepp/include/ricepp/bitstream_reader.h @@ -155,8 +155,4 @@ class bitstream_reader final { iterator_type beg_, end_; }; -template -concept bitstream_reader_type = - std::same_as>; - } // namespace ricepp diff --git a/ricepp/include/ricepp/bitstream_writer.h b/ricepp/include/ricepp/bitstream_writer.h index 46c3b6f5..925a18d7 100644 --- a/ricepp/include/ricepp/bitstream_writer.h +++ b/ricepp/include/ricepp/bitstream_writer.h @@ -134,8 +134,4 @@ class bitstream_writer final { iterator_type out_; }; -template -concept bitstream_writer_type = - std::same_as>; - } // namespace ricepp diff --git a/ricepp/include/ricepp/codec.h b/ricepp/include/ricepp/codec.h index a202bf5b..4b039684 100644 --- a/ricepp/include/ricepp/codec.h +++ b/ricepp/include/ricepp/codec.h @@ -52,8 +52,9 @@ class codec final { : block_size_{block_size} , traits_{traits} {} - template - void encode(std::span input, W& writer) const { + template + void encode(std::span input, + BitstreamWriter& writer) const { assert(input.size() % kComponentStreamCount == 0); std::array last_value; @@ -77,8 +78,9 @@ class codec final { writer.flush(); } - template - void decode(std::span output, R& reader) const { + template + void + decode(std::span output, BitstreamReader& reader) const { assert(output.size() % kComponentStreamCount == 0); std::array last_value; diff --git a/ricepp/include/ricepp/detail/decode.h b/ricepp/include/ricepp/detail/decode.h index 62a23661..0a6dfee2 100644 --- a/ricepp/include/ricepp/detail/decode.h +++ b/ricepp/include/ricepp/detail/decode.h @@ -32,11 +32,11 @@ namespace ricepp::detail { template + typename BitstreamReader> requires std::unsigned_integral && std::same_as>, typename PixelTraits::value_type> -void decode_block(V block, R& reader, PixelTraits const& traits, +void decode_block(V block, BitstreamReader& reader, PixelTraits const& traits, typename PixelTraits::value_type& last_value) { using pixel_value_type = typename PixelTraits::value_type; static constexpr unsigned kPixelBits{PixelTraits::kBitCount}; diff --git a/ricepp/include/ricepp/detail/encode.h b/ricepp/include/ricepp/detail/encode.h index 7ec0ec53..ae3add63 100644 --- a/ricepp/include/ricepp/detail/encode.h +++ b/ricepp/include/ricepp/detail/encode.h @@ -80,11 +80,11 @@ compute_best_split(T const& delta, size_t size, uint64_t sum) noexcept { } template + typename BitstreamWriter> requires std::unsigned_integral && std::same_as>, typename PixelTraits::value_type> -void encode_block(V block, W& writer, PixelTraits const& traits, +void encode_block(V block, BitstreamWriter& writer, PixelTraits const& traits, typename PixelTraits::value_type& last_value) { using pixel_value_type = typename PixelTraits::value_type; static constexpr unsigned kPixelBits{PixelTraits::kBitCount}; @@ -99,6 +99,7 @@ void encode_block(V block, W& writer, PixelTraits const& traits, assert(block.size() <= MaxBlockSize); uint64_t sum{0}; + for (size_t i = 0; i < block.size(); ++i) { auto const pixel = traits.read(block[i]); auto const diff = static_cast(pixel - last);