FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/tests/lls.c
Date: 2026-09-30 10:56:58
Exec Total Coverage
Lines: 18 18 100.0%
Functions: 2 2 100.0%
Branches: 8 8 100.0%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <limits.h>
20 #include <stdio.h>
21
22 #include "libavutil/internal.h"
23 #include "libavutil/lfg.h"
24 #include "libavutil/lls.h"
25 #include "libavutil/mem_internal.h"
26
27 /* Values below the printed precision are rounding noise whose sign varies
28 * between platforms, so print them as zero. */
29 900 static double clean(double v)
30 {
31
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 793 times.
900 return fabs(v) < 1e-9 ? 0.0 : v;
32 }
33
34 1 int main(void)
35 {
36 LLSModel m;
37 int i, order;
38 AVLFG lfg;
39
40 1 av_lfg_init(&lfg, 1);
41 1 avpriv_init_lls(&m, 3);
42
43
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1 times.
101 for (i = 0; i < 100; i++) {
44 100 LOCAL_ALIGNED(32, double, var, [4]);
45 double eval;
46
47 100 var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
48 100 var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
49 100 var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
50 100 var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
51 100 m.update_lls(&m, var);
52 100 avpriv_solve_lls(&m, 0.001, 0);
53
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 100 times.
400 for (order = 0; order < 3; order++) {
54 300 eval = m.evaluate_lls(&m, var + 1, order);
55 300 printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n",
56 var[0], order, eval,
57
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 4 times.
300 sqrt(FFMAX(m.variance[order], 0) / (i + 1)),
58 clean(m.coeff[order][0]), clean(m.coeff[order][1]),
59 clean(m.coeff[order][2]));
60 }
61 }
62 1 return 0;
63 }
64