pcm/{Traits,Dsd*}: use std::byte
This commit is contained in:
@@ -8,7 +8,7 @@ GenerateBitReverseTable() noexcept
|
||||
{
|
||||
BitReverseTable table{};
|
||||
for (unsigned i = 0; i < 256; ++i)
|
||||
table.data[i] = BitReverseMultiplyModulus(i);
|
||||
table.data[i] = BitReverseMultiplyModulus(static_cast<std::byte>(i));
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#ifndef MPD_BIT_REVERSE_HXX
|
||||
#define MPD_BIT_REVERSE_HXX
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @see http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv
|
||||
*/
|
||||
constexpr uint8_t
|
||||
BitReverseMultiplyModulus(uint8_t _in) noexcept
|
||||
constexpr std::byte
|
||||
BitReverseMultiplyModulus(std::byte _in) noexcept
|
||||
{
|
||||
uint64_t in = _in;
|
||||
return uint8_t((in * 0x0202020202ULL & 0x010884422010ULL) % 1023);
|
||||
uint64_t in = static_cast<uint64_t>(_in);
|
||||
return static_cast<std::byte>((in * 0x0202020202ULL & 0x010884422010ULL) % 1023);
|
||||
}
|
||||
|
||||
/* in order to avoid including <array> in this header, this `struct`
|
||||
is a workaround for GenerateBitReverseTable() being able to return
|
||||
the plain array */
|
||||
struct BitReverseTable {
|
||||
uint8_t data[256];
|
||||
std::byte data[256];
|
||||
};
|
||||
|
||||
extern const BitReverseTable bit_reverse_table;
|
||||
|
||||
[[gnu::const]]
|
||||
static inline uint8_t
|
||||
bit_reverse(uint8_t x) noexcept
|
||||
static inline std::byte
|
||||
BitReverse(std::byte x) noexcept
|
||||
{
|
||||
return bit_reverse_table.data[x];
|
||||
return bit_reverse_table.data[static_cast<std::size_t>(x)];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user