| 1 |
/* |
| 2 |
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2023 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-dsp-lib |
| 6 |
* Created on: 3 нояб. 2023 г. |
| 7 |
* |
| 8 |
* lsp-dsp-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-dsp-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef PRIVATE_DSP_ARCH_ARM_NEON_D32_DYNAMICS_EXPANDER_H_ |
| 23 |
#define PRIVATE_DSP_ARCH_ARM_NEON_D32_DYNAMICS_EXPANDER_H_ |
| 24 |
|
| 25 |
#include <private/dsp/arch/arm/neon-d32/pmath/exp.h> |
| 26 |
#include <private/dsp/arch/arm/neon-d32/pmath/log.h> |
| 27 |
|
| 28 |
namespace lsp |
| 29 |
{ |
| 30 |
namespace neon_d32 |
| 31 |
{ |
| 32 |
IF_ARCH_ARM( |
| 33 |
static const float expander_const[] __lsp_aligned16 = |
| 34 |
{ |
| 35 |
LSP_DSP_VEC4(1.0f) |
| 36 |
}; |
| 37 |
) |
| 38 |
|
| 39 |
#define PROCESS_UKNEE_SINGLE_X8 \ |
| 40 |
/* in: q0 = lx0, q1 = lx1 */ \ |
| 41 |
__ASM_EMIT("add %[off], %[exp], #0x10") \ |
| 42 |
__ASM_EMIT("vld4.f32 {d16[], d18[], d20[], d22[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 43 |
__ASM_EMIT("vld4.f32 {d17[], d19[], d21[], d23[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 44 |
__ASM_EMIT("vld4.f32 {d24[], d26[], d28[], d30[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 45 |
__ASM_EMIT("vld4.f32 {d25[], d27[], d29[], d31[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 46 |
__ASM_EMIT("vmul.f32 q2, q0, q11") /* q2 = herm[0]*lx0 */ \ |
| 47 |
__ASM_EMIT("vmul.f32 q3, q1, q11") \ |
| 48 |
__ASM_EMIT("vmul.f32 q4, q0, q14") /* q4 = tilt[0]*lx0 */ \ |
| 49 |
__ASM_EMIT("vmul.f32 q5, q1, q14") \ |
| 50 |
__ASM_EMIT("vadd.f32 q2, q2, q12") /* q2 = herm[0]*lx0+herm[1] */ \ |
| 51 |
__ASM_EMIT("vadd.f32 q3, q3, q12") \ |
| 52 |
__ASM_EMIT("vldm %[mem], {q6-q7}") /* q6 = x0, q7 = x1 */ \ |
| 53 |
__ASM_EMIT("vmul.f32 q2, q2, q0") /* q2 = (herm[0]*lx0+herm[1])*lx0 */ \ |
| 54 |
__ASM_EMIT("vmul.f32 q3, q3, q1") \ |
| 55 |
__ASM_EMIT("vcge.f32 q6, q6, q9") /* q6 = [x0 >= end] */ \ |
| 56 |
__ASM_EMIT("vcge.f32 q7, q7, q9") \ |
| 57 |
__ASM_EMIT("vadd.f32 q2, q2, q13") /* q2 = KV = (herm[0]*lx0+herm[1])*lx0+herm[2] */ \ |
| 58 |
__ASM_EMIT("vadd.f32 q3, q3, q13") \ |
| 59 |
__ASM_EMIT("vadd.f32 q0, q4, q15") /* q0 = TV = tilt[0]*lx0+tilt[1] */ \ |
| 60 |
__ASM_EMIT("vadd.f32 q1, q5, q15") \ |
| 61 |
__ASM_EMIT("vldm %[LOG2E], {q15}") \ |
| 62 |
__ASM_EMIT("vbif q0, q2, q6") /* q0 = [x0 >= end] ? TV : KV */ \ |
| 63 |
__ASM_EMIT("vbif q1, q3, q7") \ |
| 64 |
EXP_CORE_X8 /* q0 = EV = expf([x0 >= end] ? TV : KV) */ \ |
| 65 |
__ASM_EMIT("vld1.f32 {d20[], d21[]}, [%[exp]]") /* q10= start */ \ |
| 66 |
__ASM_EMIT("vldm %[mem], {q2-q3}") /* q2 = x0, q3=x1 */ \ |
| 67 |
__ASM_EMIT("vldm %[X2C], {q11}") /* q11= 1.0 */ \ |
| 68 |
__ASM_EMIT("vcle.f32 q6, q2, q10") /* q6 = [x0 <= start] */ \ |
| 69 |
__ASM_EMIT("vcle.f32 q7, q3, q10") \ |
| 70 |
__ASM_EMIT("vbit q0, q11, q6") /* q0 = [x0 <= start] ? 1.0 : EV */ \ |
| 71 |
__ASM_EMIT("vbit q1, q11, q7") \ |
| 72 |
/* out: q0 = g0, q1 = g1 */ |
| 73 |
|
| 74 |
#define PROCESS_UKNEE_SINGLE_X4 \ |
| 75 |
/* in: q0 = lx0 */ \ |
| 76 |
__ASM_EMIT("add %[off], %[exp], #0x10") \ |
| 77 |
__ASM_EMIT("vld4.f32 {d16[], d18[], d20[], d22[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 78 |
__ASM_EMIT("vld4.f32 {d17[], d19[], d21[], d23[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 79 |
__ASM_EMIT("vld4.f32 {d24[], d26[], d28[], d30[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 80 |
__ASM_EMIT("vld4.f32 {d25[], d27[], d29[], d31[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 81 |
__ASM_EMIT("vmul.f32 q2, q0, q11") /* q2 = herm[0]*lx0 */ \ |
| 82 |
__ASM_EMIT("vmul.f32 q4, q0, q14") /* q4 = tilt[0]*lx0 */ \ |
| 83 |
__ASM_EMIT("vadd.f32 q2, q2, q12") /* q2 = herm[0]*lx0+herm[1] */ \ |
| 84 |
__ASM_EMIT("vldm %[mem], {q6}") /* q6 = x0, q7 = x1 */ \ |
| 85 |
__ASM_EMIT("vmul.f32 q2, q2, q0") /* q2 = (herm[0]*lx0+herm[1])*lx0 */ \ |
| 86 |
__ASM_EMIT("vcge.f32 q6, q6, q9") /* q6 = [x0 >= end] */ \ |
| 87 |
__ASM_EMIT("vadd.f32 q2, q2, q13") /* q2 = KV = (herm[0]*lx0+herm[1])*lx0+herm[2] */ \ |
| 88 |
__ASM_EMIT("vadd.f32 q0, q4, q15") /* q0 = TV = tilt[0]*lx0+tilt[1] */ \ |
| 89 |
__ASM_EMIT("vldm %[LOG2E], {q15}") \ |
| 90 |
__ASM_EMIT("vbif q0, q2, q6") /* q0 = [x0 >= end] ? TV : KV */ \ |
| 91 |
EXP_CORE_X4 /* q0 = EV = expf([x0 >= end] ? TV : KV) */ \ |
| 92 |
__ASM_EMIT("vld1.f32 {d20[], d21[]}, [%[exp]]") /* q10= start */ \ |
| 93 |
__ASM_EMIT("vldm %[mem], {q2-q3}") /* q2 = x0, q3=x1 */ \ |
| 94 |
__ASM_EMIT("vldm %[X2C], {q11}") /* q11= 1.0 */ \ |
| 95 |
__ASM_EMIT("vcle.f32 q6, q2, q10") /* q6 = [x0 <= start] */ \ |
| 96 |
__ASM_EMIT("vbit q0, q11, q6") /* q0 = [x0 <= start] ? 1.0 : EV */ \ |
| 97 |
/* out: q0 = g0 */ |
| 98 |
|
| 99 |
#define PROCESS_UEXP_FULL_X8 \ |
| 100 |
/* in: q0 = x0, q1 = x1 */ \ |
| 101 |
__ASM_EMIT("vld3.f32 {d26[], d28[], d30[]}, [%[exp]]") /* q13 = start, q14=end, q15=thresh */ \ |
| 102 |
__ASM_EMIT("vld3.f32 {d27[], d29[], d31[]}, [%[exp]]") /* q13 = start, q14=end, q15=thresh */ \ |
| 103 |
__ASM_EMIT("vabs.f32 q0, q0") /* q0 = fabsf(x0) */ \ |
| 104 |
__ASM_EMIT("vabs.f32 q1, q1") \ |
| 105 |
__ASM_EMIT("vmin.f32 q0, q0, q15") /* q0 = min(fabsf(x0), thresh */ \ |
| 106 |
__ASM_EMIT("vmin.f32 q1, q1, q15") \ |
| 107 |
__ASM_EMIT("vcgt.f32 q2, q0, q13") /* q2 = [fabs(x0) > start] */ \ |
| 108 |
__ASM_EMIT("vcgt.f32 q3, q1, q13") \ |
| 109 |
__ASM_EMIT("vorr q2, q2, q3") \ |
| 110 |
__ASM_EMIT("vext.32 q4, q2, q2, #2") \ |
| 111 |
__ASM_EMIT("vorr q2, q2, q4") \ |
| 112 |
__ASM_EMIT("vext.32 q4, q2, q2, #1") \ |
| 113 |
__ASM_EMIT("vorr q2, q2, q4") \ |
| 114 |
__ASM_EMIT("vmov.32 %[off], d4[0]") \ |
| 115 |
__ASM_EMIT("cmp %[off], #0") \ |
| 116 |
__ASM_EMIT("bne 100f") \ |
| 117 |
__ASM_EMIT("vldm %[X2C], {q0}") /* q0 = 1.0f */ \ |
| 118 |
__ASM_EMIT("vmov q1, q0") \ |
| 119 |
__ASM_EMIT("b 200f") \ |
| 120 |
__ASM_EMIT("100:") \ |
| 121 |
__ASM_EMIT("vstm %[mem], {q0-q1}") /* mem[0x00] = fabfs(x0) */ \ |
| 122 |
__ASM_EMIT("vldm %[LOGC], {q14-q15}") \ |
| 123 |
LOGE_CORE_X8 /* q0 = lx0 = logf(fabsf(x0)) */ \ |
| 124 |
PROCESS_UKNEE_SINGLE_X8 /* apply knee 0 */ \ |
| 125 |
__ASM_EMIT("200:") \ |
| 126 |
/* out: q0 = G0, q1= G1 */ |
| 127 |
|
| 128 |
#define PROCESS_UEXP_FULL_X4 \ |
| 129 |
/* in: q0 = x0, q1 = x1 */ \ |
| 130 |
__ASM_EMIT("vld3.f32 {d26[], d28[], d30[]}, [%[exp]]") /* q13 = start, q14=end, q15=thresh */ \ |
| 131 |
__ASM_EMIT("vld3.f32 {d27[], d29[], d31[]}, [%[exp]]") /* q13 = start, q14=end, q15=thresh */ \ |
| 132 |
__ASM_EMIT("vabs.f32 q0, q0") /* q0 = fabsf(x0) */ \ |
| 133 |
__ASM_EMIT("vmin.f32 q0, q0, q15") /* q0 = min(fabsf(x0), thresh */ \ |
| 134 |
__ASM_EMIT("vstm %[mem], {q0}") /* mem[0x00] = fabfs(x0) */ \ |
| 135 |
__ASM_EMIT("vldm %[LOGC], {q14-q15}") \ |
| 136 |
LOGE_CORE_X4 /* q0 = lx0 = logf(fabsf(x0)) */ \ |
| 137 |
PROCESS_UKNEE_SINGLE_X4 /* apply knee 0 */ \ |
| 138 |
/* out: q0 = G0, q1= G1 */ |
| 139 |
|
| 140 |
void uexpander_x1_gain(float *dst, const float *src, const dsp::expander_knee_t *c, size_t count) |
| 141 |
{ |
| 142 |
IF_ARCH_ARM( |
| 143 |
float mem[16] __lsp_aligned16; |
| 144 |
size_t off; |
| 145 |
); |
| 146 |
|
| 147 |
ARCH_ARM_ASM( |
| 148 |
// x8 blocks |
| 149 |
__ASM_EMIT("subs %[count], #8") |
| 150 |
__ASM_EMIT("blo 2f") |
| 151 |
__ASM_EMIT("1:") |
| 152 |
__ASM_EMIT("vld1.32 {q0-q1}, [%[src]]!") |
| 153 |
PROCESS_UEXP_FULL_X8 |
| 154 |
__ASM_EMIT("subs %[count], #8") |
| 155 |
__ASM_EMIT("vst1.32 {q0-q1}, [%[dst]]!") |
| 156 |
__ASM_EMIT("bhs 1b") |
| 157 |
__ASM_EMIT("2:") |
| 158 |
// x4 block |
| 159 |
__ASM_EMIT("adds %[count], #4") |
| 160 |
__ASM_EMIT("blt 4f") |
| 161 |
__ASM_EMIT("vld1.32 {q0}, [%[src]]!") |
| 162 |
PROCESS_UEXP_FULL_X4 |
| 163 |
__ASM_EMIT("sub %[count], #4") |
| 164 |
__ASM_EMIT("vst1.32 {q0}, [%[dst]]!") |
| 165 |
__ASM_EMIT("4:") |
| 166 |
// Tail: 1x-3x block |
| 167 |
__ASM_EMIT("adds %[count], #4") |
| 168 |
__ASM_EMIT("bls 12f") |
| 169 |
__ASM_EMIT("tst %[count], #1") |
| 170 |
__ASM_EMIT("beq 6f") |
| 171 |
__ASM_EMIT("vld1.32 {d0[0]}, [%[src]]!") |
| 172 |
__ASM_EMIT("6:") |
| 173 |
__ASM_EMIT("tst %[count], #2") |
| 174 |
__ASM_EMIT("beq 8f") |
| 175 |
__ASM_EMIT("vld1.32 {d1}, [%[src]]") |
| 176 |
__ASM_EMIT("8:") |
| 177 |
PROCESS_UEXP_FULL_X4 |
| 178 |
__ASM_EMIT("tst %[count], #1") |
| 179 |
__ASM_EMIT("beq 10f") |
| 180 |
__ASM_EMIT("vst1.32 {d0[0]}, [%[dst]]!") |
| 181 |
__ASM_EMIT("10:") |
| 182 |
__ASM_EMIT("tst %[count], #2") |
| 183 |
__ASM_EMIT("beq 12f") |
| 184 |
__ASM_EMIT("vst1.32 {d1}, [%[dst]]") |
| 185 |
__ASM_EMIT("12:") |
| 186 |
|
| 187 |
: [dst] "+r" (dst), [src] "+r" (src), |
| 188 |
[count] "+r" (count), |
| 189 |
[off] "=&r" (off) |
| 190 |
: [exp] "r" (c), |
| 191 |
[L2C] "r" (&LOG2_CONST[0]), |
| 192 |
[LOGC] "r" (&LOGE_C[0]), |
| 193 |
[mem] "r" (&mem[0]), |
| 194 |
[X2C] "r" (&expander_const[0]), |
| 195 |
[E2C] "r" (&EXP2_CONST[0]), |
| 196 |
[LOG2E] "r" (&EXP_LOG2E[0]) |
| 197 |
: "cc", "memory", |
| 198 |
"q0", "q1", "q2", "q3", |
| 199 |
"q4", "q5", "q6", "q7", |
| 200 |
"q8", "q9", "q10", "q11", |
| 201 |
"q12", "q13", "q14", "q15" |
| 202 |
); |
| 203 |
} |
| 204 |
|
| 205 |
void uexpander_x1_curve(float *dst, const float *src, const dsp::expander_knee_t *c, size_t count) |
| 206 |
{ |
| 207 |
IF_ARCH_ARM( |
| 208 |
float mem[16] __lsp_aligned16; |
| 209 |
size_t off; |
| 210 |
); |
| 211 |
|
| 212 |
ARCH_ARM_ASM( |
| 213 |
// x8 blocks |
| 214 |
__ASM_EMIT("subs %[count], #8") |
| 215 |
__ASM_EMIT("blo 2f") |
| 216 |
__ASM_EMIT("1:") |
| 217 |
__ASM_EMIT("vld1.32 {q0-q1}, [%[src]]") |
| 218 |
PROCESS_UEXP_FULL_X8 |
| 219 |
__ASM_EMIT("vld1.32 {q2-q3}, [%[src]]!") |
| 220 |
__ASM_EMIT("subs %[count], #8") |
| 221 |
__ASM_EMIT("vmul.f32 q0, q0, q2") |
| 222 |
__ASM_EMIT("vmul.f32 q1, q1, q3") |
| 223 |
__ASM_EMIT("vst1.32 {q0-q1}, [%[dst]]!") |
| 224 |
__ASM_EMIT("bhs 1b") |
| 225 |
__ASM_EMIT("2:") |
| 226 |
// x4 block |
| 227 |
__ASM_EMIT("adds %[count], #4") |
| 228 |
__ASM_EMIT("blt 4f") |
| 229 |
__ASM_EMIT("vld1.32 {q0}, [%[src]]") |
| 230 |
PROCESS_UEXP_FULL_X4 |
| 231 |
__ASM_EMIT("vld1.32 {q2}, [%[src]]!") |
| 232 |
__ASM_EMIT("sub %[count], #4") |
| 233 |
__ASM_EMIT("vmul.f32 q0, q0, q2") |
| 234 |
__ASM_EMIT("vst1.32 {q0}, [%[dst]]!") |
| 235 |
__ASM_EMIT("4:") |
| 236 |
// Tail: 1x-3x block |
| 237 |
__ASM_EMIT("adds %[count], #4") |
| 238 |
__ASM_EMIT("bls 12f") |
| 239 |
__ASM_EMIT("tst %[count], #1") |
| 240 |
__ASM_EMIT("beq 6f") |
| 241 |
__ASM_EMIT("vld1.32 {d0[0]}, [%[src]]!") |
| 242 |
__ASM_EMIT("6:") |
| 243 |
__ASM_EMIT("tst %[count], #2") |
| 244 |
__ASM_EMIT("beq 8f") |
| 245 |
__ASM_EMIT("vld1.32 {d1}, [%[src]]") |
| 246 |
__ASM_EMIT("8:") |
| 247 |
__ASM_EMIT("vmov q1, q0") |
| 248 |
PROCESS_UEXP_FULL_X4 |
| 249 |
__ASM_EMIT("vmul.f32 q0, q0, q1") |
| 250 |
__ASM_EMIT("tst %[count], #1") |
| 251 |
__ASM_EMIT("beq 10f") |
| 252 |
__ASM_EMIT("vst1.32 {d0[0]}, [%[dst]]!") |
| 253 |
__ASM_EMIT("10:") |
| 254 |
__ASM_EMIT("tst %[count], #2") |
| 255 |
__ASM_EMIT("beq 12f") |
| 256 |
__ASM_EMIT("vst1.32 {d1}, [%[dst]]") |
| 257 |
__ASM_EMIT("12:") |
| 258 |
|
| 259 |
: [dst] "+r" (dst), [src] "+r" (src), |
| 260 |
[count] "+r" (count), |
| 261 |
[off] "=&r" (off) |
| 262 |
: [exp] "r" (c), |
| 263 |
[L2C] "r" (&LOG2_CONST[0]), |
| 264 |
[LOGC] "r" (&LOGE_C[0]), |
| 265 |
[mem] "r" (&mem[0]), |
| 266 |
[X2C] "r" (&expander_const[0]), |
| 267 |
[E2C] "r" (&EXP2_CONST[0]), |
| 268 |
[LOG2E] "r" (&EXP_LOG2E[0]) |
| 269 |
: "cc", "memory", |
| 270 |
"q0", "q1", "q2", "q3", |
| 271 |
"q4", "q5", "q6", "q7", |
| 272 |
"q8", "q9", "q10", "q11", |
| 273 |
"q12", "q13", "q14", "q15" |
| 274 |
); |
| 275 |
} |
| 276 |
|
| 277 |
#undef PROCESS_UEXP_FULL_X4 |
| 278 |
#undef PROCESS_UEXP_FULL_X8 |
| 279 |
#undef PROCESS_UKNEE_SINGLE_X4 |
| 280 |
#undef PROCESS_UKNEE_SINGLE_X8 |
| 281 |
|
| 282 |
#define PROCESS_DKNEE_SINGLE_X8 \ |
| 283 |
/* in: q0 = lx0, q1 = lx1 */ \ |
| 284 |
__ASM_EMIT("add %[off], %[exp], #0x10") \ |
| 285 |
__ASM_EMIT("vld4.f32 {d16[], d18[], d20[], d22[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 286 |
__ASM_EMIT("vld4.f32 {d17[], d19[], d21[], d23[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 287 |
__ASM_EMIT("vld4.f32 {d24[], d26[], d28[], d30[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 288 |
__ASM_EMIT("vld4.f32 {d25[], d27[], d29[], d31[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 289 |
__ASM_EMIT("vmul.f32 q2, q0, q11") /* q2 = herm[0]*lx0 */ \ |
| 290 |
__ASM_EMIT("vmul.f32 q3, q1, q11") \ |
| 291 |
__ASM_EMIT("vmul.f32 q4, q0, q14") /* q4 = tilt[0]*lx0 */ \ |
| 292 |
__ASM_EMIT("vmul.f32 q5, q1, q14") \ |
| 293 |
__ASM_EMIT("vadd.f32 q2, q2, q12") /* q2 = herm[0]*lx0+herm[1] */ \ |
| 294 |
__ASM_EMIT("vadd.f32 q3, q3, q12") \ |
| 295 |
__ASM_EMIT("vldm %[mem], {q6-q7}") /* q6 = x0, q7=x7 */ \ |
| 296 |
__ASM_EMIT("vmul.f32 q2, q2, q0") /* q2 = (herm[0]*lx0+herm[1])*lx0 */ \ |
| 297 |
__ASM_EMIT("vmul.f32 q3, q3, q1") \ |
| 298 |
__ASM_EMIT("vcle.f32 q6, q6, q8") /* q6 = [x0 <= start] */ \ |
| 299 |
__ASM_EMIT("vcle.f32 q7, q7, q8") \ |
| 300 |
__ASM_EMIT("vadd.f32 q2, q2, q13") /* q2 = KV = (herm[0]*lx0+herm[1])*lx0+herm[2] */ \ |
| 301 |
__ASM_EMIT("vadd.f32 q3, q3, q13") \ |
| 302 |
__ASM_EMIT("vadd.f32 q0, q4, q15") /* q0 = TV = tilt[0]*lx0+tilt[1] */ \ |
| 303 |
__ASM_EMIT("vadd.f32 q1, q5, q15") \ |
| 304 |
__ASM_EMIT("vldm %[LOG2E], {q15}") \ |
| 305 |
__ASM_EMIT("vbif q0, q2, q6") /* q0 = [x0 <= start] ? TV : KV */ \ |
| 306 |
__ASM_EMIT("vbif q1, q3, q7") \ |
| 307 |
EXP_CORE_X8 /* q0 = EV = expf([x0 >= end] ? TV : KV) */ \ |
| 308 |
__ASM_EMIT("vld3.f32 {d20[], d22[], d24[]}, [%[exp]]") /* q10= start, q11=end, q12=threshold */ \ |
| 309 |
__ASM_EMIT("vld3.f32 {d21[], d23[], d25[]}, [%[exp]]") /* q10= start, q11=end, q12=threshold */ \ |
| 310 |
__ASM_EMIT("vldm %[mem], {q2-q3}") /* q2 = x0, q3=x1 */ \ |
| 311 |
__ASM_EMIT("vldm %[X2C], {q13}") /* q13= 1.0 */ \ |
| 312 |
__ASM_EMIT("vcge.f32 q6, q2, q11") /* q6 = [x0 >= end] */ \ |
| 313 |
__ASM_EMIT("vcge.f32 q7, q3, q11") \ |
| 314 |
__ASM_EMIT("vcge.f32 q8, q2, q12") /* q8 = [x0 >= threshold] */ \ |
| 315 |
__ASM_EMIT("vcge.f32 q9, q3, q12") \ |
| 316 |
__ASM_EMIT("vbit q0, q13, q6") /* q0 = [x0 >= end] ? 1.0 : EV */ \ |
| 317 |
__ASM_EMIT("vbit q1, q13, q7") \ |
| 318 |
__ASM_EMIT("vand q0, q0, q8") /* q0 = [x0 < threshold] ? 0.0 : [x0 <= start] ? gain : EV */ \ |
| 319 |
__ASM_EMIT("vand q1, q1, q8") \ |
| 320 |
/* out: q0 = g0, q1 = g1 */ |
| 321 |
|
| 322 |
#define PROCESS_DKNEE_SINGLE_X4 \ |
| 323 |
/* in: q0 = lx0 */ \ |
| 324 |
__ASM_EMIT("add %[off], %[exp], #0x10") \ |
| 325 |
__ASM_EMIT("vld4.f32 {d16[], d18[], d20[], d22[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 326 |
__ASM_EMIT("vld4.f32 {d17[], d19[], d21[], d23[]}, [%[exp]]") /* q8 = start, q9=end, q10=threshold q11=herm[0] */ \ |
| 327 |
__ASM_EMIT("vld4.f32 {d24[], d26[], d28[], d30[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 328 |
__ASM_EMIT("vld4.f32 {d25[], d27[], d29[], d31[]}, [%[off]]") /* q12 = herm[1], q13=herm[2], q14=tilt[0] q15=tilt[1] */ \ |
| 329 |
__ASM_EMIT("vmul.f32 q2, q0, q11") /* q2 = herm[0]*lx0 */ \ |
| 330 |
__ASM_EMIT("vmul.f32 q4, q0, q14") /* q4 = tilt[0]*lx0 */ \ |
| 331 |
__ASM_EMIT("vadd.f32 q2, q2, q12") /* q2 = herm[0]*lx0+herm[1] */ \ |
| 332 |
__ASM_EMIT("vldm %[mem], {q6}") /* q6 = x0 */ \ |
| 333 |
__ASM_EMIT("vmul.f32 q2, q2, q0") /* q2 = (herm[0]*lx0+herm[1])*lx0 */ \ |
| 334 |
__ASM_EMIT("vcle.f32 q6, q6, q8") /* q6 = [x0 <= start] */ \ |
| 335 |
__ASM_EMIT("vadd.f32 q2, q2, q13") /* q2 = KV = (herm[0]*lx0+herm[1])*lx0+herm[2] */ \ |
| 336 |
__ASM_EMIT("vadd.f32 q0, q4, q15") /* q0 = TV = tilt[0]*lx0+tilt[1] */ \ |
| 337 |
__ASM_EMIT("vldm %[LOG2E], {q15}") \ |
| 338 |
__ASM_EMIT("vbif q0, q2, q6") /* q0 = [x0 <= start] ? TV : KV */ \ |
| 339 |
EXP_CORE_X4 /* q0 = EV = expf([x0 >= end] ? TV : KV) */ \ |
| 340 |
__ASM_EMIT("vld3.f32 {d20[], d22[], d24[]}, [%[exp]]") /* q10= start, q11=end, q12=threshold */ \ |
| 341 |
__ASM_EMIT("vld3.f32 {d21[], d23[], d25[]}, [%[exp]]") /* q10= start, q11=end, q12=threshold */ \ |
| 342 |
__ASM_EMIT("vldm %[mem], {q2}") /* q2 = x0 */ \ |
| 343 |
__ASM_EMIT("vldm %[X2C], {q13}") /* q13= 1.0 */ \ |
| 344 |
__ASM_EMIT("vcge.f32 q6, q2, q11") /* q6 = [x0 >= end] */ \ |
| 345 |
__ASM_EMIT("vcge.f32 q8, q2, q12") /* q8 = [x0 >= threshold] */ \ |
| 346 |
__ASM_EMIT("vbit q0, q13, q6") /* q0 = [x0 >= end] ? 1.0 : EV */ \ |
| 347 |
__ASM_EMIT("vand q0, q0, q8") /* q0 = [x0 < threshold] ? 0.0 : [x0 <= start] ? gain : EV */ \ |
| 348 |
/* out: q0 = g0 */ |
| 349 |
|
| 350 |
#define PROCESS_DEXP_FULL_X8 \ |
| 351 |
/* in: q0 = x0, q1 = x1 */ \ |
| 352 |
__ASM_EMIT("add %[off], %[exp], #0x4") \ |
| 353 |
__ASM_EMIT("vld1.f32 {d26[], d27[]}, [%[off]]") /* q13 = end */ \ |
| 354 |
__ASM_EMIT("vabs.f32 q0, q0") /* q0 = fabsf(x0) */ \ |
| 355 |
__ASM_EMIT("vabs.f32 q1, q1") \ |
| 356 |
__ASM_EMIT("vclt.f32 q2, q0, q13") /* q2 = [fabs(x0) < end] */ \ |
| 357 |
__ASM_EMIT("vclt.f32 q3, q1, q13") \ |
| 358 |
__ASM_EMIT("vorr q2, q2, q3") \ |
| 359 |
__ASM_EMIT("vext.32 q4, q2, q2, #2") \ |
| 360 |
__ASM_EMIT("vorr q2, q2, q4") \ |
| 361 |
__ASM_EMIT("vext.32 q4, q2, q2, #1") \ |
| 362 |
__ASM_EMIT("vorr q2, q2, q4") \ |
| 363 |
__ASM_EMIT("vmov.32 %[off], d4[0]") \ |
| 364 |
__ASM_EMIT("cmp %[off], #0") \ |
| 365 |
__ASM_EMIT("bne 100f") \ |
| 366 |
__ASM_EMIT("vldm %[X2C], {q0}") /* q0 = 1.0f */ \ |
| 367 |
__ASM_EMIT("vmov q1, q0") \ |
| 368 |
__ASM_EMIT("b 200f") \ |
| 369 |
__ASM_EMIT("100:") \ |
| 370 |
__ASM_EMIT("vstm %[mem], {q0-q1}") /* mem[0x00] = fabfs(x0) */ \ |
| 371 |
__ASM_EMIT("vldm %[LOGC], {q14-q15}") \ |
| 372 |
LOGE_CORE_X8 /* q0 = lx0 = logf(fabsf(x0)) */ \ |
| 373 |
PROCESS_DKNEE_SINGLE_X8 /* apply knee 0 */ \ |
| 374 |
__ASM_EMIT("200:") \ |
| 375 |
/* out: q0 = G0, q1= G1 */ |
| 376 |
|
| 377 |
#define PROCESS_DEXP_FULL_X4 \ |
| 378 |
/* in: q0 = x0, q1 = x1 */ \ |
| 379 |
__ASM_EMIT("vabs.f32 q0, q0") /* q0 = fabsf(x0) */ \ |
| 380 |
__ASM_EMIT("vstm %[mem], {q0}") /* mem[0x00] = fabfs(x0) */ \ |
| 381 |
__ASM_EMIT("vldm %[LOGC], {q14-q15}") \ |
| 382 |
LOGE_CORE_X4 /* q0 = lx0 = logf(fabsf(x0)) */ \ |
| 383 |
PROCESS_DKNEE_SINGLE_X4 /* apply knee 0 */ \ |
| 384 |
/* out: q0 = G0, q1= G1 */ |
| 385 |
|
| 386 |
void dexpander_x1_gain(float *dst, const float *src, const dsp::expander_knee_t *c, size_t count) |
| 387 |
{ |
| 388 |
IF_ARCH_ARM( |
| 389 |
float mem[16] __lsp_aligned16; |
| 390 |
size_t off; |
| 391 |
); |
| 392 |
|
| 393 |
ARCH_ARM_ASM( |
| 394 |
// x8 blocks |
| 395 |
__ASM_EMIT("subs %[count], #8") |
| 396 |
__ASM_EMIT("blo 2f") |
| 397 |
__ASM_EMIT("1:") |
| 398 |
__ASM_EMIT("vld1.32 {q0-q1}, [%[src]]!") |
| 399 |
PROCESS_DEXP_FULL_X8 |
| 400 |
__ASM_EMIT("subs %[count], #8") |
| 401 |
__ASM_EMIT("vst1.32 {q0-q1}, [%[dst]]!") |
| 402 |
__ASM_EMIT("bhs 1b") |
| 403 |
__ASM_EMIT("2:") |
| 404 |
// x4 block |
| 405 |
__ASM_EMIT("adds %[count], #4") |
| 406 |
__ASM_EMIT("blt 4f") |
| 407 |
__ASM_EMIT("vld1.32 {q0}, [%[src]]!") |
| 408 |
PROCESS_DEXP_FULL_X4 |
| 409 |
__ASM_EMIT("sub %[count], #4") |
| 410 |
__ASM_EMIT("vst1.32 {q0}, [%[dst]]!") |
| 411 |
__ASM_EMIT("4:") |
| 412 |
// Tail: 1x-3x block |
| 413 |
__ASM_EMIT("adds %[count], #4") |
| 414 |
__ASM_EMIT("bls 12f") |
| 415 |
__ASM_EMIT("tst %[count], #1") |
| 416 |
__ASM_EMIT("beq 6f") |
| 417 |
__ASM_EMIT("vld1.32 {d0[0]}, [%[src]]!") |
| 418 |
__ASM_EMIT("6:") |
| 419 |
__ASM_EMIT("tst %[count], #2") |
| 420 |
__ASM_EMIT("beq 8f") |
| 421 |
__ASM_EMIT("vld1.32 {d1}, [%[src]]") |
| 422 |
__ASM_EMIT("8:") |
| 423 |
PROCESS_DEXP_FULL_X4 |
| 424 |
__ASM_EMIT("tst %[count], #1") |
| 425 |
__ASM_EMIT("beq 10f") |
| 426 |
__ASM_EMIT("vst1.32 {d0[0]}, [%[dst]]!") |
| 427 |
__ASM_EMIT("10:") |
| 428 |
__ASM_EMIT("tst %[count], #2") |
| 429 |
__ASM_EMIT("beq 12f") |
| 430 |
__ASM_EMIT("vst1.32 {d1}, [%[dst]]") |
| 431 |
__ASM_EMIT("12:") |
| 432 |
|
| 433 |
: [dst] "+r" (dst), [src] "+r" (src), |
| 434 |
[count] "+r" (count), |
| 435 |
[off] "=&r" (off) |
| 436 |
: [exp] "r" (c), |
| 437 |
[L2C] "r" (&LOG2_CONST[0]), |
| 438 |
[LOGC] "r" (&LOGE_C[0]), |
| 439 |
[mem] "r" (&mem[0]), |
| 440 |
[X2C] "r" (&expander_const[0]), |
| 441 |
[E2C] "r" (&EXP2_CONST[0]), |
| 442 |
[LOG2E] "r" (&EXP_LOG2E[0]) |
| 443 |
: "cc", "memory", |
| 444 |
"q0", "q1", "q2", "q3", |
| 445 |
"q4", "q5", "q6", "q7", |
| 446 |
"q8", "q9", "q10", "q11", |
| 447 |
"q12", "q13", "q14", "q15" |
| 448 |
); |
| 449 |
} |
| 450 |
|
| 451 |
void dexpander_x1_curve(float *dst, const float *src, const dsp::expander_knee_t *c, size_t count) |
| 452 |
{ |
| 453 |
IF_ARCH_ARM( |
| 454 |
float mem[16] __lsp_aligned16; |
| 455 |
size_t off; |
| 456 |
); |
| 457 |
|
| 458 |
ARCH_ARM_ASM( |
| 459 |
// x8 blocks |
| 460 |
__ASM_EMIT("subs %[count], #8") |
| 461 |
__ASM_EMIT("blo 2f") |
| 462 |
__ASM_EMIT("1:") |
| 463 |
__ASM_EMIT("vld1.32 {q0-q1}, [%[src]]") |
| 464 |
PROCESS_DEXP_FULL_X8 |
| 465 |
__ASM_EMIT("vld1.32 {q2-q3}, [%[src]]!") |
| 466 |
__ASM_EMIT("subs %[count], #8") |
| 467 |
__ASM_EMIT("vmul.f32 q0, q0, q2") |
| 468 |
__ASM_EMIT("vmul.f32 q1, q1, q3") |
| 469 |
__ASM_EMIT("vst1.32 {q0-q1}, [%[dst]]!") |
| 470 |
__ASM_EMIT("bhs 1b") |
| 471 |
__ASM_EMIT("2:") |
| 472 |
// x4 block |
| 473 |
__ASM_EMIT("adds %[count], #4") |
| 474 |
__ASM_EMIT("blt 4f") |
| 475 |
__ASM_EMIT("vld1.32 {q0}, [%[src]]") |
| 476 |
PROCESS_DEXP_FULL_X4 |
| 477 |
__ASM_EMIT("vld1.32 {q2}, [%[src]]!") |
| 478 |
__ASM_EMIT("sub %[count], #4") |
| 479 |
__ASM_EMIT("vmul.f32 q0, q0, q2") |
| 480 |
__ASM_EMIT("vst1.32 {q0}, [%[dst]]!") |
| 481 |
__ASM_EMIT("4:") |
| 482 |
// Tail: 1x-3x block |
| 483 |
__ASM_EMIT("adds %[count], #4") |
| 484 |
__ASM_EMIT("bls 12f") |
| 485 |
__ASM_EMIT("tst %[count], #1") |
| 486 |
__ASM_EMIT("beq 6f") |
| 487 |
__ASM_EMIT("vld1.32 {d0[0]}, [%[src]]!") |
| 488 |
__ASM_EMIT("6:") |
| 489 |
__ASM_EMIT("tst %[count], #2") |
| 490 |
__ASM_EMIT("beq 8f") |
| 491 |
__ASM_EMIT("vld1.32 {d1}, [%[src]]") |
| 492 |
__ASM_EMIT("8:") |
| 493 |
__ASM_EMIT("vmov q1, q0") |
| 494 |
PROCESS_DEXP_FULL_X4 |
| 495 |
__ASM_EMIT("vmul.f32 q0, q0, q1") |
| 496 |
__ASM_EMIT("tst %[count], #1") |
| 497 |
__ASM_EMIT("beq 10f") |
| 498 |
__ASM_EMIT("vst1.32 {d0[0]}, [%[dst]]!") |
| 499 |
__ASM_EMIT("10:") |
| 500 |
__ASM_EMIT("tst %[count], #2") |
| 501 |
__ASM_EMIT("beq 12f") |
| 502 |
__ASM_EMIT("vst1.32 {d1}, [%[dst]]") |
| 503 |
__ASM_EMIT("12:") |
| 504 |
|
| 505 |
: [dst] "+r" (dst), [src] "+r" (src), |
| 506 |
[count] "+r" (count), |
| 507 |
[off] "=&r" (off) |
| 508 |
: [exp] "r" (c), |
| 509 |
[L2C] "r" (&LOG2_CONST[0]), |
| 510 |
[LOGC] "r" (&LOGE_C[0]), |
| 511 |
[mem] "r" (&mem[0]), |
| 512 |
[X2C] "r" (&expander_const[0]), |
| 513 |
[E2C] "r" (&EXP2_CONST[0]), |
| 514 |
[LOG2E] "r" (&EXP_LOG2E[0]) |
| 515 |
: "cc", "memory", |
| 516 |
"q0", "q1", "q2", "q3", |
| 517 |
"q4", "q5", "q6", "q7", |
| 518 |
"q8", "q9", "q10", "q11", |
| 519 |
"q12", "q13", "q14", "q15" |
| 520 |
); |
| 521 |
} |
| 522 |
|
| 523 |
#undef PROCESS_DEXP_FULL_X4 |
| 524 |
#undef PROCESS_DEXP_FULL_X8 |
| 525 |
#undef PROCESS_DKNEE_SINGLE_X4 |
| 526 |
#undef PROCESS_DKNEE_SINGLE_X8 |
| 527 |
|
| 528 |
} /* namespace neon_d32 */ |
| 529 |
} /* namespace lsp */ |
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
#endif /* PRIVATE_DSP_ARCH_ARM_NEON_D32_DYNAMICS_EXPANDER_H_ */ |