blob: 8ea8d11d5efb850fe2dbca13838c94683a7a093e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Macros.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// The macros.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Helpers
{
/// <summary>
/// The macros.
/// </summary>
public class Macros
{
/// <summary>
/// The even.
/// #define EVEN( a ) ( (a) + ( (a) & 1 ) )
/// </summary>
/// <param name="a">
/// The a.
/// </param>
/// <returns>
/// The <see cref="bool"/>.
/// </returns>
public static bool Even(int a)
{
return (a) + ((a) & 1) == 1;
}
/// <summary>
/// The multipl e_ mo d_ down.
/// #define MULTIPLE_MOD_DOWN( a, b ) ((b==1)?a:( b * ( (a) / b ) ))
/// </summary>
/// <param name="a">
/// The a.
/// </param>
/// <param name="b">
/// The b.
/// </param>
/// <returns>
/// The <see cref="double"/>.
/// </returns>
public static int MultipleModDown(int a, int b)
{
return (b == 1) ? a : (b * ((a) / b));
}
/// <summary>
/// The multiple mod up.
/// #define MULTIPLE_MOD_UP( a, b ) ((b==1)?a:( b * ( ( (a) + (b) - 1) / b ) ))
/// </summary>
/// <param name="a">
/// The a.
/// </param>
/// <param name="b">
/// The b.
/// </param>
/// <returns>
/// The <see cref="double"/>.
/// </returns>
public static int MultipleModUp(int a, int b)
{
return (b == 1) ? a : (b * (((a) + (b) - 1) / b));
}
/// <summary>
/// The multiple of mod x
/// #define MULTIPLE_MOD( a, b ) ((b==1)?a:( b * ( ( (a) + (b / 2) - 1) / b ) ))
/// </summary>
/// <param name="a">
/// The a.
/// </param>
/// <param name="b">
/// The b.
/// </param>
/// <returns>
/// The <see cref="double"/>.
/// </returns>
public static int MultipleMod(int a, int b)
{
return (b == 1) ? a : (b * (((a) + (b / 2) - 1) / b));
}
/// <summary>
/// The multiple of 16.
/// #define MULTIPLE_16( a ) ( 16 * ( ( (a) + 8 ) / 16 ) )
/// </summary>
/// <param name="a">
/// The a.
/// </param>
/// <returns>
/// The <see cref="bool"/>.
/// </returns>
public static bool Multiple16(int a)
{
return 16 * (((a) + 8) / 16) == 1;
}
}
}
|