CMSIS-DSP: Ensure correlation array index is signed.

This attempts to ensures that even on a 64bit system, the array access
will be treated as a negative number, not a large unsigned offset ending
up reading from the middle of nowhere.
pull/19/head
David Green 5 years ago committed by Christophe Favergeon
parent 2f3a3730fd
commit 2074a3b291

@ -1136,7 +1136,7 @@ void arm_correlate_f16(
if ((((i - j) < srcBLen) && (j < srcALen)))
{
/* z[i] += x[i-j] * y[j] */
sum += pIn1[j] * pIn2[-((int32_t) i - j)];
sum += pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)];
}
}

@ -1074,7 +1074,7 @@ void arm_correlate_f32(
if ((((i - j) < srcBLen) && (j < srcALen)))
{
/* z[i] += x[i-j] * y[j] */
sum += pIn1[j] * pIn2[-((int32_t) i - j)];
sum += pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)];
}
}

@ -882,7 +882,7 @@ void arm_correlate_q15(
if (((i - j) < srcBLen) && (j < srcALen))
{
/* z[i] += x[i-j] * y[j] */
sum += ((q31_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
sum += ((q31_t) pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)]);
}
}

@ -858,7 +858,7 @@ void arm_correlate_q31(
if (((i - j) < srcBLen) && (j < srcALen))
{
/* z[i] += x[i-j] * y[j] */
sum += ((q63_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
sum += ((q63_t) pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)]);
}
}

@ -981,7 +981,7 @@ void arm_correlate_q7(
if (((i - j) < srcBLen) && (j < srcALen))
{
/* z[i] += x[i-j] * y[j] */
sum += ((q15_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
sum += ((q15_t) pIn1[j] * pIn2[-((int32_t) i - (int32_t) j)]);
}
}

Loading…
Cancel
Save