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_scale_factor_process_armv7
25
26ixheaacd_scale_factor_process_armv7:
27
28
29
30
31    STMFD           sp!, {r4-r12, r14}
32    LDR             r9, [sp, #0x28]
33    LDR             r11, [sp, #0x2c]
34
35    CMP             r2, #0
36
37    BLE             END
38    MOV             r10, #0
39    CMP             r11, #2
40    MOVLE           r11, #0x25
41    MOVGT           r11, #0x22
42
43TBANDS_LOOP:
44
45    LDRSH           r5, [r1], #2
46    LDRB            r4, [r3], #1
47
48    LDR             r6, [sp, #0x30]
49    LDR             r7, [sp, #0x34]
50
51    CMP             r5, #0x18
52    BGE             SCALE_FACTOR_GE_12
53
54    CMP             r4, #0
55    BLE             OFFSET_ZERO
56
57SCALE_FACTOR_LT_12:
58
59    STR             r10, [r0], #4
60    STR             r10, [r0], #4
61    STR             r10, [r0], #4
62    STR             r10, [r0], #4
63    SUBS            r4, r4, #4
64    BGT             SCALE_FACTOR_LT_12
65    B               OFFSET_ZERO
66
67SCALE_FACTOR_GE_12:
68
69    SUBS            r6, r11, r5, ASR #2
70
71
72    AND             r5, r5, #3
73
74
75    LDR             r5, [r9, r5, LSL #2]
76
77    BLE             SHIFT_LE_ZERO
78
79    SUB             r14, r6, #1
80
81SHIFT_POSITIVE:
82    LDRD            r6, [r0, #0]
83
84    SMULWB          r6, r6, r5
85    SMULWB          r7, r7, r5
86
87    MOV             r6, r6, ASR r14
88    MOV             r7, r7, ASR r14
89
90    STRD            r6, [r0], #8
91
92    LDRD            r6, [r0, #0]
93
94    SMULWB          r6, r6, r5
95    SMULWB          r7, r7, r5
96    SUBS            r4, r4, #4
97
98    MOV             r6, r6, ASR r14
99    MOV             r7, r7, ASR r14
100
101    STRD            r6, [r0], #8
102
103    BGT             SHIFT_POSITIVE
104    B               OFFSET_ZERO
105SHIFT_LE_ZERO:
106
107    RSBS            r14, r6, #0
108    BGT             SHIFT_NEGTIVE1
109
110SHIFT_ZERO:
111    LDRD            r6, [r0, #0]
112
113    SMULWB          r6, r6, r5
114    SMULWB          r7, r7, r5
115    MOV             r6, r6, LSL #1
116    MOV             r7, r7, LSL #1
117
118    STRD            r6, [r0], #8
119
120    SUBS            r4, r4, #2
121
122    BGT             SHIFT_ZERO
123    B               OFFSET_ZERO
124
125SHIFT_NEGTIVE1:
126    SUB             r14, r14, #1
127SHIFT_NEGTIVE:
128    LDRD            r6, [r0, #0]
129    MOV             r6, r6, LSL r14
130    MOV             r7, r7, LSL r14
131
132    SMULWB          r6, r6, r5
133    SMULWB          r7, r7, r5
134    MOV             r6, r6, LSL #2
135    MOV             r7, r7, LSL #2
136
137    STRD            r6, [r0], #8
138
139    SUBS            r4, r4, #2
140
141    BGT             SHIFT_NEGTIVE
142
143OFFSET_ZERO:
144    SUBS            r2, r2, #1
145    BGT             TBANDS_LOOP
146END:
147    LDMFD           sp!, {r4-r12, r15}
148