Add clamping in score_2D_transform_pow8()
To prevent FE_UNDERFLOW errors.
BUG=aomedia:1897
Change-Id: I1754f9ed046508c370c0536da28988d4300f9ec1
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index fc34028..e3eabdb 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1723,16 +1723,19 @@
static void score_2D_transform_pow8(float *scores_2D, float shift) {
float sum = 0.0f;
int i;
-
for (i = 0; i < 16; i++) {
- float v, v2, v4;
- v = AOMMAX(scores_2D[i] + shift, 0.0f);
- v2 = v * v;
- v4 = v2 * v2;
+ const float v = AOMMIN(AOMMAX(scores_2D[i] + shift, 0.0f), 100.0f);
+ const float v2 = v * v;
+ const float v4 = v2 * v2;
scores_2D[i] = v4 * v4;
sum += scores_2D[i];
}
- for (i = 0; i < 16; i++) scores_2D[i] /= sum;
+ for (i = 0; i < 16; i++) {
+ if (scores_2D[i] < sum * 1e-4)
+ scores_2D[i] = 0.0f;
+ else
+ scores_2D[i] /= sum;
+ }
}
// These thresholds were calibrated to provide a certain number of TX types