@@ -106,11 +106,11 @@ struct RsqrtOutput {
106
106
}
107
107
108
108
/// Fixed point `rsqrt` for `ssim_boost`
109
- fn ssim_boost_rsqrt ( x : u64 ) -> RsqrtOutput {
109
+ const fn ssim_boost_rsqrt ( x : u64 ) -> RsqrtOutput {
110
110
const INSHIFT : u8 = 16 ;
111
111
const OUTSHIFT : u8 = 14 ;
112
112
113
- let k = ( ( ILog :: ilog ( x ) - 1 ) >> 1 ) as i16 ;
113
+ let k = ( x . ilog2 ( ) >> 1 ) as i16 ;
114
114
/*t is x in the range [0.25, 1) in QINSHIFT, or x*2^(-s).
115
115
Shift by log2(x) - log2(0.25*(1 << INSHIFT)) to ensure 0.25 lower bound.*/
116
116
let s: i16 = 2 * k - ( INSHIFT as i16 - 2 ) ;
@@ -140,7 +140,7 @@ fn ssim_boost_rsqrt(x: u64) -> RsqrtOutput {
140
140
Coefficients here, and the final result r, are Q14. */
141
141
let rsqrt: i32 = 23557 + mult16_16_q15 ( n, -13490 + mult16_16_q15 ( n, 6711 ) ) ;
142
142
143
- debug_assert ! ( ( 16384 .. 32768 ) . contains ( & rsqrt) ) ;
143
+ debug_assert ! ( 16384 <= rsqrt && rsqrt < 32768 ) ;
144
144
RsqrtOutput { norm : rsqrt as u16 , shift : rsqrt_shift }
145
145
}
146
146
@@ -156,7 +156,7 @@ pub fn ssim_boost(svar: u32, dvar: u32, bit_depth: usize) -> DistortionScale {
156
156
157
157
/// Apply ssim boost to a given input
158
158
#[ inline( always) ]
159
- pub fn apply_ssim_boost (
159
+ pub const fn apply_ssim_boost (
160
160
input : u32 , svar : u32 , dvar : u32 , bit_depth : usize ,
161
161
) -> u32 {
162
162
let coeff_shift = bit_depth - 8 ;
0 commit comments