1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <stdint.h>
23
26 void *
table,
int table_size,
27 double min,
double max,
double phase)
28 {
29 uint32_t
i, phase_offset = phase /
M_PI / 2 * table_size + 0.5;
30
31 for (
i = 0;
i < table_size;
i++) {
32 uint32_t point = (
i + phase_offset) % table_size;
33 double d;
34
35 switch (wave_type) {
37 d = (sin((
double)point / table_size * 2 *
M_PI) + 1) / 2;
38 break;
40 d = (
double)point * 2 / table_size;
41 switch (4 * point / table_size) {
42 case 0: d = d + 0.5; break;
43 case 1:
44 case 2: d = 1.5 - d; break;
45 case 3: d = d - 1.5; break;
46 }
47 break;
48 default:
50 }
51
53 switch (sample_fmt) {
55 float *fp = (
float *)
table;
58 continue; }
60 double *dp = (
double *)
table;
61 *dp++ = d;
63 continue; }
64 }
65
66 d += d < 0 ? -0.5 : 0.5;
67 switch (sample_fmt) {
70 *sp++ = (int16_t)d;
72 continue; }
77 continue; }
78 default:
80 }
81 }
82 }