Enable more floating point exceptions BUG=aomedia:1897 Change-Id: I7e3a2d5b1a3896e42b26d872b6468950f8746906
diff --git a/aom/src/aom_encoder.c b/aom/src/aom_encoder.c index 523f40b..01917c9 100644 --- a/aom/src/aom_encoder.c +++ b/aom/src/aom_encoder.c
@@ -190,7 +190,8 @@ #if HAVE_FEXCEPT && CONFIG_DEBUG #define FLOATING_POINT_SET_EXCEPTIONS \ - const int float_excepts = feenableexcept(FE_DIVBYZERO); + const int float_excepts = \ + feenableexcept(FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW); #define FLOATING_POINT_RESTORE_EXCEPTIONS feenableexcept(float_excepts); #else #define FLOATING_POINT_SET_EXCEPTIONS
diff --git a/aom_dsp/noise_util.c b/aom_dsp/noise_util.c index 87e8e9f..7e7e380 100644 --- a/aom_dsp/noise_util.c +++ b/aom_dsp/noise_util.c
@@ -96,7 +96,9 @@ for (int x = 0; x < block_size; ++x) { int i = y * block_size + x; float *c = noise_tx->tx_block + 2 * i; - const float p = c[0] * c[0] + c[1] * c[1]; + const float c0 = AOMMAX((float)fabs(c[0]), 1e-8f); + const float c1 = AOMMAX((float)fabs(c[1]), 1e-8f); + const float p = c0 * c0 + c1 * c1; if (p > kBeta * psd[i] && p > 1e-6) { noise_tx->tx_block[2 * i + 0] *= (p - psd[i]) / AOMMAX(p, kEps); noise_tx->tx_block[2 * i + 1] *= (p - psd[i]) / AOMMAX(p, kEps);
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 897daef..871ffbd 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -1526,15 +1526,17 @@ float sum = 0.0f; int i; for (i = 0; i < 16; i++) { - const float v = AOMMIN(AOMMAX(scores_2D[i] + shift, 0.0f), 100.0f); + const float v = AOMMIN(AOMMAX(scores_2D[i] + shift, 1e-3f), 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++) { - if (scores_2D[i] < sum * 1e-4) + if (scores_2D[i] * 10000 < sum) scores_2D[i] = 0.0f; + else if (sum < 1e-16f) + scores_2D[i] *= 1e16f; else scores_2D[i] /= sum; }