int32 Xs
int32 Ys
int32 Xe
int32 Ye
frac32 max
frac32 min
frac32 CV
int32 Xs
int32 Ys
int32 Xe
int32 Ye
frac32.s.map max
frac32.s.map min
objref ref
int i;
int j;
int Xs = (param_Xs + inlet_Xs) & 15;
int Xe = ((param_Xe + inlet_Xe) - Xs) & 15;
int Ys = (param_Ys + inlet_Ys) & 15;
int Ye = ((param_Ye + inlet_Ye) - Ys) & 15;
int size = Xe * Ye * 3;
int32_t temp = 0;
for (i = Xs; i < (Xe + Xs); i++) {
for (j = Ys; j < (Ye + Ys); j++) {
temp += attr_ref.array[i][j];
}
}
int32_t max = __SSAT(param_max + inlet_max, 27);
int32_t min = __SSAT(param_min + inlet_min, 27);
int32_t width = max - min;
outlet_CV = ___SMMUL(((temp << 16) / size) << 14, width << 2) + min;