simple_channel_mixer.S 8.72 KB
Newer Older
1 2 3 4 5 6
 @*****************************************************************************
 @ simple_channel_mixer.S : ARM NEON channel mixer
 @*****************************************************************************
 @ Copyright (C) 2012 David Geldreich <david.geldreich@free.fr>
 @                    Sébastien Toque
 @
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
7 8 9
 @ This program is free software; you can redistribute it and/or modify it
 @ under the terms of the GNU Lesser General Public License as published by
 @ the Free Software Foundation; either version 2.1 of the License, or
10 11 12 13
 @ (at your option) any later version.
 @
 @ This program is distributed in the hope that it will be useful,
 @ but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
14 15
 @ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 @ GNU Lesser General Public License for more details.
16
 @
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
17
 @ You should have received a copy of the GNU Lesser General Public License
18 19 20 21 22 23
 @ along with this program; if not, write to the Free Software Foundation,
 @ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 @****************************************************************************/

	.fpu neon
	.text
24
	.align 2
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279

#define DST		r0
#define SRC		r1
#define NUM		r2
#define LFE		r3
#define COEFF	r4

coeff_7to2:
	.float 0.5
	.float 0.5
	.float 0.25
	.float 0.25
	.global convert_7to2_neon_asm
	.type	convert_7to2_neon_asm, %function
convert_7to2_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_7to2
	vld1.32 {q0},[COEFF]
0:                                                @ use local label
	vld1.32 {q2},[SRC]!                           @ load 0,1,2,3
	vmul.f32 q2,q2,q0                             @ 0.5*src[0] 0.5*src[1] 0.25*src[2] 0.25*src[3]
	vld1.32 {d6},[SRC]!                           @ load 4,5
	vmul.f32 d6,d6,d1                             @ 0.25*src[4] 0.25*src[5]
	vadd.f32 d4,d4,d5                             @ 0.5*src[0] + 0.25*src[2]
                                                  @ 0.5*src[1] + 0.25*src[3]
	vadd.f32 d4,d4,d6                             @ 0.5*src[0] + 0.25*src[2] + 0.25*src[4]
                                                  @ 0.5*src[1] + 0.25*src[3] + 0.25*src[5]
	flds s14,[SRC]                                @ load 6
	vdup.32 d7,d7[0]
	teq LFE,#0
	ite eq
	addeq SRC,SRC,#4
	addne SRC,SRC,#8                              @ skip the lfe channel
	vadd.f32 d4,d4,d7                             @ 0.5*src[0] + 0.25*src[2] + 0.25*src[4] + src[6]
                                                  @ 0.5*src[1] + 0.25*src[3] + 0.25*src[5] + src[6]
	vst1.32 d4, [DST]!
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}


coeff_5to2:
	.float 0.5
	.float 0.5
	.float 0.33
	.float 0.33
	.global convert_5to2_neon_asm
	.type	convert_5to2_neon_asm, %function
convert_5to2_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_5to2
	vld1.32 {q0},[COEFF]                          @ load constants
0:                                                @ use local label
	vld1.32 {q1},[SRC]!                           @ load 0,1,2,3
	flds s8,[SRC]                                 @ load 4
	vdup.32 d4,d4[0]
	teq LFE,#0
	ite eq
	addeq SRC,SRC,#4
	addne SRC,SRC,#8                              @ skip the lfe channel
	vmul.f32 q1,q1,q0                             @ 0.5*src[0] 0.5*src[1] 0.33*src[2] 0.33*src[3]/3
	vadd.f32 d2,d2,d3                             @ 0.5*src[0] + 0.33*src[2]
                                                  @ 0.5*src[1] + 0.33*src[3]
	vadd.f32 d2,d2,d4                             @ 0.5*src[0] + 0.33*src[2] + src[4]
                                                  @ 0.5*src[1] + 0.33*src[3] + src[4]
	vst1.32 d2,[DST]!
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}


coeff_4to2:
	.float 0.5
	.float 0.5
	.global convert_4to2_neon_asm
	.type	convert_4to2_neon_asm, %function
convert_4to2_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_4to2
	vld1.32 {d0},[COEFF]                          @ load constants
0:                                                @ use local label
	vld1.32 {q1},[SRC]!
	vmul.f32 d2,d2,d0                             @ 0.5*src[0] 0.5*src[1]
	vdup.32 d4,d3[0]                              @ dup src[2]
	vdup.32 d3,d3[1]                              @ dup src[3]
	vadd.f32 d2,d2,d3                             @ +src[3]
	vadd.f32 d2,d2,d4                             @ +src[2]
	vst1.32 d2,[DST]!
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}


coeff_3to2:
	.float 0.5
	.float 0.5
	.global convert_3to2_neon_asm
	.type	convert_3to2_neon_asm, %function
convert_3to2_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_3to2
	vld1.32 {d0},[COEFF]                          @ load constants
0:                                                @ use local label
	vld1.32 {d1},[SRC]!                           @ load 0,1
	flds s4,[SRC]                                 @ load 2
	vdup.32 d2,d2[0]
	teq LFE,#0
	ite eq
	addeq SRC,SRC,#4
	addne SRC,SRC,#8                              @ skip the lfe channel
	vmul.f32 d1,d1,d0                             @ 0.5*src[0] 0.5*src[1]
	vadd.f32 d1,d1,d2                             @ 0.5*src[0] + src[2]
                                                  @ 0.5*src[1] + src[2]
	vst1.32 d1,[DST]!
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}


coeff_7to1:
	.float 0.25
	.float 0.25
	.float 0.125
	.float 0.125
	.global convert_7to1_neon_asm
	.type	convert_7to1_neon_asm, %function
convert_7to1_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_7to1
	vld1.32 {q0},[COEFF]
0:                                                @ use local label
	vld1.32 {q1},[SRC]!                           @ load 0,1,2,3
	vmul.f32 q1,q1,q0                             @ 0.25*src[0] 0.25*src[1] 0.125*src[2] 0.125*src[3]
	vld1.32 {d4},[SRC]!                           @ load 4,5
	vmul.f32 d4,d4,d1                             @ 0.125*src[4] 0.125*src[5]
	vadd.f32 d2,d2,d3
	vadd.f32 d2,d2,d4
	flds s10,[SRC]                                @ load 6
	teq LFE,#0
	ite eq
	addeq SRC,SRC,#4
	addne SRC,SRC,#8                              @ skip the lfe channel
	vadd.f32 s4,s4,s5
	vadd.f32 s4,s4,s10
	fsts s4,[DST]
	add DST,DST,#4
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}


coeff_5to1:
	.float 0.25
	.float 0.25
	.float 0.16666667
	.float 0.16666667
	.global convert_5to1_neon_asm
	.type	convert_5to1_neon_asm, %function
convert_5to1_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_5to1
	vld1.32 {q0},[COEFF]
0:                                                @ use local label
	vld1.32 {q1},[SRC]!                           @ load 0,1,2,3
	vmul.f32 q1,q1,q0                             @ 0.25*src[0] 0.25*src[1] src[2]/6 src[3]/6
	vadd.f32 d2,d2,d3
	flds s10,[SRC]                                @ load 4
	teq LFE,#0
	ite eq
	addeq SRC,SRC,#4
	addne SRC,SRC,#8                              @ skip the lfe channel
	vadd.f32 s4,s4,s5
	vadd.f32 s4,s4,s10
	fsts s4,[DST]
	add DST,DST,#4
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}


coeff_7to4:
	.float 0.5
	.float 0.5
	.float 0.16666667
	.float 0.16666667
	.global convert_7to4_neon_asm
	.type	convert_7to4_neon_asm, %function
convert_7to4_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_7to4
	vld1.32 {q0},[COEFF]
0:                                                @ use local label
	vld1.32 {q1},[SRC]!                           @ load 0,1,2,3
	vmul.f32 q1,q1,q0                             @ 0.5*src[0] 0.5*src[1] src[2]/6 src[3]/6
	vld1.32 {d5},[SRC]!                           @ load 4,5
	flds s14,[SRC]                                @ load 6
	vadd.f32 d2,d2,d3                             @ 0.5*src[0] + src[2]/6
                                                  @ 0.5*src[1] + src[3]/6
	vdup.32 d4,d7[0]                              @ so q2 : src[6] src[6] src[4] src[5]
	vadd.f32 q2,q2,q1                             @ src[6] + 0.5*src[0] + src[2]/6
                                                  @ src[6] + 0.5*src[1] + src[3]/6
                                                  @ src[4] + src[2]/6
                                                  @ src[5] + src[3]/6
	teq LFE,#0
	ite eq
	addeq SRC,SRC,#4
	addne SRC,SRC,#8                              @ skip the lfe channel
	vst1.32 {q2}, [DST]!
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}


coeff_5to4:
	.float 0.5
	.float 0.5
	.global convert_5to4_neon_asm
	.type	convert_5to4_neon_asm, %function
convert_5to4_neon_asm:
	push {r4,lr}

	adr COEFF, coeff_5to4
	vld1.32 {d0},[COEFF]
0:                                                @ use local label
	vld1.32 {q1},[SRC]!                           @ load 0,1,2,3
	vmul.f32 d2,d2,d0                             @ 0.5*src[0] 0.5*src[1]
	flds s8,[SRC]                                 @ load 4
	vdup.32 d4,d4[0]
	vadd.f32 d2,d2,d4                             @ 0.5*src[0] + src[4]
                                                  @ 0.5*src[1] + src[4]
                                                  @ src[2]
                                                  @ src[3]
	teq LFE,#0
	ite eq
	addeq SRC,SRC,#4
	addne SRC,SRC,#8                              @ skip the lfe channel
	vst1.32 {q1}, [DST]!
	subs NUM,NUM,#1
	bne 0b

	pop {r4,pc}