diff options
Diffstat (limited to 'lib/jxl/transpose-inl.h')
-rw-r--r-- | lib/jxl/transpose-inl.h | 124 |
1 files changed, 63 insertions, 61 deletions
diff --git a/lib/jxl/transpose-inl.h b/lib/jxl/transpose-inl.h index d12b129..4674420 100644 --- a/lib/jxl/transpose-inl.h +++ b/lib/jxl/transpose-inl.h @@ -74,50 +74,51 @@ JXL_INLINE_TRANSPOSE void GenericTransposeBlock(TransposeSimdTag<true>, static_assert(COLS_or_0 % 8 == 0, "Invalid number of columns"); for (size_t n = 0; n < ROWS; n += 8) { for (size_t m = 0; m < COLS; m += 8) { - auto i0 = from.LoadPart(BlockDesc<8>(), n + 0, m + 0); - auto i1 = from.LoadPart(BlockDesc<8>(), n + 1, m + 0); - auto i2 = from.LoadPart(BlockDesc<8>(), n + 2, m + 0); - auto i3 = from.LoadPart(BlockDesc<8>(), n + 3, m + 0); - auto i4 = from.LoadPart(BlockDesc<8>(), n + 4, m + 0); - auto i5 = from.LoadPart(BlockDesc<8>(), n + 5, m + 0); - auto i6 = from.LoadPart(BlockDesc<8>(), n + 6, m + 0); - auto i7 = from.LoadPart(BlockDesc<8>(), n + 7, m + 0); + const BlockDesc<8> d; + auto i0 = from.LoadPart(d, n + 0, m + 0); + auto i1 = from.LoadPart(d, n + 1, m + 0); + auto i2 = from.LoadPart(d, n + 2, m + 0); + auto i3 = from.LoadPart(d, n + 3, m + 0); + auto i4 = from.LoadPart(d, n + 4, m + 0); + auto i5 = from.LoadPart(d, n + 5, m + 0); + auto i6 = from.LoadPart(d, n + 6, m + 0); + auto i7 = from.LoadPart(d, n + 7, m + 0); // Surprisingly, this straightforward implementation (24 cycles on port5) // is faster than load128+insert and LoadDup128+ConcatUpperLower+blend. - const auto q0 = InterleaveLower(i0, i2); - const auto q1 = InterleaveLower(i1, i3); - const auto q2 = InterleaveUpper(i0, i2); - const auto q3 = InterleaveUpper(i1, i3); - const auto q4 = InterleaveLower(i4, i6); - const auto q5 = InterleaveLower(i5, i7); - const auto q6 = InterleaveUpper(i4, i6); - const auto q7 = InterleaveUpper(i5, i7); - - const auto r0 = InterleaveLower(q0, q1); - const auto r1 = InterleaveUpper(q0, q1); - const auto r2 = InterleaveLower(q2, q3); - const auto r3 = InterleaveUpper(q2, q3); - const auto r4 = InterleaveLower(q4, q5); - const auto r5 = InterleaveUpper(q4, q5); - const auto r6 = InterleaveLower(q6, q7); - const auto r7 = InterleaveUpper(q6, q7); - - i0 = ConcatLowerLower(r4, r0); - i1 = ConcatLowerLower(r5, r1); - i2 = ConcatLowerLower(r6, r2); - i3 = ConcatLowerLower(r7, r3); - i4 = ConcatUpperUpper(r4, r0); - i5 = ConcatUpperUpper(r5, r1); - i6 = ConcatUpperUpper(r6, r2); - i7 = ConcatUpperUpper(r7, r3); - to.StorePart(BlockDesc<8>(), i0, m + 0, n + 0); - to.StorePart(BlockDesc<8>(), i1, m + 1, n + 0); - to.StorePart(BlockDesc<8>(), i2, m + 2, n + 0); - to.StorePart(BlockDesc<8>(), i3, m + 3, n + 0); - to.StorePart(BlockDesc<8>(), i4, m + 4, n + 0); - to.StorePart(BlockDesc<8>(), i5, m + 5, n + 0); - to.StorePart(BlockDesc<8>(), i6, m + 6, n + 0); - to.StorePart(BlockDesc<8>(), i7, m + 7, n + 0); + const auto q0 = InterleaveLower(d, i0, i2); + const auto q1 = InterleaveLower(d, i1, i3); + const auto q2 = InterleaveUpper(d, i0, i2); + const auto q3 = InterleaveUpper(d, i1, i3); + const auto q4 = InterleaveLower(d, i4, i6); + const auto q5 = InterleaveLower(d, i5, i7); + const auto q6 = InterleaveUpper(d, i4, i6); + const auto q7 = InterleaveUpper(d, i5, i7); + + const auto r0 = InterleaveLower(d, q0, q1); + const auto r1 = InterleaveUpper(d, q0, q1); + const auto r2 = InterleaveLower(d, q2, q3); + const auto r3 = InterleaveUpper(d, q2, q3); + const auto r4 = InterleaveLower(d, q4, q5); + const auto r5 = InterleaveUpper(d, q4, q5); + const auto r6 = InterleaveLower(d, q6, q7); + const auto r7 = InterleaveUpper(d, q6, q7); + + i0 = ConcatLowerLower(d, r4, r0); + i1 = ConcatLowerLower(d, r5, r1); + i2 = ConcatLowerLower(d, r6, r2); + i3 = ConcatLowerLower(d, r7, r3); + i4 = ConcatUpperUpper(d, r4, r0); + i5 = ConcatUpperUpper(d, r5, r1); + i6 = ConcatUpperUpper(d, r6, r2); + i7 = ConcatUpperUpper(d, r7, r3); + to.StorePart(d, i0, m + 0, n + 0); + to.StorePart(d, i1, m + 1, n + 0); + to.StorePart(d, i2, m + 2, n + 0); + to.StorePart(d, i3, m + 3, n + 0); + to.StorePart(d, i4, m + 4, n + 0); + to.StorePart(d, i5, m + 5, n + 0); + to.StorePart(d, i6, m + 6, n + 0); + to.StorePart(d, i7, m + 7, n + 0); } } } @@ -137,25 +138,26 @@ JXL_INLINE_TRANSPOSE void GenericTransposeBlock(TransposeSimdTag<true>, static_assert(COLS_or_0 % 4 == 0, "Invalid number of columns"); for (size_t n = 0; n < ROWS; n += 4) { for (size_t m = 0; m < COLS; m += 4) { - const auto p0 = from.LoadPart(BlockDesc<4>(), n + 0, m + 0); - const auto p1 = from.LoadPart(BlockDesc<4>(), n + 1, m + 0); - const auto p2 = from.LoadPart(BlockDesc<4>(), n + 2, m + 0); - const auto p3 = from.LoadPart(BlockDesc<4>(), n + 3, m + 0); - - const auto q0 = InterleaveLower(p0, p2); - const auto q1 = InterleaveLower(p1, p3); - const auto q2 = InterleaveUpper(p0, p2); - const auto q3 = InterleaveUpper(p1, p3); - - const auto r0 = InterleaveLower(q0, q1); - const auto r1 = InterleaveUpper(q0, q1); - const auto r2 = InterleaveLower(q2, q3); - const auto r3 = InterleaveUpper(q2, q3); - - to.StorePart(BlockDesc<4>(), r0, m + 0, n + 0); - to.StorePart(BlockDesc<4>(), r1, m + 1, n + 0); - to.StorePart(BlockDesc<4>(), r2, m + 2, n + 0); - to.StorePart(BlockDesc<4>(), r3, m + 3, n + 0); + const BlockDesc<4> d; + const auto p0 = from.LoadPart(d, n + 0, m + 0); + const auto p1 = from.LoadPart(d, n + 1, m + 0); + const auto p2 = from.LoadPart(d, n + 2, m + 0); + const auto p3 = from.LoadPart(d, n + 3, m + 0); + + const auto q0 = InterleaveLower(d, p0, p2); + const auto q1 = InterleaveLower(d, p1, p3); + const auto q2 = InterleaveUpper(d, p0, p2); + const auto q3 = InterleaveUpper(d, p1, p3); + + const auto r0 = InterleaveLower(d, q0, q1); + const auto r1 = InterleaveUpper(d, q0, q1); + const auto r2 = InterleaveLower(d, q2, q3); + const auto r3 = InterleaveUpper(d, q2, q3); + + to.StorePart(d, r0, m + 0, n + 0); + to.StorePart(d, r1, m + 1, n + 0); + to.StorePart(d, r2, m + 2, n + 0); + to.StorePart(d, r3, m + 3, n + 0); } } } |