@@ -16,36 +16,36 @@ export class InterpolatorConfig {
1616 overf = false ;
1717
1818 constructor ( value : number ) {
19- this . shift = ( value >>> 0 ) & 0b11111 ;
20- this . maskLSB = ( value >>> 5 ) & 0b11111 ;
21- this . maskMSB = ( value >>> 10 ) & 0b11111 ;
22- this . signed = Boolean ( ( value >>> 15 ) & 1 ) ;
23- this . crossInput = Boolean ( ( value >>> 16 ) & 1 ) ;
19+ this . shift = ( value >>> 0 ) & 0b11111 ;
20+ this . maskLSB = ( value >>> 5 ) & 0b11111 ;
21+ this . maskMSB = ( value >>> 10 ) & 0b11111 ;
22+ this . signed = Boolean ( ( value >>> 15 ) & 1 ) ;
23+ this . crossInput = Boolean ( ( value >>> 16 ) & 1 ) ;
2424 this . crossResult = Boolean ( ( value >>> 17 ) & 1 ) ;
25- this . addRaw = Boolean ( ( value >>> 18 ) & 1 ) ;
26- this . forceMSB = ( value >>> 19 ) & 0b11 ;
27- this . blend = Boolean ( ( value >>> 21 ) & 1 ) ;
28- this . clamp = Boolean ( ( value >>> 22 ) & 1 ) ;
29- this . overf0 = Boolean ( ( value >>> 23 ) & 1 ) ;
30- this . overf1 = Boolean ( ( value >>> 24 ) & 1 ) ;
31- this . overf = Boolean ( ( value >>> 25 ) & 1 ) ;
25+ this . addRaw = Boolean ( ( value >>> 18 ) & 1 ) ;
26+ this . forceMSB = ( value >>> 19 ) & 0b11 ;
27+ this . blend = Boolean ( ( value >>> 21 ) & 1 ) ;
28+ this . clamp = Boolean ( ( value >>> 22 ) & 1 ) ;
29+ this . overf0 = Boolean ( ( value >>> 23 ) & 1 ) ;
30+ this . overf1 = Boolean ( ( value >>> 24 ) & 1 ) ;
31+ this . overf = Boolean ( ( value >>> 25 ) & 1 ) ;
3232 }
3333
3434 toUint32 ( ) {
3535 return (
36- ( ( this . shift & 0b11111 ) << 0 ) |
37- ( ( this . maskLSB & 0b11111 ) << 5 ) |
38- ( ( this . maskMSB & 0b11111 ) << 10 ) |
39- ( ( Number ( this . signed ) & 1 ) << 15 ) |
40- ( ( Number ( this . crossInput ) & 1 ) << 16 ) |
41- ( ( Number ( this . crossResult ) & 1 ) << 17 ) |
42- ( ( Number ( this . addRaw ) & 1 ) << 18 ) |
43- ( ( this . forceMSB & 0b11 ) << 19 ) |
44- ( ( Number ( this . blend ) & 1 ) << 21 ) |
45- ( ( Number ( this . clamp ) & 1 ) << 22 ) |
46- ( ( Number ( this . overf0 ) & 1 ) << 23 ) |
47- ( ( Number ( this . overf1 ) & 1 ) << 24 ) |
48- ( ( Number ( this . overf ) & 1 ) << 25 )
36+ ( ( this . shift & 0b11111 ) << 0 ) |
37+ ( ( this . maskLSB & 0b11111 ) << 5 ) |
38+ ( ( this . maskMSB & 0b11111 ) << 10 ) |
39+ ( ( Number ( this . signed ) & 1 ) << 15 ) |
40+ ( ( Number ( this . crossInput ) & 1 ) << 16 ) |
41+ ( ( Number ( this . crossResult ) & 1 ) << 17 ) |
42+ ( ( Number ( this . addRaw ) & 1 ) << 18 ) |
43+ ( ( this . forceMSB & 0b11 ) << 19 ) |
44+ ( ( Number ( this . blend ) & 1 ) << 21 ) |
45+ ( ( Number ( this . clamp ) & 1 ) << 22 ) |
46+ ( ( Number ( this . overf0 ) & 1 ) << 23 ) |
47+ ( ( Number ( this . overf1 ) & 1 ) << 24 ) |
48+ ( ( Number ( this . overf ) & 1 ) << 25 )
4949 ) ;
5050 }
5151}
@@ -99,8 +99,8 @@ export class Interpolator {
9999 const overf1 = Boolean ( ( input1 >>> ctrl1 . shift ) & ~ msbmask1 ) ;
100100 const overf = overf0 || overf1 ;
101101
102- const sextmask0 = ( uresult0 & ( 1 << ctrl0 . maskMSB ) ) ? ( - 1 << ctrl0 . maskMSB ) : 0 ;
103- const sextmask1 = ( uresult1 & ( 1 << ctrl1 . maskMSB ) ) ? ( - 1 << ctrl1 . maskMSB ) : 0 ;
102+ const sextmask0 = uresult0 & ( 1 << ctrl0 . maskMSB ) ? - 1 << ctrl0 . maskMSB : 0 ;
103+ const sextmask1 = uresult1 & ( 1 << ctrl1 . maskMSB ) ? - 1 << ctrl1 . maskMSB : 0 ;
104104
105105 const sresult0 = uresult0 | sextmask0 ;
106106 const sresult1 = uresult1 | sextmask1 ;
@@ -112,18 +112,32 @@ export class Interpolator {
112112 const addresult1 = this . base1 + ( ctrl1 . addRaw ? input1 : result1 ) ;
113113 const addresult2 = this . base2 + result0 + ( do_blend ? 0 : result1 ) ;
114114
115- const uclamp0 = u32 ( result0 ) < u32 ( this . base0 ) ? this . base0 : ( u32 ( result0 ) > u32 ( this . base1 ) ? this . base1 : result0 ) ;
116- const sclamp0 = s32 ( result0 ) < s32 ( this . base0 ) ? this . base0 : ( s32 ( result0 ) > s32 ( this . base1 ) ? this . base1 : result0 ) ;
115+ const uclamp0 =
116+ u32 ( result0 ) < u32 ( this . base0 )
117+ ? this . base0
118+ : u32 ( result0 ) > u32 ( this . base1 )
119+ ? this . base1
120+ : result0 ;
121+ const sclamp0 =
122+ s32 ( result0 ) < s32 ( this . base0 )
123+ ? this . base0
124+ : s32 ( result0 ) > s32 ( this . base1 )
125+ ? this . base1
126+ : result0 ;
117127 const clamp0 = ctrl0 . signed ? sclamp0 : uclamp0 ;
118128
119129 const alpha1 = result1 & 0xff ;
120- const ublend1 = u32 ( this . base0 ) + ( Math . floor ( ( alpha1 * ( u32 ( this . base1 ) - u32 ( this . base0 ) ) ) / 256 ) | 0 ) ;
121- const sblend1 = s32 ( this . base0 ) + ( Math . floor ( ( alpha1 * ( s32 ( this . base1 ) - s32 ( this . base0 ) ) ) / 256 ) | 0 ) ;
130+ const ublend1 =
131+ u32 ( this . base0 ) + ( Math . floor ( ( alpha1 * ( u32 ( this . base1 ) - u32 ( this . base0 ) ) ) / 256 ) | 0 ) ;
132+ const sblend1 =
133+ s32 ( this . base0 ) + ( Math . floor ( ( alpha1 * ( s32 ( this . base1 ) - s32 ( this . base0 ) ) ) / 256 ) | 0 ) ;
122134 const blend1 = ctrl1 . signed ? sblend1 : ublend1 ;
123135
124136 this . smresult0 = u32 ( result0 ) ;
125137 this . smresult1 = u32 ( result1 ) ;
126- this . result0 = u32 ( do_blend ? alpha1 : ( do_clamp ? clamp0 : addresult0 ) | ( ctrl0 . forceMSB << 28 ) ) ;
138+ this . result0 = u32 (
139+ do_blend ? alpha1 : ( do_clamp ? clamp0 : addresult0 ) | ( ctrl0 . forceMSB << 28 )
140+ ) ;
127141 this . result1 = u32 ( ( do_blend ? blend1 : addresult1 ) | ( ctrl0 . forceMSB << 28 ) ) ;
128142 this . result2 = u32 ( addresult2 ) ;
129143
0 commit comments