| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License along | ||
| 15 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <float.h> | ||
| 20 | #include <stdio.h> | ||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | #include "libavutil/lls.h" | ||
| 24 | #include "checkasm.h" | ||
| 25 | |||
| 26 | 12 | static void test_update(LLSModel *lls, const double *var) | |
| 27 | { | ||
| 28 | double refcovar[MAX_VARS][MAX_VARS]; | ||
| 29 | 12 | declare_func(void, LLSModel *, const double *); | |
| 30 | |||
| 31 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
|
12 | call_ref(lls, var); |
| 32 | |||
| 33 |
2/2✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
|
396 | for (size_t i = 0; i < MAX_VARS; i++) |
| 34 |
2/2✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 384 times.
|
12672 | for (size_t j = 0; j < MAX_VARS; j++) |
| 35 | 12288 | refcovar[i][j] = lls->covariance[i][j]; | |
| 36 | |||
| 37 | 12 | memset(lls->covariance, 0, sizeof (lls->covariance)); | |
| 38 | 12 | call_new(lls, var); | |
| 39 | |||
| 40 |
2/2✓ Branch 0 taken 208 times.
✓ Branch 1 taken 12 times.
|
220 | for (size_t i = 0; i < lls->indep_count; i++) |
| 41 |
2/2✓ Branch 0 taken 2568 times.
✓ Branch 1 taken 208 times.
|
2776 | for (size_t j = i; j < lls->indep_count; j++) { |
| 42 |
2/2✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 384 times.
|
2568 | double eps = FFMAX(2 * DBL_EPSILON * fabs(refcovar[i][j]), |
| 43 | 8 * DBL_EPSILON); | ||
| 44 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2568 times.
|
2568 | if (!double_near_abs_eps(refcovar[i][j], lls->covariance[i][j], |
| 45 | eps)) { | ||
| 46 | ✗ | fprintf(stderr, "%zu, %zu: %- .12f - %- .12f = % .12g\n", i, j, | |
| 47 | refcovar[i][j], lls->covariance[i][j], | ||
| 48 | ✗ | refcovar[i][j] - lls->covariance[i][j]); | |
| 49 | ✗ | fail(); | |
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
|
12 | bench_new(lls, var); |
| 54 | 12 | } | |
| 55 | |||
| 56 | 12 | static void test_evaluate(LLSModel *lls, const double *param, int order) | |
| 57 | { | ||
| 58 | double refprod, newprod, eps; | ||
| 59 | 12 | declare_func_float(double, LLSModel *, const double *, int); | |
| 60 | |||
| 61 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
|
12 | refprod = call_ref(lls, param, order); |
| 62 | 12 | newprod = call_new(lls, param, order); | |
| 63 | |||
| 64 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | eps = FFMAX(2 * DBL_EPSILON * fabs(refprod), 0.2); |
| 65 | |||
| 66 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
|
12 | if (!double_near_abs_eps(refprod, newprod, eps)) { |
| 67 | ✗ | fprintf(stderr, "%- .12f - %- .12f = % .12g\n", | |
| 68 | refprod, newprod, refprod - newprod); | ||
| 69 | ✗ | fail(); | |
| 70 | } | ||
| 71 | |||
| 72 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
|
12 | if (order == lls->indep_count) |
| 73 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
|
6 | bench_new(lls, param, order); |
| 74 | 12 | } | |
| 75 | |||
| 76 | 14 | void checkasm_check_lls(void) | |
| 77 | { | ||
| 78 | static const unsigned char counts[] = { 8, 12, MAX_VARS, }; | ||
| 79 | |||
| 80 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
|
56 | for (size_t i = 0; i < FF_ARRAY_ELEMS(counts); i++) { |
| 81 | 42 | LOCAL_ALIGNED_32(double, var, [MAX_VARS_ALIGN]); | |
| 82 | 42 | LOCAL_ALIGNED_32(double, param, [FFALIGN(MAX_VARS+2,4)]); | |
| 83 | LLSModel lls; | ||
| 84 | |||
| 85 | 42 | avpriv_init_lls(&lls, counts[i]); | |
| 86 | 42 | randomize_stddev_dbl(var, MAX_VARS_ALIGN, 10.0); | |
| 87 | 42 | randomize_stddev_dbl(param, MAX_VARS_ALIGN, 10.0); | |
| 88 | |||
| 89 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 30 times.
|
42 | if (check_func(lls.update_lls, "update_lls_%d", counts[i])) |
| 90 | 12 | test_update(&lls, var); | |
| 91 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 42 times.
|
126 | for (size_t j = 0; j <= i; j++) |
| 92 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 72 times.
|
84 | if (check_func(lls.evaluate_lls, "evaluate_lls_%d_%d", counts[i], |
| 93 | counts[j])) | ||
| 94 | 12 | test_evaluate(&lls, param + 1, counts[j]); | |
| 95 | } | ||
| 96 | 14 | report("lls"); | |
| 97 | 14 | } | |
| 98 |