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 "libavutil/intreadwrite.h" | ||
20 | #include "libavutil/mem.h" | ||
21 | #include "libavutil/mem_internal.h" | ||
22 | |||
23 | #include "libavcodec/mpegvideoencdsp.h" | ||
24 | |||
25 | #include "checkasm.h" | ||
26 | |||
27 | #define randomize_buffers(buf, size) \ | ||
28 | do { \ | ||
29 | for (int j = 0; j < size; j += 4) \ | ||
30 | AV_WN32(buf + j, rnd()); \ | ||
31 | } while (0) | ||
32 | |||
33 | 13 | static void check_pix_sum(MpegvideoEncDSPContext *c) | |
34 | { | ||
35 | 13 | LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]); | |
36 | |||
37 | 13 | declare_func(int, const uint8_t *pix, ptrdiff_t line_size); | |
38 | |||
39 |
2/2✓ Branch 1 taken 832 times.
✓ Branch 2 taken 13 times.
|
845 | randomize_buffers(src, 16 * 16); |
40 | |||
41 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
|
39 | for (int n = 0; n < 2; n++) { |
42 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
|
26 | const char *negstride_str = n ? "_negstride" : ""; |
43 |
2/2✓ Branch 3 taken 4 times.
✓ Branch 4 taken 22 times.
|
26 | if (check_func(c->pix_sum, "pix_sum%s", negstride_str)) { |
44 | int sum0, sum1; | ||
45 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | const uint8_t *pix = src + (n ? (15 * 16) : 0); |
46 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | ptrdiff_t line_size = 16 * (n ? -1 : 1); |
47 | 4 | sum0 = call_ref(pix, line_size); | |
48 | 4 | sum1 = call_new(pix, line_size); | |
49 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (sum0 != sum1) |
50 | ✗ | fail(); | |
51 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 4 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.
|
4 | bench_new(pix, line_size); |
52 | } | ||
53 | } | ||
54 | 13 | } | |
55 | |||
56 | 13 | static void check_pix_norm1(MpegvideoEncDSPContext *c) | |
57 | { | ||
58 | 13 | LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]); | |
59 | |||
60 | 13 | declare_func(int, const uint8_t *pix, ptrdiff_t line_size); | |
61 | |||
62 |
2/2✓ Branch 1 taken 832 times.
✓ Branch 2 taken 13 times.
|
845 | randomize_buffers(src, 16 * 16); |
63 | |||
64 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
|
39 | for (int n = 0; n < 2; n++) { |
65 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
|
26 | const char *negstride_str = n ? "_negstride" : ""; |
66 |
2/2✓ Branch 3 taken 4 times.
✓ Branch 4 taken 22 times.
|
26 | if (check_func(c->pix_norm1, "pix_norm1%s", negstride_str)) { |
67 | int sum0, sum1; | ||
68 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | const uint8_t *pix = src + (n ? (15 * 16) : 0); |
69 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | ptrdiff_t line_size = 16 * (n ? -1 : 1); |
70 | 4 | sum0 = call_ref(pix, line_size); | |
71 | 4 | sum1 = call_new(pix, line_size); | |
72 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (sum0 != sum1) |
73 | ✗ | fail(); | |
74 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 4 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.
|
4 | bench_new(pix, line_size); |
75 | } | ||
76 | } | ||
77 | 13 | } | |
78 | |||
79 | #define NUM_LINES 4 | ||
80 | #define MAX_LINE_SIZE 1920 | ||
81 | #define EDGE_WIDTH 16 | ||
82 | #define LINESIZE (EDGE_WIDTH + MAX_LINE_SIZE + EDGE_WIDTH) | ||
83 | #define BUFSIZE ((EDGE_WIDTH + NUM_LINES + EDGE_WIDTH) * LINESIZE) | ||
84 | |||
85 | 13 | static void check_draw_edges(MpegvideoEncDSPContext *c) | |
86 | { | ||
87 | static const int input_sizes[] = {8, 128, 1080, MAX_LINE_SIZE, -MAX_LINE_SIZE}; | ||
88 | 13 | LOCAL_ALIGNED_16(uint8_t, buf0, [BUFSIZE]); | |
89 | 13 | LOCAL_ALIGNED_16(uint8_t, buf1, [BUFSIZE]); | |
90 | |||
91 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
|
13 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *buf, ptrdiff_t wrap, int width, int height, |
92 | int w, int h, int sides); | ||
93 | |||
94 |
2/2✓ Branch 0 taken 65 times.
✓ Branch 1 taken 13 times.
|
78 | for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { |
95 | 65 | int input_size = input_sizes[isi]; | |
96 | 65 | int negstride = input_size < 0; | |
97 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 52 times.
|
65 | const char *negstride_str = negstride ? "_negstride" : ""; |
98 | 65 | int width = FFABS(input_size); | |
99 | 65 | ptrdiff_t linesize = EDGE_WIDTH + width + EDGE_WIDTH; | |
100 | /* calculate height based on specified width to use the entire buffer. */ | ||
101 | 65 | int height = (BUFSIZE / linesize) - (2 * EDGE_WIDTH); | |
102 | 65 | uint8_t *dst0 = buf0 + EDGE_WIDTH * linesize + EDGE_WIDTH; | |
103 | 65 | uint8_t *dst1 = buf1 + EDGE_WIDTH * linesize + EDGE_WIDTH; | |
104 | |||
105 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 52 times.
|
65 | if (negstride) { |
106 | 13 | dst0 += (height - 1) * linesize; | |
107 | 13 | dst1 += (height - 1) * linesize; | |
108 | 13 | linesize *= -1; | |
109 | } | ||
110 | |||
111 |
2/2✓ Branch 0 taken 195 times.
✓ Branch 1 taken 65 times.
|
260 | for (int shift = 0; shift < 3; shift++) { |
112 | 195 | int edge = EDGE_WIDTH >> shift; | |
113 |
2/2✓ Branch 3 taken 30 times.
✓ Branch 4 taken 165 times.
|
195 | if (check_func(c->draw_edges, "draw_edges_%d_%d_%d%s", width, height, edge, negstride_str)) { |
114 |
2/2✓ Branch 1 taken 527040 times.
✓ Branch 2 taken 30 times.
|
527070 | randomize_buffers(buf0, BUFSIZE); |
115 | 30 | memcpy(buf1, buf0, BUFSIZE); | |
116 | 30 | call_ref(dst0, linesize, width, height, edge, edge, EDGE_BOTTOM | EDGE_TOP); | |
117 | 30 | call_new(dst1, linesize, width, height, edge, edge, EDGE_BOTTOM | EDGE_TOP); | |
118 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | if (memcmp(buf0, buf1, BUFSIZE)) |
119 | ✗ | fail(); | |
120 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 30 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.
|
30 | bench_new(dst1, linesize, width, height, edge, edge, EDGE_BOTTOM | EDGE_TOP); |
121 | } | ||
122 | } | ||
123 | } | ||
124 | 13 | } | |
125 | |||
126 | #undef NUM_LINES | ||
127 | #undef MAX_LINE_SIZE | ||
128 | #undef EDGE_WIDTH | ||
129 | #undef LINESIZE | ||
130 | #undef BUFSIZE | ||
131 | |||
132 | 13 | void checkasm_check_mpegvideoencdsp(void) | |
133 | { | ||
134 | 13 | AVCodecContext avctx = { | |
135 | .bits_per_raw_sample = 8, | ||
136 | }; | ||
137 | 13 | MpegvideoEncDSPContext c = { 0 }; | |
138 | |||
139 | 13 | ff_mpegvideoencdsp_init(&c, &avctx); | |
140 | |||
141 | 13 | check_pix_sum(&c); | |
142 | 13 | report("pix_sum"); | |
143 | 13 | check_pix_norm1(&c); | |
144 | 13 | report("pix_norm1"); | |
145 | 13 | check_draw_edges(&c); | |
146 | 13 | report("draw_edges"); | |
147 | 13 | } | |
148 |