Home | History | Annotate | Download | only in aacdec
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /*
     19 
     20  Filename: dst16.c
     21 
     22 ------------------------------------------------------------------------------
     23  REVISION HISTORY
     24 
     25 
     26  Who:                                   Date: MM/DD/YYYY
     27  Description:
     28 
     29 ------------------------------------------------------------------------------
     30  INPUT AND OUTPUT DEFINITIONS
     31 
     32     Int32 x             32-bit integer input length 16
     33 
     34 
     35 ------------------------------------------------------------------------------
     36  FUNCTION DESCRIPTION
     37 
     38     Implement discrete sine transform of lenght 16
     39 
     40 ------------------------------------------------------------------------------
     41  REQUIREMENTS
     42 
     43 
     44 ------------------------------------------------------------------------------
     45  REFERENCES
     46 
     47 ------------------------------------------------------------------------------
     48  PSEUDO-CODE
     49 
     50 ------------------------------------------------------------------------------
     51 */
     52 
     53 
     54 /*----------------------------------------------------------------------------
     55 ; INCLUDES
     56 ----------------------------------------------------------------------------*/
     57 
     58 #ifdef AAC_PLUS
     59 
     60 #include "dst16.h"
     61 #include "dst8.h"
     62 #include "fxp_mul32.h"
     63 
     64 /*----------------------------------------------------------------------------
     65 ; MACROS
     66 ; Define module specific macros here
     67 ----------------------------------------------------------------------------*/
     68 
     69 
     70 /*----------------------------------------------------------------------------
     71 ; DEFINES
     72 ; Include all pre-processor statements here. Include conditional
     73 ; compile variables also.
     74 ----------------------------------------------------------------------------*/
     75 
     76 
     77 #define R_SHIFT     28
     78 #define Qfmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
     79 
     80 const Int32 CosTable_8[8] =
     81 {
     82     Qfmt(0.50241928618816F),   Qfmt(0.52249861493969F),
     83     Qfmt(0.56694403481636F),   Qfmt(0.64682178335999F),
     84     Qfmt(0.78815462345125F),   Qfmt(1.06067768599035F),
     85     Qfmt(1.72244709823833F),   Qfmt(5.10114861868916F)
     86 };
     87 
     88 /*----------------------------------------------------------------------------
     89 ; LOCAL FUNCTION DEFINITIONS
     90 ; Function Prototype declaration
     91 ----------------------------------------------------------------------------*/
     92 
     93 /*----------------------------------------------------------------------------
     94 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
     95 ; Variable declaration - defined here and used outside this module
     96 ----------------------------------------------------------------------------*/
     97 
     98 /*----------------------------------------------------------------------------
     99 ; EXTERNAL FUNCTION REFERENCES
    100 ; Declare functions defined elsewhere and referenced in this module
    101 ----------------------------------------------------------------------------*/
    102 
    103 /*----------------------------------------------------------------------------
    104 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
    105 ; Declare variables used in this module but defined elsewhere
    106 ----------------------------------------------------------------------------*/
    107 
    108 /*----------------------------------------------------------------------------
    109 ; FUNCTION CODE
    110 ----------------------------------------------------------------------------*/
    111 
    112 
    113 void dst_16(Int32 vec[], Int32 scratch_mem[])     /* scratch_mem size 8 */
    114 {
    115     Int32 *temp_even = scratch_mem;
    116 
    117     Int i;
    118     const Int32 *pt_cos = &CosTable_8[7];
    119     Int32 tmp0 = vec[15] >> 1;
    120     Int32 tmp1, tmp2;
    121     Int32 *pt_even = temp_even;
    122     Int32 *pt_odd  = vec;
    123     Int32 *pt_vec  = vec;
    124     Int32 *pt_vecN_1;
    125     Int32 tmp3;
    126 
    127 
    128     *(pt_even++) = *(pt_vec++);
    129     tmp1         = *(pt_vec++);
    130     *(pt_odd++) = tmp1;
    131 
    132     for (i = 3; i != 0; i--)
    133     {
    134         *(pt_even++) = *(pt_vec++);
    135         tmp2         = *(pt_vec++);
    136         *(pt_even++) = *(pt_vec++);
    137         tmp3         = *(pt_vec++);
    138         *(pt_odd++) = tmp2 + tmp1;
    139         *(pt_odd++) = tmp3 + tmp2;
    140         tmp1         = tmp3;
    141 
    142     }
    143 
    144     *(pt_even)   = *(pt_vec++);
    145     *(pt_odd++) = *(pt_vec) + tmp1;
    146 
    147 
    148     dst_8(temp_even);
    149     dst_8(vec);
    150 
    151     pt_vec  = &vec[7];
    152 
    153     pt_even = &temp_even[7];
    154     pt_vecN_1  = &vec[8];
    155 
    156     tmp1 = *(pt_even--);
    157 
    158     for (i = 4; i != 0; i--)
    159     {
    160         tmp3  = fxp_mul32_Q28((*(pt_vec) - tmp0), *(pt_cos--));
    161         tmp2 = *(pt_even--);
    162         *(pt_vec--)     = tmp3 + tmp1;
    163         *(pt_vecN_1++)  = tmp3 - tmp1;
    164         tmp3  = fxp_mul32_Q28((*(pt_vec) + tmp0), *(pt_cos--));
    165         tmp1 = *(pt_even--);
    166         *(pt_vecN_1++)  = tmp3 - tmp2;
    167         *(pt_vec--)     = tmp3 + tmp2;
    168     }
    169 
    170 }
    171 
    172 #endif
    173