| 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/vf_threshold_init.h" | ||
| 22 | #include "libavutil/intreadwrite.h" | ||
| 23 | #include "libavutil/mem_internal.h" | ||
| 24 | |||
| 25 | #define WIDTH 256 | ||
| 26 | #define WIDTH_PADDED 256 + 32 | ||
| 27 | |||
| 28 | #define randomize_buffers(buf, size) \ | ||
| 29 | do { \ | ||
| 30 | int j; \ | ||
| 31 | uint8_t *tmp_buf = (uint8_t *)buf;\ | ||
| 32 | for (j = 0; j < size; j++) \ | ||
| 33 | tmp_buf[j] = rnd() & 0xFF; \ | ||
| 34 | } while (0) | ||
| 35 | |||
| 36 | 28 | static void check_threshold(int depth){ | |
| 37 | 28 | LOCAL_ALIGNED_32(uint8_t, in , [WIDTH_PADDED]); | |
| 38 | 28 | LOCAL_ALIGNED_32(uint8_t, threshold, [WIDTH_PADDED]); | |
| 39 | 28 | LOCAL_ALIGNED_32(uint8_t, min , [WIDTH_PADDED]); | |
| 40 | 28 | LOCAL_ALIGNED_32(uint8_t, max , [WIDTH_PADDED]); | |
| 41 | 28 | LOCAL_ALIGNED_32(uint8_t, out_ref , [WIDTH_PADDED]); | |
| 42 | 28 | LOCAL_ALIGNED_32(uint8_t, out_new , [WIDTH_PADDED]); | |
| 43 | 28 | ptrdiff_t line_size = WIDTH_PADDED; | |
| 44 | 28 | int w = WIDTH; | |
| 45 | |||
| 46 | 28 | declare_func(void, const uint8_t *in, const uint8_t *threshold, | |
| 47 | const uint8_t *min, const uint8_t *max, uint8_t *out, | ||
| 48 | ptrdiff_t ilinesize, ptrdiff_t tlinesize, | ||
| 49 | ptrdiff_t flinesize, ptrdiff_t slinesize, | ||
| 50 | ptrdiff_t olinesize, int w, int h); | ||
| 51 | |||
| 52 | ThresholdContext s; | ||
| 53 | 28 | s.depth = depth; | |
| 54 | 28 | ff_threshold_init(&s); | |
| 55 | |||
| 56 | 28 | memset(in, 0, WIDTH_PADDED); | |
| 57 | 28 | memset(threshold, 0, WIDTH_PADDED); | |
| 58 | 28 | memset(min, 0, WIDTH_PADDED); | |
| 59 | 28 | memset(max, 0, WIDTH_PADDED); | |
| 60 | 28 | memset(out_ref, 0, WIDTH_PADDED); | |
| 61 | 28 | memset(out_new, 0, WIDTH_PADDED); | |
| 62 |
2/2✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 28 times.
|
7196 | randomize_buffers(in, WIDTH); |
| 63 |
2/2✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 28 times.
|
7196 | randomize_buffers(threshold, WIDTH); |
| 64 |
2/2✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 28 times.
|
7196 | randomize_buffers(min, WIDTH); |
| 65 |
2/2✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 28 times.
|
7196 | randomize_buffers(max, WIDTH); |
| 66 | |||
| 67 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
|
28 | if (depth == 16) |
| 68 | 14 | w /= 2; | |
| 69 | |||
| 70 |
2/2✓ Branch 3 taken 6 times.
✓ Branch 4 taken 22 times.
|
28 | if (check_func(s.threshold, "threshold%d", depth)) { |
| 71 | 6 | call_ref(in, threshold, min, max, out_ref, line_size, line_size, line_size, line_size, line_size, w, 1); | |
| 72 | 6 | call_new(in, threshold, min, max, out_new, line_size, line_size, line_size, line_size, line_size, w, 1); | |
| 73 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (memcmp(out_ref, out_new, WIDTH)) |
| 74 | ✗ | fail(); | |
| 75 |
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(in, threshold, min, max, out_new, line_size, line_size, line_size, line_size, line_size, w, 1); |
| 76 | } | ||
| 77 | 28 | } | |
| 78 | |||
| 79 | 14 | void checkasm_check_vf_threshold(void) | |
| 80 | { | ||
| 81 | 14 | check_threshold(8); | |
| 82 | 14 | report("threshold8"); | |
| 83 | |||
| 84 | 14 | check_threshold(16); | |
| 85 | 14 | report("threshold16"); | |
| 86 | 14 | } | |
| 87 |