1@/******************************************************************************
2@ *
3@ * Copyright (C) 2018 The Android Open Source Project
4@ *
5@ * Licensed under the Apache License, Version 2.0 (the "License");
6@ * you may not use this file except in compliance with the License.
7@ * You may obtain a copy of the License at:
8@ *
9@ * http://www.apache.org/licenses/LICENSE-2.0
10@ *
11@ * Unless required by applicable law or agreed to in writing, software
12@ * distributed under the License is distributed on an "AS IS" BASIS,
13@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14@ * See the License for the specific language governing permissions and
15@ * limitations under the License.
16@ *
17@ *****************************************************************************
18@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19@*/
20
21
22.text
23.p2align 2
24.global ixheaacd_enery_calc_per_subband_armv7
25
26ixheaacd_enery_calc_per_subband_armv7:
27    STMFD           sp!, {r4-r12, r14}
28
29    LDR             r10, [sp, #0x34]
30    MOV             R4, R2
31    MOV             R5, R3
32    MOV             R2, R0
33    MOV             R3, R1
34    SUB             R12, R3, R2
35    LDR             r10, [r10, #0]
36    ADD             r10, r10, r12, LSL #1
37    LDRSH           r9, [r10, #0x20]
38    LDR             R1, [sp, #0x28]
39    MOV             R1, R1, LSL #1
40
41    SUBS            R5, R5, R4
42    LDR             R0, [sp, #0x38]
43    LDR             R7, [sp, #0x2C]
44
45
46    LDR             R8, [sp, #0x30]
47
48    BLE             ENDCALC
49
50
51    MOVS            R8, R8
52    BEQ             HQ_PART
53
54
55    ADD             R0, R0, R4, LSL #2
56    ADD             R0, R0, R2, LSL #8
57    SUB             R2, R3, R2
58    MOV             R10, #20
59
60
61    B               LP_SBR_LOOP
62
63HQ_PART:
64    ADD             R0, R0, R4, LSL #2
65    ADD             R0, R0, R2, LSL #9
66    SUB             R2, R3, R2
67    MOV             R2, R2, LSL #1
68    MOV             R10, #21
69    SUB             R1, R1, #1
70
71
72
73LP_SBR_LOOP:
74
75    MOV             R6, #0
76    MOV             R8, R0
77    MOVS            R11, R2
78    BLE             STORE_ZEROES
79    MOV             R6, #1
80
81LOOP1_CALC_MAX:
82    LDR             R4, [R8], #0x100
83    LDR             R12, [R8], #0x100
84    EOR             R4, R4, R4, ASR #31
85    ORR             R6, R6, R4
86    EOR             R12, R12, R12, ASR #31
87    SUBS            R11, R11, #2
88    ORRGE           R6, R6, R12
89    BGT             LOOP1_CALC_MAX
90
91CALC_NORM:
92
93    CLZ             R6, R6
94    RSBS            R14, R6, R10
95    MOV             R6, #0
96    MOV             R8, R0
97    MOV             R11, R2
98    BLE             NEG_SHIFT
99
100LOOP2_APPLY_POS_SHIFT:
101    LDR             R4, [R8], #0x100
102    LDR             R12, [R8], #0x100
103    SUBS            R11, R11, #2
104    MOV             R4, R4, ASR R14
105    SMLABB          R6, R4, R4, R6
106    MOV             R12, R12, ASR R14
107    SMLABB          R6, R12, R12, R6
108    BGT             LOOP2_APPLY_POS_SHIFT
109
110    B               CONVERT_TO_MANT_EXP
111
112NEG_SHIFT:
113    RSB             R12, R14, #0
114
115LOOP2_APPLY_NEG_SHIFT:
116    LDR             R4, [R8], #0x100
117    LDR             R3, [R8], #0x100
118    SUBS            R11, R11, #2
119    MOV             R4, R4, LSL R12
120    SMLABB          R6, R4, R4, R6
121    MOV             R3, R3, LSL R12
122    SMLABB          R6, R3, R3, R6
123    BGT             LOOP2_APPLY_NEG_SHIFT
124
125
126CONVERT_TO_MANT_EXP:
127    SUB             R14, R14, #23
128    ADD             R0, R0, #4
129    MOVS            R6, R6
130    BEQ             STORE_ZEROES
131
132    CLZ             R12, R6
133    RSB             R12, R12, #17
134    MOV             R4, R6, ASR  R12
135
136    SMULBB          R11, R4, R9
137    ADD             R12, R12, R14, LSL#1
138
139    MOV             R11, R11, ASR #15
140    CMP             R11, #0x00008000
141    MVNEQ           R11, R11
142    STRH            R11, [R7], #2
143    ADD             R11, R1, R12
144    STRH            R11, [R7], #2
145    SUBS            R5, R5, #1
146    BGT             LP_SBR_LOOP
147
148    B               ENDCALC
149
150STORE_ZEROES:
151    STR             R6, [R7], #4
152    SUBS            R5, R5, #1
153    BGT             LP_SBR_LOOP
154
155ENDCALC:
156
157    LDMFD           sp!, {r4-r12, r15}
158
159