Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void idct(complex* v, int n) {
- float k = PI / (2 * n);
- complex* new = (complex*)malloc(sizeof(complex) * n);
- complex * scratch = (complex*)malloc(sizeof(complex) * n);
- complex aux;
- new[0].Re = v[0].Re / (n * 2);
- for (int i = 1; i < n; i++) {
- aux.Im = sin(i * k);
- aux.Re = cos(i * k);
- new[i].Re = (v[n-i].Re * aux.Im + v[i].Re * aux.Re) / (n * 2);
- new[i].Im = (aux.Im * v[i].Re - v[n-i].Re * aux.Re) / (n * 2);
- }
- fft(new, n, scratch);
- for (int i = 0; i < n / 2; i++) {
- v[2 * i].Re = new[i].Re;
- v[2 * i + 1].Re = new[n - 1 - i].Re;
- }
- for (int i = 1; i < n-1; i+=2) {
- aux = v[i];
- v[i] = v[i + 1];
- v[i + 1] = aux;
- }
- free(scratch);
- free(new);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement