1956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@/*
2956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** Copyright 2003-2010, VisualOn, Inc.
3956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ **
4956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** Licensed under the Apache License, Version 2.0 (the "License");
5956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** you may not use this file except in compliance with the License.
6956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** You may obtain a copy of the License at
7956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ **
8956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ **     http://www.apache.org/licenses/LICENSE-2.0
9956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ **
10956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** Unless required by applicable law or agreed to in writing, software
11956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** distributed under the License is distributed on an "AS IS" BASIS,
12956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** See the License for the specific language governing permissions and
14956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ ** limitations under the License.
15956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@ */
16956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@
17956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@void Residu (
18956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@    Word16 a[], /* (i)     : prediction coefficients                      */
19956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@    Word16 x[], /* (i)     : speech signal                                */
20956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@    Word16 y[], /* (o)     : residual signal                              */
21956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@    Word16 lg   /* (i)     : size of filtering                            */
22956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@)
23956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@a[]        RN     r0
24956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@x[]        RN     r1
25956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@y[]        RN     r2
26956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong@lg         RN     r3
27956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
28956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	.section   .text
29b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        .global    Residu_opt
30956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
31956c553ab0ce72f8074ad0fda2ffd66a0305700cJames DongResidu_opt:
32956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
33b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        STMFD          r13!, {r4 - r12, r14}
34956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r7, r3, #4                       @i = lg - 4
35b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard
36b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       {D0, D1, D2, D3}, [r0]!              @get all a[]
37956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VLD1.S16       {D4}, [r0]!
38956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VMOV.S32       Q8,  #0x8000
39b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard
40956c553ab0ce72f8074ad0fda2ffd66a0305700cJames DongLOOP1:
41956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        ADD            r9, r1, r7, LSL #1               @copy the address
42956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        ADD            r10, r2, r7, LSL #1
43956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        MOV            r8, r9
44956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VLD1.S16       D5, [r8]!                       @get x[i], x[i+1], x[i+2], x[i+3]
45956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VQDMULL.S16    Q10, D5, D0[0]                  @finish the first L_mult
46956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
47956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #2                       @get the x[i-1] address
48b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
49956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VQDMLAL.S16    Q10, D5, D0[1]
50956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
51956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #4                       @load the x[i-2] address
52956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VLD1.S16       D5, [r8]!
53956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VQDMLAL.S16    Q10, D5, D0[2]
54956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
55956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #6                       @load the x[i-3] address
56b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
57b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D0[3]
58956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
59956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #8                       @load the x[i-4] address
60b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
61b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D1[0]
62956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
63956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #10                      @load the x[i-5] address
64b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
65b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D1[1]
66956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
67956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #12                      @load the x[i-6] address
68b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
69b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D1[2]
70956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
71956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #14                      @load the x[i-7] address
72b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
73b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D1[3]
74956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
75956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #16                      @load the x[i-8] address
76b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
77b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D2[0]
78956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
79956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #18                      @load the x[i-9] address
80b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
81b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D2[1]
82b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard
83956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r8, r9, #20                      @load the x[i-10] address
84b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VLD1.S16       D5, [r8]!
85b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard        VQDMLAL.S16    Q10, D5, D2[2]
86956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
87956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	SUB            r8, r9, #22                      @load the x[i-11] address
88956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VLD1.S16       D5, [r8]!
89956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VQDMLAL.S16    Q10, D5, D2[3]
90956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
91956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	SUB            r8, r9, #24                      @load the x[i-12] address
92956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VLD1.S16       D5, [r8]!
93956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VQDMLAL.S16    Q10, D5, D3[0]
94956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
95956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	SUB            r8, r9, #26                      @load the x[i-13] address
96956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VLD1.S16       D5, [r8]!
97956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VQDMLAL.S16    Q10, D5, D3[1]
98956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
99956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	SUB            r8, r9, #28                      @load the x[i-14] address
100956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VLD1.S16       D5, [r8]!
101956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VQDMLAL.S16    Q10, D5, D3[2]
102956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
103956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	SUB            r8, r9, #30                      @load the x[i-15] address
104956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VLD1.S16       D5, [r8]!
105956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VQDMLAL.S16    Q10, D5, D3[3]
106956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
107956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	SUB            r8, r9, #32                      @load the x[i-16] address
108956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VLD1.S16       D5, [r8]!
109956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong	VQDMLAL.S16    Q10, D5, D4[0]
110956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
111956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        SUB            r7, r7, #4                       @i-=4
112956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VQSHL.S32      Q10, Q10, #4
113956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VQADD.S32      Q10, Q10, Q8
114956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VSHRN.S32      D5, Q10, #16
115956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        VST1.S16       D5, [r10]!
116956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        CMP            r7,  #0
117956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
118956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        BGE            LOOP1
119956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
120b676a05348e4c516fa8b57e33b10548e6142c3f8Mans RullgardResidu_asm_end:
121b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard
122956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        LDMFD      r13!, {r4 - r12, r15}
123b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard
124956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong        @ENDFUNC
1253f7149c1c8f211c9ef5eb6c4012f078d9d08387bChih-Hung Hsieh        .end
126956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
127956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong
128