Home | History | Annotate | Download | only in src
      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 
     21    PacketVideo Corp.
     22    MP3 Decoder Library
     23 
     24    Filename: pvmp3_dct6.cpp
     25 
     26      Date: 09/21/2007
     27 
     28 ------------------------------------------------------------------------------
     29  REVISION HISTORY
     30 
     31 
     32  Description:
     33 
     34 ------------------------------------------------------------------------------
     35  INPUT AND OUTPUT DEFINITIONS
     36 
     37 Input
     38     Int32  vec[]             vector of 6  32-bit integers
     39 Returns
     40     Int32  vec[]             dct computation in-place
     41 
     42 
     43 ------------------------------------------------------------------------------
     44  FUNCTION DESCRIPTION
     45 
     46     Returns the dct of length 6 of the input vector
     47 
     48 ------------------------------------------------------------------------------
     49  REQUIREMENTS
     50 
     51 
     52 ------------------------------------------------------------------------------
     53  REFERENCES
     54 
     55 ------------------------------------------------------------------------------
     56  PSEUDO-CODE
     57 
     58 ------------------------------------------------------------------------------
     59 */
     60 
     61 
     62 /*----------------------------------------------------------------------------
     63 ; INCLUDES
     64 ----------------------------------------------------------------------------*/
     65 
     66 #include "pvmp3_audio_type_defs.h"
     67 #include "pv_mp3dec_fxd_op.h"
     68 #include "pvmp3_mdct_6.h"
     69 
     70 
     71 /*----------------------------------------------------------------------------
     72 ; MACROS
     73 ; Define module specific macros here
     74 ----------------------------------------------------------------------------*/
     75 
     76 
     77 /*----------------------------------------------------------------------------
     78 ; DEFINES
     79 ; Include all pre-processor statements here. Include conditional
     80 ; compile variables also.
     81 ----------------------------------------------------------------------------*/
     82 #define Qfmt30(a)   (Int32)(a*((Int32)1<<30) + (a>=0?0.5F:-0.5F))
     83 
     84 #define cos_pi_6     Qfmt30(  0.86602540378444f)
     85 #define cos_2_pi_6   Qfmt30(  0.5f)
     86 #define cos_7_pi_12  Qfmt30( -0.25881904510252f)
     87 #define cos_3_pi_12  Qfmt30(  0.70710678118655f)
     88 #define cos_11_pi_12 Qfmt30( -0.96592582628907f)
     89 
     90 /*----------------------------------------------------------------------------
     91 ; LOCAL FUNCTION DEFINITIONS
     92 ; Function Prototype declaration
     93 ----------------------------------------------------------------------------*/
     94 
     95 /*----------------------------------------------------------------------------
     96 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
     97 ; Variable declaration - defined here and used outside this module
     98 ----------------------------------------------------------------------------*/
     99 
    100 /*----------------------------------------------------------------------------
    101 ; EXTERNAL FUNCTION REFERENCES
    102 ; Declare functions defined elsewhere and referenced in this module
    103 ----------------------------------------------------------------------------*/
    104 
    105 /*----------------------------------------------------------------------------
    106 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
    107 ; Declare variables used in this module but defined elsewhere
    108 ----------------------------------------------------------------------------*/
    109 
    110 /*----------------------------------------------------------------------------
    111 ; FUNCTION CODE
    112 ----------------------------------------------------------------------------*/
    113 
    114 void pvmp3_dct_6(int32 vec[])
    115 {
    116 
    117     Int32 tmp0;
    118     Int32 tmp1;
    119     Int32 tmp2;
    120     Int32 tmp3;
    121     Int32 tmp4;
    122     Int32 tmp5;
    123 
    124 
    125     /*  split input vector */
    126 
    127     tmp0 =  vec[5] + vec[0];
    128     tmp5 =  vec[5] - vec[0];
    129     tmp1 =  vec[4] + vec[1];
    130     tmp4 =  vec[4] - vec[1];
    131     tmp2 =  vec[3] + vec[2];
    132     tmp3 =  vec[3] - vec[2];
    133 
    134     vec[0]  = tmp0 + tmp2 ;
    135     vec[2]  = fxp_mul32_Q30(tmp0 - tmp2,   cos_pi_6);
    136     vec[4]  = (vec[0] >> 1) - tmp1;
    137     vec[0] += tmp1;
    138 
    139     tmp0    =  fxp_mul32_Q30(tmp3,  cos_7_pi_12);
    140     tmp0    =  fxp_mac32_Q30(tmp4,  -cos_3_pi_12, tmp0);
    141     vec[1]  =  fxp_mac32_Q30(tmp5,  cos_11_pi_12, tmp0);
    142 
    143     vec[3]  =  fxp_mul32_Q30((tmp3 + tmp4  - tmp5), cos_3_pi_12);
    144     tmp0    =  fxp_mul32_Q30(tmp3, cos_11_pi_12);
    145     tmp0    =  fxp_mac32_Q30(tmp4,  cos_3_pi_12, tmp0);
    146     vec[5]  =  fxp_mac32_Q30(tmp5,  cos_7_pi_12, tmp0);
    147 
    148 }
    149 
    150 
    151 
    152 
    153