| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2016 Martin Storsjo | ||
| 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 <stdbool.h> | ||
| 22 | #include <string.h> | ||
| 23 | |||
| 24 | #include "config_components.h" | ||
| 25 | #include "libavcodec/vp8dsp.h" | ||
| 26 | |||
| 27 | #include "libavutil/common.h" | ||
| 28 | #include "libavutil/intreadwrite.h" | ||
| 29 | #include "libavutil/mem_internal.h" | ||
| 30 | |||
| 31 | #include "checkasm.h" | ||
| 32 | |||
| 33 | #define PIXEL_STRIDE 16 | ||
| 34 | |||
| 35 | #define randomize_buffers(src, dst, stride, coef) \ | ||
| 36 | do { \ | ||
| 37 | int x, y; \ | ||
| 38 | for (y = 0; y < 4; y++) { \ | ||
| 39 | AV_WN32A((src) + y * (stride), rnd()); \ | ||
| 40 | AV_WN32A((dst) + y * (stride), rnd()); \ | ||
| 41 | for (x = 0; x < 4; x++) \ | ||
| 42 | (coef)[y * 4 + x] = (src)[y * (stride) + x] - \ | ||
| 43 | (dst)[y * (stride) + x]; \ | ||
| 44 | } \ | ||
| 45 | } while (0) | ||
| 46 | |||
| 47 | 500 | static void dct4x4(int16_t *coef) | |
| 48 | { | ||
| 49 | int i; | ||
| 50 |
2/2✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 500 times.
|
2500 | for (i = 0; i < 4; i++) { |
| 51 | 2000 | const int a1 = (coef[i*4 + 0] + coef[i*4 + 3]) * 8; | |
| 52 | 2000 | const int b1 = (coef[i*4 + 1] + coef[i*4 + 2]) * 8; | |
| 53 | 2000 | const int c1 = (coef[i*4 + 1] - coef[i*4 + 2]) * 8; | |
| 54 | 2000 | const int d1 = (coef[i*4 + 0] - coef[i*4 + 3]) * 8; | |
| 55 | 2000 | coef[i*4 + 0] = a1 + b1; | |
| 56 | 2000 | coef[i*4 + 1] = (c1 * 2217 + d1 * 5352 + 14500) >> 12; | |
| 57 | 2000 | coef[i*4 + 2] = a1 - b1; | |
| 58 | 2000 | coef[i*4 + 3] = (d1 * 2217 - c1 * 5352 + 7500) >> 12; | |
| 59 | } | ||
| 60 |
2/2✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 500 times.
|
2500 | for (i = 0; i < 4; i++) { |
| 61 | 2000 | const int a1 = coef[i + 0*4] + coef[i + 3*4]; | |
| 62 | 2000 | const int b1 = coef[i + 1*4] + coef[i + 2*4]; | |
| 63 | 2000 | const int c1 = coef[i + 1*4] - coef[i + 2*4]; | |
| 64 | 2000 | const int d1 = coef[i + 0*4] - coef[i + 3*4]; | |
| 65 | 2000 | coef[i + 0*4] = (a1 + b1 + 7) >> 4; | |
| 66 | 2000 | coef[i + 1*4] = ((c1 * 2217 + d1 * 5352 + 12000) >> 16) + !!d1; | |
| 67 | 2000 | coef[i + 2*4] = (a1 - b1 + 7) >> 4; | |
| 68 | 2000 | coef[i + 3*4] = (d1 * 2217 - c1 * 5352 + 51000) >> 16; | |
| 69 | } | ||
| 70 | 500 | } | |
| 71 | |||
| 72 | 28 | static void wht4x4(int16_t *coef) | |
| 73 | { | ||
| 74 | int i; | ||
| 75 |
2/2✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
|
140 | for (i = 0; i < 4; i++) { |
| 76 | 112 | int a1 = coef[0 * 4 + i]; | |
| 77 | 112 | int b1 = coef[1 * 4 + i]; | |
| 78 | 112 | int c1 = coef[2 * 4 + i]; | |
| 79 | 112 | int d1 = coef[3 * 4 + i]; | |
| 80 | int e1; | ||
| 81 | 112 | a1 += b1; | |
| 82 | 112 | d1 -= c1; | |
| 83 | 112 | e1 = (a1 - d1) >> 1; | |
| 84 | 112 | b1 = e1 - b1; | |
| 85 | 112 | c1 = e1 - c1; | |
| 86 | 112 | a1 -= c1; | |
| 87 | 112 | d1 += b1; | |
| 88 | 112 | coef[0 * 4 + i] = a1; | |
| 89 | 112 | coef[1 * 4 + i] = c1; | |
| 90 | 112 | coef[2 * 4 + i] = d1; | |
| 91 | 112 | coef[3 * 4 + i] = b1; | |
| 92 | } | ||
| 93 |
2/2✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
|
140 | for (i = 0; i < 4; i++) { |
| 94 | 112 | int a1 = coef[i * 4 + 0]; | |
| 95 | 112 | int b1 = coef[i * 4 + 1]; | |
| 96 | 112 | int c1 = coef[i * 4 + 2]; | |
| 97 | 112 | int d1 = coef[i * 4 + 3]; | |
| 98 | int e1; | ||
| 99 | 112 | a1 += b1; | |
| 100 | 112 | d1 -= c1; | |
| 101 | 112 | e1 = (a1 - d1) >> 1; | |
| 102 | 112 | b1 = e1 - b1; | |
| 103 | 112 | c1 = e1 - c1; | |
| 104 | 112 | a1 -= c1; | |
| 105 | 112 | d1 += b1; | |
| 106 | 112 | coef[i * 4 + 0] = a1 * 2; | |
| 107 | 112 | coef[i * 4 + 1] = c1 * 2; | |
| 108 | 112 | coef[i * 4 + 2] = d1 * 2; | |
| 109 | 112 | coef[i * 4 + 3] = b1 * 2; | |
| 110 | } | ||
| 111 | 28 | } | |
| 112 | |||
| 113 | 28 | static void check_idct(VP8DSPContext *d, bool is_vp7) | |
| 114 | { | ||
| 115 | 28 | LOCAL_ALIGNED_16(uint8_t, src, [4 * 4]); | |
| 116 | 28 | LOCAL_ALIGNED_16(uint8_t, dst, [4 * 4]); | |
| 117 | 28 | LOCAL_ALIGNED_16(uint8_t, dst0, [4 * 4]); | |
| 118 | 28 | LOCAL_ALIGNED_16(uint8_t, dst1, [4 * 4]); | |
| 119 | 28 | LOCAL_ALIGNED_16(int16_t, coef, [4 * 4]); | |
| 120 | 28 | LOCAL_ALIGNED_16(int16_t, subcoef0, [4 * 4]); | |
| 121 | 28 | LOCAL_ALIGNED_16(int16_t, subcoef1, [4 * 4]); | |
| 122 | int dc; | ||
| 123 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
|
28 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *block, ptrdiff_t stride); |
| 124 | |||
| 125 |
4/4✓ Branch 2 taken 448 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 112 times.
✓ Branch 5 taken 28 times.
|
588 | randomize_buffers(src, dst, 4, coef); |
| 126 | |||
| 127 | 28 | dct4x4(coef); | |
| 128 | |||
| 129 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
|
84 | for (dc = 0; dc <= 1; dc++) { |
| 130 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | void (*idct)(uint8_t *, int16_t *, ptrdiff_t) = dc ? d->vp8_idct_dc_add : d->vp8_idct_add; |
| 131 | |||
| 132 |
4/4✓ Branch 2 taken 28 times.
✓ Branch 3 taken 28 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 49 times.
|
56 | if (check_func(idct, "vp%d_idct_%sadd", 8 - is_vp7, dc ? "dc_" : "")) { |
| 133 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
|
7 | if (dc) { |
| 134 | 4 | memset(subcoef0, 0, 4 * 4 * sizeof(int16_t)); | |
| 135 | 4 | subcoef0[0] = coef[0]; | |
| 136 | } else { | ||
| 137 | 3 | memcpy(subcoef0, coef, 4 * 4 * sizeof(int16_t)); | |
| 138 | } | ||
| 139 | 7 | memcpy(dst0, dst, 4 * 4); | |
| 140 | 7 | memcpy(dst1, dst, 4 * 4); | |
| 141 | 7 | memcpy(subcoef1, subcoef0, 4 * 4 * sizeof(int16_t)); | |
| 142 | // Note, this uses a pixel stride of 4, even though the real decoder uses a stride as a | ||
| 143 | // multiple of 16. If optimizations want to take advantage of that, this test needs to be | ||
| 144 | // updated to make it more like the h264dsp tests. | ||
| 145 | 7 | call_ref(dst0, subcoef0, 4); | |
| 146 | 7 | call_new(dst1, subcoef1, 4); | |
| 147 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if (memcmp(dst0, dst1, 4 * 4) || |
| 148 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | memcmp(subcoef0, subcoef1, 4 * 4 * sizeof(int16_t))) |
| 149 | ✗ | fail(); | |
| 150 | |||
| 151 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
7 | bench_new(dst1, subcoef1, 4); |
| 152 | } | ||
| 153 | } | ||
| 154 | 28 | } | |
| 155 | |||
| 156 | 28 | static void check_idct_dc4(VP8DSPContext *d, bool is_vp7) | |
| 157 | { | ||
| 158 | 28 | LOCAL_ALIGNED_16(uint8_t, src, [4 * 4 * 4]); | |
| 159 | 28 | LOCAL_ALIGNED_16(uint8_t, dst, [4 * 4 * 4]); | |
| 160 | 28 | LOCAL_ALIGNED_16(uint8_t, dst0, [4 * 4 * 4]); | |
| 161 | 28 | LOCAL_ALIGNED_16(uint8_t, dst1, [4 * 4 * 4]); | |
| 162 | 28 | LOCAL_ALIGNED_16(int16_t, coef, [4], [4 * 4]); | |
| 163 | 28 | LOCAL_ALIGNED_16(int16_t, subcoef0, [4], [4 * 4]); | |
| 164 | 28 | LOCAL_ALIGNED_16(int16_t, subcoef1, [4], [4 * 4]); | |
| 165 | int i, chroma; | ||
| 166 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
|
28 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t block[4][16], ptrdiff_t stride); |
| 167 | |||
| 168 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
|
84 | for (chroma = 0; chroma <= 1; chroma++) { |
| 169 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | void (*idct4dc)(uint8_t *, int16_t[4][16], ptrdiff_t) = chroma ? d->vp8_idct_dc_add4uv : d->vp8_idct_dc_add4y; |
| 170 |
4/4✓ Branch 2 taken 28 times.
✓ Branch 3 taken 28 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 50 times.
|
56 | if (check_func(idct4dc, "vp%d_idct_dc_add4%s", 8 - is_vp7, chroma ? "uv" : "y")) { |
| 171 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
|
6 | ptrdiff_t stride = chroma ? 8 : 16; |
| 172 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
|
6 | int w = chroma ? 2 : 4; |
| 173 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
|
30 | for (i = 0; i < 4; i++) { |
| 174 | 24 | int blockx = 4 * (i % w); | |
| 175 | 24 | int blocky = 4 * (i / w); | |
| 176 |
4/4✓ Branch 2 taken 384 times.
✓ Branch 3 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 5 taken 24 times.
|
504 | randomize_buffers(src + stride * blocky + blockx, dst + stride * blocky + blockx, stride, coef[i]); |
| 177 | 24 | dct4x4(coef[i]); | |
| 178 | 24 | memset(&coef[i][1], 0, 15 * sizeof(int16_t)); | |
| 179 | } | ||
| 180 | |||
| 181 | 6 | memcpy(dst0, dst, 4 * 4 * 4); | |
| 182 | 6 | memcpy(dst1, dst, 4 * 4 * 4); | |
| 183 | 6 | memcpy(subcoef0, coef, 4 * 4 * 4 * sizeof(int16_t)); | |
| 184 | 6 | memcpy(subcoef1, coef, 4 * 4 * 4 * sizeof(int16_t)); | |
| 185 | 6 | call_ref(dst0, subcoef0, stride); | |
| 186 | 6 | call_new(dst1, subcoef1, stride); | |
| 187 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (memcmp(dst0, dst1, 4 * 4 * 4) || |
| 188 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | memcmp(subcoef0, subcoef1, 4 * 4 * 4 * sizeof(int16_t))) |
| 189 | ✗ | fail(); | |
| 190 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
6 | bench_new(dst1, subcoef1, stride); |
| 191 | } | ||
| 192 | } | ||
| 193 | |||
| 194 | 28 | } | |
| 195 | |||
| 196 | 28 | static void check_luma_dc_wht(VP8DSPContext *d, bool is_vp7) | |
| 197 | { | ||
| 198 | 28 | LOCAL_ALIGNED_16(int16_t, dc, [4 * 4]); | |
| 199 | 28 | LOCAL_ALIGNED_16(int16_t, dc0, [4 * 4]); | |
| 200 | 28 | LOCAL_ALIGNED_16(int16_t, dc1, [4 * 4]); | |
| 201 | int16_t block[4][4][16]; | ||
| 202 | 28 | LOCAL_ALIGNED_16(int16_t, block0, [4], [4][16]); | |
| 203 | 28 | LOCAL_ALIGNED_16(int16_t, block1, [4], [4][16]); | |
| 204 | int dc_only; | ||
| 205 | int blockx, blocky; | ||
| 206 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
|
28 | declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t block[4][4][16], int16_t dc[16]); |
| 207 | |||
| 208 |
2/2✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
|
140 | for (blocky = 0; blocky < 4; blocky++) { |
| 209 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 112 times.
|
560 | for (blockx = 0; blockx < 4; blockx++) { |
| 210 | uint8_t src[16], dst[16]; | ||
| 211 |
4/4✓ Branch 2 taken 7168 times.
✓ Branch 3 taken 1792 times.
✓ Branch 4 taken 1792 times.
✓ Branch 5 taken 448 times.
|
9408 | randomize_buffers(src, dst, 4, block[blocky][blockx]); |
| 212 | |||
| 213 | 448 | dct4x4(block[blocky][blockx]); | |
| 214 | 448 | dc[blocky * 4 + blockx] = block[blocky][blockx][0]; | |
| 215 | 448 | block[blocky][blockx][0] = rnd(); | |
| 216 | } | ||
| 217 | } | ||
| 218 | 28 | wht4x4(dc); | |
| 219 | |||
| 220 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
|
84 | for (dc_only = 0; dc_only <= 1; dc_only++) { |
| 221 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | void (*idct)(int16_t [4][4][16], int16_t [16]) = dc_only ? d->vp8_luma_dc_wht_dc : d->vp8_luma_dc_wht; |
| 222 | |||
| 223 |
4/4✓ Branch 2 taken 28 times.
✓ Branch 3 taken 28 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 51 times.
|
56 | if (check_func(idct, "vp%d_luma_dc_wht%s", 8 - is_vp7, dc_only ? "_dc" : "")) { |
| 224 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | if (dc_only) { |
| 225 | 2 | memset(dc0, 0, 16 * sizeof(int16_t)); | |
| 226 | 2 | dc0[0] = dc[0]; | |
| 227 | } else { | ||
| 228 | 3 | memcpy(dc0, dc, 16 * sizeof(int16_t)); | |
| 229 | } | ||
| 230 | 5 | memcpy(dc1, dc0, 16 * sizeof(int16_t)); | |
| 231 | 5 | memcpy(block0, block, 4 * 4 * 16 * sizeof(int16_t)); | |
| 232 | 5 | memcpy(block1, block, 4 * 4 * 16 * sizeof(int16_t)); | |
| 233 | 5 | call_ref(block0, dc0); | |
| 234 | 5 | call_new(block1, dc1); | |
| 235 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (memcmp(block0, block1, 4 * 4 * 16 * sizeof(int16_t)) || |
| 236 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | memcmp(dc0, dc1, 16 * sizeof(int16_t))) |
| 237 | ✗ | fail(); | |
| 238 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
5 | bench_new(block1, dc1); |
| 239 | } | ||
| 240 | } | ||
| 241 | 28 | } | |
| 242 | |||
| 243 | #define SRC_BUF_STRIDE 32 | ||
| 244 | #define SRC_BUF_SIZE (((size << (size < 16)) + 5) * SRC_BUF_STRIDE) | ||
| 245 | // The mc subpixel interpolation filter needs the 2 previous pixels in either | ||
| 246 | // direction, the +1 is to make sure the actual load addresses always are | ||
| 247 | // unaligned. | ||
| 248 | #define src (buf + 2 * SRC_BUF_STRIDE + 2 + 1) | ||
| 249 | |||
| 250 | #undef randomize_buffers | ||
| 251 | #define randomize_buffers() \ | ||
| 252 | do { \ | ||
| 253 | int k; \ | ||
| 254 | for (k = 0; k < SRC_BUF_SIZE; k += 4) { \ | ||
| 255 | AV_WN32A(buf + k, rnd()); \ | ||
| 256 | } \ | ||
| 257 | } while (0) | ||
| 258 | |||
| 259 | 14 | static void check_mc(VP8DSPContext *d) | |
| 260 | { | ||
| 261 | 14 | LOCAL_ALIGNED_16(uint8_t, buf, [32 * 32]); | |
| 262 | 14 | BUF_RECT(uint8_t, dst0, 16, 16); | |
| 263 | 14 | BUF_RECT(uint8_t, dst1, 16, 16); | |
| 264 | int type, k, dx, dy; | ||
| 265 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 2 taken 1 times.
|
14 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t, |
| 266 | const uint8_t *, ptrdiff_t, int, int, int); | ||
| 267 | |||
| 268 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 14 times.
|
42 | for (type = 0; type < 2; type++) { |
| 269 |
2/2✓ Branch 0 taken 196 times.
✓ Branch 1 taken 28 times.
|
224 | for (k = 1; k < 8; k++) { |
| 270 | 196 | int hsize = k / 3; | |
| 271 | 196 | int size = 16 >> hsize; | |
| 272 | 196 | int height = (size << 1) >> (k % 3); | |
| 273 |
2/2✓ Branch 0 taken 588 times.
✓ Branch 1 taken 196 times.
|
784 | for (dy = 0; dy < 3; dy++) { |
| 274 |
2/2✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 588 times.
|
2352 | for (dx = 0; dx < 3; dx++) { |
| 275 | char str[100]; | ||
| 276 |
2/2✓ Branch 0 taken 882 times.
✓ Branch 1 taken 882 times.
|
1764 | vp8_mc_func func = (type ? d->put_vp8_bilinear_pixels_tab : d->put_vp8_epel_pixels_tab)[hsize][dy][dx]; |
| 277 | |||
| 278 |
4/4✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1176 times.
✓ Branch 2 taken 392 times.
✓ Branch 3 taken 196 times.
|
1764 | if (dx || dy) { |
| 279 |
2/2✓ Branch 0 taken 784 times.
✓ Branch 1 taken 784 times.
|
1568 | if (type == 0) { |
| 280 | static const char *dx_names[] = { "", "h4", "h6" }; | ||
| 281 | static const char *dy_names[] = { "", "v4", "v6" }; | ||
| 282 | 784 | snprintf(str, sizeof(str), "epel%d_%s%s", size, dx_names[dx], dy_names[dy]); | |
| 283 | } else { | ||
| 284 |
4/4✓ Branch 0 taken 588 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 196 times.
|
784 | snprintf(str, sizeof(str), "bilin%d_%s%s", size, dx ? "h" : "", dy ? "v" : ""); |
| 285 | } | ||
| 286 | } else { | ||
| 287 | 196 | snprintf(str, sizeof(str), "pixels%d", size); | |
| 288 | } | ||
| 289 | |||
| 290 |
2/2✓ Branch 3 taken 78 times.
✓ Branch 4 taken 1686 times.
|
1764 | if (check_func(func, "vp8_put_%s", str)) { |
| 291 | int mx, my; | ||
| 292 | int i; | ||
| 293 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 24 times.
|
78 | if (type == 0) { |
| 294 |
4/4✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 18 times.
|
54 | mx = dx == 2 ? 2 + 2 * (rnd() % 3) : dx == 1 ? 1 + 2 * (rnd() % 4) : 0; |
| 295 |
4/4✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 18 times.
|
54 | my = dy == 2 ? 2 + 2 * (rnd() % 3) : dy == 1 ? 1 + 2 * (rnd() % 4) : 0; |
| 296 | } else { | ||
| 297 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
|
24 | mx = dx ? 1 + (rnd() % 7) : 0; |
| 298 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
|
24 | my = dy ? 1 + (rnd() % 7) : 0; |
| 299 | } | ||
| 300 |
2/2✓ Branch 1 taken 11632 times.
✓ Branch 2 taken 78 times.
|
11710 | randomize_buffers(); |
| 301 |
2/2✓ Branch 0 taken 468 times.
✓ Branch 1 taken 78 times.
|
546 | for (i = -2; i <= 3; i++) { |
| 302 |
4/4✓ Branch 0 taken 390 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 312 times.
|
468 | int val = (i == -1 || i == 2) ? 0 : 0xff; |
| 303 | // Set pixels in the first row and column to the maximum pattern, | ||
| 304 | // to test for potential overflows in the filter. | ||
| 305 | 468 | src[i ] = val; | |
| 306 | 468 | src[i * SRC_BUF_STRIDE] = val; | |
| 307 | } | ||
| 308 | 78 | CLEAR_BUF_RECT(dst0); | |
| 309 | 78 | CLEAR_BUF_RECT(dst1); | |
| 310 | 78 | call_ref(dst0, dst0_stride, src, SRC_BUF_STRIDE, height, mx, my); | |
| 311 | 78 | call_new(dst1, dst1_stride, src, SRC_BUF_STRIDE, height, mx, my); | |
| 312 | 78 | checkasm_check_padded(uint8_t, dst0, dst0_stride, dst1, dst1_stride, size, height, "dst"); | |
| 313 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
78 | bench_new(dst1, size, src, SRC_BUF_STRIDE, height, mx, my); |
| 314 | } | ||
| 315 | } | ||
| 316 | } | ||
| 317 | } | ||
| 318 | } | ||
| 319 | 14 | } | |
| 320 | |||
| 321 | #undef randomize_buffers | ||
| 322 | |||
| 323 | #define setpx(a, b, c) buf[(a) + (b) * jstride] = av_clip_uint8(c) | ||
| 324 | // Set the pixel to c +/- [0,d] | ||
| 325 | #define setdx(a, b, c, d) setpx(a, b, c - (d) + (rnd() % ((d) * 2 + 1))) | ||
| 326 | // Set the pixel to c +/- [d,d+e] (making sure it won't be clipped) | ||
| 327 | #define setdx2(a, b, o, c, d, e) setpx(a, b, o = c + ((d) + (rnd() % (e))) * (c >= 128 ? -1 : 1)) | ||
| 328 | |||
| 329 | 290 | static void randomize_loopfilter_buffers(int lineoff, int str, | |
| 330 | int dir, int flim_E, int flim_I, | ||
| 331 | int hev_thresh, uint8_t *buf, | ||
| 332 | int force_hev) | ||
| 333 | { | ||
| 334 | 290 | uint32_t mask = 0xff; | |
| 335 |
2/2✓ Branch 0 taken 154 times.
✓ Branch 1 taken 136 times.
|
290 | int off = dir ? lineoff : lineoff * str; |
| 336 |
2/2✓ Branch 0 taken 154 times.
✓ Branch 1 taken 136 times.
|
290 | int istride = dir ? 1 : str; |
| 337 |
2/2✓ Branch 0 taken 136 times.
✓ Branch 1 taken 154 times.
|
290 | int jstride = dir ? str : 1; |
| 338 | int i; | ||
| 339 |
2/2✓ Branch 0 taken 1160 times.
✓ Branch 1 taken 290 times.
|
1450 | for (i = 0; i < 8; i += 2) { |
| 340 | // Row 0 will trigger hev for q0/q1, row 2 will trigger hev for p0/p1, | ||
| 341 | // rows 4 and 6 will not trigger hev. | ||
| 342 | // force_hev 1 will make sure all rows trigger hev, while force_hev -1 | ||
| 343 | // makes none of them trigger it. | ||
| 344 | 1160 | int idx = off + i * istride, p2, p1, p0, q0, q1, q2; | |
| 345 | 1160 | setpx(idx, 0, q0 = rnd() & mask); | |
| 346 |
6/6✓ Branch 0 taken 290 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 204 times.
✓ Branch 5 taken 752 times.
|
1160 | if (i == 0 && force_hev >= 0 || force_hev > 0) |
| 347 |
2/2✓ Branch 1 taken 196 times.
✓ Branch 2 taken 212 times.
|
408 | setdx2(idx, 1, q1, q0, hev_thresh + 1, flim_I - hev_thresh - 1); |
| 348 | else | ||
| 349 | 752 | setdx(idx, 1, q1 = q0, hev_thresh); | |
| 350 | 1160 | setdx(idx, 2, q2 = q1, flim_I); | |
| 351 | 1160 | setdx(idx, 3, q2, flim_I); | |
| 352 | 1160 | setdx(idx, -1, p0 = q0, flim_E >> 2); | |
| 353 |
6/6✓ Branch 0 taken 290 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 204 times.
✓ Branch 5 taken 752 times.
|
1160 | if (i == 2 && force_hev >= 0 || force_hev > 0) |
| 354 |
2/2✓ Branch 1 taken 201 times.
✓ Branch 2 taken 207 times.
|
408 | setdx2(idx, -2, p1, p0, hev_thresh + 1, flim_I - hev_thresh - 1); |
| 355 | else | ||
| 356 | 752 | setdx(idx, -2, p1 = p0, hev_thresh); | |
| 357 | 1160 | setdx(idx, -3, p2 = p1, flim_I); | |
| 358 | 1160 | setdx(idx, -4, p2, flim_I); | |
| 359 | } | ||
| 360 | 290 | } | |
| 361 | |||
| 362 | // Fill the buffer with random pixels | ||
| 363 | 213 | static void fill_loopfilter_buffers(uint8_t *buf, ptrdiff_t stride, int w, int h) | |
| 364 | { | ||
| 365 | int x, y; | ||
| 366 |
2/2✓ Branch 0 taken 3408 times.
✓ Branch 1 taken 213 times.
|
3621 | for (y = 0; y < h; y++) |
| 367 |
2/2✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 3408 times.
|
57936 | for (x = 0; x < w; x++) |
| 368 | 54528 | buf[y * stride + x] = rnd() & 0xff; | |
| 369 | 213 | } | |
| 370 | |||
| 371 | #define randomize_buffers(buf, lineoff, str, force_hev) \ | ||
| 372 | randomize_loopfilter_buffers(lineoff, str, dir, flim_E, flim_I, hev_thresh, buf, force_hev) | ||
| 373 | |||
| 374 | 28 | static void check_loopfilter_16y(VP8DSPContext *d, bool is_vp7) | |
| 375 | { | ||
| 376 | 28 | LOCAL_ALIGNED_16(uint8_t, base0, [32 + 16 * 16]); | |
| 377 | 28 | LOCAL_ALIGNED_16(uint8_t, base1, [32 + 16 * 16]); | |
| 378 | int dir, edge, force_hev; | ||
| 379 | 28 | int flim_E = 20, flim_I = 10, hev_thresh = 7; | |
| 380 | 28 | declare_func(void, uint8_t *, ptrdiff_t, int, int, int); | |
| 381 | |||
| 382 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
|
84 | for (dir = 0; dir < 2; dir++) { |
| 383 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | int midoff = dir ? 4 * 16 : 4; |
| 384 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | int midoff_aligned = dir ? 4 * 16 : 16; |
| 385 | 56 | uint8_t *buf0 = base0 + midoff_aligned; | |
| 386 | 56 | uint8_t *buf1 = base1 + midoff_aligned; | |
| 387 |
2/2✓ Branch 0 taken 112 times.
✓ Branch 1 taken 56 times.
|
168 | for (edge = 0; edge < 2; edge++) { |
| 388 | 112 | void (*func)(uint8_t *, ptrdiff_t, int, int, int) = NULL; | |
| 389 |
4/5✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
|
112 | switch (dir << 1 | edge) { |
| 390 | 28 | case (0 << 1) | 0: func = d->vp8_h_loop_filter16y; break; | |
| 391 | 28 | case (1 << 1) | 0: func = d->vp8_v_loop_filter16y; break; | |
| 392 | 28 | case (0 << 1) | 1: func = d->vp8_h_loop_filter16y_inner; break; | |
| 393 | 28 | case (1 << 1) | 1: func = d->vp8_v_loop_filter16y_inner; break; | |
| 394 | } | ||
| 395 |
6/6✓ Branch 2 taken 56 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 56 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 95 times.
|
112 | if (check_func(func, "vp%d_loop_filter16y%s_%s", 8 - is_vp7, edge ? "_inner" : "", dir ? "v" : "h")) { |
| 396 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 17 times.
|
68 | for (force_hev = -1; force_hev <= 1; force_hev++) { |
| 397 | 51 | fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16); | |
| 398 | 51 | randomize_buffers(buf0, 0, 16, force_hev); | |
| 399 | 51 | randomize_buffers(buf0, 8, 16, force_hev); | |
| 400 | 51 | memcpy(buf1 - midoff, buf0 - midoff, 16 * 16); | |
| 401 | 51 | call_ref(buf0, 16, flim_E, flim_I, hev_thresh); | |
| 402 | 51 | call_new(buf1, 16, flim_E, flim_I, hev_thresh); | |
| 403 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16)) |
| 404 | ✗ | fail(); | |
| 405 | } | ||
| 406 | 17 | fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16); | |
| 407 | 17 | randomize_buffers(buf0, 0, 16, 0); | |
| 408 | 17 | randomize_buffers(buf0, 8, 16, 0); | |
| 409 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
17 | bench_new(buf0, 16, flim_E, flim_I, hev_thresh); |
| 410 | } | ||
| 411 | } | ||
| 412 | } | ||
| 413 | 28 | } | |
| 414 | |||
| 415 | 28 | static void check_loopfilter_8uv(VP8DSPContext *d, bool is_vp7) | |
| 416 | { | ||
| 417 | 28 | LOCAL_ALIGNED_16(uint8_t, base0u, [32 + 16 * 16]); | |
| 418 | 28 | LOCAL_ALIGNED_16(uint8_t, base0v, [32 + 16 * 16]); | |
| 419 | 28 | LOCAL_ALIGNED_16(uint8_t, base1u, [32 + 16 * 16]); | |
| 420 | 28 | LOCAL_ALIGNED_16(uint8_t, base1v, [32 + 16 * 16]); | |
| 421 | int dir, edge, force_hev; | ||
| 422 | 28 | int flim_E = 20, flim_I = 10, hev_thresh = 7; | |
| 423 | 28 | declare_func(void, uint8_t *, uint8_t *, ptrdiff_t, int, int, int); | |
| 424 | |||
| 425 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
|
84 | for (dir = 0; dir < 2; dir++) { |
| 426 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | int midoff = dir ? 4 * 16 : 4; |
| 427 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | int midoff_aligned = dir ? 4 * 16 : 16; |
| 428 | 56 | uint8_t *buf0u = base0u + midoff_aligned; | |
| 429 | 56 | uint8_t *buf0v = base0v + midoff_aligned; | |
| 430 | 56 | uint8_t *buf1u = base1u + midoff_aligned; | |
| 431 | 56 | uint8_t *buf1v = base1v + midoff_aligned; | |
| 432 |
2/2✓ Branch 0 taken 112 times.
✓ Branch 1 taken 56 times.
|
168 | for (edge = 0; edge < 2; edge++) { |
| 433 | 112 | void (*func)(uint8_t *, uint8_t *, ptrdiff_t, int, int, int) = NULL; | |
| 434 |
4/5✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
|
112 | switch (dir << 1 | edge) { |
| 435 | 28 | case (0 << 1) | 0: func = d->vp8_h_loop_filter8uv; break; | |
| 436 | 28 | case (1 << 1) | 0: func = d->vp8_v_loop_filter8uv; break; | |
| 437 | 28 | case (0 << 1) | 1: func = d->vp8_h_loop_filter8uv_inner; break; | |
| 438 | 28 | case (1 << 1) | 1: func = d->vp8_v_loop_filter8uv_inner; break; | |
| 439 | } | ||
| 440 |
6/6✓ Branch 2 taken 56 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 56 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 95 times.
|
112 | if (check_func(func, "vp%d_loop_filter8uv%s_%s", 8 - is_vp7, edge ? "_inner" : "", dir ? "v" : "h")) { |
| 441 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 17 times.
|
68 | for (force_hev = -1; force_hev <= 1; force_hev++) { |
| 442 | 51 | fill_loopfilter_buffers(buf0u - midoff, 16, 16, 16); | |
| 443 | 51 | fill_loopfilter_buffers(buf0v - midoff, 16, 16, 16); | |
| 444 | 51 | randomize_buffers(buf0u, 0, 16, force_hev); | |
| 445 | 51 | randomize_buffers(buf0v, 0, 16, force_hev); | |
| 446 | 51 | memcpy(buf1u - midoff, buf0u - midoff, 16 * 16); | |
| 447 | 51 | memcpy(buf1v - midoff, buf0v - midoff, 16 * 16); | |
| 448 | |||
| 449 | 51 | call_ref(buf0u, buf0v, 16, flim_E, flim_I, hev_thresh); | |
| 450 | 51 | call_new(buf1u, buf1v, 16, flim_E, flim_I, hev_thresh); | |
| 451 |
1/2✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
|
51 | if (memcmp(buf0u - midoff, buf1u - midoff, 16 * 16) || |
| 452 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | memcmp(buf0v - midoff, buf1v - midoff, 16 * 16)) |
| 453 | ✗ | fail(); | |
| 454 | } | ||
| 455 | 17 | fill_loopfilter_buffers(buf0u - midoff, 16, 16, 16); | |
| 456 | 17 | fill_loopfilter_buffers(buf0v - midoff, 16, 16, 16); | |
| 457 | 17 | randomize_buffers(buf0u, 0, 16, 0); | |
| 458 | 17 | randomize_buffers(buf0v, 0, 16, 0); | |
| 459 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
17 | bench_new(buf0u, buf0v, 16, flim_E, flim_I, hev_thresh); |
| 460 | } | ||
| 461 | } | ||
| 462 | } | ||
| 463 | 28 | } | |
| 464 | |||
| 465 | 28 | static void check_loopfilter_simple(VP8DSPContext *d, bool is_vp7) | |
| 466 | { | ||
| 467 | 28 | LOCAL_ALIGNED_16(uint8_t, base0, [32 + 16 * 16]); | |
| 468 | 28 | LOCAL_ALIGNED_16(uint8_t, base1, [32 + 16 * 16]); | |
| 469 | int dir; | ||
| 470 | 28 | int flim_E = 20, flim_I = 30, hev_thresh = 0; | |
| 471 | 28 | declare_func(void, uint8_t *, ptrdiff_t, int); | |
| 472 | |||
| 473 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
|
84 | for (dir = 0; dir < 2; dir++) { |
| 474 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | int midoff = dir ? 4 * 16 : 4; |
| 475 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | int midoff_aligned = dir ? 4 * 16 : 16; |
| 476 | 56 | uint8_t *buf0 = base0 + midoff_aligned; | |
| 477 | 56 | uint8_t *buf1 = base1 + midoff_aligned; | |
| 478 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | void (*func)(uint8_t *, ptrdiff_t, int) = dir ? d->vp8_v_loop_filter_simple : d->vp8_h_loop_filter_simple; |
| 479 |
4/4✓ Branch 2 taken 28 times.
✓ Branch 3 taken 28 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 47 times.
|
56 | if (check_func(func, "vp%d_loop_filter_simple_%s", 8 - is_vp7, dir ? "v" : "h")) { |
| 480 | 9 | fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16); | |
| 481 | 9 | randomize_buffers(buf0, 0, 16, -1); | |
| 482 | 9 | randomize_buffers(buf0, 8, 16, -1); | |
| 483 | 9 | memcpy(buf1 - midoff, buf0 - midoff, 16 * 16); | |
| 484 | 9 | call_ref(buf0, 16, flim_E); | |
| 485 | 9 | call_new(buf1, 16, flim_E); | |
| 486 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16)) |
| 487 | ✗ | fail(); | |
| 488 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
9 | bench_new(buf0, 16, flim_E); |
| 489 | } | ||
| 490 | } | ||
| 491 | 28 | } | |
| 492 | |||
| 493 | 28 | static void checkasm_check_vp78dsp(VP8DSPContext *d, bool is_vp7) | |
| 494 | { | ||
| 495 | #if CONFIG_VP7_DECODER | ||
| 496 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
|
28 | if (is_vp7) |
| 497 | 14 | ff_vp7dsp_init(d); | |
| 498 | else | ||
| 499 | #endif | ||
| 500 | 14 | ff_vp8dsp_init(d); | |
| 501 | 28 | check_idct(d, is_vp7); | |
| 502 | 28 | check_idct_dc4(d, is_vp7); | |
| 503 | 28 | check_luma_dc_wht(d, is_vp7); | |
| 504 | 28 | report("idct"); | |
| 505 | 28 | check_loopfilter_16y(d, is_vp7); | |
| 506 | 28 | check_loopfilter_8uv(d, is_vp7); | |
| 507 | 28 | check_loopfilter_simple(d, is_vp7); | |
| 508 | 28 | report("loopfilter"); | |
| 509 | 28 | } | |
| 510 | |||
| 511 | 14 | void checkasm_check_vp8dsp(void) | |
| 512 | { | ||
| 513 | // Needs to be zeroed because not all size 16 epel functions exist. | ||
| 514 | 14 | VP8DSPContext d = { 0 }; | |
| 515 | |||
| 516 | 14 | ff_vp78dsp_init(&d); | |
| 517 | 14 | check_mc(&d); | |
| 518 | 14 | report("mc"); | |
| 519 | 14 | checkasm_check_vp78dsp(&d, false); | |
| 520 | #if CONFIG_VP7_DECODER | ||
| 521 | 14 | checkasm_check_vp78dsp(&d, true); | |
| 522 | #endif | ||
| 523 | 14 | } | |
| 524 |