git subrepo clone https://github.com/libretro/libretro-common.git deps/libretro-common
[pcsx_rearmed.git] / deps / libretro-common / audio / conversion / s16_to_float_neon.S
CommitLineData
3719602c
PC
1/* Copyright (C) 2010-2020 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (s16_to_float_neon.S).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22#if defined(__ARM_NEON__) && defined(HAVE_ARM_NEON_ASM_OPTIMIZATIONS)
23
24#ifndef __MACH__
25.arm
26#endif
27
28.align 4
29.globl convert_s16_float_asm
30#ifndef __MACH__
31.type convert_s16_float_asm, %function
32#endif
33.globl _convert_s16_float_asm
34#ifndef __MACH__
35.type _convert_s16_float_asm, %function
36#endif
37# convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain)
38convert_s16_float_asm:
39_convert_s16_float_asm:
40 # Hacky way to get a constant of 2^-15.
41 # Might be faster to just load a constant from memory.
42 # It's just done once however ...
43 vmov.f32 q8, #0.25
44 vmul.f32 q8, q8, q8
45 vmul.f32 q8, q8, q8
46 vmul.f32 q8, q8, q8
47 vadd.f32 q8, q8, q8
48
49 # Apply gain
50 vld1.f32 {d6[0]}, [r3]
51 vmul.f32 q8, q8, d6[0]
52
531:
54 # Preload here?
55 vld1.s16 {q0}, [r1]!
56
57 # Widen to 32-bit
58 vmovl.s16 q1, d0
59 vmovl.s16 q2, d1
60
61 # Convert to float
62 vcvt.f32.s32 q1, q1
63 vcvt.f32.s32 q2, q2
64
65 vmul.f32 q1, q1, q8
66 vmul.f32 q2, q2, q8
67
68 vst1.f32 {q1-q2}, [r0]!
69
70 # Guaranteed to get samples in multiples of 8.
71 subs r2, r2, #8
72 bne 1b
73
74 bx lr
75
76#endif