+ memcpy( saved, buf + 512, 512 * sizeof(float));
+ }
+}
+
+static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce)
+{
+ IndividualChannelStream *ics = &sce->ics;
+ float *in = sce->coeffs;
+ float *out = sce->ret;
+ float *saved = sce->saved;
+ float *buf = ac->buf_mdct;
+
+ // imdct
+ ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
+
+ // window overlapping
+ if (ics->use_kb_window[1]) {
+ // AAC LD uses a low overlap sine window instead of a KBD window
+ memcpy(out, saved, 192 * sizeof(float));
+ ac->fdsp.vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128, 64);
+ memcpy( out + 320, buf + 64, 192 * sizeof(float));
+ } else {
+ ac->fdsp.vector_fmul_window(out, saved, buf, ff_sine_512, 256);
+ }
+
+ // buffer update
+ memcpy(saved, buf + 256, 256 * sizeof(float));
+}
+
+static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce)
+{
+ float *in = sce->coeffs;
+ float *out = sce->ret;
+ float *saved = sce->saved;
+ float *buf = ac->buf_mdct;
+ int i;
+ const int n = ac->oc[1].m4ac.frame_length_short ? 480 : 512;
+ const int n2 = n >> 1;
+ const int n4 = n >> 2;
+ const float *const window = n == 480 ? ff_aac_eld_window_480 :
+ ff_aac_eld_window_512;
+
+ // Inverse transform, mapped to the conventional IMDCT by
+ // Chivukula, R.K.; Reznik, Y.A.; Devarajan, V.,
+ // "Efficient algorithms for MPEG-4 AAC-ELD, AAC-LD and AAC-LC filterbanks,"
+ // Audio, Language and Image Processing, 2008. ICALIP 2008. International Conference on
+ // URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4590245&isnumber=4589950
+ for (i = 0; i < n2; i+=2) {
+ float temp;
+ temp = in[i ]; in[i ] = -in[n - 1 - i]; in[n - 1 - i] = temp;
+ temp = -in[i + 1]; in[i + 1] = in[n - 2 - i]; in[n - 2 - i] = temp;
+ }
+ if (n == 480)
+ ac->mdct480->imdct_half(ac->mdct480, buf, in, 1, -1.f/(16*1024*960));
+ else
+ ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
+ for (i = 0; i < n; i+=2) {
+ buf[i] = -buf[i];
+ }
+ // Like with the regular IMDCT at this point we still have the middle half
+ // of a transform but with even symmetry on the left and odd symmetry on
+ // the right
+
+ // window overlapping
+ // The spec says to use samples [0..511] but the reference decoder uses
+ // samples [128..639].
+ for (i = n4; i < n2; i ++) {
+ out[i - n4] = buf[n2 - 1 - i] * window[i - n4] +
+ saved[ i + n2] * window[i + n - n4] +
+ -saved[ n + n2 - 1 - i] * window[i + 2*n - n4] +
+ -saved[2*n + n2 + i] * window[i + 3*n - n4];
+ }
+ for (i = 0; i < n2; i ++) {
+ out[n4 + i] = buf[i] * window[i + n2 - n4] +
+ -saved[ n - 1 - i] * window[i + n2 + n - n4] +
+ -saved[ n + i] * window[i + n2 + 2*n - n4] +
+ saved[2*n + n - 1 - i] * window[i + n2 + 3*n - n4];
+ }
+ for (i = 0; i < n4; i ++) {
+ out[n2 + n4 + i] = buf[ i + n2] * window[i + n - n4] +
+ -saved[ n2 - 1 - i] * window[i + 2*n - n4] +
+ -saved[ n + n2 + i] * window[i + 3*n - n4];