| 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 | |||
| 22 | #include "libavfilter/vf_blackdetect.h" | ||
| 23 | #include "libavutil/mem_internal.h" | ||
| 24 | |||
| 25 | #define WIDTH 256 | ||
| 26 | #define HEIGHT 16 | ||
| 27 | #define STRIDE (WIDTH + 32) | ||
| 28 | |||
| 29 | 28 | static void check_blackdetect(int depth) | |
| 30 | { | ||
| 31 | 28 | LOCAL_ALIGNED_32(uint8_t, in, [HEIGHT * STRIDE]); | |
| 32 | |||
| 33 | 28 | declare_func(unsigned, const uint8_t *in, ptrdiff_t stride, | |
| 34 | ptrdiff_t width, ptrdiff_t height, | ||
| 35 | unsigned threshold); | ||
| 36 | |||
| 37 | 28 | memset(in, 0, HEIGHT * STRIDE); | |
| 38 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 28 times.
|
476 | for (int y = 0; y < HEIGHT; y++) { |
| 39 |
2/2✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 448 times.
|
115136 | for (int x = 0; x < WIDTH; x++) |
| 40 | 114688 | in[y * STRIDE + x] = rnd() & 0xFF; | |
| 41 | } | ||
| 42 | |||
| 43 | 28 | const unsigned threshold = 16 << (depth - 8); | |
| 44 | |||
| 45 | 28 | int w = WIDTH; | |
| 46 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
|
28 | if (depth == 16) |
| 47 | 14 | w /= 2; | |
| 48 | |||
| 49 |
2/2✓ Branch 4 taken 4 times.
✓ Branch 5 taken 24 times.
|
28 | if (check_func(ff_blackdetect_get_fn(depth), "blackdetect%d", depth)) { |
| 50 | /* Ensure odd tail is handled correctly */ | ||
| 51 | 4 | unsigned count_ref = call_ref(in, STRIDE, w - 8, HEIGHT, threshold); | |
| 52 | 4 | unsigned count_new = call_new(in, STRIDE, w - 8, HEIGHT, threshold); | |
| 53 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (count_ref != count_new) { |
| 54 | ✗ | fprintf(stderr, "blackdetect%d: count mismatch: %u != %u\n", | |
| 55 | depth, count_ref, count_new); | ||
| 56 | ✗ | fail(); | |
| 57 | } | ||
| 58 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 4 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.
|
4 | bench_new(in, STRIDE, w, HEIGHT, 16); |
| 59 | } | ||
| 60 | 28 | } | |
| 61 | |||
| 62 | 14 | void checkasm_check_blackdetect(void) | |
| 63 | { | ||
| 64 | 14 | check_blackdetect(8); | |
| 65 | 14 | report("blackdetect8"); | |
| 66 | |||
| 67 | 14 | check_blackdetect(16); | |
| 68 | 14 | report("blackdetect16"); | |
| 69 | 14 | } | |
| 70 |