1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Michael Sevakis
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 /****************************************************************************
23 * void sample_output_mono(int count, struct dsp_data *data,
24 * const int32_t *src[], int16_t *dst)
26 .section .text, "ax", %progbits
28 .global sample_output_mono
29 .type sample_output_mono, %function
31 @ input: r0 = count, r1 = data, r2 = src, r3 = dst
32 stmfd sp!, { r4, lr } @
34 ldr r1, [r1] @ r1 = data->output_scale
35 ldr r2, [r2] @ r2 = src[0]
37 mov r4, #1 @ r4 = 1 << (scale - 1)
39 subs r0, r0, #1 @ odd: end at 0; even: end at -1
41 beq 2f @ Zero? Only one sample!
44 ldmia r2!, { r12, r14 } @ load Mi0, Mi1
45 qadd r12, r12, r4 @ round, scale, saturate and
46 qadd r14, r14, r4 @ pack Mi0 to So0, Mi1 to So1
47 mov r12, r12, asr r1 @
48 mov r14, r14, asr r1 @
51 pkhbt r12, r12, r12, asl #16 @
52 pkhbt r14, r14, r14, asl #16 @
54 stmia r3!, { r12, r14 } @ store So0, So1
57 ldmltfd sp!, { r4, pc } @ if count was even, we're done
60 ldr r12, [r2] @ round, scale, saturate
61 qadd r12, r12, r4 @ and pack Mi to So
62 mov r12, r12, asr r1 @
64 pkhbt r12, r12, r12, asl #16 @
65 str r12, [r3] @ store So
67 ldmfd sp!, { r4, pc } @
68 .size sample_output_mono, .-sample_output_mono
70 /****************************************************************************
71 * void sample_output_stereo(int count, struct dsp_data *data,
72 * const int32_t *src[], int16_t *dst)
74 .section .text, "ax", %progbits
76 .global sample_output_stereo
77 .type sample_output_stereo, %function
79 @ input: r0 = count, r1 = data, r2 = src, r3 = dst
80 stmfd sp!, { r4-r7, lr } @
82 ldr r1, [r1] @ r1 = data->output_scale
83 ldmia r2, { r2, r4 } @ r2 = src[0], r4 = src[1]
85 mov r5, #1 @ r5 = 1 << (scale - 1)
87 subs r0, r0, #1 @ odd: end at 0; even: end at -1
89 beq 2f @ Zero? Only one sample!
92 ldmia r2!, { r6, r7 } @ r6, r7 = Li0, Li1
93 ldmia r4!, { r12, r14 } @ r12, r14 = Ri0, Ri1
94 qadd r6, r6, r5 @ round, scale, saturate and pack
95 qadd r7, r7, r5 @ Li0+Ri0 to So0, Li1+Ri1 to So1
100 mov r12, r12, asr r1 @
101 mov r14, r14, asr r1 @
106 pkhbt r6, r6, r12, asl #16 @
107 pkhbt r7, r7, r14, asl #16 @
109 stmia r3!, { r6, r7 } @ store So0, So1
112 ldmltfd sp!, { r4-r7, pc } @ if count was even, we're done
115 ldr r6, [r2] @ r6 = Li
116 ldr r12, [r4] @ r12 = Ri
117 qadd r6, r6, r5 @ round, scale, saturate
118 qadd r12, r12, r5 @ and pack Li+Ri to So
120 mov r12, r12, asr r1 @
123 pkhbt r6, r6, r12, asl #16 @
124 str r6, [r3] @ store So
126 ldmfd sp!, { r4-r7, pc } @
127 .size sample_output_stereo, .-sample_output_stereo