PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
upsamplers.c
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2005, ps2dev - http://www.ps2dev.org
7# Licenced under GNU Library General Public License version 2
8*/
9
15#include <stdio.h>
16#include "upsamplers.h"
17
18#if 0
20static const short int up_8000_lut[512] =
21{
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
23 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
24 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
25 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05,
26 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06,
27 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
28 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09,
29 0x09, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0a,
30 0x0a, 0x0a, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
31 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0d, 0x0d,
32 0x0d, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e,
33 0x0e, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
34 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11,
35 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12,
36 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
37 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15,
38 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16,
39 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
40 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
41 0x19, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1a,
42 0x1a, 0x1a, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
43 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
44 0x1d, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e, 0x1e, 0x1e,
45 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
46 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21,
47 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22,
48 0x22, 0x22, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23,
49 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25,
50 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x26,
51 0x26, 0x26, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27,
52 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29,
53 0x29, 0x29, 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2a,
54 0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,
55 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d,
56 0x2d, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2e,
57 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
58 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31,
59 0x31, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32, 0x32,
60 0x32, 0x32, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
61 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x35, 0x35,
62 0x35, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x36,
63 0x36, 0x36, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37,
64 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x39, 0x39,
65 0x39, 0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3a,
66 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
67 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3d, 0x3d,
68 0x3d, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e, 0x3e,
69 0x3e, 0x3e, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
70 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41,
71 0x41, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x42,
72 0x42, 0x42, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43,
73 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45,
74 0x45, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x46,
75 0x46, 0x46, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47,
76 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49,
77 0x49, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4a,
78 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b,
79 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
80 0x4d, 0x4d, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4e,
81 0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f,
82 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x51, 0x51,
83 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52,
84 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53,
85 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x55, 0x55,
86};
87#endif
88
90static const short int up_11025_lut[512] =
91{
92 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
93 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03,
94 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05,
95 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07,
96 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08,
97 0x09, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0a,
98 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c,
99 0x0c, 0x0d, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,
100 0x0e, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, 0x10, 0x10,
101 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x12,
102 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13,
103 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15,
104 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17,
105 0x17, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19,
106 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1a, 0x1b, 0x1b,
107 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1d,
108 0x1d, 0x1d, 0x1d, 0x1e, 0x1e, 0x1e, 0x1e, 0x1f,
109 0x1f, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x20,
110 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22,
111 0x22, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24,
112 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26,
113 0x26, 0x26, 0x27, 0x27, 0x27, 0x27, 0x27, 0x28,
114 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, 0x2a,
115 0x2a, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2b,
116 0x2c, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d,
117 0x2d, 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f,
118 0x2f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31,
119 0x31, 0x31, 0x32, 0x32, 0x32, 0x32, 0x32, 0x33,
120 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x34, 0x35,
121 0x35, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x36,
122 0x37, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38, 0x38,
123 0x38, 0x39, 0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a,
124 0x3a, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3c, 0x3c,
125 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e,
126 0x3e, 0x3e, 0x3e, 0x3f, 0x3f, 0x3f, 0x3f, 0x40,
127 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x41, 0x41,
128 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x43,
129 0x43, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45,
130 0x45, 0x46, 0x46, 0x46, 0x46, 0x46, 0x47, 0x47,
131 0x47, 0x47, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49,
132 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4a, 0x4b,
133 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,
134 0x4d, 0x4d, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4e,
135 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,
136 0x50, 0x51, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52,
137 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54,
138 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x56,
139 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 0x57, 0x57,
140 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x59,
141 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b,
142 0x5b, 0x5c, 0x5c, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d,
143 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
144 0x5f, 0x5f, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61,
145 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x62, 0x62,
146 0x63, 0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x64,
147 0x65, 0x65, 0x65, 0x65, 0x65, 0x66, 0x66, 0x66,
148 0x66, 0x67, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,
149 0x68, 0x68, 0x69, 0x69, 0x69, 0x69, 0x6a, 0x6a,
150 0x6a, 0x6a, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6c,
151 0x6c, 0x6c, 0x6c, 0x6d, 0x6d, 0x6d, 0x6d, 0x6e,
152 0x6e, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f,
153 0x70, 0x70, 0x70, 0x70, 0x71, 0x71, 0x71, 0x71,
154 0x71, 0x72, 0x72, 0x72, 0x72, 0x73, 0x73, 0x73,
155 0x73, 0x73, 0x74, 0x74, 0x74, 0x74, 0x75, 0x75,
156};
157
159static const short up_22050_lut[512] =
160{
161 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03,
162 0x03, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x06,
163 0x07, 0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a,
164 0x0b, 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e,
165 0x0e, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
166 0x12, 0x12, 0x13, 0x13, 0x14, 0x14, 0x15, 0x15,
167 0x16, 0x16, 0x16, 0x17, 0x17, 0x18, 0x18, 0x19,
168 0x19, 0x1a, 0x1a, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c,
169 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x20, 0x20,
170 0x21, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24,
171 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x27,
172 0x28, 0x28, 0x29, 0x29, 0x2a, 0x2a, 0x2b, 0x2b,
173 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2f,
174 0x2f, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x32,
175 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x36, 0x36,
176 0x37, 0x37, 0x38, 0x38, 0x38, 0x39, 0x39, 0x3a,
177 0x3a, 0x3b, 0x3b, 0x3c, 0x3c, 0x3d, 0x3d, 0x3e,
178 0x3e, 0x3e, 0x3f, 0x3f, 0x40, 0x40, 0x41, 0x41,
179 0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x45,
180 0x45, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49,
181 0x49, 0x49, 0x4a, 0x4a, 0x4b, 0x4b, 0x4c, 0x4c,
182 0x4d, 0x4d, 0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50,
183 0x50, 0x51, 0x51, 0x52, 0x52, 0x53, 0x53, 0x54,
184 0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x57, 0x57,
185 0x58, 0x58, 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5b,
186 0x5b, 0x5c, 0x5c, 0x5d, 0x5d, 0x5e, 0x5e, 0x5f,
187 0x5f, 0x60, 0x60, 0x60, 0x61, 0x61, 0x62, 0x62,
188 0x63, 0x63, 0x64, 0x64, 0x65, 0x65, 0x65, 0x66,
189 0x66, 0x67, 0x67, 0x68, 0x68, 0x69, 0x69, 0x6a,
190 0x6a, 0x6b, 0x6b, 0x6b, 0x6c, 0x6c, 0x6d, 0x6d,
191 0x6e, 0x6e, 0x6f, 0x6f, 0x70, 0x70, 0x71, 0x71,
192 0x71, 0x72, 0x72, 0x73, 0x73, 0x74, 0x74, 0x75,
193 0x75, 0x76, 0x76, 0x76, 0x77, 0x77, 0x78, 0x78,
194 0x79, 0x79, 0x7a, 0x7a, 0x7b, 0x7b, 0x7c, 0x7c,
195 0x7c, 0x7d, 0x7d, 0x7e, 0x7e, 0x7f, 0x7f, 0x80,
196 0x80, 0x81, 0x81, 0x82, 0x82, 0x82, 0x83, 0x83,
197 0x84, 0x84, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87,
198 0x87, 0x88, 0x88, 0x89, 0x89, 0x8a, 0x8a, 0x8b,
199 0x8b, 0x8c, 0x8c, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e,
200 0x8f, 0x8f, 0x90, 0x90, 0x91, 0x91, 0x92, 0x92,
201 0x93, 0x93, 0x93, 0x94, 0x94, 0x95, 0x95, 0x96,
202 0x96, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
203 0x9a, 0x9a, 0x9b, 0x9b, 0x9c, 0x9c, 0x9d, 0x9d,
204 0x9e, 0x9e, 0x9e, 0x9f, 0x9f, 0xa0, 0xa0, 0xa1,
205 0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4,
206 0xa5, 0xa5, 0xa6, 0xa6, 0xa7, 0xa7, 0xa8, 0xa8,
207 0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xab, 0xab, 0xac,
208 0xac, 0xad, 0xad, 0xae, 0xae, 0xaf, 0xaf, 0xaf,
209 0xb0, 0xb0, 0xb1, 0xb1, 0xb2, 0xb2, 0xb3, 0xb3,
210 0xb4, 0xb4, 0xb4, 0xb5, 0xb5, 0xb6, 0xb6, 0xb7,
211 0xb7, 0xb8, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xba,
212 0xbb, 0xbb, 0xbc, 0xbc, 0xbd, 0xbd, 0xbe, 0xbe,
213 0xbf, 0xbf, 0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc2,
214 0xc2, 0xc3, 0xc3, 0xc4, 0xc4, 0xc5, 0xc5, 0xc5,
215 0xc6, 0xc6, 0xc7, 0xc7, 0xc8, 0xc8, 0xc9, 0xc9,
216 0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd,
217 0xcd, 0xce, 0xce, 0xcf, 0xcf, 0xd0, 0xd0, 0xd1,
218 0xd1, 0xd1, 0xd2, 0xd2, 0xd3, 0xd3, 0xd4, 0xd4,
219 0xd5, 0xd5, 0xd6, 0xd6, 0xd6, 0xd7, 0xd7, 0xd8,
220 0xd8, 0xd9, 0xd9, 0xda, 0xda, 0xdb, 0xdb, 0xdc,
221 0xdc, 0xdc, 0xdd, 0xdd, 0xde, 0xde, 0xdf, 0xdf,
222 0xe0, 0xe0, 0xe1, 0xe1, 0xe2, 0xe2, 0xe2, 0xe3,
223 0xe3, 0xe4, 0xe4, 0xe5, 0xe5, 0xe6, 0xe6, 0xe7,
224 0xe7, 0xe7, 0xe8, 0xe8, 0xe9, 0xe9, 0xea, 0xea,
225};
226
228static const short up_32000_lut[512] = {
229 0x0000, 0x0000, 0x0001, 0x0002, 0x0002, 0x0003, 0x0004, 0x0004,
230 0x0005, 0x0006, 0x0006, 0x0007, 0x0008, 0x0008, 0x0009, 0x000a,
231 0x000a, 0x000b, 0x000c, 0x000c, 0x000d, 0x000e, 0x000e, 0x000f,
232 0x0010, 0x0010, 0x0011, 0x0012, 0x0012, 0x0013, 0x0014, 0x0014,
233 0x0015, 0x0016, 0x0016, 0x0017, 0x0018, 0x0018, 0x0019, 0x001a,
234 0x001a, 0x001b, 0x001c, 0x001c, 0x001d, 0x001e, 0x001e, 0x001f,
235 0x0020, 0x0020, 0x0021, 0x0022, 0x0022, 0x0023, 0x0024, 0x0024,
236 0x0025, 0x0026, 0x0026, 0x0027, 0x0028, 0x0028, 0x0029, 0x002a,
237 0x002a, 0x002b, 0x002c, 0x002c, 0x002d, 0x002e, 0x002e, 0x002f,
238 0x0030, 0x0030, 0x0031, 0x0032, 0x0032, 0x0033, 0x0034, 0x0034,
239 0x0035, 0x0036, 0x0036, 0x0037, 0x0038, 0x0038, 0x0039, 0x003a,
240 0x003a, 0x003b, 0x003c, 0x003c, 0x003d, 0x003e, 0x003e, 0x003f,
241 0x0040, 0x0040, 0x0041, 0x0042, 0x0042, 0x0043, 0x0044, 0x0044,
242 0x0045, 0x0046, 0x0046, 0x0047, 0x0048, 0x0048, 0x0049, 0x004a,
243 0x004a, 0x004b, 0x004c, 0x004c, 0x004d, 0x004e, 0x004e, 0x004f,
244 0x0050, 0x0050, 0x0051, 0x0052, 0x0052, 0x0053, 0x0054, 0x0054,
245 0x0055, 0x0056, 0x0056, 0x0057, 0x0058, 0x0058, 0x0059, 0x005a,
246 0x005a, 0x005b, 0x005c, 0x005c, 0x005d, 0x005e, 0x005e, 0x005f,
247 0x0060, 0x0060, 0x0061, 0x0062, 0x0062, 0x0063, 0x0064, 0x0064,
248 0x0065, 0x0066, 0x0066, 0x0067, 0x0068, 0x0068, 0x0069, 0x006a,
249 0x006a, 0x006b, 0x006c, 0x006c, 0x006d, 0x006e, 0x006e, 0x006f,
250 0x0070, 0x0070, 0x0071, 0x0072, 0x0072, 0x0073, 0x0074, 0x0074,
251 0x0075, 0x0076, 0x0076, 0x0077, 0x0078, 0x0078, 0x0079, 0x007a,
252 0x007a, 0x007b, 0x007c, 0x007c, 0x007d, 0x007e, 0x007e, 0x007f,
253 0x0080, 0x0080, 0x0081, 0x0082, 0x0082, 0x0083, 0x0084, 0x0084,
254 0x0085, 0x0086, 0x0086, 0x0087, 0x0088, 0x0088, 0x0089, 0x008a,
255 0x008a, 0x008b, 0x008c, 0x008c, 0x008d, 0x008e, 0x008e, 0x008f,
256 0x0090, 0x0090, 0x0091, 0x0092, 0x0092, 0x0093, 0x0094, 0x0094,
257 0x0095, 0x0096, 0x0096, 0x0097, 0x0098, 0x0098, 0x0099, 0x009a,
258 0x009a, 0x009b, 0x009c, 0x009c, 0x009d, 0x009e, 0x009e, 0x009f,
259 0x00a0, 0x00a0, 0x00a1, 0x00a2, 0x00a2, 0x00a3, 0x00a4, 0x00a4,
260 0x00a5, 0x00a6, 0x00a6, 0x00a7, 0x00a8, 0x00a8, 0x00a9, 0x00aa,
261 0x00aa, 0x00ab, 0x00ac, 0x00ac, 0x00ad, 0x00ae, 0x00ae, 0x00af,
262 0x00b0, 0x00b0, 0x00b1, 0x00b2, 0x00b2, 0x00b3, 0x00b4, 0x00b4,
263 0x00b5, 0x00b6, 0x00b6, 0x00b7, 0x00b8, 0x00b8, 0x00b9, 0x00ba,
264 0x00ba, 0x00bb, 0x00bc, 0x00bc, 0x00bd, 0x00be, 0x00be, 0x00bf,
265 0x00c0, 0x00c0, 0x00c1, 0x00c2, 0x00c2, 0x00c3, 0x00c4, 0x00c4,
266 0x00c5, 0x00c6, 0x00c6, 0x00c7, 0x00c8, 0x00c8, 0x00c9, 0x00ca,
267 0x00ca, 0x00cb, 0x00cc, 0x00cc, 0x00cd, 0x00ce, 0x00ce, 0x00cf,
268 0x00d0, 0x00d0, 0x00d1, 0x00d2, 0x00d2, 0x00d3, 0x00d4, 0x00d4,
269 0x00d5, 0x00d6, 0x00d6, 0x00d7, 0x00d8, 0x00d8, 0x00d9, 0x00da,
270 0x00da, 0x00db, 0x00dc, 0x00dc, 0x00dd, 0x00de, 0x00de, 0x00df,
271 0x00e0, 0x00e0, 0x00e1, 0x00e2, 0x00e2, 0x00e3, 0x00e4, 0x00e4,
272 0x00e5, 0x00e6, 0x00e6, 0x00e7, 0x00e8, 0x00e8, 0x00e9, 0x00ea,
273 0x00ea, 0x00eb, 0x00ec, 0x00ec, 0x00ed, 0x00ee, 0x00ee, 0x00ef,
274 0x00f0, 0x00f0, 0x00f1, 0x00f2, 0x00f2, 0x00f3, 0x00f4, 0x00f4,
275 0x00f5, 0x00f6, 0x00f6, 0x00f7, 0x00f8, 0x00f8, 0x00f9, 0x00fa,
276 0x00fa, 0x00fb, 0x00fc, 0x00fc, 0x00fd, 0x00fe, 0x00fe, 0x00ff,
277 0x0100, 0x0100, 0x0101, 0x0102, 0x0102, 0x0103, 0x0104, 0x0104,
278 0x0105, 0x0106, 0x0106, 0x0107, 0x0108, 0x0108, 0x0109, 0x010a,
279 0x010a, 0x010b, 0x010c, 0x010c, 0x010d, 0x010e, 0x010e, 0x010f,
280 0x0110, 0x0110, 0x0111, 0x0112, 0x0112, 0x0113, 0x0114, 0x0114,
281 0x0115, 0x0116, 0x0116, 0x0117, 0x0118, 0x0118, 0x0119, 0x011a,
282 0x011a, 0x011b, 0x011c, 0x011c, 0x011d, 0x011e, 0x011e, 0x011f,
283 0x0120, 0x0120, 0x0121, 0x0122, 0x0122, 0x0123, 0x0124, 0x0124,
284 0x0125, 0x0126, 0x0126, 0x0127, 0x0128, 0x0128, 0x0129, 0x012a,
285 0x012a, 0x012b, 0x012c, 0x012c, 0x012d, 0x012e, 0x012e, 0x012f,
286 0x0130, 0x0130, 0x0131, 0x0132, 0x0132, 0x0133, 0x0134, 0x0134,
287 0x0135, 0x0136, 0x0136, 0x0137, 0x0138, 0x0138, 0x0139, 0x013a,
288 0x013a, 0x013b, 0x013c, 0x013c, 0x013d, 0x013e, 0x013e, 0x013f,
289 0x0140, 0x0140, 0x0141, 0x0142, 0x0142, 0x0143, 0x0144, 0x0144,
290 0x0145, 0x0146, 0x0146, 0x0147, 0x0148, 0x0148, 0x0149, 0x014a,
291 0x014a, 0x014b, 0x014c, 0x014c, 0x014d, 0x014e, 0x014e, 0x014f,
292 0x0150, 0x0150, 0x0151, 0x0152, 0x0152, 0x0153, 0x0154, 0x0154,
293};
294
296static const short up_44100_lut[512] =
297{
298 0x0000, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006,
299 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000b, 0x000c, 0x000d,
300 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015,
301 0x0016, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c,
302 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0021, 0x0022, 0x0023,
303 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b,
304 0x002c, 0x002d, 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032,
305 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0038, 0x0039,
306 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x0041,
307 0x0042, 0x0043, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048,
308 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x004f,
309 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
310 0x0058, 0x0059, 0x005a, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e,
311 0x005f, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0065,
312 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d,
313 0x006e, 0x006f, 0x0070, 0x0071, 0x0071, 0x0072, 0x0073, 0x0074,
314 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c,
315 0x007c, 0x007d, 0x007e, 0x007f, 0x0080, 0x0081, 0x0082, 0x0083,
316 0x0084, 0x0085, 0x0086, 0x0087, 0x0087, 0x0088, 0x0089, 0x008a,
317 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, 0x0090, 0x0091, 0x0092,
318 0x0093, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099,
319 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009e, 0x009f, 0x00a0,
320 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8,
321 0x00a9, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
322 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b4, 0x00b5, 0x00b6,
323 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be,
324 0x00bf, 0x00c0, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5,
325 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cb, 0x00cc,
326 0x00cd, 0x00ce, 0x00cf, 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4,
327 0x00d5, 0x00d6, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db,
328 0x00dc, 0x00dd, 0x00de, 0x00df, 0x00e0, 0x00e1, 0x00e2, 0x00e2,
329 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea,
330 0x00eb, 0x00ec, 0x00ed, 0x00ed, 0x00ee, 0x00ef, 0x00f0, 0x00f1,
331 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f8,
332 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff, 0x0100,
333 0x0101, 0x0102, 0x0103, 0x0104, 0x0104, 0x0105, 0x0106, 0x0107,
334 0x0108, 0x0109, 0x010a, 0x010b, 0x010c, 0x010d, 0x010e, 0x010f,
335 0x010f, 0x0110, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116,
336 0x0117, 0x0118, 0x0119, 0x011a, 0x011a, 0x011b, 0x011c, 0x011d,
337 0x011e, 0x011f, 0x0120, 0x0121, 0x0122, 0x0123, 0x0124, 0x0125,
338 0x0126, 0x0126, 0x0127, 0x0128, 0x0129, 0x012a, 0x012b, 0x012c,
339 0x012d, 0x012e, 0x012f, 0x0130, 0x0131, 0x0131, 0x0132, 0x0133,
340 0x0134, 0x0135, 0x0136, 0x0137, 0x0138, 0x0139, 0x013a, 0x013b,
341 0x013c, 0x013c, 0x013d, 0x013e, 0x013f, 0x0140, 0x0141, 0x0142,
342 0x0143, 0x0144, 0x0145, 0x0146, 0x0147, 0x0147, 0x0148, 0x0149,
343 0x014a, 0x014b, 0x014c, 0x014d, 0x014e, 0x014f, 0x0150, 0x0151,
344 0x0152, 0x0153, 0x0153, 0x0154, 0x0155, 0x0156, 0x0157, 0x0158,
345 0x0159, 0x015a, 0x015b, 0x015c, 0x015d, 0x015e, 0x015e, 0x015f,
346 0x0160, 0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x0166, 0x0167,
347 0x0168, 0x0169, 0x0169, 0x016a, 0x016b, 0x016c, 0x016d, 0x016e,
348 0x016f, 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x0175, 0x0175,
349 0x0176, 0x0177, 0x0178, 0x0179, 0x017a, 0x017b, 0x017c, 0x017d,
350 0x017e, 0x017f, 0x0180, 0x0180, 0x0181, 0x0182, 0x0183, 0x0184,
351 0x0185, 0x0186, 0x0187, 0x0188, 0x0189, 0x018a, 0x018b, 0x018b,
352 0x018c, 0x018d, 0x018e, 0x018f, 0x0190, 0x0191, 0x0192, 0x0193,
353 0x0194, 0x0195, 0x0196, 0x0197, 0x0197, 0x0198, 0x0199, 0x019a,
354 0x019b, 0x019c, 0x019d, 0x019e, 0x019f, 0x01a0, 0x01a1, 0x01a2,
355 0x01a2, 0x01a3, 0x01a4, 0x01a5, 0x01a6, 0x01a7, 0x01a8, 0x01a9,
356 0x01aa, 0x01ab, 0x01ac, 0x01ad, 0x01ad, 0x01ae, 0x01af, 0x01b0,
357 0x01b1, 0x01b2, 0x01b3, 0x01b4, 0x01b5, 0x01b6, 0x01b7, 0x01b8,
358 0x01b9, 0x01b9, 0x01ba, 0x01bb, 0x01bc, 0x01bd, 0x01be, 0x01bf,
359 0x01c0, 0x01c1, 0x01c2, 0x01c3, 0x01c4, 0x01c4, 0x01c5, 0x01c6,
360 0x01c7, 0x01c8, 0x01c9, 0x01ca, 0x01cb, 0x01cc, 0x01cd, 0x01ce,
361 0x01cf, 0x01cf, 0x01d0, 0x01d1, 0x01d2, 0x01d3, 0x01d4, 0x01d5,
362};
363
370static void demux(short *mux, short *left, short *right, int len)
371{
372 while (len > 0)
373 {
374 *left++ = *mux++;
375 *right++ = *mux++;
376 len--;
377 }
378}
379
380static int up_12000_16_stereo(struct upsample_t *up)
381{
382 int p;
383 short *left = up->left;
384 short *right = up->right;
385 short *src = (short *)up->src;
386
387 for (p=0; p<128; p++)
388 {
389 *left++ = src[0];
390 *right++ = src[1];
391 *left++ = src[0];
392 *right++ = src[1];
393 *left++ = src[0];
394 *right++ = src[1];
395 *left++ = *src++;
396 *right++ = *src++;
397 }
398
399 return 512;
400}
401
402static int up_24000_16_stereo(struct upsample_t *up)
403{
404 int p;
405 short *left = up->left;
406 short *right = up->right;
407 short *src = (short *)up->src;
408
409 for (p=0; p<256; p++)
410 {
411 *left++ = src[0];
412 *right++ = src[1];
413 *left++ = *src++;
414 *right++ = *src++;
415 }
416
417 return 1024;
418}
419
420static void up_generic_16_stereo(struct upsample_t *up, const short *lut)
421{
422 int p;
423 short *left = up->left;
424 short *right = up->right;
425 short *src = (short *)up->src;
426
427 for (p=0; p<512; p++)
428 {
429 int q;
430
431 q = lut[p] << 1;
432 *left++ = src[q + 0];
433 *right++ = src[q + 1];
434 }
435}
436
437static void up_generic_16_mono(struct upsample_t *up, const short *lut)
438{
439 int p;
440 short *left = up->left;
441 short *right = up->right;
442 short *src = (short *)up->src;
443
444 for (p=0; p<512; p++)
445 {
446 int q;
447
448 q = lut[p];
449 *left++ = *right++ = src[q];
450 }
451}
452
453static void up_generic_8_mono(struct upsample_t *up, const short *lut)
454{
455 int p;
456 short *left = up->left;
457 short *right = up->right;
458 char *src = (char *)up->src;
459
460 for (p=0; p<512; p++)
461 {
462 int q;
463 signed char b;
464
465 q = lut[p];
466 b = src[q];
467 *left++ = *right++ = (short)((b + (b << 8)) - 32768);
468 }
469}
470
471static void up_generic_8_stereo(struct upsample_t *up, const short *lut)
472{
473 int p;
474 short *left = up->left;
475 short *right = up->right;
476 char *src = (char *)up->src;
477
478 for (p=0; p<512; p++)
479 {
480 int q;
481 signed char b;
482
483 q = lut[p] << 1;
484 b = src[q + 0];
485 *left++ = (short)((b + (b << 8)) - 32768);
486 b = src[q + 1];
487 *right++ = (short)((b + (b << 8)) - 32768);
488 }
489}
490
491static int up_11025_8_mono(struct upsample_t *up)
492{
493 up_generic_8_mono(up, up_11025_lut);
494 return 116; /* (11025 / 48000) * 512 */
495}
496
497static int up_11025_8_stereo(struct upsample_t *up)
498{
499 up_generic_8_stereo(up, up_11025_lut);
500 return 234; /* (11025 / 48000) * 512 * stereo */
501}
502
503static int up_11025_16_mono(struct upsample_t *up)
504{
505 up_generic_16_mono(up, up_11025_lut);
506 return 234; /* (11025 / 48000) * 512 * 16bit */
507}
508
509static int up_11025_16_stereo(struct upsample_t *up)
510{
511 up_generic_16_stereo(up, up_11025_lut);
512 return 470; /* (11025 / 48000) * 512 * stereo * 16bit */
513}
514
515static int up_22050_8_mono(struct upsample_t *up)
516{
517 up_generic_8_mono(up, up_22050_lut);
518 return 235; /* (22050 / 48000) * 512 */
519}
520
521static int up_22050_16_mono(struct upsample_t *up)
522{
523 up_generic_16_mono(up, up_22050_lut);
524 return 470; /* (22050 / 48000) * 512 * 2 */
525}
526
527static int up_22050_16_stereo(struct upsample_t *up)
528{
529 up_generic_16_stereo(up, up_22050_lut);
530 return 940; /* (22050 / 48000) * 512 * stereo * 16bit */
531}
532
533static int up_32000_8_mono(struct upsample_t *up)
534{
535 up_generic_8_mono(up, up_32000_lut);
536 return 340; /* (32000 / 48000) * 512 */
537}
538
539static int up_32000_16_mono(struct upsample_t *up)
540{
541 up_generic_16_mono(up, up_32000_lut);
542 return 682; /* (32000 / 48000) * 512 * 16bit */
543}
544
545static int up_32000_16_stereo(struct upsample_t *up)
546{
547 up_generic_16_stereo(up, up_32000_lut);
548 return 1364; /* (32000 / 48000) * 512 * stereo * 16bit */
549}
550
551static int up_44100_8_mono(struct upsample_t *up)
552{
553 up_generic_8_mono(up, up_44100_lut);
554 return 470; /* (44100 / 48000) * 512 */
555}
556
557static int up_44100_16_mono(struct upsample_t *up)
558{
559 up_generic_16_mono(up, up_44100_lut);
560 return 940; /* (44100 / 48000) * 512 * 16bit */
561}
562
563static int up_44100_16_stereo(struct upsample_t *up)
564{
565 up_generic_16_stereo(up, up_44100_lut);
566 return 1880; /* (44100 / 48000) * 512 * stereo * 16bit */
567}
568
569static int up_48000_16_mono(struct upsample_t *up)
570{
571 int i;
572 short *left = (short *)up->left;
573 short *right = (short *)up->right;
574 short *src = (short *)up->src;
575
576 for (i=0; i<512; i++)
577 {
578 *left++ = *right++ = *src++;
579 }
580
581 return 1024; /* 512 * 16bit */
582}
583
584static int up_48000_16_stereo(struct upsample_t *up)
585{
586 /* simple demux */
587 demux((short *)up->src, up->left, up->right, 512);
588 return 2048; /* 512 * stereo * 16bit */
589}
590
591typedef struct entry_t
592{
594 int freq;
596 int bits;
600 upsampler_t func;
601} entry_t;
602
605{
606 {11025, 8, 1, up_11025_8_mono},
607 {11025, 8, 2, up_11025_8_stereo},
608 {11025, 16, 1, up_11025_16_mono},
609 {11025, 16, 2, up_11025_16_stereo},
610 {12000, 16, 2, up_12000_16_stereo},
611 {22050, 8, 1, up_22050_8_mono},
612 {22050, 16, 1, up_22050_16_mono},
613 {22050, 16, 2, up_22050_16_stereo},
614 {24000, 16, 2, up_24000_16_stereo},
615 {32000, 8, 1, up_32000_8_mono},
616 {32000, 16, 1, up_32000_16_mono},
617 {32000, 16, 2, up_32000_16_stereo},
618 {44100, 8, 1, up_44100_8_mono},
619 {44100, 16, 1, up_44100_16_mono},
620 {44100, 16, 2, up_44100_16_stereo},
621 {48000, 16, 1, up_48000_16_mono},
622 {48000, 16, 2, up_48000_16_stereo},
623 {0, 0, 0, 0}
624};
625
636upsampler_t find_upsampler(int freq, int bits, int channels)
637{
638 struct entry_t *p = upsamplers;
639 while (p->func != NULL)
640 {
641 if (p->freq == freq && p->bits == bits && p->channels == channels)
642 {
643 /* found us an upsampler */
644 return p->func;
645 }
646
647 p++;
648 }
649
650 /* no more upsamplers */
651 return NULL;
652}
653
upsampler_t find_upsampler(int freq, int bits, int channels)
Definition upsamplers.c:636
static const short up_44100_lut[512]
Definition upsamplers.c:296
static const short up_32000_lut[512]
Definition upsamplers.c:228
static const short int up_11025_lut[512]
Definition upsamplers.c:90
int channels
Definition upsamplers.c:598
static void demux(short *mux, short *left, short *right, int len)
Definition upsamplers.c:370
static entry_t upsamplers[]
Definition upsamplers.c:604
upsampler_t func
Definition upsamplers.c:600
static const short up_22050_lut[512]
Definition upsamplers.c:159