Home | History | Annotate | Download | only in decoder
      1 /******************************************************************************
      2  *                                                                            *
      3  * Copyright (C) 2018 The Android Open Source Project
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at:
      8  *
      9  * http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  *
     17  *****************************************************************************
     18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
     19 */
     20 #include <string.h>
     21 #include <ixheaacd_type_def.h>
     22 
     23 #include "ixheaacd_constants.h"
     24 
     25 #include <ixheaacd_basic_ops32.h>
     26 #include "ixheaacd_windows.h"
     27 
     28 static PLATFORM_INLINE WORD32 ixheaacd_mult32_sh1(WORD32 a, WORD32 b) {
     29   WORD32 result;
     30   WORD64 temp_result;
     31 
     32   temp_result = (WORD64)a * (WORD64)b;
     33   result = (WORD32)(temp_result >> 31);
     34 
     35   return (result);
     36 }
     37 
     38 VOID ixheaacd_memset(FLOAT32 *x, WORD32 n) {
     39   memset(x, 0, n * sizeof(FLOAT32));
     40   return;
     41 }
     42 
     43 VOID ixheaacd_mem_cpy(const FLOAT32 x[], FLOAT32 y[], WORD32 n) {
     44   memcpy(y, x, n * sizeof(FLOAT32));
     45   return;
     46 }
     47 
     48 VOID ixheaacd_vec_cnst_mul(FLOAT32 a, FLOAT32 x[], FLOAT32 z[], WORD32 n) {
     49   WORD32 i;
     50   for (i = 0; i < n; i++) {
     51     z[i] = (FLOAT32)a * x[i];
     52   }
     53   return;
     54 }
     55 
     56 VOID ixheaacd_combine_fac(WORD32 *src1, WORD32 *src2, WORD32 *dest, WORD32 len,
     57                           WORD8 output_q, WORD8 fac_q) {
     58   WORD32 i;
     59   if (fac_q > output_q) {
     60     for (i = 0; i < len; i++) {
     61       *dest = ixheaacd_add32_sat(*src1, ((*src2) >> (fac_q - output_q)));
     62       dest++;
     63       src1++;
     64       src2++;
     65     }
     66   } else {
     67     for (i = 0; i < len; i++) {
     68       *dest = ixheaacd_add32_sat(*src1, ((*src2) << (output_q - fac_q)));
     69       dest++;
     70       src1++;
     71       src2++;
     72     }
     73   }
     74 }
     75 
     76 WORD8 ixheaacd_windowing_long1(WORD32 *src1, WORD32 *src2,
     77                                const WORD32 *win_fwd, const WORD32 *win_rev,
     78                                WORD32 *dest, WORD32 vlen, WORD8 shift1,
     79                                WORD8 shift2) {
     80   WORD32 i;
     81   WORD32 *rsrc2 = src2 + vlen - 1;
     82 
     83   if (shift1 > shift2) {
     84     for (i = 0; i < vlen / 2; i++) {
     85       *dest = ixheaacd_add32_sat(
     86           ((ixheaacd_mult32_sh1(*src1, *win_fwd)) >> (shift1 - shift2)),
     87           ixheaacd_mult32_sh1(*src2, *win_rev));
     88       *(dest + (vlen - (2 * i)) - 1) = ixheaacd_add32_sat(
     89           ((ixheaacd_mult32_sh1(-(*src1), *win_rev)) >> (shift1 - shift2)),
     90           ixheaacd_mult32_sh1(*rsrc2, *win_fwd));
     91 
     92       src1++;
     93       src2++;
     94       win_fwd++;
     95       win_rev--;
     96       rsrc2--;
     97       dest++;
     98     }
     99     return (shift2);
    100   } else {
    101     for (i = 0; i < vlen / 2; i++) {
    102       *dest = ixheaacd_add32_sat(
    103           ixheaacd_mult32_sh1(*src1, *win_fwd),
    104           ((ixheaacd_mult32_sh1(*src2, *win_rev)) >> (shift2 - shift1)));
    105 
    106       *(dest + (vlen - (2 * i)) - 1) = ixheaacd_add32_sat(
    107           ixheaacd_mult32_sh1(-(*src1), *win_rev),
    108           ((ixheaacd_mult32_sh1(*rsrc2, *win_fwd)) >> (shift2 - shift1)));
    109       src1++;
    110       src2++;
    111       win_fwd++;
    112       win_rev--;
    113       rsrc2--;
    114       dest++;
    115     }
    116     return (shift1);
    117   }
    118 }
    119 
    120 WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd,
    121                                WORD32 *fac_data_out, WORD32 *over_lap,
    122                                WORD32 *p_out_buffer,
    123                                offset_lengths *ixheaacd_drc_offset,
    124                                WORD8 shiftp, WORD8 shift_olap, WORD8 fac_q) {
    125   WORD32 i;
    126   WORD32 *dest = p_out_buffer;
    127 
    128   win_fwd += ixheaacd_drc_offset->lfac;
    129 
    130   if (shiftp > fac_q) {
    131     if (shift_olap > fac_q) {
    132       for (i = 0;
    133            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    134            i++) {
    135         dest[i] = over_lap[i] >> (shift_olap - fac_q);
    136       }
    137 
    138       for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    139            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls;
    140            i++) {
    141         dest[i] = ixheaacd_add32_sat(
    142             (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 +
    143                                        ixheaacd_drc_offset->n_flat_ls +
    144                                        ixheaacd_drc_offset->lfac - i - 1],
    145                                  *win_fwd) >>
    146              (shiftp - fac_q)),
    147             (*fac_data_out));
    148         win_fwd++;
    149         fac_data_out++;
    150       }
    151 
    152       for (;
    153            i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3);
    154            i++) {
    155         dest[i] =
    156             ixheaacd_add32_sat((-src1[ixheaacd_drc_offset->n_long / 2 +
    157                                       ixheaacd_drc_offset->n_flat_ls +
    158                                       ixheaacd_drc_offset->lfac - i - 1] >>
    159                                 (shiftp - fac_q)),
    160                                (*fac_data_out));
    161         fac_data_out++;
    162       }
    163 
    164       for (; i < ixheaacd_drc_offset->n_long; i++) {
    165         dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 +
    166                         ixheaacd_drc_offset->n_flat_ls +
    167                         ixheaacd_drc_offset->lfac - i - 1] >>
    168                   (shiftp - fac_q);
    169       }
    170       return (fac_q);
    171     } else {
    172       memcpy(dest, over_lap, sizeof(WORD32) * (ixheaacd_drc_offset->n_flat_ls +
    173                                                ixheaacd_drc_offset->lfac));
    174 
    175       for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    176            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls;
    177            i++) {
    178         dest[i] = ixheaacd_add32_sat(
    179             (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 +
    180                                        ixheaacd_drc_offset->n_flat_ls +
    181                                        ixheaacd_drc_offset->lfac - i - 1],
    182                                  *win_fwd) >>
    183              (shiftp - shift_olap)),
    184             (*fac_data_out) >> (fac_q - shift_olap));
    185         win_fwd++;
    186         fac_data_out++;
    187       }
    188 
    189       for (;
    190            i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3);
    191            i++) {
    192         dest[i] =
    193             ixheaacd_add32_sat((-src1[ixheaacd_drc_offset->n_long / 2 +
    194                                       ixheaacd_drc_offset->n_flat_ls +
    195                                       ixheaacd_drc_offset->lfac - i - 1] >>
    196                                 (shiftp - shift_olap)),
    197                                (*fac_data_out) >> (fac_q - shift_olap));
    198         fac_data_out++;
    199       }
    200 
    201       for (; i < ixheaacd_drc_offset->n_long; i++) {
    202         dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 +
    203                         ixheaacd_drc_offset->n_flat_ls +
    204                         ixheaacd_drc_offset->lfac - i - 1] >>
    205                   (shiftp - shift_olap);
    206       }
    207       return (shift_olap);
    208     }
    209   } else {
    210     if (shift_olap > shiftp) {
    211       for (i = 0;
    212            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    213            i++) {
    214         dest[i] = over_lap[i] >> (shift_olap - shiftp);
    215       }
    216 
    217       for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    218            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls;
    219            i++) {
    220         dest[i] = ixheaacd_add32_sat(
    221             ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 +
    222                                       ixheaacd_drc_offset->n_flat_ls +
    223                                       ixheaacd_drc_offset->lfac - i - 1],
    224                                 *win_fwd),
    225             (*fac_data_out) >> (fac_q - shiftp));
    226         win_fwd++;
    227         fac_data_out++;
    228       }
    229 
    230       for (;
    231            i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3);
    232            i++) {
    233         dest[i] = ixheaacd_add32_sat(-src1[ixheaacd_drc_offset->n_long / 2 +
    234                                            ixheaacd_drc_offset->n_flat_ls +
    235                                            ixheaacd_drc_offset->lfac - i - 1],
    236                                      (*fac_data_out) >> (fac_q - shiftp));
    237         fac_data_out++;
    238       }
    239 
    240       for (; i < ixheaacd_drc_offset->n_long; i++) {
    241         dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 +
    242                         ixheaacd_drc_offset->n_flat_ls +
    243                         ixheaacd_drc_offset->lfac - i - 1];
    244       }
    245       return (shiftp);
    246     } else {
    247       memcpy(dest, over_lap, sizeof(WORD32) * (ixheaacd_drc_offset->n_flat_ls +
    248                                                ixheaacd_drc_offset->lfac));
    249 
    250       for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    251            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls;
    252            i++) {
    253         dest[i] = ixheaacd_add32_sat(
    254             (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 +
    255                                        ixheaacd_drc_offset->n_flat_ls +
    256                                        ixheaacd_drc_offset->lfac - i - 1],
    257                                  *win_fwd) >>
    258              (shiftp - shift_olap)),
    259             (*fac_data_out) >> (fac_q - shift_olap));
    260         win_fwd++;
    261         fac_data_out++;
    262       }
    263 
    264       for (;
    265            i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3);
    266            i++) {
    267         dest[i] =
    268             ixheaacd_add32_sat((-src1[ixheaacd_drc_offset->n_long / 2 +
    269                                       ixheaacd_drc_offset->n_flat_ls +
    270                                       ixheaacd_drc_offset->lfac - i - 1] >>
    271                                 (shiftp - shift_olap)),
    272                                (*fac_data_out) >> (fac_q - shift_olap));
    273         fac_data_out++;
    274       }
    275 
    276       for (; i < ixheaacd_drc_offset->n_long; i++) {
    277         dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 +
    278                         ixheaacd_drc_offset->n_flat_ls +
    279                         ixheaacd_drc_offset->lfac - i - 1] >>
    280                   (shiftp - shift_olap);
    281       }
    282       return (shift_olap);
    283     }
    284   }
    285 }
    286 
    287 WORD8 ixheaacd_windowing_long3(WORD32 *src1, const WORD32 *win_fwd,
    288                                WORD32 *over_lap, WORD32 *p_out_buffer,
    289                                const WORD32 *win_rev,
    290                                offset_lengths *ixheaacd_drc_offset,
    291                                WORD8 shiftp, WORD8 shift_olap) {
    292   WORD32 i;
    293   WORD32 *dest = p_out_buffer;
    294 
    295   if (shiftp > shift_olap) {
    296     memcpy(dest, over_lap, sizeof(FLOAT32) * ixheaacd_drc_offset->n_flat_ls);
    297 
    298     for (i = ixheaacd_drc_offset->n_flat_ls;
    299          i < ixheaacd_drc_offset->n_long / 2; i++) {
    300       dest[i] = ixheaacd_add32_sat(
    301           (ixheaacd_mult32_sh1(src1[i], *win_fwd) >> (shiftp - shift_olap)),
    302           ixheaacd_mult32_sh1(over_lap[i], *win_rev));
    303       win_fwd++;
    304       win_rev--;
    305     }
    306 
    307     for (i = ixheaacd_drc_offset->n_long / 2;
    308          i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls;
    309          i++) {
    310       dest[i] = ixheaacd_add32_sat(
    311           (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long - i - 1],
    312                                *win_fwd) >>
    313            (shiftp - shift_olap)),
    314           ixheaacd_mult32_sh1(over_lap[i], *win_rev));
    315       win_fwd++;
    316       win_rev--;
    317     }
    318 
    319     for (; i < ixheaacd_drc_offset->n_long; i++) {
    320       dest[i] =
    321           -src1[ixheaacd_drc_offset->n_long - i - 1] >> (shiftp - shift_olap);
    322     }
    323 
    324     return (shift_olap);
    325   } else {
    326     for (i = 0; i < ixheaacd_drc_offset->n_flat_ls; i++) {
    327       dest[i] = over_lap[i] >> (shift_olap - shiftp);
    328     }
    329 
    330     for (i = ixheaacd_drc_offset->n_flat_ls;
    331          i < ixheaacd_drc_offset->n_long / 2; i++) {
    332       dest[i] = ixheaacd_add32_sat(
    333           ixheaacd_mult32_sh1(src1[i], *win_fwd),
    334           ixheaacd_mult32_sh1(over_lap[i], *win_rev) >> (shift_olap - shiftp));
    335       win_fwd++;
    336       win_rev--;
    337     }
    338 
    339     for (i = ixheaacd_drc_offset->n_long / 2;
    340          i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls;
    341          i++) {
    342       dest[i] = ixheaacd_add32_sat(
    343           ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long - i - 1],
    344                               *win_fwd),
    345           ixheaacd_mult32_sh1(over_lap[i], *win_rev) >> (shift_olap - shiftp));
    346       win_fwd++;
    347       win_rev--;
    348     }
    349 
    350     for (; i < ixheaacd_drc_offset->n_long; i++) {
    351       dest[i] = -src1[ixheaacd_drc_offset->n_long - i - 1];
    352     }
    353 
    354     return (shiftp);
    355   }
    356 }
    357 
    358 VOID ixheaacd_windowing_short1(WORD32 *src1, WORD32 *src2, WORD32 *fp,
    359                                offset_lengths *ixheaacd_drc_offset,
    360                                WORD8 shiftp, WORD8 shift_olap) {
    361   WORD32 i;
    362   WORD32 *dest = fp;
    363 
    364   if (shift_olap > shiftp) {
    365     if (ixheaacd_drc_offset->n_short > ixheaacd_drc_offset->lfac) {
    366       for (i = 0; i < ixheaacd_drc_offset->lfac; i++) {
    367         dest[i] = dest[i] >> (shift_olap - shiftp);
    368       }
    369       for (i = ixheaacd_drc_offset->lfac; i < ixheaacd_drc_offset->n_short;
    370            i++) {
    371         dest[i] = ixheaacd_mult32_sh1(
    372             -src1[ixheaacd_drc_offset->n_short - i - 1], src2[i]);
    373       }
    374 
    375       for (; i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    376            i++) {
    377         dest[i] = 0;
    378       }
    379     } else {
    380       for (i = 0; i < ixheaacd_drc_offset->lfac; i++) {
    381         dest[i] = dest[i] >> (shift_olap - shiftp);
    382       }
    383       for (i = ixheaacd_drc_offset->lfac;
    384            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    385            i++) {
    386         dest[i] = 0;
    387       }
    388     }
    389   } else {
    390     if (ixheaacd_drc_offset->n_short > ixheaacd_drc_offset->lfac) {
    391       for (i = ixheaacd_drc_offset->lfac; i < ixheaacd_drc_offset->n_short;
    392            i++) {
    393         dest[i] = ixheaacd_mult32_sh1(
    394                       -src1[ixheaacd_drc_offset->n_short - i - 1], src2[i]) >>
    395                   (shiftp - shift_olap);
    396       }
    397 
    398       for (; i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    399            i++) {
    400         dest[i] = 0;
    401       }
    402     } else {
    403       for (i = ixheaacd_drc_offset->lfac;
    404            i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac;
    405            i++) {
    406         dest[i] = 0;
    407       }
    408     }
    409   }
    410 }
    411 
    412 VOID ixheaacd_windowing_short2(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp,
    413                                offset_lengths *ixheaacd_drc_offset,
    414                                WORD8 shiftp, WORD8 shift_olap) {
    415   WORD32 i;
    416 
    417   WORD32 *win_rev = win_fwd + ixheaacd_drc_offset->n_short - 1;
    418 
    419   if (shift_olap > shiftp) {
    420     for (i = 0; i < ixheaacd_drc_offset->n_short / 2; i++) {
    421       fp[i] = ixheaacd_add32_sat(
    422           ixheaacd_mult32_sh1(src1[i], *win_fwd),
    423           (ixheaacd_mult32_sh1(fp[i], *win_rev) >> (shift_olap - shiftp)));
    424 
    425       fp[ixheaacd_drc_offset->n_short - i - 1] = ixheaacd_add32_sat(
    426           ixheaacd_mult32_sh1(-src1[i], *win_rev),
    427           (ixheaacd_mult32_sh1(fp[ixheaacd_drc_offset->n_short - i - 1],
    428                                *win_fwd) >>
    429            (shift_olap - shiftp)));
    430       win_fwd++;
    431       win_rev--;
    432     }
    433 
    434     for (i = ixheaacd_drc_offset->n_short;
    435          i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_short;
    436          i++) {
    437       fp[i] = 0;
    438     }
    439   } else {
    440     for (i = 0; i < ixheaacd_drc_offset->n_short / 2; i++) {
    441       fp[i] = ixheaacd_add32_sat(
    442           (ixheaacd_mult32_sh1(src1[i], *win_fwd) >> (shiftp - shift_olap)),
    443           ixheaacd_mult32_sh1(fp[i], *win_rev));
    444 
    445       fp[ixheaacd_drc_offset->n_short - i - 1] = ixheaacd_add32_sat(
    446           (ixheaacd_mult32_sh1(-src1[i], *win_rev) >> (shiftp - shift_olap)),
    447           ixheaacd_mult32_sh1(fp[ixheaacd_drc_offset->n_short - i - 1],
    448                               *win_fwd));
    449 
    450       win_fwd++;
    451       win_rev--;
    452     }
    453 
    454     for (i = ixheaacd_drc_offset->n_short;
    455          i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_short;
    456          i++) {
    457       fp[i] = 0;
    458     }
    459   }
    460 }
    461 
    462 WORD8 ixheaacd_windowing_short3(WORD32 *src1, WORD32 *win_rev, WORD32 *fp,
    463                                 WORD32 n_short, WORD8 shiftp,
    464                                 WORD8 shift_olap) {
    465   WORD32 i;
    466   const WORD32 *win_fwd = win_rev - n_short + 1;
    467   if (shift_olap > shiftp) {
    468     for (i = 0; i < n_short / 2; i++) {
    469       fp[i] = ixheaacd_add32_sat(
    470           ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_rev),
    471           (fp[i] >> (shift_olap - shiftp)));
    472 
    473       fp[n_short - i - 1] = ixheaacd_add32_sat(
    474           ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_fwd),
    475           (fp[n_short - i - 1] >> (shift_olap - shiftp)));
    476       win_rev--;
    477       win_fwd++;
    478     }
    479     return (shiftp);
    480   } else {
    481     for (i = 0; i < n_short / 2; i++) {
    482       fp[i] = ixheaacd_add32_sat(
    483           (ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_rev) >>
    484            (shiftp - shift_olap)),
    485           fp[i]);
    486 
    487       fp[n_short - i - 1] = ixheaacd_add32_sat(
    488           (ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_fwd) >>
    489            (shiftp - shift_olap)),
    490           fp[n_short - i - 1]);
    491 
    492       win_rev--;
    493       win_fwd++;
    494     }
    495     return (shift_olap);
    496   }
    497 }
    498 
    499 WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp,
    500                                 WORD32 *win_fwd1, WORD32 n_short, WORD32 flag,
    501                                 WORD8 shiftp, WORD8 shift_olap,
    502                                 WORD8 output_q) {
    503   WORD32 i;
    504   const WORD32 *win_rev = win_fwd + n_short - 1;
    505   const WORD32 *win_rev1 = win_fwd1 - n_short + 1;
    506   if (shift_olap > output_q) {
    507     for (i = 0; i < n_short / 2; i++) {
    508       fp[i] = ixheaacd_add32_sat(
    509           ixheaacd_mult32_sh1(src1[n_short / 2 + i], *win_fwd) >>
    510               (shiftp - output_q),
    511           fp[i]);
    512 
    513       fp[n_short - i - 1] = ixheaacd_add32_sat(
    514           ixheaacd_mult32_sh1(-src1[n_short / 2 + i], *win_rev) >>
    515               (shiftp - output_q),
    516           fp[n_short - i - 1]);
    517 
    518       win_fwd++;
    519       win_rev--;
    520     }
    521     if (flag == 1) {
    522       for (; i < n_short; i++) {
    523         fp[i + n_short / 2] = ixheaacd_add32_sat(
    524             ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_fwd1) >>
    525                 (shiftp - output_q),
    526             (fp[i + n_short / 2] >> (shift_olap - output_q)));
    527 
    528         fp[3 * n_short - n_short / 2 - i - 1] = ixheaacd_add32_sat(
    529             ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_rev1) >>
    530                 (shiftp - output_q),
    531             (fp[3 * n_short - n_short / 2 - i - 1] >> (shift_olap - output_q)));
    532 
    533         win_fwd1--;
    534         win_rev1++;
    535       }
    536     } else {
    537       for (; i < n_short; i++) {
    538         fp[i + n_short / 2] =
    539             ixheaacd_add32_sat(-src1[n_short - i - 1] >> (shiftp - output_q),
    540                                fp[i + n_short / 2] >> (shift_olap - output_q));
    541         fp[3 * n_short - n_short / 2 - i - 1] = ixheaacd_add32_sat(
    542             -src1[n_short - i - 1] >> (shiftp - output_q),
    543             fp[3 * n_short - n_short / 2 - i - 1] >> (shift_olap - output_q));
    544       }
    545     }
    546     return (output_q);
    547   } else {
    548     for (i = 0; i < n_short / 2; i++) {
    549       fp[i] = ixheaacd_add32_sat(
    550           ixheaacd_mult32_sh1(src1[n_short / 2 + i], *win_fwd) >>
    551               (shiftp - shift_olap),
    552           fp[i] >> (output_q - shift_olap));
    553 
    554       fp[n_short - i - 1] = ixheaacd_add32_sat(
    555           ixheaacd_mult32_sh1(-src1[n_short / 2 + i], *win_rev) >>
    556               (shiftp - shift_olap),
    557           fp[n_short - i - 1]);
    558 
    559       win_fwd++;
    560       win_rev--;
    561     }
    562     if (flag == 1) {
    563       for (; i < n_short; i++) {
    564         fp[i + n_short / 2] = ixheaacd_add32_sat(
    565             ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_fwd1) >>
    566                 (shiftp - shift_olap),
    567             fp[i + n_short / 2]);
    568 
    569         fp[3 * n_short - n_short / 2 - i - 1] = ixheaacd_add32_sat(
    570             ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_rev1) >>
    571                 (shiftp - shift_olap),
    572             fp[3 * n_short - n_short / 2 - i - 1]);
    573 
    574         win_fwd1--;
    575         win_rev1++;
    576       }
    577     } else {
    578       for (; i < n_short; i++) {
    579         fp[i + n_short / 2] =
    580             ixheaacd_add32_sat(-src1[n_short - i - 1] >> (shiftp - shift_olap),
    581                                fp[i + n_short / 2]);
    582         fp[3 * n_short - n_short / 2 - i - 1] =
    583             ixheaacd_add32_sat(-src1[n_short - i - 1] >> (shiftp - shift_olap),
    584                                fp[3 * n_short - n_short / 2 - i - 1]);
    585       }
    586     }
    587     return (shift_olap);
    588   }
    589 }
    590 
    591 VOID ixheaacd_scale_down(WORD32 *dest, WORD32 *src, WORD32 len, WORD8 shift1,
    592                          WORD8 shift2) {
    593   WORD32 i;
    594   if (shift1 > shift2) {
    595     for (i = 0; i < len; i++) {
    596       *dest = *src >> (shift1 - shift2);
    597       src++;
    598       dest++;
    599     }
    600   } else {
    601     for (i = 0; i < len; i++) {
    602       *dest = *src << (shift2 - shift1);
    603       src++;
    604       dest++;
    605     }
    606   }
    607 }
    608