Skip to content

Commit 965e74f

Browse files
committed
Updates, color encoding
1 parent 91f0c9f commit 965e74f

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

avif-coder/src/main/cpp/colorspace/DataSpaceToNCLX.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2023 Radzivon Bartoshyk
4+
* Copyright (c) 2024 Radzivon Bartoshyk
55
* avif-coder [https://github.com/awxkee/avif-coder]
66
*
77
* Created by Radzivon Bartoshyk on 07/03/2024

avif-coder/src/main/cpp/colorspace/eotf-inl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ namespace coder::HWY_NAMESPACE {
224224
}
225225

226226
HWY_FAST_MATH_INLINE float HLGEotf(float v) {
227-
v = max(0.0f, v);
227+
v = std::max(0.0f, v);
228228
constexpr float a = 0.17883277f;
229229
constexpr float b = 0.28466892f;
230230
constexpr float c = 0.55991073f;
@@ -237,7 +237,7 @@ namespace coder::HWY_NAMESPACE {
237237

238238
template<class D, typename T = Vec<D>, HWY_IF_FLOAT(TFromD<D>)>
239239
HWY_FAST_MATH_INLINE T dciP3PQGammaCorrection(const D d, T color) {
240-
const auto pw = Set(d, 1 / 2.6f);
240+
const auto pw = Set(d, 1.f / 2.6f);
241241
return coder::HWY_NAMESPACE::Pow(d, color, pw);
242242
}
243243

@@ -248,7 +248,7 @@ namespace coder::HWY_NAMESPACE {
248248
}
249249

250250
HWY_FAST_MATH_INLINE float dciP3PQGammaCorrection(float linear) {
251-
return std::powf(linear, 1 / 2.6f);
251+
return std::powf(linear, 1.f / 2.6f);
252252
}
253253

254254
HWY_FAST_MATH_INLINE float gammaOtf(float linear, const float gamma) {

avif-coder/src/main/cpp/imagebits/CopyUnalignedRGBA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace coder::HWY_NAMESPACE {
5757
Copy1Row(const D d, const Buf *HWY_RESTRICT src, Buf *HWY_RESTRICT dst, int width) {
5858
int x = 0;
5959
using VU = Vec<decltype(d)>;
60-
int pixels = d.MaxLanes();
60+
const int pixels = d.MaxLanes();
6161
for (; x + pixels < width; x += pixels) {
6262
VU a = LoadU(d, src);
6363
StoreU(a, d, reinterpret_cast<Buf *>(dst));

avif-coder/src/main/cpp/imagebits/Rgb565.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ namespace coder::HWY_NAMESPACE {
355355
void RGBAF16To565HWY(const uint16_t *sourceData, int srcStride,
356356
uint16_t *dst, int dstStride, int width,
357357
int height) {
358-
const float maxColors = powf(2, (float) 8) - 1;
358+
const float maxColors = std::powf(2.f, static_cast<float>(8.0f)) - 1.f;
359359

360360
auto mSrc = reinterpret_cast<const uint8_t *>(sourceData);
361361
auto mDst = reinterpret_cast<uint8_t *>(dst);

avif-coder/src/main/cpp/imagebits/RgbaU16toHF.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,7 @@ HWY_BEFORE_NAMESPACE();
4444

4545
namespace coder::HWY_NAMESPACE {
4646

47-
using hwy::HWY_NAMESPACE::ScalableTag;
48-
using hwy::HWY_NAMESPACE::Vec;
49-
using hwy::HWY_NAMESPACE::Set;
50-
using hwy::HWY_NAMESPACE::LoadU;
51-
using hwy::HWY_NAMESPACE::PromoteUpperTo;
52-
using hwy::HWY_NAMESPACE::PromoteLowerTo;
53-
using hwy::HWY_NAMESPACE::Mul;
54-
using hwy::HWY_NAMESPACE::Combine;
55-
using hwy::HWY_NAMESPACE::FixedTag;
56-
using hwy::HWY_NAMESPACE::DemoteTo;
57-
using hwy::HWY_NAMESPACE::ConvertTo;
58-
using hwy::HWY_NAMESPACE::StoreU;
47+
using namespace hwy::HWY_NAMESPACE;
5948
using hwy::float16_t;
6049
using hwy::float32_t;
6150

@@ -65,9 +54,9 @@ namespace coder::HWY_NAMESPACE {
6554
int x = 0;
6655
const ScalableTag<float16_t> df16;
6756
const ScalableTag<uint16_t> du16;
68-
const FixedTag<uint32_t, df16.MaxLanes() / 2> du32;
69-
const FixedTag<float32_t, df16.MaxLanes() / 2> df32;
70-
const FixedTag<float16_t, df16.MaxLanes() / 2> df16h;
57+
const Rebind<uint32_t, Half<decltype(df16)>> du32;
58+
const Rebind<float32_t, Half<decltype(df16)>> df32;
59+
const Rebind<float16_t, Half<decltype(df16)>> df16h;
7160
const int lanes = df16.MaxLanes();
7261
using VF16 = Vec<decltype(df16)>;
7362
using VU16 = Vec<decltype(du16)>;

avif-coder/src/main/cpp/imagebits/half.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
1-
//
2-
// Created by Radzivon Bartoshyk on 20/10/2023.
3-
//
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2023 Radzivon Bartoshyk
5+
* avif-coder [https://github.com/awxkee/avif-coder]
6+
*
7+
* Created by Radzivon Bartoshyk on 20/10/2023
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in all
17+
* copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
* SOFTWARE.
26+
*
27+
*/
28+
429
#include "half.hpp"
530

631
float LoadHalf(uint16_t f) {

0 commit comments

Comments
 (0)