| 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 <assert.h> | ||
| 20 | #include <stddef.h> | ||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | #include "checkasm.h" | ||
| 24 | #include "libavutil/intreadwrite.h" | ||
| 25 | #include "libavutil/macros.h" | ||
| 26 | #include "libavutil/mem_internal.h" | ||
| 27 | #include "libavcodec/vp6data.h" | ||
| 28 | #include "libavcodec/vp56dsp.h" | ||
| 29 | |||
| 30 | #define randomize_buffer(buf) \ | ||
| 31 | do { \ | ||
| 32 | for (size_t k = 0; k < (sizeof(buf) & ~3); k += 4) \ | ||
| 33 | AV_WN32A(buf + k, rnd()); \ | ||
| 34 | for (size_t k = sizeof(buf) & ~3; k < sizeof(buf); ++k) \ | ||
| 35 | buf[k] = rnd(); \ | ||
| 36 | } while (0) | ||
| 37 | |||
| 38 | |||
| 39 | 14 | void checkasm_check_vp6dsp(void) | |
| 40 | { | ||
| 41 | enum { | ||
| 42 | BLOCK_SIZE_1D = 8, | ||
| 43 | SRC_ROWS_ABOVE = 1, | ||
| 44 | SRC_ROWS_BELOW = 2, | ||
| 45 | SRC_COLS_LEFT = 1, | ||
| 46 | SRC_COLS_RIGHT = 2, | ||
| 47 | SRC_ROWS = SRC_ROWS_ABOVE + BLOCK_SIZE_1D + SRC_ROWS_BELOW, | ||
| 48 | SRC_ROW_SIZE = SRC_COLS_LEFT + BLOCK_SIZE_1D + SRC_COLS_RIGHT, | ||
| 49 | MAX_STRIDE = 64, ///< arbitrary | ||
| 50 | SRC_BUF_SIZE = (SRC_ROWS - 1) * MAX_STRIDE + SRC_ROW_SIZE + 7 /* to vary misalignment */, | ||
| 51 | DST_BUF_SIZE = (BLOCK_SIZE_1D - 1) * MAX_STRIDE + BLOCK_SIZE_1D, | ||
| 52 | }; | ||
| 53 | VP6DSPContext vp6dsp; | ||
| 54 | |||
| 55 | 14 | ff_vp6dsp_init(&vp6dsp); | |
| 56 | |||
| 57 | 14 | declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride, | |
| 58 | const int16_t *h_weights, const int16_t *v_weights); | ||
| 59 | |||
| 60 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 12 times.
|
14 | if (check_func(vp6dsp.vp6_filter_diag4, "filter_diag4")) { |
| 61 | DECLARE_ALIGNED(8, uint8_t, dstbuf_ref)[DST_BUF_SIZE]; | ||
| 62 | DECLARE_ALIGNED(8, uint8_t, dstbuf_new)[DST_BUF_SIZE]; | ||
| 63 | DECLARE_ALIGNED(8, uint8_t, srcbuf)[SRC_BUF_SIZE]; | ||
| 64 | |||
| 65 |
3/4✓ Branch 1 taken 228 times.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
230 | randomize_buffer(dstbuf_ref); |
| 66 |
4/4✓ Branch 1 taken 328 times.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
|
334 | randomize_buffer(srcbuf); |
| 67 | 2 | memcpy(dstbuf_new, dstbuf_ref, sizeof(dstbuf_new)); | |
| 68 | |||
| 69 | 2 | ptrdiff_t stride = (rnd() % (MAX_STRIDE / 16) + 1) * 16; | |
| 70 | 2 | const uint8_t *src = srcbuf + SRC_COLS_LEFT + rnd() % 8U; | |
| 71 | 2 | uint8_t *dst_new = dstbuf_new, *dst_ref = dstbuf_ref; | |
| 72 | |||
| 73 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
|
2 | if (rnd() & 1) { |
| 74 | 1 | dst_new += (BLOCK_SIZE_1D - 1) * stride; | |
| 75 | 1 | dst_ref += (BLOCK_SIZE_1D - 1) * stride; | |
| 76 | 1 | src += (SRC_ROWS - 1) * stride; | |
| 77 | 1 | stride *= -1; | |
| 78 | } | ||
| 79 | 2 | src += SRC_ROWS_ABOVE * stride; | |
| 80 | |||
| 81 | 2 | unsigned select = rnd() % FF_ARRAY_ELEMS(vp6_block_copy_filter); | |
| 82 | 2 | unsigned x8 = 1 + rnd() % (FF_ARRAY_ELEMS(vp6_block_copy_filter[0]) - 1); | |
| 83 | 2 | unsigned y8 = 1 + rnd() % (FF_ARRAY_ELEMS(vp6_block_copy_filter[0]) - 1); | |
| 84 | 2 | const int16_t *h_weights = vp6_block_copy_filter[select][x8]; | |
| 85 | 2 | const int16_t *v_weights = vp6_block_copy_filter[select][y8]; | |
| 86 | |||
| 87 | 2 | call_ref(dst_ref, src, stride, h_weights, v_weights); | |
| 88 | 2 | call_new(dst_new, src, stride, h_weights, v_weights); | |
| 89 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (memcmp(dstbuf_new, dstbuf_ref, sizeof(dstbuf_new))) |
| 90 | ✗ | fail(); | |
| 91 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 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.
|
2 | bench_new(dst_new, src, stride, h_weights, v_weights); |
| 92 | } | ||
| 93 | 14 | report("filter_diag4"); | |
| 94 | 14 | } | |
| 95 |