| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (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 | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License along | ||
| 15 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <string.h> | ||
| 20 | #include "checkasm.h" | ||
| 21 | #include "libavfilter/avfilter.h" | ||
| 22 | #include "libavfilter/convolution.h" | ||
| 23 | #include "libavutil/intreadwrite.h" | ||
| 24 | #include "libavutil/mem_internal.h" | ||
| 25 | |||
| 26 | #define WIDTH 512 | ||
| 27 | #define HEIGHT 512 | ||
| 28 | #define SRC_STRIDE 512 | ||
| 29 | #define PIXELS (WIDTH * HEIGHT) | ||
| 30 | |||
| 31 | #define randomize_buffers(buf, size) \ | ||
| 32 | do { \ | ||
| 33 | int j; \ | ||
| 34 | uint8_t *tmp_buf = (uint8_t *)buf;\ | ||
| 35 | for (j = 0; j< size; j++) \ | ||
| 36 | tmp_buf[j] = rnd() & 0xFF; \ | ||
| 37 | } while (0) | ||
| 38 | |||
| 39 | 14 | static void check_sobel(const char * report_name) | |
| 40 | { | ||
| 41 | 14 | LOCAL_ALIGNED_32(uint8_t, src, [PIXELS]); | |
| 42 | 14 | LOCAL_ALIGNED_32(uint8_t, dst_ref, [PIXELS]); | |
| 43 | 14 | LOCAL_ALIGNED_32(uint8_t, dst_new, [PIXELS]); | |
| 44 | 14 | const int height = WIDTH; | |
| 45 | 14 | const int width = HEIGHT; | |
| 46 | 14 | const int stride = SRC_STRIDE; | |
| 47 | 14 | const int dstride = SRC_STRIDE; | |
| 48 | 14 | int mode = 0; | |
| 49 | const uint8_t *c[49]; | ||
| 50 | 14 | const int radius = 1; | |
| 51 | 14 | const int bpc = 1; | |
| 52 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | const int step = mode == MATRIX_COLUMN ? 16 : 1; |
| 53 | 14 | const int slice_start = 0; | |
| 54 | 14 | const int slice_end = height; | |
| 55 | int y; | ||
| 56 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | const int sizew = mode == MATRIX_COLUMN ? height : width; |
| 57 | 14 | float scale = 2; | |
| 58 | 14 | float delta = 10; | |
| 59 | |||
| 60 | ConvolutionContext s; | ||
| 61 | |||
| 62 | 14 | declare_func(void, uint8_t *dst, int width, float scale, float delta, const int *const matrix, | |
| 63 | const uint8_t *c[], int peak, int radius, int dstride, int stride, int size); | ||
| 64 | |||
| 65 | 14 | s.scale = scale; | |
| 66 | 14 | s.delta = delta; | |
| 67 | 14 | s.depth = 8; | |
| 68 | 14 | s.nb_planes = 3; | |
| 69 | 14 | s.planes = 15; | |
| 70 | 14 | ff_sobel_init(&s, s.depth, s.nb_planes); | |
| 71 | |||
| 72 | 14 | memset(dst_ref, 0, PIXELS); | |
| 73 | 14 | memset(dst_new, 0, PIXELS); | |
| 74 |
2/2✓ Branch 1 taken 3670016 times.
✓ Branch 2 taken 14 times.
|
3670030 | randomize_buffers(src, PIXELS); |
| 75 | |||
| 76 |
2/2✓ Branch 3 taken 1 times.
✓ Branch 4 taken 13 times.
|
14 | if (check_func(s.filter[0], "%s", report_name)) { |
| 77 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (y = slice_start; y < slice_end; y += step) { |
| 78 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
|
512 | const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : radius * bpc; |
| 79 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
|
512 | const int yoff = mode == MATRIX_COLUMN ? radius * dstride : 0; |
| 80 | |||
| 81 | 512 | s.setup[0](radius, c, src, stride, radius, width, y, height, bpc); | |
| 82 | 512 | call_ref(dst_ref + yoff + xoff, sizew - 2 * radius, | |
| 83 | scale, delta, NULL, c, 0, radius, | ||
| 84 | dstride, stride, slice_end - step); | ||
| 85 | 512 | call_new(dst_new + yoff + xoff, sizew - 2 * radius, | |
| 86 | scale, delta, NULL, c, 0, radius, | ||
| 87 | dstride, stride, slice_end - step); | ||
| 88 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
|
512 | if (memcmp(dst_ref + yoff + xoff, dst_new + yoff + xoff, slice_end - step)) |
| 89 | ✗ | fail(); | |
| 90 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 512 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.
|
512 | bench_new(dst_new + yoff + xoff, sizew - 2 * radius, |
| 91 | scale, delta, NULL, c, 0, radius, | ||
| 92 | dstride, stride, slice_end - step); | ||
| 93 |
1/2✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
|
512 | if (mode != MATRIX_COLUMN) |
| 94 | 512 | dst_ref += dstride; | |
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | 14 | } | |
| 99 | |||
| 100 | 14 | void checkasm_check_vf_sobel(void) | |
| 101 | { | ||
| 102 | 14 | check_sobel("sobel"); | |
| 103 | 14 | report("convolution:sobel"); | |
| 104 | 14 | } | |
| 105 |