Skip to content

Commit b2d214d

Browse files
committed
Replace direct array access with iterator approach
1 parent 74f86ad commit b2d214d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/arch/ssse3.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ pub unsafe fn dequantize_and_idct_block_8x8(
148148

149149
// Read the DCT coefficients, scale them up and dequantize them.
150150
let mut data = [_mm_setzero_si128(); 8];
151-
for i in 0..8 {
152-
data[i] = _mm_slli_epi16(
151+
for (i, item) in data.iter_mut().enumerate() {
152+
*item = _mm_slli_epi16(
153153
_mm_mullo_epi16(
154154
_mm_loadu_si128(coefficients.as_ptr().wrapping_add(i * 8) as *const _),
155155
_mm_loadu_si128(quantization_table.as_ptr().wrapping_add(i * 8) as *const _),
@@ -164,7 +164,7 @@ pub unsafe fn dequantize_and_idct_block_8x8(
164164
idct8(&mut data);
165165
transpose8(&mut data);
166166

167-
for i in 0..8 {
167+
for (i, item) in data.iter_mut().enumerate() {
168168
let mut buf = [0u8; 16];
169169
// The two passes of the IDCT algorithm give us a factor of 8, so the shift here is
170170
// increased by 3.
@@ -174,7 +174,7 @@ pub unsafe fn dequantize_and_idct_block_8x8(
174174
// We want rounding right shift, so we should add (1/2) << (SHIFT+3) before shifting.
175175
const ROUNDING_BIAS: i16 = (1 << (SHIFT + 3)) >> 1;
176176

177-
let data_with_offset = _mm_adds_epi16(data[i], _mm_set1_epi16(OFFSET + ROUNDING_BIAS));
177+
let data_with_offset = _mm_adds_epi16(*item, _mm_set1_epi16(OFFSET + ROUNDING_BIAS));
178178

179179
_mm_storeu_si128(
180180
buf.as_mut_ptr() as *mut _,

0 commit comments

Comments
 (0)