• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_poly_phase_synthesis.cpp
25 
26 
27      Date: 09/21/2007
28 
29 ------------------------------------------------------------------------------
30  REVISION HISTORY
31 
32 
33  Description:
34 
35 ------------------------------------------------------------------------------
36  INPUT AND OUTPUT DEFINITIONS
37 
38   Input
39     tmp3dec_chan   *pChVars,          decoder state structure per channel
40     int32          numChannels,       number of channels
41     e_equalization equalizerType,     equalization mode
42     int16          *outPcm            pointer to the PCM output data
43 
44   Output
45     int16          *outPcm            pointer to the PCM output data
46 
47 ------------------------------------------------------------------------------
48  FUNCTION DESCRIPTION
49 
50     polyphase synthesis
51     Each time the subband samples for all 32 polyphase subbands of one
52     channel have been calculated, they can be applied to the synthesis
53     subband filter and 32 consecutive audio samples can be calculated
54 
55 ------------------------------------------------------------------------------
56  REQUIREMENTS
57 
58 
59 ------------------------------------------------------------------------------
60  REFERENCES
61 
62  [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
63      ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
64 
65 ------------------------------------------------------------------------------
66  PSEUDO-CODE
67 
68 ------------------------------------------------------------------------------
69 */
70 
71 
72 /*----------------------------------------------------------------------------
73 ; INCLUDES
74 ----------------------------------------------------------------------------*/
75 
76 #include "pvmp3_poly_phase_synthesis.h"
77 #include "pvmp3_polyphase_filter_window.h"
78 #include "pv_mp3dec_fxd_op.h"
79 #include "pvmp3_dec_defs.h"
80 #include "pvmp3_dct_16.h"
81 #include "pvmp3_equalizer.h"
82 #include "mp3_mem_funcs.h"
83 
84 
85 /*----------------------------------------------------------------------------
86 ; MACROS
87 ; Define module specific macros here
88 ----------------------------------------------------------------------------*/
89 
90 
91 /*----------------------------------------------------------------------------
92 ; DEFINES
93 ; Include all pre-processor statements here. Include conditional
94 ; compile variables also.
95 ----------------------------------------------------------------------------*/
96 
97 /*----------------------------------------------------------------------------
98 ; LOCAL FUNCTION DEFINITIONS
99 ; Function Prototype declaration
100 ----------------------------------------------------------------------------*/
101 
102 /*----------------------------------------------------------------------------
103 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
104 ; Variable declaration - defined here and used outside this module
105 ----------------------------------------------------------------------------*/
106 
107 /*----------------------------------------------------------------------------
108 ; EXTERNAL FUNCTION REFERENCES
109 ; Declare functions defined elsewhere and referenced in this module
110 ----------------------------------------------------------------------------*/
111 
112 /*----------------------------------------------------------------------------
113 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
114 ; Declare variables used in this module but defined elsewhere
115 ----------------------------------------------------------------------------*/
116 
117 
118 /*----------------------------------------------------------------------------
119 ; FUNCTION CODE
120 ----------------------------------------------------------------------------*/
121 
pvmp3_poly_phase_synthesis(tmp3dec_chan * pChVars,int32 numChannels,e_equalization equalizerType,int16 * outPcm)122 void pvmp3_poly_phase_synthesis(tmp3dec_chan   *pChVars,
123                                 int32          numChannels,
124                                 e_equalization equalizerType,
125                                 int16          *outPcm)
126 {
127     /*
128      *  Equalizer
129      */
130     pvmp3_equalizer(pChVars->circ_buffer,
131                     equalizerType,
132                     pChVars->work_buf_int32);
133 
134 
135     int16 * ptr_out = outPcm;
136 
137 
138     for (int32  band = 0; band < FILTERBANK_BANDS; band += 2)
139     {
140         int32 *inData  = &pChVars->circ_buffer[544 - (band<<5)];
141 
142         /*
143          *   DCT 32
144          */
145 
146         pvmp3_split(&inData[16]);
147 
148         pvmp3_dct_16(&inData[16], 0);
149         pvmp3_dct_16(inData, 1);     // Even terms
150 
151         pvmp3_merge_in_place_N32(inData);
152 
153         pvmp3_polyphase_filter_window(inData,
154                                       ptr_out,
155                                       numChannels);
156 
157         inData  -= SUBBANDS_NUMBER;
158 
159         /*
160          *   DCT 32
161          */
162 
163         pvmp3_split(&inData[16]);
164 
165         pvmp3_dct_16(&inData[16], 0);
166         pvmp3_dct_16(inData, 1);     // Even terms
167 
168         pvmp3_merge_in_place_N32(inData);
169 
170         pvmp3_polyphase_filter_window(inData,
171                                       ptr_out + (numChannels << 5),
172                                       numChannels);
173 
174         ptr_out += (numChannels << 6);
175 
176         inData  -= SUBBANDS_NUMBER;
177 
178     }/* end band loop */
179 
180     pv_memmove(&pChVars->circ_buffer[576],
181                pChVars->circ_buffer,
182                480*sizeof(*pChVars->circ_buffer));
183 
184 }
185 
186 
187 
188