Skip to content

Commit 0d9fd0b

Browse files
committed
changed trunc and round to simpler forms, instead of the function call that was used before. This improved speed by decent amount
1 parent a209e38 commit 0d9fd0b

File tree

6 files changed

+60
-4
lines changed

6 files changed

+60
-4
lines changed

src/apps/apps.xcodeproj/xcshareddata/xcschemes/ojph_expand.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</Testables>
4141
</TestAction>
4242
<LaunchAction
43-
buildConfiguration = "Debug"
43+
buildConfiguration = "Release"
4444
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4545
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4646
launchStyle = "0"

src/apps/apps.xcodeproj/xcuserdata/aous.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,37 @@
5252
landmarkType = "0">
5353
</BreakpointContent>
5454
</BreakpointProxy>
55+
<BreakpointProxy
56+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
57+
<BreakpointContent
58+
uuid = "37CC6DAA-5E0A-44BB-9EE3-BBE83978793C"
59+
shouldBeEnabled = "No"
60+
ignoreCount = "0"
61+
continueAfterRunningActions = "No"
62+
filePath = "../core/transform/ojph_transform_avx.cpp"
63+
startingColumnNumber = "9223372036854775807"
64+
endingColumnNumber = "9223372036854775807"
65+
startingLineNumber = "288"
66+
endingLineNumber = "288"
67+
landmarkName = "avx_irrev_horz_wvlt_bwd_tx(dst, lsrc, hsrc, width, even)"
68+
landmarkType = "9">
69+
</BreakpointContent>
70+
</BreakpointProxy>
71+
<BreakpointProxy
72+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
73+
<BreakpointContent
74+
uuid = "8046ADD0-A6AF-47B8-A639-114F0AC9B88D"
75+
shouldBeEnabled = "No"
76+
ignoreCount = "0"
77+
continueAfterRunningActions = "No"
78+
filePath = "../core/codestream/ojph_codestream.cpp"
79+
startingColumnNumber = "9223372036854775807"
80+
endingColumnNumber = "9223372036854775807"
81+
startingLineNumber = "3031"
82+
endingLineNumber = "3031"
83+
landmarkName = "subband::push_line()"
84+
landmarkType = "7">
85+
</BreakpointContent>
86+
</BreakpointProxy>
5587
</Breakpoints>
5688
</Bucket>

src/core/codestream/ojph_codestream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,7 @@ namespace ojph {
30283028
si32 *dp = lines->i32;
30293029
for (int i = band_rect.siz.w; i > 0; --i)
30303030
{
3031-
si32 t = (si32)trunc(*sp++ * delta_inv);
3031+
si32 t = ojph_trunc(*sp++ * delta_inv);
30323032
si32 val = t >= 0 ? t : -t;
30333033
si32 sign = t >= 0 ? 0 : 0x80000000;
30343034
*dp++ = sign | val;

src/core/common/ojph_arch.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include <cstdio>
4343
#include <cstdint>
44+
#include <cmath>
4445

4546
#include "ojph_defs.h"
4647

@@ -122,6 +123,29 @@ namespace ojph {
122123
#endif
123124
}
124125

126+
////////////////////////////////////////////////////////////////////////////
127+
static inline si32 ojph_round(float val)
128+
{
129+
#ifdef OJPH_COMPILER_MSVC
130+
return (si32)(val + (val >= 0.0f ? 0.5f : -0.5f));
131+
#elif (defined OJPH_COMPILER_GNUC)
132+
return (si32)(val + (val >= 0.0f ? 0.5f : -0.5f));
133+
#else
134+
return (si32)round(float val);
135+
#endif
136+
}
137+
138+
////////////////////////////////////////////////////////////////////////////
139+
static inline si32 ojph_trunc(float val)
140+
{
141+
#ifdef OJPH_COMPILER_MSVC
142+
return (si32)(val);
143+
#elif (defined OJPH_COMPILER_GNUC)
144+
return (si32)(val);
145+
#else
146+
return (si32)trunc(float val);
147+
#endif
148+
}
125149

126150
////////////////////////////////////////////////////////////////////////////
127151
// constants

src/core/transform/ojph_colour.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ namespace ojph {
196196
int width)
197197
{
198198
for (int i = width; i > 0; --i)
199-
*dp++ = (si32)round((*sp++ + 0.5f) * mul);
199+
*dp++ = ojph_round((*sp++ + 0.5f) * mul);
200200
}
201201

202202
//////////////////////////////////////////////////////////////////////////
203203
void gen_cnvrt_float_to_si32(const float *sp, si32 *dp, float mul,
204204
int width)
205205
{
206206
for (int i = width; i > 0; --i)
207-
*dp++ = (si32)round(*sp++ * mul);
207+
*dp++ = ojph_round(*sp++ * mul);
208208
}
209209

210210
//////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)