Merge commit '42cf7f91f1e9dabf494ff469d8f67ac8b33b0f63'
[ffmpeg.git] / libavcodec / arm / flacdsp_arm.S
1 /*
2  * Copyright (c) 2012 Mans Rullgard <mans@mansr.com>
3  *
4  * This file is part of FFmpeg
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #include "libavutil/arm/asm.S"
22
23 function flac_lpc_16_1_arm
24         ldr             r12, [sp]
25         push            {r4, lr}
26         ldr             r1,  [r1]
27         subs            r12, r12, #2
28         ldr             lr,  [r0], #4
29         beq             2f
30         it              lt
31         poplt           {r4, pc}
32 1:
33         mul             r4,  lr,  r1
34         ldm             r0,  {r2, lr}
35         add_sh          r2,  r2,  r4,  asr r3
36         mul             r4,  r2,  r1
37         subs            r12, r12, #2
38         add_sh          lr,  lr,  r4,  asr r3
39         stm             r0!, {r2, lr}
40         bgt             1b
41         it              lt
42         poplt           {r4, pc}
43 2:
44         mul             r4,  lr,  r1
45         ldr             r2,  [r0]
46         add_sh          r2,  r2,  r4,  asr r3
47         str             r2,  [r0]
48         pop             {r4, pc}
49 endfunc
50
51 function flac_lpc_16_2_arm
52         ldr             r12, [sp]
53         subs            r12, r12, r2
54         it              le
55         bxle            lr
56
57         push            {r4-r9, lr}
58         ldm             r0!, {r6, r7}
59         ldm             r1,  {r8, r9}
60         subs            r12, r12, #1
61         beq             2f
62 1:
63         mul             r4,  r6,  r8
64         mul             r5,  r7,  r8
65         mla             r4,  r7,  r9,  r4
66         ldm             r0,  {r6, r7}
67         add_sh          r6,  r6,  r4,  asr r3
68         mla             r5,  r6,  r9,  r5
69         add_sh          r7,  r7,  r5,  asr r3
70         stm             r0!, {r6, r7}
71         subs            r12, r12, #2
72         bgt             1b
73         it              lt
74         poplt           {r4-r9, pc}
75 2:
76         mul             r4,  r6,  r8
77         mla             r4,  r7,  r9,  r4
78         ldr             r5,  [r0]
79         add_sh          r5,  r5,  r4,  asr r3
80         str             r5,  [r0]
81         pop             {r4-r9, pc}
82 endfunc
83
84 function ff_flac_lpc_16_arm, export=1
85         cmp             r2,  #2
86         blt             flac_lpc_16_1_arm
87         beq             flac_lpc_16_2_arm
88
89         ldr             r12, [sp]
90         subs            r12, r12, r2
91         it              le
92         bxle            lr
93
94         push            {r4-r9, lr}
95
96         subs            r12, r12, #1
97         beq             3f
98 1:
99         sub             lr,  r2,  #2
100         mov             r4,  #0
101         mov             r5,  #0
102
103         ldr             r7,  [r0], #4
104         ldr             r9,  [r1], #4
105 2:
106         mla             r4,  r7,  r9,  r4
107         ldm             r0!, {r6, r7}
108         mla             r5,  r6,  r9,  r5
109         ldm             r1!, {r8, r9}
110         mla             r4,  r6,  r8,  r4
111         subs            lr,  lr,  #2
112         mla             r5,  r7,  r8,  r5
113         bgt             2b
114         blt             6f
115
116         mla             r4,  r7,  r9,  r4
117         ldr             r7,  [r0], #4
118         mla             r5,  r7,  r9,  r5
119         ldr             r9,  [r1], #4
120 6:
121         mla             r4,  r7,  r9,  r4
122         ldm             r0,  {r6, r7}
123         add_sh          r6,  r6,  r4,  asr r3
124         mla             r5,  r6,  r9,  r5
125         add_sh          r7,  r7,  r5,  asr r3
126         stm             r0!, {r6, r7}
127         sub             r0,  r0,  r2,  lsl #2
128         sub             r1,  r1,  r2,  lsl #2
129
130         subs            r12, r12, #2
131         bgt             1b
132         it              lt
133         poplt           {r4-r9, pc}
134 3:
135         mov             r4,  #0
136 4:
137         ldr             r5,  [r1], #4
138         ldr             r6,  [r0], #4
139         mla             r4,  r5,  r6,  r4
140         subs            r2,  r2,  #1
141         bgt             4b
142         ldr             r5,  [r0]
143         add_sh          r5,  r5,  r4,  asr r3
144         str             r5,  [r0]
145         pop             {r4-r9, pc}
146 endfunc