FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/rv34dsp.c
Date: 2024-05-03 15:42:48
Exec Total Coverage
Lines: 32 34 94.1%
Functions: 3 3 100.0%
Branches: 14 30 46.7%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "libavutil/mem.h"
22 #include "libavutil/mem_internal.h"
23
24 #include "libavcodec/rv34dsp.h"
25
26 #include "checkasm.h"
27
28 #define BUF_SIZE 1024
29
30 #define randomize(buf, len) \
31 do { \
32 for (int i = 0; i < len; i++) \
33 buf[i] = rnd(); \
34 } while (0)
35
36 13 static void test_rv34_inv_transform_dc(RV34DSPContext *s) {
37
2/2
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
13 declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block);
38
39
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
13 if (check_func(s->rv34_inv_transform_dc, "rv34_inv_transform_dc")) {
40 2 LOCAL_ALIGNED_16(int16_t, p1, [BUF_SIZE]);
41 2 LOCAL_ALIGNED_16(int16_t, p2, [BUF_SIZE]);
42
43
2/2
✓ Branch 1 taken 2048 times.
✓ Branch 2 taken 2 times.
2050 randomize(p1, BUF_SIZE);
44 2 memcpy(p2, p1, BUF_SIZE * sizeof(*p1));
45
46 2 call_ref(p1);
47 2 call_new(p2);
48
49
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (memcmp(p1, p2, BUF_SIZE * sizeof (*p1)) != 0) {
50 fail();
51 }
52
53
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
2 bench_new(p1);
54 }
55
56 13 report("rv34_inv_transform_dc");
57 13 }
58
59 13 static void test_rv34_idct_dc_add(RV34DSPContext *s) {
60 13 declare_func(void, uint8_t *dst, ptrdiff_t stride, int dc);
61
62
2/2
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
13 if (check_func(s->rv34_idct_dc_add, "rv34_idct_dc_add")) {
63 3 LOCAL_ALIGNED_16(uint8_t, p1, [BUF_SIZE]);
64 3 LOCAL_ALIGNED_16(uint8_t, p2, [BUF_SIZE]);
65
66
2/2
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
3075 randomize(p1, BUF_SIZE);
67 3 memcpy(p2, p1, BUF_SIZE * sizeof(*p1));
68
69 3 call_ref(p1, 4, 5);
70 3 call_new(p2, 4, 5);
71
72
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (memcmp(p1, p2, BUF_SIZE * sizeof (*p1)) != 0) {
73 fail();
74 }
75
76
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
3 bench_new(p1, 4, 5);
77 }
78
79 13 report("rv34_idct_dc_add");
80 13 }
81
82 13 void checkasm_check_rv34dsp(void)
83 {
84 13 RV34DSPContext s = { 0 };
85 13 ff_rv34dsp_init(&s);
86
87 13 test_rv34_inv_transform_dc(&s);
88 13 test_rv34_idct_dc_add(&s);
89 13 }
90