diff options
Diffstat (limited to 'media/libaom/src/aom_dsp/noise_model.c')
-rw-r--r-- | media/libaom/src/aom_dsp/noise_model.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/media/libaom/src/aom_dsp/noise_model.c b/media/libaom/src/aom_dsp/noise_model.c index 2faee85063..c7a0003a80 100644 --- a/media/libaom/src/aom_dsp/noise_model.c +++ b/media/libaom/src/aom_dsp/noise_model.c @@ -214,6 +214,7 @@ static void set_chroma_coefficient_fallback_soln(aom_equation_system_t *eqns) { int aom_noise_strength_lut_init(aom_noise_strength_lut_t *lut, int num_points) { if (!lut) return 0; + lut->num_points = 0; lut->points = (double(*)[2])aom_malloc(num_points * sizeof(*lut->points)); if (!lut->points) return 0; lut->num_points = num_points; @@ -426,6 +427,9 @@ int aom_flat_block_finder_init(aom_flat_block_finder_t *block_finder, double *AtA_inv = 0; double *A = 0; int x = 0, y = 0, i = 0, j = 0; + block_finder->A = NULL; + block_finder->AtA_inv = NULL; + if (!equation_system_init(&eqns, kLowPolyNumParams)) { fprintf(stderr, "Failed to init equation system for block_size=%d\n", block_size); @@ -632,10 +636,12 @@ int aom_flat_block_finder_run(const aom_flat_block_finder_t *block_finder, // [{var}, {ratio}, {trace}, {norm}, offset] // with one of the most discriminative being simply the variance. const double weights[5] = { -6682, -0.2056, 13087, -12434, 2.5694 }; - const float score = - (float)(1.0 / (1 + exp(-(weights[0] * var + weights[1] * ratio + - weights[2] * trace + weights[3] * norm + - weights[4])))); + double sum_weights = weights[0] * var + weights[1] * ratio + + weights[2] * trace + weights[3] * norm + + weights[4]; + // clamp the value to [-25.0, 100.0] to prevent overflow + sum_weights = fclamp(sum_weights, -25.0, 100.0); + const float score = (float)(1.0 / (1 + exp(-sum_weights))); flat_blocks[by * num_blocks_w + bx] = is_flat ? 255 : 0; scores[by * num_blocks_w + bx].score = var > kVarThreshold ? score : 0; scores[by * num_blocks_w + bx].index = by * num_blocks_w + bx; |