mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibGfx/JPEG2000/IDWT: Call PSE only when needed in _1D_EXTR
Takes `Build/lagom/bin/image -o out.tiff ~/Downloads/balloon.jpf` from
586.0 ms ± 5.6 ms to 547.7 ms ± 5.1 ms under hyperfine on my system
(6.6% less). When run under `/usr/bin/time -l`, the changes are:
Before:
14557698316 instructions retired
2500654210 cycles elapsed
After:
13958498350 instructions retired
2318667968 cycles elapsed
The lossless files goes from 1.025 s to 1.000 s (likely smaller win
because it's half the dimensions).
(Note that the "from" hyperfine number is pretty different from the
previous commit, probably due to my system being under different load,
at different battery level, or what. But the "instructions retired"
are very comparable, so that's probably a better number to look at.)
This commit is contained in:
1 parent
23925266f3
commit
83a0675316
1 file changed
+7
-1
@@ -275,7 +275,13 @@ 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)));
|
||||
};
|
||||
|
||||
for (int l = i0 - i_left, i = 0; l < i1 + i_right; ++l, ++i)
|
||||
// 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];
|
||||
for (int l = i0; l < i1; ++l, ++i)
|
||||
buffers.scanline_buffer[buffers.scanline_runway + i] = a.data[start + (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];
|
||||
|
||||
buffers.scanline_start = buffers.scanline_runway + i_left;
|
||||
|
||||
Reference in new issue
Block a user