diff options
Diffstat (limited to 'OpenSim/Framework/OpenJpeg/int_.cs')
-rw-r--r-- | OpenSim/Framework/OpenJpeg/int_.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/OpenSim/Framework/OpenJpeg/int_.cs b/OpenSim/Framework/OpenJpeg/int_.cs new file mode 100644 index 0000000..dc71728 --- /dev/null +++ b/OpenSim/Framework/OpenJpeg/int_.cs | |||
@@ -0,0 +1,58 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.Framework.OpenJpeg | ||
6 | { | ||
7 | public static class int_ | ||
8 | { | ||
9 | public static int int_min(int a, int b) | ||
10 | { | ||
11 | return a < b ? a : b; | ||
12 | } | ||
13 | |||
14 | public static int int_max(int a, int b) | ||
15 | { | ||
16 | return (a > b) ? a : b; | ||
17 | } | ||
18 | |||
19 | public static int int_clamp(int a, int min, int max) | ||
20 | { | ||
21 | if (a < min) | ||
22 | return min; | ||
23 | if (a > max) | ||
24 | return max; | ||
25 | |||
26 | return a; | ||
27 | } | ||
28 | |||
29 | public static int int_abs(int a) | ||
30 | { | ||
31 | return a < 0 ? -a : a; | ||
32 | } | ||
33 | |||
34 | public static int int_ceildiv(int a, int b) | ||
35 | { | ||
36 | return (a + b - 1) / b; | ||
37 | } | ||
38 | |||
39 | public static int int_ceildivpow2(int a, int b) | ||
40 | { | ||
41 | return (a + (1 << b) - 1) >> b; | ||
42 | } | ||
43 | |||
44 | public static int int_floordivpow2(int a, int b) | ||
45 | { | ||
46 | return a >> b; | ||
47 | } | ||
48 | |||
49 | public static int int_floorlog2(int a) | ||
50 | { | ||
51 | for (int l=0; a > 1; l++) | ||
52 | a >>= 1; | ||
53 | |||
54 | return 1; | ||
55 | } | ||
56 | |||
57 | } | ||
58 | } | ||