mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibGfx/JPEG2000/IDWT: Use raw pointers instead of op[] in _1D_EXTR
Takes `Build/lagom/bin/image -o out.tiff ~/Downloads/balloon.jpf` from
542.3 ms ± 7.0 ms to 527.2 ms ± 4.7 ms under hyperfine on my system
(2.7% less). When run under `/usr/bin/time -l`, the changes are:
Before:
13956342230 instructions retired
2322276362 cycles elapsed
After:
13251294364 instructions retired
2270195534 cycles elapsed
The absolute win on the lossless file is again a bit smaller
(due to smaller image dimensions), and the relative win is tiny
there (due to it spending much more time in bitplane decoding and
less in IDWT).
This commit is contained in:
1 parent
83a0675316
commit
32a71fa3aa
1 file changed
+9
-3
@@ -275,14 +275,20 @@ inline void _1D_EXTR(Transformation transformation, IDWTOutput& a, int start, in
|
||||
return i0 + min(mod(i - i0, 2 * (i1 - i0 - 1)), 2 * (i1 - i0 - 1) - mod(i - i0, 2 * (i1 - i0 - 1)));
|
||||
};
|
||||
|
||||
VERIFY(static_cast<int>(buffers.scanline_buffer.size()) >= buffers.scanline_runway + (i1 - i0) + 8);
|
||||
float* dst = buffers.scanline_buffer.data() + buffers.scanline_runway;
|
||||
|
||||
VERIFY(start + (i1 - 1 - i0) * delta <= static_cast<int>(a.data.size()));
|
||||
float const* src = a.data.data() + start;
|
||||
|
||||
// PSE is the identity function for i0 <= i < i1, so only call it on the edges.
|
||||
int i = 0;
|
||||
for (int l = i0 - i_left; l < i0; ++l, ++i)
|
||||
buffers.scanline_buffer[buffers.scanline_runway + i] = a.data[start + (PSE(l, i0, i1) - i0) * delta];
|
||||
dst[i] = src[(PSE(l, i0, i1) - i0) * delta];
|
||||
for (int l = i0; l < i1; ++l, ++i)
|
||||
buffers.scanline_buffer[buffers.scanline_runway + i] = a.data[start + (l - i0) * delta];
|
||||
dst[i] = src[(l - i0) * delta];
|
||||
for (int l = i1; l < i1 + i_right; ++l, ++i)
|
||||
buffers.scanline_buffer[buffers.scanline_runway + i] = a.data[start + (PSE(l, i0, i1) - i0) * delta];
|
||||
dst[i] = src[(PSE(l, i0, i1) - i0) * delta];
|
||||
|
||||
buffers.scanline_start = buffers.scanline_runway + i_left;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user