1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
19 ------------------------------------------------------------------------------
24 Filename: pvmp3_mpeg2_get_scale_factors.cpp
28 ------------------------------------------------------------------------------
34 ------------------------------------------------------------------------------
35 INPUT AND OUTPUT DEFINITIONS
39 mp3ScaleFactors *scalefac,
40 mp3SideInfo *si, side information
43 mp3Header *info, mp3 header information
44 uint32 *scalefac_IIP_buffer, auxiliary scale data
45 tbits *pMainData bit stream Data
49 III_scalefac_t *scalefac, scale factor
52 ------------------------------------------------------------------------------
55 get scale factor for mpe2 layer III LSF extension
57 ------------------------------------------------------------------------------
61 ------------------------------------------------------------------------------
64 [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
65 ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
67 ------------------------------------------------------------------------------
70 ------------------------------------------------------------------------------
74 /*----------------------------------------------------------------------------
76 ----------------------------------------------------------------------------*/
78 #include "pvmp3_mpeg2_get_scale_factors.h"
79 #include "pvmp3_mpeg2_get_scale_data.h"
82 /*----------------------------------------------------------------------------
84 ; Define module specific macros here
85 ----------------------------------------------------------------------------*/
88 /*----------------------------------------------------------------------------
90 ; Include all pre-processor statements here. Include conditional
91 ; compile variables also.
92 ----------------------------------------------------------------------------*/
94 /*----------------------------------------------------------------------------
95 ; LOCAL FUNCTION DEFINITIONS
96 ; Function Prototype declaration
97 ----------------------------------------------------------------------------*/
99 /*----------------------------------------------------------------------------
100 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
101 ; Variable declaration - defined here and used outside this module
102 ----------------------------------------------------------------------------*/
104 /*----------------------------------------------------------------------------
105 ; EXTERNAL FUNCTION REFERENCES
106 ; Declare functions defined elsewhere and referenced in this module
107 ----------------------------------------------------------------------------*/
109 /*----------------------------------------------------------------------------
110 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
111 ; Declare variables used in this module but defined elsewhere
112 ----------------------------------------------------------------------------*/
114 /*----------------------------------------------------------------------------
116 ----------------------------------------------------------------------------*/
118 void pvmp3_mpeg2_get_scale_factors(mp3ScaleFactors *scalefac,
123 uint32 *scalefac_IIP_buffer,
130 uint32 *scalefac_buffer = &scalefac_IIP_buffer[56];
132 granuleInfo *gr_info = &(si->ch[ch].gran[gr]);
134 pvmp3_mpeg2_get_scale_data(si,
138 (uint32 *)scalefac_buffer,
139 (uint32 *)scalefac_IIP_buffer,
143 if (gr_info->window_switching_flag && (gr_info->block_type == 2))
145 if (gr_info->mixed_block_flag)
147 for (sfb = 0; sfb < 6; sfb++)
149 scalefac->l[sfb] = scalefac_buffer[sfb];
154 for (sfb = 3; sfb < 12; sfb++)
156 for (window = 0; window < 3; window++)
158 scalefac->s[window][sfb] = scalefac_buffer[k];
164 /* adjust position of "illegal position" information in scalefac_IIP_buffer[] */
165 /* in mixed blocks mode for short sfb, move them 3 places up. efs 3002-07-04 */
166 for (sfb = 11; sfb >= 3; sfb--)
168 scalefac_IIP_buffer[3*sfb + 2] = scalefac_IIP_buffer[3*sfb - 1];
169 scalefac_IIP_buffer[3*sfb + 1] = scalefac_IIP_buffer[3*sfb - 2];
170 scalefac_IIP_buffer[3*sfb ] = scalefac_IIP_buffer[3*sfb - 3];
176 for (sfb = 0; sfb < 12; sfb++)
178 for (window = 0; window < 3; window++)
180 scalefac->s[window][sfb] = scalefac_buffer[k];
186 scalefac->s[0][12] = 0;
187 scalefac->s[1][12] = 0;
188 scalefac->s[2][12] = 0;
192 { /* LONG types 0,1,3 */
193 for (sfb = 0; sfb < 21; sfb++)
195 scalefac->l[sfb] = scalefac_buffer[sfb];