@@ -28,21 +28,21 @@ public abstract class ArithmeticCoderBase {
28
28
* <li>But for state sizes greater than the midpoint, because intermediate computations are limited
29
29
* to the long integer type's 63-bit unsigned precision, larger state sizes will decrease the
30
30
* maximum frequency total, which might constrain the user-supplied probability model.</li>
31
- * <li>Therefore STATE_SIZE =32 is recommended as the most versatile setting
31
+ * <li>Therefore numStateBits =32 is recommended as the most versatile setting
32
32
* because it maximizes MAX_TOTAL (which ends up being slightly over 2^30).</li>
33
- * <li>Note that STATE_SIZE =62 is legal but useless because it implies MAX_TOTAL=1,
33
+ * <li>Note that numStateBits =62 is legal but useless because it implies MAX_TOTAL=1,
34
34
* which means a frequency table can only support one symbol with non-zero frequency.</li>
35
35
* </ul>
36
36
*/
37
- protected final int STATE_SIZE ;
37
+ protected final int numStateBits ;
38
38
39
- /** Maximum range (high+1-low) during coding (trivial), which is 2^STATE_SIZE = 1000...000. */
39
+ /** Maximum range (high+1-low) during coding (trivial), which is 2^numStateBits = 1000...000. */
40
40
protected final long MAX_RANGE ;
41
41
42
- /** The top bit at width STATE_SIZE , which is 0100...000. */
42
+ /** The top bit at width numStateBits , which is 0100...000. */
43
43
protected final long TOP_MASK ;
44
44
45
- /** The second highest bit at width STATE_SIZE , which is 0010...000. This is zero when STATE_SIZE =1. */
45
+ /** The second highest bit at width numStateBits , which is 0010...000. This is zero when numStateBits =1. */
46
46
protected final long SECOND_MASK ;
47
47
48
48
/** Minimum range (high+1-low) during coding (non-trivial), which is 0010...010. */
@@ -51,7 +51,7 @@ public abstract class ArithmeticCoderBase {
51
51
/** Maximum allowed total from a frequency table at all times during coding. */
52
52
protected final long MAX_TOTAL ;
53
53
54
- /** Bit mask of STATE_SIZE ones, which is 0111...111. */
54
+ /** Bit mask of numStateBits ones, which is 0111...111. */
55
55
protected final long MASK ;
56
56
57
57
@@ -80,8 +80,8 @@ public abstract class ArithmeticCoderBase {
80
80
public ArithmeticCoderBase (int stateSize ) {
81
81
if (stateSize < 1 || stateSize > 62 )
82
82
throw new IllegalArgumentException ("State size out of range" );
83
- STATE_SIZE = stateSize ;
84
- MAX_RANGE = 1L << STATE_SIZE ;
83
+ numStateBits = stateSize ;
84
+ MAX_RANGE = 1L << numStateBits ;
85
85
TOP_MASK = MAX_RANGE >>> 1 ;
86
86
SECOND_MASK = TOP_MASK >>> 1 ;
87
87
MIN_RANGE = (MAX_RANGE >>> 2 ) + 2 ;
@@ -101,14 +101,14 @@ public ArithmeticCoderBase(int stateSize) {
101
101
* of processing the specified symbol with the specified frequency table.
102
102
* <p>Invariants that are true before and after encoding/decoding each symbol:</p>
103
103
* <ul>
104
- * <li>0 ≤ low ≤ code ≤ high < 2<sup>STATE_SIZE </sup>. ('code' exists only in the decoder.)
105
- * Therefore these variables are unsigned integers of STATE_SIZE bits.</li>
106
- * <li>(low < 1/2 * 2<sup>STATE_SIZE </sup>) && (high ≥ 1/2 * 2<sup>STATE_SIZE </sup>).
104
+ * <li>0 ≤ low ≤ code ≤ high < 2<sup>numStateBits </sup>. ('code' exists only in the decoder.)
105
+ * Therefore these variables are unsigned integers of numStateBits bits.</li>
106
+ * <li>(low < 1/2 * 2<sup>numStateBits </sup>) && (high ≥ 1/2 * 2<sup>numStateBits </sup>).
107
107
* In other words, they are in different halves of the full range.</li>
108
- * <li>(low < 1/4 * 2<sup>STATE_SIZE </sup>) || (high ≥ 3/4 * 2<sup>STATE_SIZE </sup>).
108
+ * <li>(low < 1/4 * 2<sup>numStateBits </sup>) || (high ≥ 3/4 * 2<sup>numStateBits </sup>).
109
109
* In other words, they are not both in the middle two quarters.</li>
110
110
* <li>Let range = high − low + 1, then MAX_RANGE/4 < MIN_RANGE ≤ range
111
- * ≤ MAX_RANGE = 2<sup>STATE_SIZE </sup>. These invariants for 'range' essentially dictate the maximum
111
+ * ≤ MAX_RANGE = 2<sup>numStateBits </sup>. These invariants for 'range' essentially dictate the maximum
112
112
* total that the incoming frequency table can have, such that intermediate calculations don't overflow.</li>
113
113
* </ul>
114
114
* @param freqs the frequency table to use
0 commit comments