FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/utvideodsp.c
Date: 2024-05-03 15:42:48
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 3 3 100.0%
Branches: 48 68 70.6%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2017 Jokyo Images
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 <string.h>
22
23 #include "checkasm.h"
24 #include "libavcodec/utvideodsp.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/mem_internal.h"
27
28 #define WIDTH 240
29 #define HEIGHT 120
30 #define WIDTH_PADDED (WIDTH + 16) /* padded to 32 */
31 #define BUFFER_SIZE (WIDTH_PADDED * HEIGHT)
32
33
34 #define randomize_plane(buf, type) \
35 do { \
36 int w, h; \
37 type * tmp = buf; \
38 for (h = 0; h < HEIGHT; h++) { \
39 for (w = 0; w < WIDTH; w++) \
40 tmp[w] = rnd() & 0xFF; \
41 tmp += WIDTH_PADDED; \
42 } \
43 } while (0)
44
45 #define cmp_plane(buf0, buf1, s) \
46 do { \
47 int h; \
48 for (h = 0; h < HEIGHT; h++) { \
49 if (memcmp(buf0 + h*WIDTH_PADDED, \
50 buf1 + h*WIDTH_PADDED, WIDTH *s)) \
51 fail();\
52 } \
53 } while (0)
54
55
56 #define CHECK_RESTORE(type)\
57 LOCAL_ALIGNED_32(type, src_r0, [BUFFER_SIZE]); \
58 LOCAL_ALIGNED_32(type, src_g0, [BUFFER_SIZE]); \
59 LOCAL_ALIGNED_32(type, src_b0, [BUFFER_SIZE]); \
60 LOCAL_ALIGNED_32(type, src_r1, [BUFFER_SIZE]); \
61 LOCAL_ALIGNED_32(type, src_g1, [BUFFER_SIZE]); \
62 LOCAL_ALIGNED_32(type, src_b1, [BUFFER_SIZE]); \
63 declare_func(void, type *src_r, type *src_g, type *src_b, \
64 ptrdiff_t linesize_r, ptrdiff_t linesize_g, \
65 ptrdiff_t linesize_b, int width, int height); \
66 memset(src_r0, 0, BUFFER_SIZE * sizeof(type)); \
67 memset(src_g0, 0, BUFFER_SIZE * sizeof(type)); \
68 memset(src_b0, 0, BUFFER_SIZE * sizeof(type)); \
69 randomize_plane(src_r0, type); \
70 randomize_plane(src_g0, type); \
71 randomize_plane(src_b0, type); \
72 memcpy(src_r1, src_r0, BUFFER_SIZE * sizeof(type)); \
73 memcpy(src_g1, src_g0, BUFFER_SIZE * sizeof(type)); \
74 memcpy(src_b1, src_b0, BUFFER_SIZE * sizeof(type)); \
75 call_ref(src_r0, src_g0, src_b0, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT);\
76 call_new(src_r1, src_g1, src_b1, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT);\
77 cmp_plane(src_r0, src_r1, sizeof(type)); \
78 cmp_plane(src_g0, src_g1, sizeof(type)); \
79 cmp_plane(src_b0, src_b1, sizeof(type)); \
80 bench_new(src_r1, src_g1, src_b1, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT)
81
82 3 static void check_restore_rgb_planes(void) {
83
22/32
✓ Branch 1 taken 86400 times.
✓ Branch 2 taken 360 times.
✓ Branch 3 taken 360 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 86400 times.
✓ Branch 7 taken 360 times.
✓ Branch 8 taken 360 times.
✓ Branch 9 taken 3 times.
✓ Branch 11 taken 86400 times.
✓ Branch 12 taken 360 times.
✓ Branch 13 taken 360 times.
✓ Branch 14 taken 3 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 360 times.
✓ Branch 26 taken 360 times.
✓ Branch 27 taken 3 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 360 times.
✓ Branch 32 taken 360 times.
✓ Branch 33 taken 3 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 360 times.
✓ Branch 38 taken 360 times.
✓ Branch 39 taken 3 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 3 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
261363 CHECK_RESTORE(uint8_t);
84 3 }
85
86 3 static void check_restore_rgb_planes10(void) {
87
22/32
✓ Branch 1 taken 86400 times.
✓ Branch 2 taken 360 times.
✓ Branch 3 taken 360 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 86400 times.
✓ Branch 7 taken 360 times.
✓ Branch 8 taken 360 times.
✓ Branch 9 taken 3 times.
✓ Branch 11 taken 86400 times.
✓ Branch 12 taken 360 times.
✓ Branch 13 taken 360 times.
✓ Branch 14 taken 3 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 360 times.
✓ Branch 26 taken 360 times.
✓ Branch 27 taken 3 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 360 times.
✓ Branch 32 taken 360 times.
✓ Branch 33 taken 3 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 360 times.
✓ Branch 38 taken 360 times.
✓ Branch 39 taken 3 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 3 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
261363 CHECK_RESTORE(uint16_t);
88 3 }
89
90 13 void checkasm_check_utvideodsp(void)
91 {
92 UTVideoDSPContext h;
93
94 13 ff_utvideodsp_init(&h);
95
96
2/2
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
13 if (check_func(h.restore_rgb_planes, "restore_rgb_planes"))
97 3 check_restore_rgb_planes();
98
99 13 report("restore_rgb_planes");
100
101
2/2
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
13 if (check_func(h.restore_rgb_planes10, "restore_rgb_planes10"))
102 3 check_restore_rgb_planes10();
103
104 13 report("restore_rgb_planes10");
105 13 }
106