#![allow(unused_assignments, unused_mut, unused_parens, clippy::all)]
const COSPI_1_64: i64 = 16364;
const COSPI_2_64: i64 = 16305;
const COSPI_3_64: i64 = 16207;
const COSPI_4_64: i64 = 16069;
const COSPI_5_64: i64 = 15893;
const COSPI_6_64: i64 = 15679;
const COSPI_7_64: i64 = 15426;
const COSPI_8_64: i64 = 15137;
const COSPI_9_64: i64 = 14811;
const COSPI_10_64: i64 = 14449;
const COSPI_11_64: i64 = 14053;
const COSPI_12_64: i64 = 13623;
const COSPI_13_64: i64 = 13160;
const COSPI_14_64: i64 = 12665;
const COSPI_15_64: i64 = 12140;
const COSPI_16_64: i64 = 11585;
const COSPI_17_64: i64 = 11003;
const COSPI_18_64: i64 = 10394;
const COSPI_19_64: i64 = 9760;
const COSPI_20_64: i64 = 9102;
const COSPI_21_64: i64 = 8423;
const COSPI_22_64: i64 = 7723;
const COSPI_23_64: i64 = 7005;
const COSPI_24_64: i64 = 6270;
const COSPI_25_64: i64 = 5520;
const COSPI_26_64: i64 = 4756;
const COSPI_27_64: i64 = 3981;
const COSPI_28_64: i64 = 3196;
const COSPI_29_64: i64 = 2404;
const COSPI_30_64: i64 = 1606;
const COSPI_31_64: i64 = 804;
const SINPI_1_9: i64 = 5283;
const SINPI_2_9: i64 = 9929;
const SINPI_3_9: i64 = 13377;
const SINPI_4_9: i64 = 15212;
fn wrap32(x: i64) -> i64 {
x as i32 as i64
}
fn round_shift(x: i64) -> i64 {
(x + (1 << 13)) >> 14
}
fn detect_invalid(input: &[i32], size: usize) -> bool {
input[..size]
.iter()
.any(|&value| value.unsigned_abs() >= 1 << 25)
}
pub fn iadst4(input: &[i32], output: &mut [i32]) {
let mut s0: i64 = 0;
let mut s1: i64 = 0;
let mut s2: i64 = 0;
let mut s3: i64 = 0;
let mut s4: i64 = 0;
let mut s5: i64 = 0;
let mut s6: i64 = 0;
let mut s7: i64 = 0;
let mut x0: i64 = wrap32(i64::from(input[0]));
let mut x1: i64 = wrap32(i64::from(input[1]));
let mut x2: i64 = wrap32(i64::from(input[2]));
let mut x3: i64 = wrap32(i64::from(input[3]));
if detect_invalid(input, 4) {
output[..4].fill(0);
return;
}
if (x0 | x1 | x2 | x3) == 0 {
output[..4].fill(0);
return;
}
s0 = SINPI_1_9 * x0;
s1 = SINPI_2_9 * x0;
s2 = SINPI_3_9 * x1;
s3 = SINPI_4_9 * x2;
s4 = SINPI_1_9 * x2;
s5 = SINPI_2_9 * x3;
s6 = SINPI_4_9 * x3;
s7 = wrap32(x0 - x2 + x3);
s0 = s0 + s3 + s5;
s1 = s1 - s4 - s6;
s3 = s2;
s2 = SINPI_3_9 * s7;
output[0] = (wrap32(round_shift(s0 + s3))) as i32;
output[1] = (wrap32(round_shift(s1 + s3))) as i32;
output[2] = (wrap32(round_shift(s2))) as i32;
output[3] = (wrap32(round_shift(s0 + s1 - s3))) as i32;
}
pub fn idct4(input: &[i32], output: &mut [i32]) {
let mut step = [0i64; 4];
let mut temp1: i64 = 0;
let mut temp2: i64 = 0;
if detect_invalid(input, 4) {
output[..4].fill(0);
return;
}
temp1 = (i64::from(input[0]) + i64::from(input[2])) * COSPI_16_64;
temp2 = (i64::from(input[0]) - i64::from(input[2])) * COSPI_16_64;
step[0] = wrap32(wrap32(round_shift(temp1)));
step[1] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[1]) * COSPI_24_64 - i64::from(input[3]) * COSPI_8_64;
temp2 = i64::from(input[1]) * COSPI_8_64 + i64::from(input[3]) * COSPI_24_64;
step[2] = wrap32(wrap32(round_shift(temp1)));
step[3] = wrap32(wrap32(round_shift(temp2)));
output[0] = (wrap32(step[0] + step[3])) as i32;
output[1] = (wrap32(step[1] + step[2])) as i32;
output[2] = (wrap32(step[1] - step[2])) as i32;
output[3] = (wrap32(step[0] - step[3])) as i32;
}
pub fn iadst8(input: &[i32], output: &mut [i32]) {
let mut s0: i64 = 0;
let mut s1: i64 = 0;
let mut s2: i64 = 0;
let mut s3: i64 = 0;
let mut s4: i64 = 0;
let mut s5: i64 = 0;
let mut s6: i64 = 0;
let mut s7: i64 = 0;
let mut x0: i64 = wrap32(i64::from(input[7]));
let mut x1: i64 = wrap32(i64::from(input[0]));
let mut x2: i64 = wrap32(i64::from(input[5]));
let mut x3: i64 = wrap32(i64::from(input[2]));
let mut x4: i64 = wrap32(i64::from(input[3]));
let mut x5: i64 = wrap32(i64::from(input[4]));
let mut x6: i64 = wrap32(i64::from(input[1]));
let mut x7: i64 = wrap32(i64::from(input[6]));
if detect_invalid(input, 8) {
output[..8].fill(0);
return;
}
if (x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7) == 0 {
output[..8].fill(0);
return;
}
s0 = COSPI_2_64 * x0 + COSPI_30_64 * x1;
s1 = COSPI_30_64 * x0 - COSPI_2_64 * x1;
s2 = COSPI_10_64 * x2 + COSPI_22_64 * x3;
s3 = COSPI_22_64 * x2 - COSPI_10_64 * x3;
s4 = COSPI_18_64 * x4 + COSPI_14_64 * x5;
s5 = COSPI_14_64 * x4 - COSPI_18_64 * x5;
s6 = COSPI_26_64 * x6 + COSPI_6_64 * x7;
s7 = COSPI_6_64 * x6 - COSPI_26_64 * x7;
x0 = wrap32(wrap32(round_shift(s0 + s4)));
x1 = wrap32(wrap32(round_shift(s1 + s5)));
x2 = wrap32(wrap32(round_shift(s2 + s6)));
x3 = wrap32(wrap32(round_shift(s3 + s7)));
x4 = wrap32(wrap32(round_shift(s0 - s4)));
x5 = wrap32(wrap32(round_shift(s1 - s5)));
x6 = wrap32(wrap32(round_shift(s2 - s6)));
x7 = wrap32(wrap32(round_shift(s3 - s7)));
s0 = x0;
s1 = x1;
s2 = x2;
s3 = x3;
s4 = COSPI_8_64 * x4 + COSPI_24_64 * x5;
s5 = COSPI_24_64 * x4 - COSPI_8_64 * x5;
s6 = (-COSPI_24_64) * x6 + COSPI_8_64 * x7;
s7 = COSPI_8_64 * x6 + COSPI_24_64 * x7;
x0 = wrap32(wrap32(s0 + s2));
x1 = wrap32(wrap32(s1 + s3));
x2 = wrap32(wrap32(s0 - s2));
x3 = wrap32(wrap32(s1 - s3));
x4 = wrap32(wrap32(round_shift(s4 + s6)));
x5 = wrap32(wrap32(round_shift(s5 + s7)));
x6 = wrap32(wrap32(round_shift(s4 - s6)));
x7 = wrap32(wrap32(round_shift(s5 - s7)));
s2 = COSPI_16_64 * (x2 + x3);
s3 = COSPI_16_64 * (x2 - x3);
s6 = COSPI_16_64 * (x6 + x7);
s7 = COSPI_16_64 * (x6 - x7);
x2 = wrap32(wrap32(round_shift(s2)));
x3 = wrap32(wrap32(round_shift(s3)));
x6 = wrap32(wrap32(round_shift(s6)));
x7 = wrap32(wrap32(round_shift(s7)));
output[0] = (wrap32(x0)) as i32;
output[1] = (wrap32(-x4)) as i32;
output[2] = (wrap32(x6)) as i32;
output[3] = (wrap32(-x2)) as i32;
output[4] = (wrap32(x3)) as i32;
output[5] = (wrap32(-x7)) as i32;
output[6] = (wrap32(x5)) as i32;
output[7] = (wrap32(-x1)) as i32;
}
pub fn idct8(input: &[i32], output: &mut [i32]) {
let mut step1 = [0i64; 8];
let mut step2 = [0i64; 8];
let mut temp1: i64 = 0;
let mut temp2: i64 = 0;
if detect_invalid(input, 8) {
output[..8].fill(0);
return;
}
step1[0] = wrap32(i64::from(input[0]));
step1[2] = wrap32(i64::from(input[4]));
step1[1] = wrap32(i64::from(input[2]));
step1[3] = wrap32(i64::from(input[6]));
temp1 = i64::from(input[1]) * COSPI_28_64 - i64::from(input[7]) * COSPI_4_64;
temp2 = i64::from(input[1]) * COSPI_4_64 + i64::from(input[7]) * COSPI_28_64;
step1[4] = wrap32(wrap32(round_shift(temp1)));
step1[7] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[5]) * COSPI_12_64 - i64::from(input[3]) * COSPI_20_64;
temp2 = i64::from(input[5]) * COSPI_20_64 + i64::from(input[3]) * COSPI_12_64;
step1[5] = wrap32(wrap32(round_shift(temp1)));
step1[6] = wrap32(wrap32(round_shift(temp2)));
{
let inner: [i32; 4] = std::array::from_fn(|k| step1[k] as i32);
let mut result = [0i32; 4];
idct4(&inner, &mut result);
for k in 0..4 {
step1[k] = i64::from(result[k]);
}
}
step2[4] = wrap32(wrap32(step1[4] + step1[5]));
step2[5] = wrap32(wrap32(step1[4] - step1[5]));
step2[6] = wrap32(wrap32(-step1[6] + step1[7]));
step2[7] = wrap32(wrap32(step1[6] + step1[7]));
step1[4] = wrap32(step2[4]);
temp1 = (step2[6] - step2[5]) * COSPI_16_64;
temp2 = (step2[5] + step2[6]) * COSPI_16_64;
step1[5] = wrap32(wrap32(round_shift(temp1)));
step1[6] = wrap32(wrap32(round_shift(temp2)));
step1[7] = wrap32(step2[7]);
output[0] = (wrap32(step1[0] + step1[7])) as i32;
output[1] = (wrap32(step1[1] + step1[6])) as i32;
output[2] = (wrap32(step1[2] + step1[5])) as i32;
output[3] = (wrap32(step1[3] + step1[4])) as i32;
output[4] = (wrap32(step1[3] - step1[4])) as i32;
output[5] = (wrap32(step1[2] - step1[5])) as i32;
output[6] = (wrap32(step1[1] - step1[6])) as i32;
output[7] = (wrap32(step1[0] - step1[7])) as i32;
}
pub fn iadst16(input: &[i32], output: &mut [i32]) {
let mut s0: i64 = 0;
let mut s1: i64 = 0;
let mut s2: i64 = 0;
let mut s3: i64 = 0;
let mut s4: i64 = 0;
let mut s5: i64 = 0;
let mut s6: i64 = 0;
let mut s7: i64 = 0;
let mut s8: i64 = 0;
let mut s9: i64 = 0;
let mut s10: i64 = 0;
let mut s11: i64 = 0;
let mut s12: i64 = 0;
let mut s13: i64 = 0;
let mut s14: i64 = 0;
let mut s15: i64 = 0;
let mut x0: i64 = wrap32(i64::from(input[15]));
let mut x1: i64 = wrap32(i64::from(input[0]));
let mut x2: i64 = wrap32(i64::from(input[13]));
let mut x3: i64 = wrap32(i64::from(input[2]));
let mut x4: i64 = wrap32(i64::from(input[11]));
let mut x5: i64 = wrap32(i64::from(input[4]));
let mut x6: i64 = wrap32(i64::from(input[9]));
let mut x7: i64 = wrap32(i64::from(input[6]));
let mut x8: i64 = wrap32(i64::from(input[7]));
let mut x9: i64 = wrap32(i64::from(input[8]));
let mut x10: i64 = wrap32(i64::from(input[5]));
let mut x11: i64 = wrap32(i64::from(input[10]));
let mut x12: i64 = wrap32(i64::from(input[3]));
let mut x13: i64 = wrap32(i64::from(input[12]));
let mut x14: i64 = wrap32(i64::from(input[1]));
let mut x15: i64 = wrap32(i64::from(input[14]));
if detect_invalid(input, 16) {
output[..16].fill(0);
return;
}
if (x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15) == 0 {
output[..16].fill(0);
return;
}
s0 = x0 * COSPI_1_64 + x1 * COSPI_31_64;
s1 = x0 * COSPI_31_64 - x1 * COSPI_1_64;
s2 = x2 * COSPI_5_64 + x3 * COSPI_27_64;
s3 = x2 * COSPI_27_64 - x3 * COSPI_5_64;
s4 = x4 * COSPI_9_64 + x5 * COSPI_23_64;
s5 = x4 * COSPI_23_64 - x5 * COSPI_9_64;
s6 = x6 * COSPI_13_64 + x7 * COSPI_19_64;
s7 = x6 * COSPI_19_64 - x7 * COSPI_13_64;
s8 = x8 * COSPI_17_64 + x9 * COSPI_15_64;
s9 = x8 * COSPI_15_64 - x9 * COSPI_17_64;
s10 = x10 * COSPI_21_64 + x11 * COSPI_11_64;
s11 = x10 * COSPI_11_64 - x11 * COSPI_21_64;
s12 = x12 * COSPI_25_64 + x13 * COSPI_7_64;
s13 = x12 * COSPI_7_64 - x13 * COSPI_25_64;
s14 = x14 * COSPI_29_64 + x15 * COSPI_3_64;
s15 = x14 * COSPI_3_64 - x15 * COSPI_29_64;
x0 = wrap32(wrap32(round_shift(s0 + s8)));
x1 = wrap32(wrap32(round_shift(s1 + s9)));
x2 = wrap32(wrap32(round_shift(s2 + s10)));
x3 = wrap32(wrap32(round_shift(s3 + s11)));
x4 = wrap32(wrap32(round_shift(s4 + s12)));
x5 = wrap32(wrap32(round_shift(s5 + s13)));
x6 = wrap32(wrap32(round_shift(s6 + s14)));
x7 = wrap32(wrap32(round_shift(s7 + s15)));
x8 = wrap32(wrap32(round_shift(s0 - s8)));
x9 = wrap32(wrap32(round_shift(s1 - s9)));
x10 = wrap32(wrap32(round_shift(s2 - s10)));
x11 = wrap32(wrap32(round_shift(s3 - s11)));
x12 = wrap32(wrap32(round_shift(s4 - s12)));
x13 = wrap32(wrap32(round_shift(s5 - s13)));
x14 = wrap32(wrap32(round_shift(s6 - s14)));
x15 = wrap32(wrap32(round_shift(s7 - s15)));
s0 = x0;
s1 = x1;
s2 = x2;
s3 = x3;
s4 = x4;
s5 = x5;
s6 = x6;
s7 = x7;
s8 = x8 * COSPI_4_64 + x9 * COSPI_28_64;
s9 = x8 * COSPI_28_64 - x9 * COSPI_4_64;
s10 = x10 * COSPI_20_64 + x11 * COSPI_12_64;
s11 = x10 * COSPI_12_64 - x11 * COSPI_20_64;
s12 = -x12 * COSPI_28_64 + x13 * COSPI_4_64;
s13 = x12 * COSPI_4_64 + x13 * COSPI_28_64;
s14 = -x14 * COSPI_12_64 + x15 * COSPI_20_64;
s15 = x14 * COSPI_20_64 + x15 * COSPI_12_64;
x0 = wrap32(wrap32(s0 + s4));
x1 = wrap32(wrap32(s1 + s5));
x2 = wrap32(wrap32(s2 + s6));
x3 = wrap32(wrap32(s3 + s7));
x4 = wrap32(wrap32(s0 - s4));
x5 = wrap32(wrap32(s1 - s5));
x6 = wrap32(wrap32(s2 - s6));
x7 = wrap32(wrap32(s3 - s7));
x8 = wrap32(wrap32(round_shift(s8 + s12)));
x9 = wrap32(wrap32(round_shift(s9 + s13)));
x10 = wrap32(wrap32(round_shift(s10 + s14)));
x11 = wrap32(wrap32(round_shift(s11 + s15)));
x12 = wrap32(wrap32(round_shift(s8 - s12)));
x13 = wrap32(wrap32(round_shift(s9 - s13)));
x14 = wrap32(wrap32(round_shift(s10 - s14)));
x15 = wrap32(wrap32(round_shift(s11 - s15)));
s0 = x0;
s1 = x1;
s2 = x2;
s3 = x3;
s4 = x4 * COSPI_8_64 + x5 * COSPI_24_64;
s5 = x4 * COSPI_24_64 - x5 * COSPI_8_64;
s6 = -x6 * COSPI_24_64 + x7 * COSPI_8_64;
s7 = x6 * COSPI_8_64 + x7 * COSPI_24_64;
s8 = x8;
s9 = x9;
s10 = x10;
s11 = x11;
s12 = x12 * COSPI_8_64 + x13 * COSPI_24_64;
s13 = x12 * COSPI_24_64 - x13 * COSPI_8_64;
s14 = -x14 * COSPI_24_64 + x15 * COSPI_8_64;
s15 = x14 * COSPI_8_64 + x15 * COSPI_24_64;
x0 = wrap32(wrap32(s0 + s2));
x1 = wrap32(wrap32(s1 + s3));
x2 = wrap32(wrap32(s0 - s2));
x3 = wrap32(wrap32(s1 - s3));
x4 = wrap32(wrap32(round_shift(s4 + s6)));
x5 = wrap32(wrap32(round_shift(s5 + s7)));
x6 = wrap32(wrap32(round_shift(s4 - s6)));
x7 = wrap32(wrap32(round_shift(s5 - s7)));
x8 = wrap32(wrap32(s8 + s10));
x9 = wrap32(wrap32(s9 + s11));
x10 = wrap32(wrap32(s8 - s10));
x11 = wrap32(wrap32(s9 - s11));
x12 = wrap32(wrap32(round_shift(s12 + s14)));
x13 = wrap32(wrap32(round_shift(s13 + s15)));
x14 = wrap32(wrap32(round_shift(s12 - s14)));
x15 = wrap32(wrap32(round_shift(s13 - s15)));
s2 = (-COSPI_16_64) * (x2 + x3);
s3 = COSPI_16_64 * (x2 - x3);
s6 = COSPI_16_64 * (x6 + x7);
s7 = COSPI_16_64 * (-x6 + x7);
s10 = COSPI_16_64 * (x10 + x11);
s11 = COSPI_16_64 * (-x10 + x11);
s14 = (-COSPI_16_64) * (x14 + x15);
s15 = COSPI_16_64 * (x14 - x15);
x2 = wrap32(wrap32(round_shift(s2)));
x3 = wrap32(wrap32(round_shift(s3)));
x6 = wrap32(wrap32(round_shift(s6)));
x7 = wrap32(wrap32(round_shift(s7)));
x10 = wrap32(wrap32(round_shift(s10)));
x11 = wrap32(wrap32(round_shift(s11)));
x14 = wrap32(wrap32(round_shift(s14)));
x15 = wrap32(wrap32(round_shift(s15)));
output[0] = (wrap32(x0)) as i32;
output[1] = (wrap32(-x8)) as i32;
output[2] = (wrap32(x12)) as i32;
output[3] = (wrap32(-x4)) as i32;
output[4] = (wrap32(x6)) as i32;
output[5] = (wrap32(x14)) as i32;
output[6] = (wrap32(x10)) as i32;
output[7] = (wrap32(x2)) as i32;
output[8] = (wrap32(x3)) as i32;
output[9] = (wrap32(x11)) as i32;
output[10] = (wrap32(x15)) as i32;
output[11] = (wrap32(x7)) as i32;
output[12] = (wrap32(x5)) as i32;
output[13] = (wrap32(-x13)) as i32;
output[14] = (wrap32(x9)) as i32;
output[15] = (wrap32(-x1)) as i32;
}
pub fn idct16(input: &[i32], output: &mut [i32]) {
let mut step1 = [0i64; 16];
let mut step2 = [0i64; 16];
let mut temp1: i64 = 0;
let mut temp2: i64 = 0;
if detect_invalid(input, 16) {
output[..16].fill(0);
return;
}
step1[0] = wrap32(i64::from(input[0 / 2]));
step1[1] = wrap32(i64::from(input[16 / 2]));
step1[2] = wrap32(i64::from(input[8 / 2]));
step1[3] = wrap32(i64::from(input[24 / 2]));
step1[4] = wrap32(i64::from(input[4 / 2]));
step1[5] = wrap32(i64::from(input[20 / 2]));
step1[6] = wrap32(i64::from(input[12 / 2]));
step1[7] = wrap32(i64::from(input[28 / 2]));
step1[8] = wrap32(i64::from(input[2 / 2]));
step1[9] = wrap32(i64::from(input[18 / 2]));
step1[10] = wrap32(i64::from(input[10 / 2]));
step1[11] = wrap32(i64::from(input[26 / 2]));
step1[12] = wrap32(i64::from(input[6 / 2]));
step1[13] = wrap32(i64::from(input[22 / 2]));
step1[14] = wrap32(i64::from(input[14 / 2]));
step1[15] = wrap32(i64::from(input[30 / 2]));
step2[0] = wrap32(step1[0]);
step2[1] = wrap32(step1[1]);
step2[2] = wrap32(step1[2]);
step2[3] = wrap32(step1[3]);
step2[4] = wrap32(step1[4]);
step2[5] = wrap32(step1[5]);
step2[6] = wrap32(step1[6]);
step2[7] = wrap32(step1[7]);
temp1 = step1[8] * COSPI_30_64 - step1[15] * COSPI_2_64;
temp2 = step1[8] * COSPI_2_64 + step1[15] * COSPI_30_64;
step2[8] = wrap32(wrap32(round_shift(temp1)));
step2[15] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[9] * COSPI_14_64 - step1[14] * COSPI_18_64;
temp2 = step1[9] * COSPI_18_64 + step1[14] * COSPI_14_64;
step2[9] = wrap32(wrap32(round_shift(temp1)));
step2[14] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[10] * COSPI_22_64 - step1[13] * COSPI_10_64;
temp2 = step1[10] * COSPI_10_64 + step1[13] * COSPI_22_64;
step2[10] = wrap32(wrap32(round_shift(temp1)));
step2[13] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[11] * COSPI_6_64 - step1[12] * COSPI_26_64;
temp2 = step1[11] * COSPI_26_64 + step1[12] * COSPI_6_64;
step2[11] = wrap32(wrap32(round_shift(temp1)));
step2[12] = wrap32(wrap32(round_shift(temp2)));
step1[0] = wrap32(step2[0]);
step1[1] = wrap32(step2[1]);
step1[2] = wrap32(step2[2]);
step1[3] = wrap32(step2[3]);
temp1 = step2[4] * COSPI_28_64 - step2[7] * COSPI_4_64;
temp2 = step2[4] * COSPI_4_64 + step2[7] * COSPI_28_64;
step1[4] = wrap32(wrap32(round_shift(temp1)));
step1[7] = wrap32(wrap32(round_shift(temp2)));
temp1 = step2[5] * COSPI_12_64 - step2[6] * COSPI_20_64;
temp2 = step2[5] * COSPI_20_64 + step2[6] * COSPI_12_64;
step1[5] = wrap32(wrap32(round_shift(temp1)));
step1[6] = wrap32(wrap32(round_shift(temp2)));
step1[8] = wrap32(wrap32(step2[8] + step2[9]));
step1[9] = wrap32(wrap32(step2[8] - step2[9]));
step1[10] = wrap32(wrap32(-step2[10] + step2[11]));
step1[11] = wrap32(wrap32(step2[10] + step2[11]));
step1[12] = wrap32(wrap32(step2[12] + step2[13]));
step1[13] = wrap32(wrap32(step2[12] - step2[13]));
step1[14] = wrap32(wrap32(-step2[14] + step2[15]));
step1[15] = wrap32(wrap32(step2[14] + step2[15]));
temp1 = (step1[0] + step1[1]) * COSPI_16_64;
temp2 = (step1[0] - step1[1]) * COSPI_16_64;
step2[0] = wrap32(wrap32(round_shift(temp1)));
step2[1] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[2] * COSPI_24_64 - step1[3] * COSPI_8_64;
temp2 = step1[2] * COSPI_8_64 + step1[3] * COSPI_24_64;
step2[2] = wrap32(wrap32(round_shift(temp1)));
step2[3] = wrap32(wrap32(round_shift(temp2)));
step2[4] = wrap32(wrap32(step1[4] + step1[5]));
step2[5] = wrap32(wrap32(step1[4] - step1[5]));
step2[6] = wrap32(wrap32(-step1[6] + step1[7]));
step2[7] = wrap32(wrap32(step1[6] + step1[7]));
step2[8] = wrap32(step1[8]);
step2[15] = wrap32(step1[15]);
temp1 = -step1[9] * COSPI_8_64 + step1[14] * COSPI_24_64;
temp2 = step1[9] * COSPI_24_64 + step1[14] * COSPI_8_64;
step2[9] = wrap32(wrap32(round_shift(temp1)));
step2[14] = wrap32(wrap32(round_shift(temp2)));
temp1 = -step1[10] * COSPI_24_64 - step1[13] * COSPI_8_64;
temp2 = -step1[10] * COSPI_8_64 + step1[13] * COSPI_24_64;
step2[10] = wrap32(wrap32(round_shift(temp1)));
step2[13] = wrap32(wrap32(round_shift(temp2)));
step2[11] = wrap32(step1[11]);
step2[12] = wrap32(step1[12]);
step1[0] = wrap32(wrap32(step2[0] + step2[3]));
step1[1] = wrap32(wrap32(step2[1] + step2[2]));
step1[2] = wrap32(wrap32(step2[1] - step2[2]));
step1[3] = wrap32(wrap32(step2[0] - step2[3]));
step1[4] = wrap32(step2[4]);
temp1 = (step2[6] - step2[5]) * COSPI_16_64;
temp2 = (step2[5] + step2[6]) * COSPI_16_64;
step1[5] = wrap32(wrap32(round_shift(temp1)));
step1[6] = wrap32(wrap32(round_shift(temp2)));
step1[7] = wrap32(step2[7]);
step1[8] = wrap32(wrap32(step2[8] + step2[11]));
step1[9] = wrap32(wrap32(step2[9] + step2[10]));
step1[10] = wrap32(wrap32(step2[9] - step2[10]));
step1[11] = wrap32(wrap32(step2[8] - step2[11]));
step1[12] = wrap32(wrap32(-step2[12] + step2[15]));
step1[13] = wrap32(wrap32(-step2[13] + step2[14]));
step1[14] = wrap32(wrap32(step2[13] + step2[14]));
step1[15] = wrap32(wrap32(step2[12] + step2[15]));
step2[0] = wrap32(wrap32(step1[0] + step1[7]));
step2[1] = wrap32(wrap32(step1[1] + step1[6]));
step2[2] = wrap32(wrap32(step1[2] + step1[5]));
step2[3] = wrap32(wrap32(step1[3] + step1[4]));
step2[4] = wrap32(wrap32(step1[3] - step1[4]));
step2[5] = wrap32(wrap32(step1[2] - step1[5]));
step2[6] = wrap32(wrap32(step1[1] - step1[6]));
step2[7] = wrap32(wrap32(step1[0] - step1[7]));
step2[8] = wrap32(step1[8]);
step2[9] = wrap32(step1[9]);
temp1 = (-step1[10] + step1[13]) * COSPI_16_64;
temp2 = (step1[10] + step1[13]) * COSPI_16_64;
step2[10] = wrap32(wrap32(round_shift(temp1)));
step2[13] = wrap32(wrap32(round_shift(temp2)));
temp1 = (-step1[11] + step1[12]) * COSPI_16_64;
temp2 = (step1[11] + step1[12]) * COSPI_16_64;
step2[11] = wrap32(wrap32(round_shift(temp1)));
step2[12] = wrap32(wrap32(round_shift(temp2)));
step2[14] = wrap32(step1[14]);
step2[15] = wrap32(step1[15]);
output[0] = (wrap32(step2[0] + step2[15])) as i32;
output[1] = (wrap32(step2[1] + step2[14])) as i32;
output[2] = (wrap32(step2[2] + step2[13])) as i32;
output[3] = (wrap32(step2[3] + step2[12])) as i32;
output[4] = (wrap32(step2[4] + step2[11])) as i32;
output[5] = (wrap32(step2[5] + step2[10])) as i32;
output[6] = (wrap32(step2[6] + step2[9])) as i32;
output[7] = (wrap32(step2[7] + step2[8])) as i32;
output[8] = (wrap32(step2[7] - step2[8])) as i32;
output[9] = (wrap32(step2[6] - step2[9])) as i32;
output[10] = (wrap32(step2[5] - step2[10])) as i32;
output[11] = (wrap32(step2[4] - step2[11])) as i32;
output[12] = (wrap32(step2[3] - step2[12])) as i32;
output[13] = (wrap32(step2[2] - step2[13])) as i32;
output[14] = (wrap32(step2[1] - step2[14])) as i32;
output[15] = (wrap32(step2[0] - step2[15])) as i32;
}
pub fn idct32(input: &[i32], output: &mut [i32]) {
let mut step1 = [0i64; 32];
let mut step2 = [0i64; 32];
let mut temp1: i64 = 0;
let mut temp2: i64 = 0;
if detect_invalid(input, 32) {
output[..32].fill(0);
return;
}
step1[0] = wrap32(i64::from(input[0]));
step1[1] = wrap32(i64::from(input[16]));
step1[2] = wrap32(i64::from(input[8]));
step1[3] = wrap32(i64::from(input[24]));
step1[4] = wrap32(i64::from(input[4]));
step1[5] = wrap32(i64::from(input[20]));
step1[6] = wrap32(i64::from(input[12]));
step1[7] = wrap32(i64::from(input[28]));
step1[8] = wrap32(i64::from(input[2]));
step1[9] = wrap32(i64::from(input[18]));
step1[10] = wrap32(i64::from(input[10]));
step1[11] = wrap32(i64::from(input[26]));
step1[12] = wrap32(i64::from(input[6]));
step1[13] = wrap32(i64::from(input[22]));
step1[14] = wrap32(i64::from(input[14]));
step1[15] = wrap32(i64::from(input[30]));
temp1 = i64::from(input[1]) * COSPI_31_64 - i64::from(input[31]) * COSPI_1_64;
temp2 = i64::from(input[1]) * COSPI_1_64 + i64::from(input[31]) * COSPI_31_64;
step1[16] = wrap32(wrap32(round_shift(temp1)));
step1[31] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[17]) * COSPI_15_64 - i64::from(input[15]) * COSPI_17_64;
temp2 = i64::from(input[17]) * COSPI_17_64 + i64::from(input[15]) * COSPI_15_64;
step1[17] = wrap32(wrap32(round_shift(temp1)));
step1[30] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[9]) * COSPI_23_64 - i64::from(input[23]) * COSPI_9_64;
temp2 = i64::from(input[9]) * COSPI_9_64 + i64::from(input[23]) * COSPI_23_64;
step1[18] = wrap32(wrap32(round_shift(temp1)));
step1[29] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[25]) * COSPI_7_64 - i64::from(input[7]) * COSPI_25_64;
temp2 = i64::from(input[25]) * COSPI_25_64 + i64::from(input[7]) * COSPI_7_64;
step1[19] = wrap32(wrap32(round_shift(temp1)));
step1[28] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[5]) * COSPI_27_64 - i64::from(input[27]) * COSPI_5_64;
temp2 = i64::from(input[5]) * COSPI_5_64 + i64::from(input[27]) * COSPI_27_64;
step1[20] = wrap32(wrap32(round_shift(temp1)));
step1[27] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[21]) * COSPI_11_64 - i64::from(input[11]) * COSPI_21_64;
temp2 = i64::from(input[21]) * COSPI_21_64 + i64::from(input[11]) * COSPI_11_64;
step1[21] = wrap32(wrap32(round_shift(temp1)));
step1[26] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[13]) * COSPI_19_64 - i64::from(input[19]) * COSPI_13_64;
temp2 = i64::from(input[13]) * COSPI_13_64 + i64::from(input[19]) * COSPI_19_64;
step1[22] = wrap32(wrap32(round_shift(temp1)));
step1[25] = wrap32(wrap32(round_shift(temp2)));
temp1 = i64::from(input[29]) * COSPI_3_64 - i64::from(input[3]) * COSPI_29_64;
temp2 = i64::from(input[29]) * COSPI_29_64 + i64::from(input[3]) * COSPI_3_64;
step1[23] = wrap32(wrap32(round_shift(temp1)));
step1[24] = wrap32(wrap32(round_shift(temp2)));
step2[0] = wrap32(step1[0]);
step2[1] = wrap32(step1[1]);
step2[2] = wrap32(step1[2]);
step2[3] = wrap32(step1[3]);
step2[4] = wrap32(step1[4]);
step2[5] = wrap32(step1[5]);
step2[6] = wrap32(step1[6]);
step2[7] = wrap32(step1[7]);
temp1 = step1[8] * COSPI_30_64 - step1[15] * COSPI_2_64;
temp2 = step1[8] * COSPI_2_64 + step1[15] * COSPI_30_64;
step2[8] = wrap32(wrap32(round_shift(temp1)));
step2[15] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[9] * COSPI_14_64 - step1[14] * COSPI_18_64;
temp2 = step1[9] * COSPI_18_64 + step1[14] * COSPI_14_64;
step2[9] = wrap32(wrap32(round_shift(temp1)));
step2[14] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[10] * COSPI_22_64 - step1[13] * COSPI_10_64;
temp2 = step1[10] * COSPI_10_64 + step1[13] * COSPI_22_64;
step2[10] = wrap32(wrap32(round_shift(temp1)));
step2[13] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[11] * COSPI_6_64 - step1[12] * COSPI_26_64;
temp2 = step1[11] * COSPI_26_64 + step1[12] * COSPI_6_64;
step2[11] = wrap32(wrap32(round_shift(temp1)));
step2[12] = wrap32(wrap32(round_shift(temp2)));
step2[16] = wrap32(wrap32(step1[16] + step1[17]));
step2[17] = wrap32(wrap32(step1[16] - step1[17]));
step2[18] = wrap32(wrap32(-step1[18] + step1[19]));
step2[19] = wrap32(wrap32(step1[18] + step1[19]));
step2[20] = wrap32(wrap32(step1[20] + step1[21]));
step2[21] = wrap32(wrap32(step1[20] - step1[21]));
step2[22] = wrap32(wrap32(-step1[22] + step1[23]));
step2[23] = wrap32(wrap32(step1[22] + step1[23]));
step2[24] = wrap32(wrap32(step1[24] + step1[25]));
step2[25] = wrap32(wrap32(step1[24] - step1[25]));
step2[26] = wrap32(wrap32(-step1[26] + step1[27]));
step2[27] = wrap32(wrap32(step1[26] + step1[27]));
step2[28] = wrap32(wrap32(step1[28] + step1[29]));
step2[29] = wrap32(wrap32(step1[28] - step1[29]));
step2[30] = wrap32(wrap32(-step1[30] + step1[31]));
step2[31] = wrap32(wrap32(step1[30] + step1[31]));
step1[0] = wrap32(step2[0]);
step1[1] = wrap32(step2[1]);
step1[2] = wrap32(step2[2]);
step1[3] = wrap32(step2[3]);
temp1 = step2[4] * COSPI_28_64 - step2[7] * COSPI_4_64;
temp2 = step2[4] * COSPI_4_64 + step2[7] * COSPI_28_64;
step1[4] = wrap32(wrap32(round_shift(temp1)));
step1[7] = wrap32(wrap32(round_shift(temp2)));
temp1 = step2[5] * COSPI_12_64 - step2[6] * COSPI_20_64;
temp2 = step2[5] * COSPI_20_64 + step2[6] * COSPI_12_64;
step1[5] = wrap32(wrap32(round_shift(temp1)));
step1[6] = wrap32(wrap32(round_shift(temp2)));
step1[8] = wrap32(wrap32(step2[8] + step2[9]));
step1[9] = wrap32(wrap32(step2[8] - step2[9]));
step1[10] = wrap32(wrap32(-step2[10] + step2[11]));
step1[11] = wrap32(wrap32(step2[10] + step2[11]));
step1[12] = wrap32(wrap32(step2[12] + step2[13]));
step1[13] = wrap32(wrap32(step2[12] - step2[13]));
step1[14] = wrap32(wrap32(-step2[14] + step2[15]));
step1[15] = wrap32(wrap32(step2[14] + step2[15]));
step1[16] = wrap32(step2[16]);
step1[31] = wrap32(step2[31]);
temp1 = -step2[17] * COSPI_4_64 + step2[30] * COSPI_28_64;
temp2 = step2[17] * COSPI_28_64 + step2[30] * COSPI_4_64;
step1[17] = wrap32(wrap32(round_shift(temp1)));
step1[30] = wrap32(wrap32(round_shift(temp2)));
temp1 = -step2[18] * COSPI_28_64 - step2[29] * COSPI_4_64;
temp2 = -step2[18] * COSPI_4_64 + step2[29] * COSPI_28_64;
step1[18] = wrap32(wrap32(round_shift(temp1)));
step1[29] = wrap32(wrap32(round_shift(temp2)));
step1[19] = wrap32(step2[19]);
step1[20] = wrap32(step2[20]);
temp1 = -step2[21] * COSPI_20_64 + step2[26] * COSPI_12_64;
temp2 = step2[21] * COSPI_12_64 + step2[26] * COSPI_20_64;
step1[21] = wrap32(wrap32(round_shift(temp1)));
step1[26] = wrap32(wrap32(round_shift(temp2)));
temp1 = -step2[22] * COSPI_12_64 - step2[25] * COSPI_20_64;
temp2 = -step2[22] * COSPI_20_64 + step2[25] * COSPI_12_64;
step1[22] = wrap32(wrap32(round_shift(temp1)));
step1[25] = wrap32(wrap32(round_shift(temp2)));
step1[23] = wrap32(step2[23]);
step1[24] = wrap32(step2[24]);
step1[27] = wrap32(step2[27]);
step1[28] = wrap32(step2[28]);
temp1 = (step1[0] + step1[1]) * COSPI_16_64;
temp2 = (step1[0] - step1[1]) * COSPI_16_64;
step2[0] = wrap32(wrap32(round_shift(temp1)));
step2[1] = wrap32(wrap32(round_shift(temp2)));
temp1 = step1[2] * COSPI_24_64 - step1[3] * COSPI_8_64;
temp2 = step1[2] * COSPI_8_64 + step1[3] * COSPI_24_64;
step2[2] = wrap32(wrap32(round_shift(temp1)));
step2[3] = wrap32(wrap32(round_shift(temp2)));
step2[4] = wrap32(wrap32(step1[4] + step1[5]));
step2[5] = wrap32(wrap32(step1[4] - step1[5]));
step2[6] = wrap32(wrap32(-step1[6] + step1[7]));
step2[7] = wrap32(wrap32(step1[6] + step1[7]));
step2[8] = wrap32(step1[8]);
step2[15] = wrap32(step1[15]);
temp1 = -step1[9] * COSPI_8_64 + step1[14] * COSPI_24_64;
temp2 = step1[9] * COSPI_24_64 + step1[14] * COSPI_8_64;
step2[9] = wrap32(wrap32(round_shift(temp1)));
step2[14] = wrap32(wrap32(round_shift(temp2)));
temp1 = -step1[10] * COSPI_24_64 - step1[13] * COSPI_8_64;
temp2 = -step1[10] * COSPI_8_64 + step1[13] * COSPI_24_64;
step2[10] = wrap32(wrap32(round_shift(temp1)));
step2[13] = wrap32(wrap32(round_shift(temp2)));
step2[11] = wrap32(step1[11]);
step2[12] = wrap32(step1[12]);
step2[16] = wrap32(wrap32(step1[16] + step1[19]));
step2[17] = wrap32(wrap32(step1[17] + step1[18]));
step2[18] = wrap32(wrap32(step1[17] - step1[18]));
step2[19] = wrap32(wrap32(step1[16] - step1[19]));
step2[20] = wrap32(wrap32(-step1[20] + step1[23]));
step2[21] = wrap32(wrap32(-step1[21] + step1[22]));
step2[22] = wrap32(wrap32(step1[21] + step1[22]));
step2[23] = wrap32(wrap32(step1[20] + step1[23]));
step2[24] = wrap32(wrap32(step1[24] + step1[27]));
step2[25] = wrap32(wrap32(step1[25] + step1[26]));
step2[26] = wrap32(wrap32(step1[25] - step1[26]));
step2[27] = wrap32(wrap32(step1[24] - step1[27]));
step2[28] = wrap32(wrap32(-step1[28] + step1[31]));
step2[29] = wrap32(wrap32(-step1[29] + step1[30]));
step2[30] = wrap32(wrap32(step1[29] + step1[30]));
step2[31] = wrap32(wrap32(step1[28] + step1[31]));
step1[0] = wrap32(wrap32(step2[0] + step2[3]));
step1[1] = wrap32(wrap32(step2[1] + step2[2]));
step1[2] = wrap32(wrap32(step2[1] - step2[2]));
step1[3] = wrap32(wrap32(step2[0] - step2[3]));
step1[4] = wrap32(step2[4]);
temp1 = (step2[6] - step2[5]) * COSPI_16_64;
temp2 = (step2[5] + step2[6]) * COSPI_16_64;
step1[5] = wrap32(wrap32(round_shift(temp1)));
step1[6] = wrap32(wrap32(round_shift(temp2)));
step1[7] = wrap32(step2[7]);
step1[8] = wrap32(wrap32(step2[8] + step2[11]));
step1[9] = wrap32(wrap32(step2[9] + step2[10]));
step1[10] = wrap32(wrap32(step2[9] - step2[10]));
step1[11] = wrap32(wrap32(step2[8] - step2[11]));
step1[12] = wrap32(wrap32(-step2[12] + step2[15]));
step1[13] = wrap32(wrap32(-step2[13] + step2[14]));
step1[14] = wrap32(wrap32(step2[13] + step2[14]));
step1[15] = wrap32(wrap32(step2[12] + step2[15]));
step1[16] = wrap32(step2[16]);
step1[17] = wrap32(step2[17]);
temp1 = -step2[18] * COSPI_8_64 + step2[29] * COSPI_24_64;
temp2 = step2[18] * COSPI_24_64 + step2[29] * COSPI_8_64;
step1[18] = wrap32(wrap32(round_shift(temp1)));
step1[29] = wrap32(wrap32(round_shift(temp2)));
temp1 = -step2[19] * COSPI_8_64 + step2[28] * COSPI_24_64;
temp2 = step2[19] * COSPI_24_64 + step2[28] * COSPI_8_64;
step1[19] = wrap32(wrap32(round_shift(temp1)));
step1[28] = wrap32(wrap32(round_shift(temp2)));
temp1 = -step2[20] * COSPI_24_64 - step2[27] * COSPI_8_64;
temp2 = -step2[20] * COSPI_8_64 + step2[27] * COSPI_24_64;
step1[20] = wrap32(wrap32(round_shift(temp1)));
step1[27] = wrap32(wrap32(round_shift(temp2)));
temp1 = -step2[21] * COSPI_24_64 - step2[26] * COSPI_8_64;
temp2 = -step2[21] * COSPI_8_64 + step2[26] * COSPI_24_64;
step1[21] = wrap32(wrap32(round_shift(temp1)));
step1[26] = wrap32(wrap32(round_shift(temp2)));
step1[22] = wrap32(step2[22]);
step1[23] = wrap32(step2[23]);
step1[24] = wrap32(step2[24]);
step1[25] = wrap32(step2[25]);
step1[30] = wrap32(step2[30]);
step1[31] = wrap32(step2[31]);
step2[0] = wrap32(wrap32(step1[0] + step1[7]));
step2[1] = wrap32(wrap32(step1[1] + step1[6]));
step2[2] = wrap32(wrap32(step1[2] + step1[5]));
step2[3] = wrap32(wrap32(step1[3] + step1[4]));
step2[4] = wrap32(wrap32(step1[3] - step1[4]));
step2[5] = wrap32(wrap32(step1[2] - step1[5]));
step2[6] = wrap32(wrap32(step1[1] - step1[6]));
step2[7] = wrap32(wrap32(step1[0] - step1[7]));
step2[8] = wrap32(step1[8]);
step2[9] = wrap32(step1[9]);
temp1 = (-step1[10] + step1[13]) * COSPI_16_64;
temp2 = (step1[10] + step1[13]) * COSPI_16_64;
step2[10] = wrap32(wrap32(round_shift(temp1)));
step2[13] = wrap32(wrap32(round_shift(temp2)));
temp1 = (-step1[11] + step1[12]) * COSPI_16_64;
temp2 = (step1[11] + step1[12]) * COSPI_16_64;
step2[11] = wrap32(wrap32(round_shift(temp1)));
step2[12] = wrap32(wrap32(round_shift(temp2)));
step2[14] = wrap32(step1[14]);
step2[15] = wrap32(step1[15]);
step2[16] = wrap32(wrap32(step1[16] + step1[23]));
step2[17] = wrap32(wrap32(step1[17] + step1[22]));
step2[18] = wrap32(wrap32(step1[18] + step1[21]));
step2[19] = wrap32(wrap32(step1[19] + step1[20]));
step2[20] = wrap32(wrap32(step1[19] - step1[20]));
step2[21] = wrap32(wrap32(step1[18] - step1[21]));
step2[22] = wrap32(wrap32(step1[17] - step1[22]));
step2[23] = wrap32(wrap32(step1[16] - step1[23]));
step2[24] = wrap32(wrap32(-step1[24] + step1[31]));
step2[25] = wrap32(wrap32(-step1[25] + step1[30]));
step2[26] = wrap32(wrap32(-step1[26] + step1[29]));
step2[27] = wrap32(wrap32(-step1[27] + step1[28]));
step2[28] = wrap32(wrap32(step1[27] + step1[28]));
step2[29] = wrap32(wrap32(step1[26] + step1[29]));
step2[30] = wrap32(wrap32(step1[25] + step1[30]));
step2[31] = wrap32(wrap32(step1[24] + step1[31]));
step1[0] = wrap32(wrap32(step2[0] + step2[15]));
step1[1] = wrap32(wrap32(step2[1] + step2[14]));
step1[2] = wrap32(wrap32(step2[2] + step2[13]));
step1[3] = wrap32(wrap32(step2[3] + step2[12]));
step1[4] = wrap32(wrap32(step2[4] + step2[11]));
step1[5] = wrap32(wrap32(step2[5] + step2[10]));
step1[6] = wrap32(wrap32(step2[6] + step2[9]));
step1[7] = wrap32(wrap32(step2[7] + step2[8]));
step1[8] = wrap32(wrap32(step2[7] - step2[8]));
step1[9] = wrap32(wrap32(step2[6] - step2[9]));
step1[10] = wrap32(wrap32(step2[5] - step2[10]));
step1[11] = wrap32(wrap32(step2[4] - step2[11]));
step1[12] = wrap32(wrap32(step2[3] - step2[12]));
step1[13] = wrap32(wrap32(step2[2] - step2[13]));
step1[14] = wrap32(wrap32(step2[1] - step2[14]));
step1[15] = wrap32(wrap32(step2[0] - step2[15]));
step1[16] = wrap32(step2[16]);
step1[17] = wrap32(step2[17]);
step1[18] = wrap32(step2[18]);
step1[19] = wrap32(step2[19]);
temp1 = (-step2[20] + step2[27]) * COSPI_16_64;
temp2 = (step2[20] + step2[27]) * COSPI_16_64;
step1[20] = wrap32(wrap32(round_shift(temp1)));
step1[27] = wrap32(wrap32(round_shift(temp2)));
temp1 = (-step2[21] + step2[26]) * COSPI_16_64;
temp2 = (step2[21] + step2[26]) * COSPI_16_64;
step1[21] = wrap32(wrap32(round_shift(temp1)));
step1[26] = wrap32(wrap32(round_shift(temp2)));
temp1 = (-step2[22] + step2[25]) * COSPI_16_64;
temp2 = (step2[22] + step2[25]) * COSPI_16_64;
step1[22] = wrap32(wrap32(round_shift(temp1)));
step1[25] = wrap32(wrap32(round_shift(temp2)));
temp1 = (-step2[23] + step2[24]) * COSPI_16_64;
temp2 = (step2[23] + step2[24]) * COSPI_16_64;
step1[23] = wrap32(wrap32(round_shift(temp1)));
step1[24] = wrap32(wrap32(round_shift(temp2)));
step1[28] = wrap32(step2[28]);
step1[29] = wrap32(step2[29]);
step1[30] = wrap32(step2[30]);
step1[31] = wrap32(step2[31]);
output[0] = (wrap32(step1[0] + step1[31])) as i32;
output[1] = (wrap32(step1[1] + step1[30])) as i32;
output[2] = (wrap32(step1[2] + step1[29])) as i32;
output[3] = (wrap32(step1[3] + step1[28])) as i32;
output[4] = (wrap32(step1[4] + step1[27])) as i32;
output[5] = (wrap32(step1[5] + step1[26])) as i32;
output[6] = (wrap32(step1[6] + step1[25])) as i32;
output[7] = (wrap32(step1[7] + step1[24])) as i32;
output[8] = (wrap32(step1[8] + step1[23])) as i32;
output[9] = (wrap32(step1[9] + step1[22])) as i32;
output[10] = (wrap32(step1[10] + step1[21])) as i32;
output[11] = (wrap32(step1[11] + step1[20])) as i32;
output[12] = (wrap32(step1[12] + step1[19])) as i32;
output[13] = (wrap32(step1[13] + step1[18])) as i32;
output[14] = (wrap32(step1[14] + step1[17])) as i32;
output[15] = (wrap32(step1[15] + step1[16])) as i32;
output[16] = (wrap32(step1[15] - step1[16])) as i32;
output[17] = (wrap32(step1[14] - step1[17])) as i32;
output[18] = (wrap32(step1[13] - step1[18])) as i32;
output[19] = (wrap32(step1[12] - step1[19])) as i32;
output[20] = (wrap32(step1[11] - step1[20])) as i32;
output[21] = (wrap32(step1[10] - step1[21])) as i32;
output[22] = (wrap32(step1[9] - step1[22])) as i32;
output[23] = (wrap32(step1[8] - step1[23])) as i32;
output[24] = (wrap32(step1[7] - step1[24])) as i32;
output[25] = (wrap32(step1[6] - step1[25])) as i32;
output[26] = (wrap32(step1[5] - step1[26])) as i32;
output[27] = (wrap32(step1[4] - step1[27])) as i32;
output[28] = (wrap32(step1[3] - step1[28])) as i32;
output[29] = (wrap32(step1[2] - step1[29])) as i32;
output[30] = (wrap32(step1[1] - step1[30])) as i32;
output[31] = (wrap32(step1[0] - step1[31])) as i32;
}