mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-17 16:31:27 -04:00
refactor: we no longer need a concept for bitstream reader/writer
This commit is contained in:
parent
27f0fd8d46
commit
afe34ed8cf
@ -155,8 +155,4 @@ class bitstream_reader final {
|
||||
iterator_type beg_, end_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept bitstream_reader_type =
|
||||
std::same_as<T, bitstream_reader<typename T::iterator_type>>;
|
||||
|
||||
} // namespace ricepp
|
||||
|
@ -134,8 +134,4 @@ class bitstream_writer final {
|
||||
iterator_type out_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept bitstream_writer_type =
|
||||
std::same_as<T, bitstream_writer<typename T::iterator_type>>;
|
||||
|
||||
} // namespace ricepp
|
||||
|
@ -52,8 +52,9 @@ class codec final {
|
||||
: block_size_{block_size}
|
||||
, traits_{traits} {}
|
||||
|
||||
template <bitstream_writer_type W>
|
||||
void encode(std::span<pixel_value_type const> input, W& writer) const {
|
||||
template <typename BitstreamWriter>
|
||||
void encode(std::span<pixel_value_type const> input,
|
||||
BitstreamWriter& writer) const {
|
||||
assert(input.size() % kComponentStreamCount == 0);
|
||||
|
||||
std::array<pixel_value_type, kComponentStreamCount> last_value;
|
||||
@ -77,8 +78,9 @@ class codec final {
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
template <bitstream_reader_type R>
|
||||
void decode(std::span<pixel_value_type> output, R& reader) const {
|
||||
template <typename BitstreamReader>
|
||||
void
|
||||
decode(std::span<pixel_value_type> output, BitstreamReader& reader) const {
|
||||
assert(output.size() % kComponentStreamCount == 0);
|
||||
|
||||
std::array<pixel_value_type, kComponentStreamCount> last_value;
|
||||
|
@ -32,11 +32,11 @@
|
||||
namespace ricepp::detail {
|
||||
|
||||
template <size_t MaxBlockSize, typename PixelTraits, ranges::viewable_range V,
|
||||
bitstream_reader_type R>
|
||||
typename BitstreamReader>
|
||||
requires std::unsigned_integral<typename PixelTraits::value_type> &&
|
||||
std::same_as<ranges::range_value_t<std::decay_t<V>>,
|
||||
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};
|
||||
|
@ -80,11 +80,11 @@ compute_best_split(T const& delta, size_t size, uint64_t sum) noexcept {
|
||||
}
|
||||
|
||||
template <size_t MaxBlockSize, typename PixelTraits, ranges::viewable_range V,
|
||||
bitstream_writer_type W>
|
||||
typename BitstreamWriter>
|
||||
requires std::unsigned_integral<typename PixelTraits::value_type> &&
|
||||
std::same_as<ranges::range_value_t<std::decay_t<V>>,
|
||||
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_value_type>(pixel - last);
|
||||
|
Loading…
x
Reference in New Issue
Block a user