| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS). | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License along | ||
| 17 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | #include "libavutil/mem.h" | ||
| 24 | #include "libavutil/mem_internal.h" | ||
| 25 | |||
| 26 | #include "libavcodec/takdsp.h" | ||
| 27 | #include "libavcodec/mathops.h" | ||
| 28 | |||
| 29 | #include "checkasm.h" | ||
| 30 | |||
| 31 | #define randomize(buf, len) \ | ||
| 32 | do { \ | ||
| 33 | for (int i = 0; i < len; i++) \ | ||
| 34 | buf[i] = rnd(); \ | ||
| 35 | } while (0) | ||
| 36 | |||
| 37 | #define BUF_SIZE 1024 | ||
| 38 | |||
| 39 | 14 | static void test_decorrelate_ls(TAKDSPContext *s) { | |
| 40 | 14 | declare_func(void, const int32_t *, int32_t *, int); | |
| 41 | |||
| 42 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 11 times.
|
14 | if (check_func(s->decorrelate_ls, "decorrelate_ls")) { |
| 43 | 3 | LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]); | |
| 44 | 3 | LOCAL_ALIGNED_32(int32_t, p2, [BUF_SIZE]); | |
| 45 | 3 | LOCAL_ALIGNED_32(int32_t, p2_2, [BUF_SIZE]); | |
| 46 | |||
| 47 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p1, BUF_SIZE); |
| 48 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p2, BUF_SIZE); |
| 49 | 3 | memcpy(p2_2, p2, BUF_SIZE * sizeof(*p2)); | |
| 50 | |||
| 51 | 3 | call_ref(p1, p2, BUF_SIZE); | |
| 52 | 3 | call_new(p1, p2_2, BUF_SIZE); | |
| 53 | |||
| 54 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (memcmp(p2, p2_2, BUF_SIZE * sizeof(*p2)) != 0) { |
| 55 | ✗ | fail(); | |
| 56 | } | ||
| 57 | |||
| 58 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 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.
|
3 | bench_new(p1, p2, BUF_SIZE); |
| 59 | } | ||
| 60 | |||
| 61 | 14 | report("decorrelate_ls"); | |
| 62 | 14 | } | |
| 63 | |||
| 64 | 14 | static void test_decorrelate_sr(TAKDSPContext *s) { | |
| 65 | 14 | declare_func(void, int32_t *, const int32_t *, int); | |
| 66 | |||
| 67 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 11 times.
|
14 | if (check_func(s->decorrelate_sr, "decorrelate_sr")) { |
| 68 | 3 | LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]); | |
| 69 | 3 | LOCAL_ALIGNED_32(int32_t, p1_2, [BUF_SIZE]); | |
| 70 | 3 | LOCAL_ALIGNED_32(int32_t, p2, [BUF_SIZE]); | |
| 71 | |||
| 72 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p1, BUF_SIZE); |
| 73 | 3 | memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1)); | |
| 74 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p2, BUF_SIZE); |
| 75 | |||
| 76 | 3 | call_ref(p1, p2, BUF_SIZE); | |
| 77 | 3 | call_new(p1_2, p2, BUF_SIZE); | |
| 78 | |||
| 79 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0) { |
| 80 | ✗ | fail(); | |
| 81 | } | ||
| 82 | |||
| 83 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 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.
|
3 | bench_new(p1, p2, BUF_SIZE); |
| 84 | } | ||
| 85 | |||
| 86 | 14 | report("decorrelate_sr"); | |
| 87 | 14 | } | |
| 88 | |||
| 89 | 14 | static void test_decorrelate_sm(TAKDSPContext *s) { | |
| 90 | 14 | declare_func(void, int32_t *, int32_t *, int); | |
| 91 | |||
| 92 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 11 times.
|
14 | if (check_func(s->decorrelate_sm, "decorrelate_sm")) { |
| 93 | 3 | LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]); | |
| 94 | 3 | LOCAL_ALIGNED_32(int32_t, p1_2, [BUF_SIZE]); | |
| 95 | 3 | LOCAL_ALIGNED_32(int32_t, p2, [BUF_SIZE]); | |
| 96 | 3 | LOCAL_ALIGNED_32(int32_t, p2_2, [BUF_SIZE]); | |
| 97 | |||
| 98 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p1, BUF_SIZE); |
| 99 | 3 | memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1)); | |
| 100 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p2, BUF_SIZE); |
| 101 | 3 | memcpy(p2_2, p2, BUF_SIZE * sizeof(*p2)); | |
| 102 | |||
| 103 | 3 | call_ref(p1, p2, BUF_SIZE); | |
| 104 | 3 | call_new(p1_2, p2_2, BUF_SIZE); | |
| 105 | |||
| 106 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0 || |
| 107 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | memcmp(p2, p2_2, BUF_SIZE * sizeof(*p2)) != 0) { |
| 108 | ✗ | fail(); | |
| 109 | } | ||
| 110 | |||
| 111 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 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.
|
3 | bench_new(p1, p2, BUF_SIZE); |
| 112 | } | ||
| 113 | |||
| 114 | 14 | report("decorrelate_sm"); | |
| 115 | 14 | } | |
| 116 | |||
| 117 | 14 | static void test_decorrelate_sf(TAKDSPContext *s) { | |
| 118 | 14 | declare_func(void, int32_t *, const int32_t *, int, int, int); | |
| 119 | |||
| 120 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 11 times.
|
14 | if (check_func(s->decorrelate_sf, "decorrelate_sf")) { |
| 121 | 3 | LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]); | |
| 122 | 3 | LOCAL_ALIGNED_32(int32_t, p1_2, [BUF_SIZE]); | |
| 123 | 3 | LOCAL_ALIGNED_32(int32_t, p2, [BUF_SIZE]); | |
| 124 | int dshift, dfactor; | ||
| 125 | |||
| 126 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p1, BUF_SIZE); |
| 127 | 3 | memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1)); | |
| 128 |
2/2✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3 times.
|
3075 | randomize(p2, BUF_SIZE); |
| 129 | 3 | dshift = (rnd() & 0xF) + 1; | |
| 130 | 3 | dfactor = sign_extend(rnd(), 10); | |
| 131 | |||
| 132 | 3 | call_ref(p1, p2, BUF_SIZE, dshift, dfactor); | |
| 133 | 3 | call_new(p1_2, p2, BUF_SIZE, dshift, dfactor); | |
| 134 | |||
| 135 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0) { |
| 136 | ✗ | fail(); | |
| 137 | } | ||
| 138 | |||
| 139 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 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.
|
3 | bench_new(p1, p2, BUF_SIZE, dshift, dfactor); |
| 140 | } | ||
| 141 | |||
| 142 | 14 | report("decorrelate_sf"); | |
| 143 | 14 | } | |
| 144 | |||
| 145 | 14 | void checkasm_check_takdsp(void) | |
| 146 | { | ||
| 147 | 14 | TAKDSPContext s = { 0 }; | |
| 148 | 14 | ff_takdsp_init(&s); | |
| 149 | |||
| 150 | 14 | test_decorrelate_ls(&s); | |
| 151 | 14 | test_decorrelate_sr(&s); | |
| 152 | 14 | test_decorrelate_sm(&s); | |
| 153 | 14 | test_decorrelate_sf(&s); | |
| 154 | 14 | } | |
| 155 |