1 /*
2 * MOFLEX Fast Audio decoder
3 * Copyright (c) 2015-2016 Florian Nouwt
4 * Copyright (c) 2017 Adib Surani
5 * Copyright (c) 2020 Paul B Mahol
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
30
35
38
41
43 {
45
47
48 for (
int i = 0;
i < 8;
i++)
49 s->table[0][
i] = (
i - 159.5f) / 160.f;
50 for (
int i = 0;
i < 11;
i++)
51 s->table[0][
i + 8] = (
i - 37.5f) / 40.f;
52 for (
int i = 0;
i < 27;
i++)
53 s->table[0][
i + 8 + 11] = (
i - 13.f) / 20.f;
54 for (
int i = 0;
i < 11;
i++)
55 s->table[0][
i + 8 + 11 + 27] = (
i + 27.5f) / 40.f;
56 for (
int i = 0;
i < 7;
i++)
57 s->table[0][
i + 8 + 11 + 27 + 11] = (
i + 152.5f) / 160.f;
58
59 memcpy(
s->table[1],
s->table[0],
sizeof(
s->table[0]));
60
61 for (
int i = 0;
i < 7;
i++)
62 s->table[2][
i] = (
i - 33.5f) / 40.f;
63 for (
int i = 0;
i < 25;
i++)
64 s->table[2][
i + 7] = (
i - 13.f) / 20.f;
65
66 for (
int i = 0;
i < 32;
i++)
67 s->table[3][
i] = -
s->table[2][31 -
i];
68
69 for (
int i = 0;
i < 16;
i++)
70 s->table[4][
i] =
i * 0.22f / 3.f - 0.6f;
71
72 for (
int i = 0;
i < 16;
i++)
73 s->table[5][
i] =
i * 0.20f / 3.f - 0.3f;
74
75 for (
int i = 0;
i < 8;
i++)
76 s->table[6][
i] =
i * 0.36f / 3.f - 0.4f;
77
78 for (
int i = 0;
i < 8;
i++)
79 s->table[7][
i] =
i * 0.34f / 3.f - 0.2f;
80
84
85 return 0;
86 }
87
89 {
91
96
97 return r & ((1 <<
bits) - 1);
98 }
99
100 static const uint8_t
bits[8] = { 6, 6, 5, 5, 4, 0, 3, 3, };
101
103 {
105 }
106
109 {
112 int subframes;
114
116 frame->nb_samples = subframes * 256;
119
121
122 for (int subframe = 0; subframe < subframes; subframe++) {
125 float result[256] = { 0 };
127 int inds[4], pads[4];
128 float m[8];
130
131 for (
int i = 0;
i < 10;
i++)
132 src[
i] = bytestream2_get_le32(&gb);
133
134 for (
int i = 0;
i < 8;
i++)
136
137 for (
int i = 0;
i < 4;
i++)
139
140 for (
int i = 0;
i < 4;
i++)
142
143 for (
int i = 0, index5 = 0;
i < 4;
i++) {
145
146 for (
int j = 0,
tmp = 0; j < 21; j++) {
148 if (j % 10 == 9)
150 if (j == 20)
151 index5 =
FFMIN(2 * index5 +
tmp % 2, 63);
152 }
153
154 m[2] =
s->table[5][index5];
155 }
156
157 for (
int i = 0;
i < 256;
i++) {
159
160 for (int j = 0; j < 8; j++) {
161 x -= m[j] * ch->
f[j];
162 ch->
f[j] += m[j] * x;
163 }
164
165 memmove(&ch->
f[0], &ch->
f[1],
sizeof(
float) * 7);
169 }
170
172 }
173 }
174
175 *got_frame = 1;
176
178 }
179
181 {
183
185
186 return 0;
187 }
188
190 .
p.
name =
"fastaudio",
200 };