void rmlt_coefs_to_samples(float coefs[], float old_samples[], float out_samples[], int dct_length) { int i; int half_dct_length; int last; float new_samples[MAX_DCT_LENGTH]; const float *win; float sum; half_dct_length = dct_length >> 1; /* Perform a Type IV (inverse) DCT on the coefficients */ dct_type_iv(coefs, new_samples, dct_length); win = (dct_length == DCT_LENGTH) ? rmlt_to_samples_window : max_rmlt_to_samples_window; last = half_dct_length - 1; for (i = 0; i < half_dct_length; i++) { /* Get the first half of the windowed samples */ sum = win[i]*new_samples[last - i]; sum += win[dct_length - i - 1]*old_samples[i]; out_samples[i] = sum; /* Get the second half of the windowed samples */ sum = win[half_dct_length + i]*new_samples[i]; sum -= win[last - i]*old_samples[last - i]; out_samples[half_dct_length + i] = sum; } /* Save the second half of the new samples for next time, when they will be the old samples. */ vec_copyf(old_samples, &new_samples[half_dct_length], half_dct_length); }
void samples_to_rmlt_coefs(const float new_samples[], float old_samples[], float coefs[], int dct_length) { int i; int half_dct_length; int last; float sum; float windowed_data[MAX_DCT_LENGTH]; const float *win; half_dct_length = dct_length >> 1; win = (dct_length == DCT_LENGTH) ? samples_to_rmlt_window : max_samples_to_rmlt_window; /* Get the first half of the windowed samples. */ last = half_dct_length - 1; for (i = 0; i < half_dct_length; i++) { sum = win[last - i]*old_samples[last - i]; sum += win[half_dct_length + i]*old_samples[half_dct_length + i]; windowed_data[i] = sum; } /* Get the second half of the windowed samples. */ last = dct_length - 1; for (i = 0; i < half_dct_length; i++) { sum = win[last - i]*new_samples[i]; sum -= win[i]*new_samples[last - i]; windowed_data[half_dct_length + i] = sum; } /* Save the new samples for next time, when they will be the old samples. */ vec_copyf(old_samples, new_samples, dct_length); /* Perform a Type IV DCT on the windowed data to get the coefficients. */ dct_type_iv(windowed_data, coefs, dct_length); }