Unified · Split
| @@ -21,6 +21,7 @@ · 20 unmodified lines | |||
| 21 | 21 | ||
| 22 | #include <float.h> | 22 | #include <float.h> |
| 23 | 23 | ||
| 24 | #include "libavutil/avassert.h" | ||
| 24 | #include "libavutil/common.h" | 25 | #include "libavutil/common.h" |
| 25 | #include "libavutil/float_dsp.h" | 26 | #include "libavutil/float_dsp.h" |
| 26 | #include "libavutil/imgutils.h" | 27 | #include "libavutil/imgutils.h" |
| @@ -217,11 +218,13 @@ static int query_formats(AVFilterContext *ctx) · 190 unmodified lines | |||
| 217 | static float dot_dsp(const NNEDIContext *const s, const float *kernel, const float *input, | 218 | static float dot_dsp(const NNEDIContext *const s, const float *kernel, const float *input, |
| 218 | int n, float scale, float bias) | 219 | int n, float scale, float bias) |
| 219 | { | 220 | { |
| 220 | float sum; | 221 | float sum, y; |
| 221 | 222 | ||
| 222 | sum = s->fdsp->scalarproduct_float(kernel, input, n); | 223 | sum = s->fdsp->scalarproduct_float(kernel, input, n); |
| 223 | 224 | ||
| 224 | return sum * scale + bias; | 225 | y = sum * scale + bias + 1e-20f; |
| 226 | |||
| 227 | return y; | ||
| 225 | } | 228 | } |
| 226 | 229 | ||
| 227 | static float elliott(float x) | 230 | static float elliott(float x) |
| @@ -334,6 +337,7 @@ static void gather_input(const float *src, ptrdiff_t src_stride, · 106 unmodified lines | |||
| 334 | float *buf, float mstd[4], | 337 | float *buf, float mstd[4], |
| 335 | const PredictorCoefficients *const model) | 338 | const PredictorCoefficients *const model) |
| 336 | { | 339 | { |
| 340 | const float scale = 1.f / model->nsize; | ||
| 337 | float sum = 0.f; | 341 | float sum = 0.f; |
| 338 | float sum_sq = 0.f; | 342 | float sum_sq = 0.f; |
| 339 | float tmp; | 343 | float tmp; |
| @@ -352,10 +356,10 @@ static void gather_input(const float *src, ptrdiff_t src_stride, · 12 unmodified lines | |||
| 352 | buf += model->xdim; | 356 | buf += model->xdim; |
| 353 | } | 357 | } |
| 354 | 358 | ||
| 355 | mstd[0] = sum / model->nsize; | 359 | mstd[0] = sum * scale; |
| 356 | mstd[3] = 0.f; | 360 | mstd[3] = 0.f; |
| 357 | 361 | ||
| 358 | tmp = sum_sq / model->nsize - mstd[0] * mstd[0]; | 362 | tmp = sum_sq * scale - mstd[0] * mstd[0]; |
| 359 | if (tmp < FLT_EPSILON) { | 363 | if (tmp < FLT_EPSILON) { |
| 360 | mstd[1] = 0.0f; | 364 | mstd[1] = 0.0f; |
| 361 | mstd[2] = 0.0f; | 365 | mstd[2] = 0.0f; |
| @@ -945,8 +949,9 @@ static void subtract_mean_new(PrescreenerCoefficients *coeffs, float half) · 583 unmodified lines | |||
| 945 | 949 | ||
| 946 | static void subtract_mean_predictor(PredictorCoefficients *model) | 950 | static void subtract_mean_predictor(PredictorCoefficients *model) |
| 947 | { | 951 | { |
| 948 | int filter_size = model->nsize; | 952 | const int filter_size = model->nsize; |
| 949 | int nns = model->nns; | 953 | const int nns = model->nns; |
| 954 | const float scale = 1.f / nns; | ||
| 950 | 955 | ||
| 951 | double softmax_means[256]; // Average of individual softmax filters. | 956 | double softmax_means[256]; // Average of individual softmax filters. |
| 952 | double elliott_means[256]; // Average of individual elliott filters. | 957 | double elliott_means[256]; // Average of individual elliott filters. |
| @@ -963,7 +968,7 @@ static void subtract_mean_predictor(PredictorCoefficients *model) · 10 unmodified lines | |||
| 963 | } | 968 | } |
| 964 | 969 | ||
| 965 | for (int k = 0; k < filter_size; k++) | 970 | for (int k = 0; k < filter_size; k++) |
| 966 | mean_filter[k] /= nns; | 971 | mean_filter[k] *= scale; |
| 967 | 972 | ||
| 968 | mean_bias = mean(model->softmax_bias_q1, nns); | 973 | mean_bias = mean(model->softmax_bias_q1, nns); |
| 969 | 974 | ||
| @@ -988,7 +993,7 @@ static void subtract_mean_predictor(PredictorCoefficients *model) · 18 unmodified lines | |||
| 988 | } | 993 | } |
| 989 | 994 | ||
| 990 | for (int k = 0; k < filter_size; k++) | 995 | for (int k = 0; k < filter_size; k++) |
| 991 | mean_filter[k] /= nns; | 996 | mean_filter[k] *= scale; |
| 992 | 997 | ||
| 993 | mean_bias = mean(model->softmax_bias_q2, nns); | 998 | mean_bias = mean(model->softmax_bias_q2, nns); |
| 994 | 999 | ||