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 
     22    PacketVideo Corp.
     23    MP3 Decoder Library
     24 
     25    Filename: pvmp3_polyphase_filter_window.cpp
     26 
     27      Date: 09/21/2007
     28 
     29 ------------------------------------------------------------------------------
     30  REVISION HISTORY
     31 
     32 
     33  Description:
     34 
     35 ------------------------------------------------------------------------------
     36  INPUT AND OUTPUT DEFINITIONS
     37 
     38 
     39 Input
     40     int32 *synth_buffer,    synthesis input buffer
     41     int16 *outPcm,          generated output ( 32 values)
     42     int32 numChannels       number of channels
     43  Returns
     44 
     45     int16 *outPcm
     46 
     47 ------------------------------------------------------------------------------
     48  FUNCTION DESCRIPTION
     49 
     50     apply polyphase filter window
     51     Input 32 subband samples
     52     Calculate 64 values
     53 ------------------------------------------------------------------------------
     54  REQUIREMENTS
     55 
     56 
     57 ------------------------------------------------------------------------------
     58  REFERENCES
     59 
     60  [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
     61      ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
     62 
     63 ------------------------------------------------------------------------------
     64  PSEUDO-CODE
     65 
     66 ------------------------------------------------------------------------------
     67 */
     68 
     69 #if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) )
     70 /*----------------------------------------------------------------------------
     71 ; INCLUDES
     72 ----------------------------------------------------------------------------*/
     73 
     74 #include "pvmp3_polyphase_filter_window.h"
     75 #include "pv_mp3dec_fxd_op.h"
     76 #include "pvmp3_dec_defs.h"
     77 #include "pvmp3_tables.h"
     78 
     79 /*----------------------------------------------------------------------------
     80 ; MACROS
     81 ; Define module1 specific macros here
     82 ----------------------------------------------------------------------------*/
     83 
     84 
     85 
     86 /*----------------------------------------------------------------------------
     87 ; DEFINES
     88 ; Include all pre-processor statements here. Include conditional
     89 ; compile variables also.
     90 ----------------------------------------------------------------------------*/
     91 
     92 /*----------------------------------------------------------------------------
     93 ; LOCAL FUNCTION DEFINITIONS
     94 ; Function Prototype declaration
     95 ----------------------------------------------------------------------------*/
     96 
     97 /*----------------------------------------------------------------------------
     98 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
     99 ; Variable declaration - defined here and used outside this module1
    100 ----------------------------------------------------------------------------*/
    101 /*----------------------------------------------------------------------------
    102 ; EXTERNAL FUNCTION REFERENCES
    103 ; Declare functions defined elsewhere and referenced in this module_x
    104 ----------------------------------------------------------------------------*/
    105 
    106 /*----------------------------------------------------------------------------
    107 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
    108 ; Declare variables used in this module_x but defined elsewhere
    109 ----------------------------------------------------------------------------*/
    110 
    111 /*----------------------------------------------------------------------------
    112 ; FUNCTION CODE
    113 ----------------------------------------------------------------------------*/
    114 
    115 void pvmp3_polyphase_filter_window(int32 *synth_buffer,
    116                                    int16 *outPcm,
    117                                    int32 numChannels)
    118 {
    119     int32 sum1;
    120     int32 sum2;
    121     const int32 *winPtr = pqmfSynthWin;
    122     int32 i;
    123 
    124 
    125     for (int16 j = 1; j < SUBBANDS_NUMBER / 2; j++)
    126     {
    127         sum1 = 0x00000020;
    128         sum2 = 0x00000020;
    129 
    130 
    131         for (i = (SUBBANDS_NUMBER >> 1);
    132                 i < HAN_SIZE + (SUBBANDS_NUMBER >> 1);
    133                 i += SUBBANDS_NUMBER << 4)
    134         {
    135             int32 *pt_1 = &synth_buffer[ i+j];
    136             int32 *pt_2 = &synth_buffer[ i-j];
    137             int32 temp1 = pt_1[ 0];
    138             int32 temp3 = pt_2[ SUBBANDS_NUMBER*15 ];
    139             int32 temp2 = pt_2[ SUBBANDS_NUMBER* 1 ];
    140             int32 temp4 = pt_1[ SUBBANDS_NUMBER*14 ];
    141 
    142             sum1  = fxp_mac32_Q32(sum1, temp1,  winPtr[ 0]);
    143             sum2  = fxp_mac32_Q32(sum2, temp3,  winPtr[ 0]);
    144             sum2  = fxp_mac32_Q32(sum2, temp1,  winPtr[ 1]);
    145             sum1  = fxp_msb32_Q32(sum1, temp3,  winPtr[ 1]);
    146             sum1  = fxp_mac32_Q32(sum1, temp2,  winPtr[ 2]);
    147             sum2  = fxp_msb32_Q32(sum2, temp4,  winPtr[ 2]);
    148             sum2  = fxp_mac32_Q32(sum2, temp2,  winPtr[ 3]);
    149             sum1  = fxp_mac32_Q32(sum1, temp4,  winPtr[ 3]);
    150 
    151             temp1 = pt_1[ SUBBANDS_NUMBER* 2];
    152             temp3 = pt_2[ SUBBANDS_NUMBER*13];
    153             temp2 = pt_2[ SUBBANDS_NUMBER* 3];
    154             temp4 = pt_1[ SUBBANDS_NUMBER*12];
    155 
    156             sum1  = fxp_mac32_Q32(sum1, temp1,  winPtr[ 4]);
    157             sum2  = fxp_mac32_Q32(sum2, temp3,  winPtr[ 4]);
    158             sum2  = fxp_mac32_Q32(sum2, temp1,  winPtr[ 5]);
    159             sum1  = fxp_msb32_Q32(sum1, temp3,  winPtr[ 5]);
    160             sum1  = fxp_mac32_Q32(sum1, temp2,  winPtr[ 6]);
    161             sum2  = fxp_msb32_Q32(sum2, temp4,  winPtr[ 6]);
    162             sum2  = fxp_mac32_Q32(sum2, temp2,  winPtr[ 7]);
    163             sum1  = fxp_mac32_Q32(sum1, temp4,  winPtr[ 7]);
    164 
    165             temp1 = pt_1[ SUBBANDS_NUMBER* 4 ];
    166             temp3 = pt_2[ SUBBANDS_NUMBER*11 ];
    167             temp2 = pt_2[ SUBBANDS_NUMBER* 5 ];
    168             temp4 = pt_1[ SUBBANDS_NUMBER*10 ];
    169 
    170             sum1  = fxp_mac32_Q32(sum1, temp1,  winPtr[ 8]);
    171             sum2  = fxp_mac32_Q32(sum2, temp3,  winPtr[ 8]);
    172             sum2  = fxp_mac32_Q32(sum2, temp1,  winPtr[ 9]);
    173             sum1  = fxp_msb32_Q32(sum1, temp3,  winPtr[ 9]);
    174             sum1  = fxp_mac32_Q32(sum1, temp2,  winPtr[10]);
    175             sum2  = fxp_msb32_Q32(sum2, temp4,  winPtr[10]);
    176             sum2  = fxp_mac32_Q32(sum2, temp2,  winPtr[11]);
    177             sum1  = fxp_mac32_Q32(sum1, temp4,  winPtr[11]);
    178 
    179             temp1 = pt_1[ SUBBANDS_NUMBER*6 ];
    180             temp3 = pt_2[ SUBBANDS_NUMBER*9 ];
    181             temp2 = pt_2[ SUBBANDS_NUMBER*7 ];
    182             temp4 = pt_1[ SUBBANDS_NUMBER*8 ];
    183 
    184             sum1  = fxp_mac32_Q32(sum1, temp1,  winPtr[12]);
    185             sum2  = fxp_mac32_Q32(sum2, temp3,  winPtr[12]);
    186             sum2  = fxp_mac32_Q32(sum2, temp1,  winPtr[13]);
    187             sum1  = fxp_msb32_Q32(sum1, temp3,  winPtr[13]);
    188             sum1  = fxp_mac32_Q32(sum1, temp2,  winPtr[14]);
    189             sum2  = fxp_msb32_Q32(sum2, temp4,  winPtr[14]);
    190             sum2  = fxp_mac32_Q32(sum2, temp2,  winPtr[15]);
    191             sum1  = fxp_mac32_Q32(sum1, temp4,  winPtr[15]);
    192 
    193             winPtr += 16;
    194         }
    195 
    196 
    197 
    198         int32 k = j << (numChannels - 1);
    199         outPcm[k] = saturate16(sum1 >> 6);
    200         outPcm[(numChannels<<5) - k] = saturate16(sum2 >> 6);
    201     }
    202 
    203 
    204 
    205     sum1 = 0x00000020;
    206     sum2 = 0x00000020;
    207 
    208 
    209     for (i = 16; i < HAN_SIZE + 16; i += (SUBBANDS_NUMBER << 2))
    210     {
    211         int32 *pt_synth = &synth_buffer[i];
    212         int32 temp1 = pt_synth[ 0                ];
    213         int32 temp2 = pt_synth[ SUBBANDS_NUMBER  ];
    214         int32 temp3 = pt_synth[ SUBBANDS_NUMBER/2];
    215 
    216         sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[0]) ;
    217         sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[1]) ;
    218         sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[2]) ;
    219 
    220         temp1 = pt_synth[ SUBBANDS_NUMBER<<1 ];
    221         temp2 = pt_synth[ 3*SUBBANDS_NUMBER  ];
    222         temp3 = pt_synth[ SUBBANDS_NUMBER*5/2];
    223 
    224         sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[3]) ;
    225         sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[4]) ;
    226         sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[5]) ;
    227 
    228         winPtr += 6;
    229     }
    230 
    231 
    232     outPcm[0] = saturate16(sum1 >> 6);
    233     outPcm[(SUBBANDS_NUMBER/2)<<(numChannels-1)] = saturate16(sum2 >> 6);
    234 
    235 
    236 }
    237 
    238 #endif // If not assembly
    239 
    240