Enable -Wconversion
This commit is contained in:
parent
5be8298d0a
commit
b28fa86e6a
23 changed files with 102 additions and 78 deletions
14
third_party/blurhash/blurhash.cpp
vendored
14
third_party/blurhash/blurhash.cpp
vendored
|
|
@ -4,6 +4,7 @@
|
|||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
|
|
@ -17,9 +18,6 @@
|
|||
using namespace std::literals;
|
||||
|
||||
namespace {
|
||||
template<class T>
|
||||
T pi = 3.14159265358979323846;
|
||||
|
||||
constexpr std::array<char, 84> int_to_b83{
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~"};
|
||||
|
||||
|
|
@ -93,7 +91,7 @@ decode83(std::string_view value)
|
|||
float
|
||||
decodeMaxAC(int quantizedMaxAC) noexcept
|
||||
{
|
||||
return (quantizedMaxAC + 1) / 166.;
|
||||
return static_cast<float>(quantizedMaxAC + 1) / 166.f;
|
||||
}
|
||||
|
||||
float
|
||||
|
|
@ -123,7 +121,7 @@ srgbToLinear(int value) noexcept
|
|||
return std::pow((x + 0.055f) / 1.055f, 2.4f);
|
||||
};
|
||||
|
||||
return srgbToLinearF(value / 255.f);
|
||||
return srgbToLinearF(static_cast<float>(value) / 255.f);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -234,7 +232,7 @@ std::vector<float>
|
|||
bases_for(size_t dimension, size_t components)
|
||||
{
|
||||
std::vector<float> bases(dimension * components, 0.f);
|
||||
auto scale = pi<float> / float(dimension);
|
||||
auto scale = std::numbers::pi_v<float> / float(dimension);
|
||||
for (size_t x = 0; x < dimension; x++) {
|
||||
for (size_t nx = 0; nx < size_t(components); nx++) {
|
||||
bases[x * components + nx] = std::cos(scale * float(nx * x));
|
||||
|
|
@ -323,7 +321,7 @@ encode(unsigned char *image, size_t width, size_t height, int components_x, int
|
|||
srgbToLinear(image[3 * x + 2 + y * width * 3])};
|
||||
|
||||
// other half of normalization.
|
||||
linear *= 1.f / width;
|
||||
linear *= 1.f / static_cast<float>(width);
|
||||
|
||||
for (size_t ny = 0; ny < size_t(components_y); ny++) {
|
||||
for (size_t nx = 0; nx < size_t(components_x); nx++) {
|
||||
|
|
@ -339,7 +337,7 @@ encode(unsigned char *image, size_t width, size_t height, int components_x, int
|
|||
// too far outside the float range.
|
||||
for (size_t i = 0; i < factors.size(); i++) {
|
||||
float normalisation = (i == 0) ? 1 : 2;
|
||||
float scale = normalisation / (height);
|
||||
float scale = normalisation / static_cast<float>(height);
|
||||
factors[i] *= scale;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue