161{
162 int q;
163 if (argc > 1) {
165 } else {
166 printf(
"input quantize=");
167 if (scanf("%d", &q) != 1) {
168 fprintf(stderr, "bad number\n");
169 return 1;
170 }
171 }
174 16, 11, 10, 16, 24, 40, 51, 61,
175 12, 12, 14, 19, 26, 58, 60, 55,
176 14, 13, 16, 24, 40, 57, 69, 56,
177 14, 17, 22, 29, 51, 87, 80, 62,
178 18, 22, 37, 56, 68, 109, 103, 77,
179 24, 35, 55, 64, 81, 104, 113, 92,
180 49, 64, 78, 87, 103, 121, 120, 101,
181 72, 92, 95, 98, 112, 100, 103, 99
182 };
183
184 for (
int i = 0; i <
N; i++) {
185 qTbl[i] /= q;
186 if (qTbl[i] == 0) qTbl[i] = 1;
187 }
188
189 try {
193 for (
int i = 0; i <
N; i++) {
194 src[i] = rand() % 2048;
195 }
196
198
200
202 quantize2(dest2, src, qTbl);
203 for (
int i = 0; i <
N; i++) {
204 if (dest[i] != dest2[i]) {
205 printf(
"err[%d] %d %d\n", i, dest[i], dest2[i]);
206 }
207 }
208
209 const int count = 10000000;
210 int begin;
211
212 begin = clock();
213 for (
int i = 0; i <
count; i++) {
215 }
216 printf(
"time=%.1fsec\n", (clock() - begin) /
double(CLOCKS_PER_SEC));
217
218 begin = clock();
219 for (
int i = 0; i <
count; i++) {
220 quantize2(dest, src, qTbl);
221 }
222 printf(
"time=%.1fsec\n", (clock() - begin) /
double(CLOCKS_PER_SEC));
223 } catch (std::exception& e) {
224 printf(
"ERR:%s\n", e.what());
225 } catch (...) {
226 printf(
"unknown error\n");
227 }
228}
LOGGING_API void printf(Category category, const char *format,...)
void quantize(uint32 dest[64], const uint32 src[64], const uint32 qTbl[64])