1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /************************************************************************** |
|
21 l3sfb.cpp - Scalefactor band (sfb) implementations for layer III. |
|
22 |
|
23 Author(s): Juha Ojanpera |
|
24 Copyright (c) 1999-2004 by Nokia Research Center, Speech and Audio Systems. |
|
25 *************************************************************************/ |
|
26 |
|
27 /*-- Project Headers. --*/ |
|
28 #include "mp3tables.h" |
|
29 #include "mpaud.h" |
|
30 #include "mpheader.h" |
|
31 |
|
32 /************************************************************************** |
|
33 External Objects Needed |
|
34 *************************************************************************/ |
|
35 |
|
36 /************************************************************************** |
|
37 Internal Objects |
|
38 *************************************************************************/ |
|
39 |
|
40 static const int16 *III_sfbOffsetLong(TMPEG_Header *header); |
|
41 |
|
42 static const int16 *III_sfbOffsetShort(TMPEG_Header *header); |
|
43 |
|
44 static const int16 *III_sfbWidthTblShort(int16 *sfb_offset, int16 *sfb_width); |
|
45 |
|
46 /************************************************************************** |
|
47 Title : III_SfbDataInit |
|
48 |
|
49 Purpose : Initializes the sfb parameters. |
|
50 |
|
51 Usage : III_SfbDataInit(sfbData, header) |
|
52 |
|
53 Input : sfbData - sfb parameters |
|
54 header - mp3 header parameters |
|
55 |
|
56 Author(s) : Juha Ojanpera |
|
57 *************************************************************************/ |
|
58 |
|
59 void |
|
60 III_SfbDataInit(CIII_SfbData *sfbData, TMPEG_Header *header) |
|
61 { |
|
62 COPY_MEMORY(sfbData->sfbOffsetLong, III_sfbOffsetLong(header), |
|
63 (MAX_LONG_SFB_BANDS + 1) * sizeof(int16)); |
|
64 |
|
65 sfbData->sfbLong = sfbData->sfbOffsetLong; |
|
66 |
|
67 COPY_MEMORY(sfbData->sfbOffsetShort, III_sfbOffsetShort(header), |
|
68 (MAX_SHORT_SFB_BANDS + 1) * sizeof(int16)); |
|
69 |
|
70 sfbData->sfbShort = sfbData->sfbOffsetShort; |
|
71 |
|
72 COPY_MEMORY(sfbData->sfbWidthShort, |
|
73 III_sfbWidthTblShort(sfbData->sfbShort, sfbData->sfbWidthShort), |
|
74 (MAX_SHORT_SFB_BANDS + 1) * sizeof(int16)); |
|
75 |
|
76 sfbData->sfbWidth = sfbData->sfbWidthShort; |
|
77 |
|
78 sfbData->bandLimit = MAX_MONO_SAMPLES; |
|
79 } |
|
80 |
|
81 /************************************************************************** |
|
82 Title : III_BandLimit |
|
83 |
|
84 Purpose : Saves the bandlimit value for Huffman decoding. |
|
85 |
|
86 Usage : III_BandLimit(sfbData, decim_factor) |
|
87 |
|
88 Input : sfbData - sfb parameters |
|
89 binLimit - number of spectral bins to be decoded from each channel |
|
90 |
|
91 Author(s) : Juha Ojanpera |
|
92 *************************************************************************/ |
|
93 |
|
94 void |
|
95 III_BandLimit(CIII_SfbData *sfbData, uint16 binLimit) |
|
96 { |
|
97 sfbData->bandLimit = binLimit; |
|
98 } |
|
99 |
|
100 |
|
101 /************************************************************************** |
|
102 Title : III_sfbOffsetLong |
|
103 |
|
104 Purpose : Obtains the scalefactor table for long blocks. |
|
105 |
|
106 Usage : y = III_sfbOffsetLong(header) |
|
107 |
|
108 Input : header - mp3 header parameters |
|
109 |
|
110 Output : y - scalefactor boundaries for long blocks |
|
111 |
|
112 Author(s) : Juha Ojanpera |
|
113 *************************************************************************/ |
|
114 |
|
115 const int16 * |
|
116 III_sfbOffsetLong(TMPEG_Header *header) |
|
117 { |
|
118 int16 fidx, mp25idx = (int16) (6 * mp25version(header)); |
|
119 |
|
120 fidx = (int16) (mp25idx + 3 * version(header) + sfreq(header)); |
|
121 |
|
122 return (&sfBandIndex[fidx].l[0]); |
|
123 } |
|
124 |
|
125 |
|
126 /************************************************************************** |
|
127 Title : III_sfbOffsetShort |
|
128 |
|
129 Purpose : Obtains the scalefactor table for short blocks. |
|
130 |
|
131 Usage : y = III_sfbOffsetShort(header) |
|
132 |
|
133 Input : header - mp3 header parameters |
|
134 |
|
135 Output : y - scalefactor boundaries for short blocks |
|
136 |
|
137 Author(s) : Juha Ojanpera |
|
138 *************************************************************************/ |
|
139 |
|
140 const int16 * |
|
141 III_sfbOffsetShort(TMPEG_Header *header) |
|
142 { |
|
143 int16 mp25idx = (int16) (6 * mp25version(header)); |
|
144 |
|
145 return (&sfBandIndex[mp25idx + 3 * version(header) + sfreq(header)].s[0]); |
|
146 } |
|
147 |
|
148 |
|
149 /************************************************************************** |
|
150 Title : III_sfbWidthTblShort |
|
151 |
|
152 Purpose : Obtains the scalefactor width table for short blocks. |
|
153 |
|
154 Usage : y = III_sfbWidthTblShort(sfb_offset, sfb_width) |
|
155 |
|
156 Input : sfb_offset - offset table of short blocks |
|
157 sfb_width - address of buffer to receive the sfb widths |
|
158 |
|
159 Output : y - sfb width table for short blocks |
|
160 |
|
161 Author(s) : Juha Ojanpera |
|
162 *************************************************************************/ |
|
163 |
|
164 const int16 * |
|
165 III_sfbWidthTblShort(int16 *sfb_offset, int16 *sfb_width) |
|
166 { |
|
167 for(int16 i = 0; i < MAX_SHORT_SFB_BANDS; i++) |
|
168 sfb_width[i] = (int16) (sfb_offset[i + 1] - sfb_offset[i]); |
|
169 |
|
170 return (sfb_width); |
|
171 } |
|