@@ -42,7 +42,7 @@ fn test_choose_idct_size() {
42
42
assert_eq ! ( choose_idct_size( Dimensions { width: 5472 , height: 3648 } , Dimensions { width: 16384 , height: 16384 } ) , 8 ) ;
43
43
}
44
44
45
- pub ( crate ) fn dequantize_and_idct_block ( scale : usize , coefficients : & [ i16 ] , quantization_table : & [ u16 ; 64 ] , output_linestride : usize , output : & mut [ u8 ] ) {
45
+ pub ( crate ) fn dequantize_and_idct_block ( scale : usize , coefficients : & [ i16 ; 64 ] , quantization_table : & [ u16 ; 64 ] , output_linestride : usize , output : & mut [ u8 ] ) {
46
46
match scale {
47
47
8 => dequantize_and_idct_block_8x8 ( coefficients, quantization_table, output_linestride, output) ,
48
48
4 => dequantize_and_idct_block_4x4 ( coefficients, quantization_table, output_linestride, output) ,
@@ -53,7 +53,7 @@ pub(crate) fn dequantize_and_idct_block(scale: usize, coefficients: &[i16], quan
53
53
}
54
54
55
55
pub fn dequantize_and_idct_block_8x8 (
56
- coefficients : & [ i16 ] ,
56
+ coefficients : & [ i16 ; 64 ] ,
57
57
quantization_table : & [ u16 ; 64 ] ,
58
58
output_linestride : usize ,
59
59
output : & mut [ u8 ]
@@ -65,7 +65,7 @@ pub fn dequantize_and_idct_block_8x8(
65
65
66
66
// This is based on stb_image's 'stbi__idct_block'.
67
67
fn dequantize_and_idct_block_8x8_inner < ' a , I > (
68
- coefficients : & [ i16 ] ,
68
+ coefficients : & [ i16 ; 64 ] ,
69
69
quantization_table : & [ u16 ; 64 ] ,
70
70
output : I ,
71
71
) where
@@ -79,9 +79,6 @@ fn dequantize_and_idct_block_8x8_inner<'a, I>(
79
79
output. len( )
80
80
) ;
81
81
82
- // optimizer hint to eliminate bounds checks within loops
83
- assert ! ( coefficients. len( ) == 64 ) ;
84
-
85
82
let mut temp = [ Wrapping ( 0 ) ; 64 ] ;
86
83
87
84
// columns
@@ -260,8 +257,7 @@ fn dequantize(c: i16, q: u16) -> Wrapping<i32> {
260
257
261
258
// 4x4 and 2x2 IDCT based on Rakesh Dugad and Narendra Ahuja: "A Fast Scheme for Image Size Change in the Compressed Domain" (2001).
262
259
// http://sylvana.net/jpegcrop/jidctred/
263
- fn dequantize_and_idct_block_4x4 ( coefficients : & [ i16 ] , quantization_table : & [ u16 ; 64 ] , output_linestride : usize , output : & mut [ u8 ] ) {
264
- debug_assert_eq ! ( coefficients. len( ) , 64 ) ;
260
+ fn dequantize_and_idct_block_4x4 ( coefficients : & [ i16 ; 64 ] , quantization_table : & [ u16 ; 64 ] , output_linestride : usize , output : & mut [ u8 ] ) {
265
261
let mut temp = [ Wrapping ( 0i32 ) ; 4 * 4 ] ;
266
262
267
263
const CONST_BITS : usize = 12 ;
@@ -317,9 +313,7 @@ fn dequantize_and_idct_block_4x4(coefficients: &[i16], quantization_table: &[u16
317
313
}
318
314
}
319
315
320
- fn dequantize_and_idct_block_2x2 ( coefficients : & [ i16 ] , quantization_table : & [ u16 ; 64 ] , output_linestride : usize , output : & mut [ u8 ] ) {
321
- debug_assert_eq ! ( coefficients. len( ) , 64 ) ;
322
-
316
+ fn dequantize_and_idct_block_2x2 ( coefficients : & [ i16 ; 64 ] , quantization_table : & [ u16 ; 64 ] , output_linestride : usize , output : & mut [ u8 ] ) {
323
317
const SCALE_BITS : usize = 3 ;
324
318
325
319
// Column 0
@@ -348,9 +342,7 @@ fn dequantize_and_idct_block_2x2(coefficients: &[i16], quantization_table: &[u16
348
342
output[ output_linestride + 1 ] = stbi_clamp ( ( x2 - x3) >> SCALE_BITS ) ;
349
343
}
350
344
351
- fn dequantize_and_idct_block_1x1 ( coefficients : & [ i16 ] , quantization_table : & [ u16 ; 64 ] , _output_linestride : usize , output : & mut [ u8 ] ) {
352
- debug_assert_eq ! ( coefficients. len( ) , 64 ) ;
353
-
345
+ fn dequantize_and_idct_block_1x1 ( coefficients : & [ i16 ; 64 ] , quantization_table : & [ u16 ; 64 ] , _output_linestride : usize , output : & mut [ u8 ] ) {
354
346
let s0 = ( Wrapping ( coefficients[ 0 ] as i32 * quantization_table[ 0 ] as i32 ) + Wrapping ( 128 * 8 ) ) / Wrapping ( 8 ) ;
355
347
output[ 0 ] = stbi_clamp ( s0) ;
356
348
}
0 commit comments