Skip to content

Commit 6d9720c

Browse files
committed
clang-format
Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com>
1 parent 3d06cf8 commit 6d9720c

File tree

4 files changed

+76
-81
lines changed

4 files changed

+76
-81
lines changed

src/libOpenImageIO/imagebufalgo_addsub.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,18 @@ add_impl_hwy_native_int(ImageBuf& R, const ImageBuf& A, const ImageBuf& B,
7272
ROI roi, int nthreads)
7373
{
7474
return hwy_binary_native_int_perpixel_op<T>(R, A, B, roi, nthreads,
75-
[](auto /*d*/, auto a, auto b) {
76-
return hn::SaturatedAdd(a, b);
77-
});
75+
[](auto /*d*/, auto a, auto b) {
76+
return hn::SaturatedAdd(a,
77+
b);
78+
});
7879
}
7980

8081
template<class Rtype, class Atype, class Btype>
8182
static bool
8283
add_impl_hwy(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
8384
int nthreads)
8485
{
85-
auto op = [](auto /*d*/, auto a, auto b) {
86-
return hn::Add(a, b);
87-
};
86+
auto op = [](auto /*d*/, auto a, auto b) { return hn::Add(a, b); };
8887

8988
// Handle packed RGBA images with an RGB ROI (preserve alpha).
9089
if constexpr (std::is_integral_v<Rtype> && std::is_same_v<Rtype, Atype>
@@ -93,8 +92,8 @@ add_impl_hwy(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
9392
return hn::SaturatedAdd(a, b);
9493
};
9594
if (hwy_binary_native_int_perpixel_op_rgba_rgb_roi<Rtype>(R, A, B, roi,
96-
nthreads,
97-
op_int))
95+
nthreads,
96+
op_int))
9897
return true;
9998
}
10099
if (hwy_binary_perpixel_op_rgba_rgb_roi<Rtype, Atype, Btype>(R, A, B, roi,
@@ -142,9 +141,9 @@ add_impl(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
142141
#if defined(OIIO_USE_HWY) && OIIO_USE_HWY
143142
if (OIIO::pvt::enable_hwy && R.localpixels() && A.localpixels()
144143
&& B.localpixels()) {
145-
auto Rv = HwyPixels(R);
146-
auto Av = HwyPixels(A);
147-
auto Bv = HwyPixels(B);
144+
auto Rv = HwyPixels(R);
145+
auto Av = HwyPixels(A);
146+
auto Bv = HwyPixels(B);
148147
const int nchannels = RoiNChannels(roi);
149148
const bool contig = ChannelsContiguous<Rtype>(Rv, nchannels)
150149
&& ChannelsContiguous<Atype>(Av, nchannels)
@@ -196,19 +195,18 @@ sub_impl_hwy_native_int(ImageBuf& R, const ImageBuf& A, const ImageBuf& B,
196195
ROI roi, int nthreads)
197196
{
198197
return hwy_binary_native_int_perpixel_op<T>(R, A, B, roi, nthreads,
199-
[](auto /*d*/, auto a, auto b) {
200-
return hn::SaturatedSub(a, b);
201-
});
198+
[](auto /*d*/, auto a, auto b) {
199+
return hn::SaturatedSub(a,
200+
b);
201+
});
202202
}
203203

204204
template<class Rtype, class Atype, class Btype>
205205
static bool
206206
sub_impl_hwy(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
207207
int nthreads)
208208
{
209-
auto op = [](auto /*d*/, auto a, auto b) {
210-
return hn::Sub(a, b);
211-
};
209+
auto op = [](auto /*d*/, auto a, auto b) { return hn::Sub(a, b); };
212210

213211
// Handle packed RGBA images with an RGB ROI (preserve alpha).
214212
if constexpr (std::is_integral_v<Rtype> && std::is_same_v<Rtype, Atype>
@@ -217,8 +215,8 @@ sub_impl_hwy(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
217215
return hn::SaturatedSub(a, b);
218216
};
219217
if (hwy_binary_native_int_perpixel_op_rgba_rgb_roi<Rtype>(R, A, B, roi,
220-
nthreads,
221-
op_int))
218+
nthreads,
219+
op_int))
222220
return true;
223221
}
224222
if (hwy_binary_perpixel_op_rgba_rgb_roi<Rtype, Atype, Btype>(R, A, B, roi,
@@ -243,9 +241,9 @@ sub_impl(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
243241
#if defined(OIIO_USE_HWY) && OIIO_USE_HWY
244242
if (OIIO::pvt::enable_hwy && R.localpixels() && A.localpixels()
245243
&& B.localpixels()) {
246-
auto Rv = HwyPixels(R);
247-
auto Av = HwyPixels(A);
248-
auto Bv = HwyPixels(B);
244+
auto Rv = HwyPixels(R);
245+
auto Av = HwyPixels(A);
246+
auto Bv = HwyPixels(B);
249247
const int nchannels = RoiNChannels(roi);
250248
const bool contig = ChannelsContiguous<Rtype>(Rv, nchannels)
251249
&& ChannelsContiguous<Atype>(Av, nchannels)

src/libOpenImageIO/imagebufalgo_hwy_pvt.h

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ LoadInterleaved4PromoteN(D d, const SrcT* ptr, size_t count);
132132
template<class D, typename DstT, typename VecMathT, typename VecAlphaLaneT>
133133
inline void
134134
StoreInterleaved4RgbAlphaPassthrough(D d, DstT* ptr, VecMathT r, VecMathT g,
135-
VecMathT b,
136-
VecAlphaLaneT a_passthrough);
135+
VecMathT b, VecAlphaLaneT a_passthrough);
137136

138137
// -----------------------------------------------------------------------
139138
// Load and Promote
@@ -267,8 +266,8 @@ PromoteVec(D d, VecT v)
267266
return hn::Mul(v_promoted, hn::Set(d, (MathT)(1.0 / 4294967295.0)));
268267
} else if constexpr (std::is_same_v<SrcT, int32_t>) {
269268
auto v_promoted = hn::ConvertTo(d, v);
270-
auto v_norm = hn::Mul(v_promoted,
271-
hn::Set(d, (MathT)(1.0 / 2147483647.0)));
269+
auto v_norm = hn::Mul(v_promoted,
270+
hn::Set(d, (MathT)(1.0 / 2147483647.0)));
272271
return hn::Max(v_norm, hn::Set(d, (MathT)-1.0));
273272
} else if constexpr (std::is_same_v<SrcT, uint64_t>) {
274273
auto d_u32 = hn::Rebind<uint32_t, D>();
@@ -551,10 +550,10 @@ DemoteVec(D d, VecT v)
551550
auto d_u8 = hn::Rebind<uint8_t, D>();
552551
return hn::DemoteTo(d_u8, v_i16);
553552
} else if constexpr (std::is_same_v<DstT, int8_t>) {
554-
VecD v_denorm = hn::Mul((VecD)v, hn::Set(d, (MathT)127.0));
555-
auto is_neg = hn::Lt(v_denorm, hn::Zero(d));
556-
auto v_bias = hn::IfThenElse(is_neg, hn::Set(d, (MathT)-0.5),
557-
hn::Set(d, (MathT)0.5));
553+
VecD v_denorm = hn::Mul((VecD)v, hn::Set(d, (MathT)127.0));
554+
auto is_neg = hn::Lt(v_denorm, hn::Zero(d));
555+
auto v_bias = hn::IfThenElse(is_neg, hn::Set(d, (MathT)-0.5),
556+
hn::Set(d, (MathT)0.5));
558557
VecD v_rounded = hn::Add(v_denorm, v_bias);
559558
VecD v_clamped = hn::Max(v_rounded, hn::Set(d, (MathT)-128.0));
560559
v_clamped = hn::Min(v_clamped, hn::Set(d, (MathT)127.0));
@@ -576,10 +575,10 @@ DemoteVec(D d, VecT v)
576575
auto d_u16 = hn::Rebind<uint16_t, D>();
577576
return hn::DemoteTo(d_u16, vi32);
578577
} else if constexpr (std::is_same_v<DstT, int16_t>) {
579-
VecD v_denorm = hn::Mul((VecD)v, hn::Set(d, (MathT)32767.0));
580-
auto is_neg = hn::Lt(v_denorm, hn::Zero(d));
581-
auto v_bias = hn::IfThenElse(is_neg, hn::Set(d, (MathT)-0.5),
582-
hn::Set(d, (MathT)0.5));
578+
VecD v_denorm = hn::Mul((VecD)v, hn::Set(d, (MathT)32767.0));
579+
auto is_neg = hn::Lt(v_denorm, hn::Zero(d));
580+
auto v_bias = hn::IfThenElse(is_neg, hn::Set(d, (MathT)-0.5),
581+
hn::Set(d, (MathT)0.5));
583582
VecD v_rounded = hn::Add(v_denorm, v_bias);
584583
VecD v_clamped = hn::Max(v_rounded, hn::Set(d, (MathT)-32768.0));
585584
v_clamped = hn::Min(v_clamped, hn::Set(d, (MathT)32767.0));
@@ -595,10 +594,10 @@ DemoteVec(D d, VecT v)
595594
auto d_u32 = hn::Rebind<uint32_t, D>();
596595
return hn::ConvertTo(d_u32, v_clamped);
597596
} else if constexpr (std::is_same_v<DstT, int32_t>) {
598-
VecD v_denorm = hn::Mul((VecD)v, hn::Set(d, (MathT)2147483647.0));
599-
auto is_neg = hn::Lt(v_denorm, hn::Zero(d));
600-
auto v_bias = hn::IfThenElse(is_neg, hn::Set(d, (MathT)-0.5),
601-
hn::Set(d, (MathT)0.5));
597+
VecD v_denorm = hn::Mul((VecD)v, hn::Set(d, (MathT)2147483647.0));
598+
auto is_neg = hn::Lt(v_denorm, hn::Zero(d));
599+
auto v_bias = hn::IfThenElse(is_neg, hn::Set(d, (MathT)-0.5),
600+
hn::Set(d, (MathT)0.5));
602601
VecD v_rounded = hn::Add(v_denorm, v_bias);
603602
VecD v_clamped = hn::Max(v_rounded, hn::Set(d, (MathT)-2147483648.0));
604603
v_clamped = hn::Min(v_clamped, hn::Set(d, (MathT)2147483647.0));
@@ -932,15 +931,15 @@ RunHwyTernaryCmd(Rtype* r, const ABCtype* a, const ABCtype* b, const ABCtype* c,
932931
/// covers the full pixel).
933932
template<typename Rtype, typename Atype, typename Btype, typename OpFunc>
934933
inline bool
935-
hwy_binary_perpixel_op(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
936-
int nthreads, OpFunc op)
934+
hwy_binary_perpixel_op(ImageBuf& R, const ImageBuf& A, const ImageBuf& B,
935+
ROI roi, int nthreads, OpFunc op)
937936
{
938937
auto Rv = HwyPixels(R);
939938
auto Av = HwyPixels(A);
940939
auto Bv = HwyPixels(B);
941940
ImageBufAlgo::parallel_image(roi, nthreads, [&, op](ROI roi) {
942941
const int nchannels = RoiNChannels(roi);
943-
const size_t n = static_cast<size_t>(roi.width())
942+
const size_t n = static_cast<size_t>(roi.width())
944943
* static_cast<size_t>(nchannels);
945944
for (int y = roi.ybegin; y < roi.yend; ++y) {
946945
Rtype* r_row = RoiRowPtr<Rtype>(Rv, y, roi);
@@ -967,7 +966,7 @@ hwy_ternary_perpixel_op(ImageBuf& R, const ImageBuf& A, const ImageBuf& B,
967966
auto Cv = HwyPixels(C);
968967
ImageBufAlgo::parallel_image(roi, nthreads, [&, op](ROI roi) {
969968
const int nchannels = RoiNChannels(roi);
970-
const size_t n = static_cast<size_t>(roi.width())
969+
const size_t n = static_cast<size_t>(roi.width())
971970
* static_cast<size_t>(nchannels);
972971
for (int y = roi.ybegin; y < roi.yend; ++y) {
973972
Rtype* r_row = RoiRowPtr<Rtype>(Rv, y, roi);
@@ -994,7 +993,7 @@ hwy_binary_native_int_perpixel_op(ImageBuf& R, const ImageBuf& A,
994993
auto Bv = HwyPixels(B);
995994
ImageBufAlgo::parallel_image(roi, nthreads, [&, op](ROI roi) {
996995
const int nchannels = RoiNChannels(roi);
997-
const size_t n = static_cast<size_t>(roi.width())
996+
const size_t n = static_cast<size_t>(roi.width())
998997
* static_cast<size_t>(nchannels);
999998
for (int y = roi.ybegin; y < roi.yend; ++y) {
1000999
T* r_row = RoiRowPtr<T>(Rv, y, roi);
@@ -1063,9 +1062,9 @@ hwy_binary_perpixel_op_rgba_rgb_roi(ImageBuf& R, const ImageBuf& A,
10631062

10641063
ImageBufAlgo::parallel_image(roi4, nthreads, [&, op](ROI roi4) {
10651064
for (int y = roi4.ybegin; y < roi4.yend; ++y) {
1066-
Rtype* r_row = RoiRowPtr<Rtype>(Rv, y, roi4);
1067-
const Atype* a_row = RoiRowPtr<Atype>(Av, y, roi4);
1068-
const Btype* b_row = RoiRowPtr<Btype>(Bv, y, roi4);
1065+
Rtype* r_row = RoiRowPtr<Rtype>(Rv, y, roi4);
1066+
const Atype* a_row = RoiRowPtr<Atype>(Av, y, roi4);
1067+
const Btype* b_row = RoiRowPtr<Btype>(Bv, y, roi4);
10691068
const size_t npixels = static_cast<size_t>(roi4.width());
10701069

10711070
size_t x = 0;
@@ -1081,8 +1080,8 @@ hwy_binary_perpixel_op_rgba_rgb_roi(ImageBuf& R, const ImageBuf& A,
10811080
auto d_dstlane = hn::Rebind<DstLaneT, decltype(d)>();
10821081
hn::Vec<decltype(d_dstlane)> dr, dg, db, da;
10831082
hn::LoadInterleaved4(d_dstlane,
1084-
reinterpret_cast<const DstLaneT*>(
1085-
r_row + off),
1083+
reinterpret_cast<const DstLaneT*>(r_row
1084+
+ off),
10861085
dr, dg, db, da);
10871086
(void)dr;
10881087
(void)dg;
@@ -1097,11 +1096,11 @@ hwy_binary_perpixel_op_rgba_rgb_roi(ImageBuf& R, const ImageBuf& A,
10971096

10981097
const size_t remaining = npixels - x;
10991098
if (remaining > 0) {
1100-
const size_t off = x * 4;
1101-
auto [ar, ag, ab, aa]
1102-
= LoadInterleaved4PromoteN(d, a_row + off, remaining);
1103-
auto [br, bg, bb, ba]
1104-
= LoadInterleaved4PromoteN(d, b_row + off, remaining);
1099+
const size_t off = x * 4;
1100+
auto [ar, ag, ab, aa] = LoadInterleaved4PromoteN(d, a_row + off,
1101+
remaining);
1102+
auto [br, bg, bb, ba] = LoadInterleaved4PromoteN(d, b_row + off,
1103+
remaining);
11051104
(void)aa;
11061105
(void)ba;
11071106
auto rr = op(d, ar, br);
@@ -1170,8 +1169,8 @@ hwy_ternary_perpixel_op_rgba_rgb_roi(ImageBuf& R, const ImageBuf& A,
11701169
auto d_dstlane = hn::Rebind<DstLaneT, decltype(d)>();
11711170
hn::Vec<decltype(d_dstlane)> dr, dg, db, da;
11721171
hn::LoadInterleaved4(d_dstlane,
1173-
reinterpret_cast<const DstLaneT*>(
1174-
r_row + off),
1172+
reinterpret_cast<const DstLaneT*>(r_row
1173+
+ off),
11751174
dr, dg, db, da);
11761175
(void)dr;
11771176
(void)dg;
@@ -1186,13 +1185,13 @@ hwy_ternary_perpixel_op_rgba_rgb_roi(ImageBuf& R, const ImageBuf& A,
11861185

11871186
const size_t remaining = npixels - x;
11881187
if (remaining > 0) {
1189-
const size_t off = x * 4;
1190-
auto [ar, ag, ab, aa]
1191-
= LoadInterleaved4PromoteN(d, a_row + off, remaining);
1192-
auto [br, bg, bb, ba]
1193-
= LoadInterleaved4PromoteN(d, b_row + off, remaining);
1194-
auto [cr, cg, cb, ca]
1195-
= LoadInterleaved4PromoteN(d, c_row + off, remaining);
1188+
const size_t off = x * 4;
1189+
auto [ar, ag, ab, aa] = LoadInterleaved4PromoteN(d, a_row + off,
1190+
remaining);
1191+
auto [br, bg, bb, ba] = LoadInterleaved4PromoteN(d, b_row + off,
1192+
remaining);
1193+
auto [cr, cg, cb, ca] = LoadInterleaved4PromoteN(d, c_row + off,
1194+
remaining);
11961195
(void)aa;
11971196
(void)ba;
11981197
(void)ca;
@@ -1246,7 +1245,7 @@ hwy_binary_native_int_perpixel_op_rgba_rgb_roi(ImageBuf& R, const ImageBuf& A,
12461245
T* r_row = RoiRowPtr<T>(Rv, y, roi4);
12471246
const T* a_row = RoiRowPtr<T>(Av, y, roi4);
12481247
const T* b_row = RoiRowPtr<T>(Bv, y, roi4);
1249-
size_t i = 0;
1248+
size_t i = 0;
12501249
for (; i + lanes <= n; i += lanes) {
12511250
auto va = hn::Load(d, a_row + i);
12521251
auto vb = hn::Load(d, b_row + i);

src/libOpenImageIO/imagebufalgo_mad.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ mad_impl_hwy(ImageBuf& R, const ImageBuf& A, const ImageBuf& B,
5656
return hn::MulAdd(a, b, c);
5757
};
5858

59-
if (hwy_ternary_perpixel_op_rgba_rgb_roi<Rtype, ABCtype>(
60-
R, A, B, C, roi, nthreads, op))
59+
if (hwy_ternary_perpixel_op_rgba_rgb_roi<Rtype, ABCtype>(R, A, B, C, roi,
60+
nthreads, op))
6161
return true;
6262

6363
return hwy_ternary_perpixel_op<Rtype, ABCtype>(R, A, B, C, roi, nthreads,
@@ -73,10 +73,10 @@ mad_impl(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, const ImageBuf& C,
7373
#if defined(OIIO_USE_HWY) && OIIO_USE_HWY
7474
if (OIIO::pvt::enable_hwy && R.localpixels() && A.localpixels()
7575
&& B.localpixels() && C.localpixels()) {
76-
auto Rv = HwyPixels(R);
77-
auto Av = HwyPixels(A);
78-
auto Bv = HwyPixels(B);
79-
auto Cv = HwyPixels(C);
76+
auto Rv = HwyPixels(R);
77+
auto Av = HwyPixels(A);
78+
auto Bv = HwyPixels(B);
79+
auto Cv = HwyPixels(C);
8080
const int nchannels = RoiNChannels(roi);
8181
const bool contig = ChannelsContiguous<Rtype>(Rv, nchannels)
8282
&& ChannelsContiguous<ABCtype>(Av, nchannels)

src/libOpenImageIO/imagebufalgo_muldiv.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ static bool
131131
mul_impl_hwy(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
132132
int nthreads)
133133
{
134-
auto op = [](auto /*d*/, auto a, auto b) {
135-
return hn::Mul(a, b);
136-
};
134+
auto op = [](auto /*d*/, auto a, auto b) { return hn::Mul(a, b); };
137135

138136
if (hwy_binary_perpixel_op_rgba_rgb_roi<Rtype, Atype, Btype>(R, A, B, roi,
139137
nthreads, op))
@@ -180,9 +178,9 @@ mul_impl(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
180178
#if defined(OIIO_USE_HWY) && OIIO_USE_HWY
181179
if (OIIO::pvt::enable_hwy && R.localpixels() && A.localpixels()
182180
&& B.localpixels()) {
183-
auto Rv = HwyPixels(R);
184-
auto Av = HwyPixels(A);
185-
auto Bv = HwyPixels(B);
181+
auto Rv = HwyPixels(R);
182+
auto Av = HwyPixels(A);
183+
auto Bv = HwyPixels(B);
186184
const int nchannels = RoiNChannels(roi);
187185
const bool contig = ChannelsContiguous<Rtype>(Rv, nchannels)
188186
&& ChannelsContiguous<Atype>(Av, nchannels)
@@ -323,9 +321,9 @@ div_impl_hwy(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
323321
int nthreads)
324322
{
325323
auto op = [](auto d, auto a, auto b) {
326-
const auto zero = hn::Zero(d);
327-
const auto nz = hn::Ne(b, zero);
328-
const auto one = hn::Set(d, 1);
324+
const auto zero = hn::Zero(d);
325+
const auto nz = hn::Ne(b, zero);
326+
const auto one = hn::Set(d, 1);
329327
const auto safe_b = hn::IfThenElse(nz, b, one);
330328
const auto q = hn::Div(a, safe_b);
331329
return hn::IfThenElse(nz, q, zero);
@@ -348,9 +346,9 @@ div_impl(ImageBuf& R, const ImageBuf& A, const ImageBuf& B, ROI roi,
348346
#if defined(OIIO_USE_HWY) && OIIO_USE_HWY
349347
if (OIIO::pvt::enable_hwy && R.localpixels() && A.localpixels()
350348
&& B.localpixels()) {
351-
auto Rv = HwyPixels(R);
352-
auto Av = HwyPixels(A);
353-
auto Bv = HwyPixels(B);
349+
auto Rv = HwyPixels(R);
350+
auto Av = HwyPixels(A);
351+
auto Bv = HwyPixels(B);
354352
const int nchannels = RoiNChannels(roi);
355353
const bool contig = ChannelsContiguous<Rtype>(Rv, nchannels)
356354
&& ChannelsContiguous<Atype>(Av, nchannels)

0 commit comments

Comments
 (0)