| 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 <stddef.h> | ||
| 20 | #include <stdint.h> | ||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | #include "checkasm.h" | ||
| 24 | #include "libavcodec/huffyuvencdsp.h" | ||
| 25 | #include "libavutil/cpu.h" | ||
| 26 | #include "libavutil/macros.h" | ||
| 27 | #include "libavutil/mem_internal.h" | ||
| 28 | |||
| 29 | enum { | ||
| 30 | MAX_WIDTH = 4096, ///< maximum test width, must be a power of two smaller than the maximum alignment | ||
| 31 | }; | ||
| 32 | |||
| 33 | #define randomize_buffers(buf, size, mask) \ | ||
| 34 | do { \ | ||
| 35 | for (size_t j = 0; j < size; ++j) \ | ||
| 36 | buf[j] = rnd() & mask; \ | ||
| 37 | } while (0) | ||
| 38 | |||
| 39 | |||
| 40 | 28 | static void check_sub_hfyu_median_pred_int16(const char *aligned, unsigned width) | |
| 41 | { | ||
| 42 | static const int bpps[] = { 9, 16, }; | ||
| 43 | HuffYUVEncDSPContext c; | ||
| 44 | |||
| 45 | 28 | declare_func(void, uint16_t *dst, const uint16_t *src1, | |
| 46 | const uint16_t *src2, unsigned mask, int w, int *left, int *left_top); | ||
| 47 | |||
| 48 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
|
84 | for (size_t i = 0; i < FF_ARRAY_ELEMS(bpps); ++i) { |
| 49 | 56 | const int bpp = bpps[i]; | |
| 50 | |||
| 51 | 56 | ff_huffyuvencdsp_init(&c, bpp, width); | |
| 52 | |||
| 53 |
2/2✓ Branch 3 taken 10 times.
✓ Branch 4 taken 46 times.
|
56 | if (check_func(c.sub_hfyu_median_pred_int16, "sub_hfyu_median_pred_int16_%dbpp%s", bpp, aligned)) { |
| 54 | DECLARE_ALIGNED(32, uint16_t, dst0)[MAX_WIDTH]; | ||
| 55 | DECLARE_ALIGNED(32, uint16_t, dst1)[MAX_WIDTH]; | ||
| 56 | uint16_t src1[MAX_WIDTH]; | ||
| 57 | uint16_t src2[MAX_WIDTH]; | ||
| 58 | 10 | const unsigned mask = (1 << bpp) - 1; | |
| 59 | 10 | int l1 = rnd() & mask, lt1 = rnd() & mask, l2 = l1, lt2 = lt1; | |
| 60 | |||
| 61 |
2/2✓ Branch 1 taken 15200 times.
✓ Branch 2 taken 10 times.
|
15210 | randomize_buffers(src1, width, mask); |
| 62 |
2/2✓ Branch 1 taken 15200 times.
✓ Branch 2 taken 10 times.
|
15210 | randomize_buffers(src2, width, mask); |
| 63 | |||
| 64 | 10 | call_ref(dst0, src1, src2, mask, width, &l1, <1); | |
| 65 | 10 | call_new(dst1, src1, src2, mask, width, &l2, <2); | |
| 66 |
3/6✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
|
10 | if (l1 != l2 || lt1 != lt2 || memcmp(dst0, dst1, width * sizeof(dst0[0]))) |
| 67 | ✗ | fail(); | |
| 68 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 10 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.
|
10 | bench_new(dst1, src1, src2, mask, width, &l2, <2); |
| 69 | } | ||
| 70 | } | ||
| 71 | 28 | } | |
| 72 | |||
| 73 | 14 | void checkasm_check_huffyuvencdsp(void) | |
| 74 | { | ||
| 75 | static unsigned width = 0; | ||
| 76 | |||
| 77 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
|
14 | if (!width) { |
| 78 | 1 | width = rnd() % MAX_WIDTH; | |
| 79 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | width = width ? width : 1; |
| 80 | } | ||
| 81 | |||
| 82 | 14 | const size_t align = av_cpu_max_align(); | |
| 83 | |||
| 84 | 14 | check_sub_hfyu_median_pred_int16("_aligned", FFALIGN(width, align / sizeof(uint16_t))); | |
| 85 | 14 | report("sub_hfyu_median_pred_int16_aligned"); | |
| 86 | |||
| 87 | 14 | check_sub_hfyu_median_pred_int16("", width); | |
| 88 | 14 | report("sub_hfyu_median_pred_int16"); | |
| 89 | 14 | } | |
| 90 |