1@/*
2@ ** Copyright 2003-2010, VisualOn, Inc.
3@ **
4@ ** Licensed under the Apache License, Version 2.0 (the "License");
5@ ** you may not use this file except in compliance with the License.
6@ ** You may obtain a copy of the License at
7@ **
8@ **     http://www.apache.org/licenses/LICENSE-2.0
9@ **
10@ ** Unless required by applicable law or agreed to in writing, software
11@ ** distributed under the License is distributed on an "AS IS" BASIS,
12@ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13@ ** See the License for the specific language governing permissions and
14@ ** limitations under the License.
15@ */
16
17@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
18@	File:		CalcWindowEnergy_v5.s
19@
20@	Content:	CalcWindowEnergy function armv5 assemble
21@
22@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
23
24	.section .text
25
26	.global	CalcWindowEnergy
27
28CalcWindowEnergy:
29	stmdb   sp!, {r4 - r11, lr}
30	sub     r13, r13, #20
31
32  mov     r3, r3, lsl #16
33	ldr     r10, [r0, #168]                    @ states0 = blockSwitchingControl->iirStates[0];
34  mov     r3, r3, asr #16
35	ldr     r11, [r0, #172]                    @ states1 = blockSwitchingControl->iirStates[1];
36
37	mov     r2, r2, lsl #16
38	ldr     r12, hiPassCoeff                   @ Coeff0 = hiPassCoeff[0];
39  mov     r2, r2, asr #16
40	ldr     r14, hiPassCoeff + 4			         @ Coeff1 = hiPassCoeff[1];
41
42	mov			r8, #0							               @ w=0
43	mov			r5, #0							               @ wOffset = 0;
44
45BLOCK_BEGIN:
46	mov			r6, #0                             @ accuUE = 0;
47	mov			r7, #0								             @ accuFE = 0;
48	mov			r4, #0							               @ i=0
49
50	str			r8, [r13, #4]
51	str			r0, [r13, #8]
52	str			r3, [r13, #12]
53
54ENERGY_BEG:
55	mov     r9, r5, lsl #1
56	ldrsh   r9, [r1, r9]											@ tempUnfiltered = timeSignal[tidx];
57
58	add			r5, r5, r2												@ tidx = tidx + chIncrement;
59
60	smulwb	r3, r14, r9												@ accu1 = L_mpy_ls(Coeff1, tempUnfiltered);
61	smull		r0, r8, r12, r11									@ accu2 = fixmul( Coeff0, states1 );
62
63	mov			r3, r3, lsl #1
64	mov			r8, r8, lsl #1
65
66	sub			r0, r3, r10												@ accu3 = accu1 - states0;
67	sub			r8,	r0, r8												@ out = accu3 - accu2;
68
69	mov		  r10, r3														@ states0 = accu1;
70	mov		  r11, r8														@ states1 = out;
71
72	mul		  r3, r9, r9
73	mov     r8, r8, asr #16
74
75	add		  r4, r4, #1
76	add     r6, r6, r3, asr #7
77
78	mul		  r9, r8, r8
79	ldr		  r3, [r13, #12]
80
81	add		  r7, r7, r9, asr #7
82
83	cmp     r4, r3
84  blt     ENERGY_BEG
85
86	ldr		  r0, [r13, #8]
87	ldr		  r8, [r13, #4]
88
89ENERGY_END:
90	add		  r4, r0, r8, lsl #2
91
92	str     r6, [r4, #72]
93	add		  r8, r8, #1
94  str     r7, [r4, #136]
95
96	cmp		  r8, #8
97	blt		  BLOCK_BEGIN
98
99BLOCK_END:
100	str     r10, [r0, #168]
101  str     r11, [r0, #172]
102  mov     r0, #1
103
104  add     r13, r13, #20
105	ldmia   sp!, {r4 - r11, pc}
106
107hiPassCoeff:
108	.word 0xbec8b439
109	.word	0x609d4952
110
111	@ENDP
112	.end
113