annotate wmaprodec.c @ 10073:57d76996ccb8 libavcodec

Add some more wmapro decoder hunks
author faust3
date Fri, 21 Aug 2009 16:54:42 +0000
parents 4b91b74ff669
children bf63f070fbf7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10073
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
1 /*
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
2 * Wmapro compatible decoder
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
3 * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
4 * Copyright (c) 2008 - 2009 Sascha Sommer, Benjamin Larsson
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
5 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
6 * This file is part of FFmpeg.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
7 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
10 * License as published by the Free Software Foundation; either
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
12 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
16 * Lesser General Public License for more details.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
17 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
21 */
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
22
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
23 /**
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
24 * @file libavcodec/wmaprodec.c
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
25 * @brief wmapro decoder implementation
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
26 * Wmapro is an MDCT based codec comparable to wma standard or AAC.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
27 * The decoding therefore consists of the following steps:
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
28 * - bitstream decoding
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
29 * - reconstruction of per-channel data
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
30 * - rescaling and inverse quantization
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
31 * - IMDCT
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
32 * - windowing and overlapp-add
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
33 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
34 * The compressed wmapro bitstream is split into individual packets.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
35 * Every such packet contains one or more wma frames.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
36 * The compressed frames may have a variable length and frames may
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
37 * cross packet boundaries.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
38 * Common to all wmapro frames is the number of samples that are stored in
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
39 * a frame.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
40 * The number of samples and a few other decode flags are stored
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
41 * as extradata that has to be passed to the decoder.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
42 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
43 * The wmapro frames themselves are again split into a variable number of
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
44 * subframes. Every subframe contains the data for 2^N time domain samples
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
45 * where N varies between 7 and 12.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
46 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
47 * Example wmapro bitstream (in samples):
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
48 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
49 * || packet 0 || packet 1 || packet 2 packets
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
50 * ---------------------------------------------------
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
51 * || frame 0 || frame 1 || frame 2 || frames
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
52 * ---------------------------------------------------
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
53 * || | | || | | | || || subframes of channel 0
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
54 * ---------------------------------------------------
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
55 * || | | || | | | || || subframes of channel 1
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
56 * ---------------------------------------------------
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
57 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
58 * The frame layouts for the individual channels of a wma frame does not need
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
59 * to be the same.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
60 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
61 * However, if the offsets and lengths of several subframes of a frame are the
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
62 * same, the subframes of the channels can be grouped.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
63 * Every group may then use special coding techniques like M/S stereo coding
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
64 * to improve the compression ratio. These channel transformations do not
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
65 * need to be applied to a whole subframe. Instead, they can also work on
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
66 * individual scale factor bands (see below).
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
67 * The coefficients that carry the audio signal in the frequency domain
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
68 * are transmitted as huffman-coded vectors with 4, 2 and 1 elements.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
69 * In addition to that, the encoder can switch to a runlevel coding scheme
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
70 * by transmitting subframe_length / 128 zero coefficients.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
71 *
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
72 * Before the audio signal can be converted to the time domain, the
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
73 * coefficients have to be rescaled and inverse quantized.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
74 * A subframe is therefore split into several scale factor bands that get
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
75 * scaled individually.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
76 * Scale factors are submitted for every frame but they might be shared
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
77 * between the subframes of a channel. Scale factors are initially DPCM-coded.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
78 * Once scale factors are shared, the differences are transmitted as runlevel
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
79 * codes.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
80 * Every subframe length and offset combination in the frame layout shares a
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
81 * common quantization factor that can be adjusted for every channel by a
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
82 * modifier.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
83 * After the inverse quantization, the coefficients get processed by an IMDCT.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
84 * The resulting values are then windowed with a sine window and the first half
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
85 * of the values are added to the second half of the output from the previous
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
86 * subframe in order to reconstruct the output samples.
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
87 */
57d76996ccb8 Add some more wmapro decoder hunks
faust3
parents: 10006
diff changeset
88
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
89 /**
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
90 *@brief Uninitialize the decoder and free all resources.
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
91 *@param avctx codec context
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
92 *@return 0 on success, < 0 otherwise
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
93 */
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
94 static av_cold int decode_end(AVCodecContext *avctx)
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
95 {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
96 WMA3DecodeContext *s = avctx->priv_data;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
97 int i;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
98
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
99 for (i = 0 ; i < WMAPRO_BLOCK_SIZES ; i++)
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
100 ff_mdct_end(&s->mdct_ctx[i]);
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
101
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
102 return 0;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
103 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
104
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
105 /**
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
106 *@brief Calculate a decorrelation matrix from the bitstream parameters.
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
107 *@param s codec context
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
108 *@param chgroup channel group for which the matrix needs to be calculated
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
109 */
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
110 static void decode_decorrelation_matrix(WMA3DecodeContext *s,
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
111 WMA3ChannelGroup *chgroup)
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
112 {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
113 int i;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
114 int offset = 0;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
115 int8_t rotation_offset[WMAPRO_MAX_CHANNELS * WMAPRO_MAX_CHANNELS];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
116 memset(chgroup->decorrelation_matrix,0,
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
117 sizeof(float) *s->num_channels * s->num_channels);
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
118
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
119 for (i = 0; i < chgroup->num_channels * (chgroup->num_channels - 1) >> 1; i++)
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
120 rotation_offset[i] = get_bits(&s->gb,6);
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
121
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
122 for (i = 0; i < chgroup->num_channels; i++)
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
123 chgroup->decorrelation_matrix[chgroup->num_channels * i + i] =
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
124 get_bits1(&s->gb) ? 1.0 : -1.0;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
125
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
126 for (i = 1; i < chgroup->num_channels; i++) {
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
127 int x;
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
128 for (x = 0; x < i; x++) {
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
129 int y;
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
130 for (y = 0; y < i + 1 ; y++) {
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
131 float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
132 float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
133 int n = rotation_offset[offset + x];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
134 float sinv;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
135 float cosv;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
136
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
137 if (n < 32) {
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
138 sinv = sin64[n];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
139 cosv = sin64[32-n];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
140 } else {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
141 sinv = sin64[64-n];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
142 cosv = -sin64[n-32];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
143 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
144
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
145 chgroup->decorrelation_matrix[y + x * chgroup->num_channels] =
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
146 (v1 * sinv) - (v2 * cosv);
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
147 chgroup->decorrelation_matrix[y + i * chgroup->num_channels] =
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
148 (v1 * cosv) + (v2 * sinv);
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
149 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
150 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
151 offset += i;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
152 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
153 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
154
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
155 /**
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
156 *@brief Reconstruct the individual channel data.
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
157 *@param s codec context
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
158 */
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
159 static void inverse_channel_transform(WMA3DecodeContext *s)
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
160 {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
161 int i;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
162
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
163 for (i = 0; i < s->num_chgroups; i++) {
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
164
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
165 if (s->chgroup[i].transform == 1) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
166 /** M/S stereo decoding */
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
167 int16_t* sfb_offsets = s->cur_sfb_offsets;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
168 float* ch0 = *sfb_offsets + s->channel[0].coeffs;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
169 float* ch1 = *sfb_offsets++ + s->channel[1].coeffs;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
170 const char* tb = s->chgroup[i].transform_band;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
171 const char* tb_end = tb + s->num_bands;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
172
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
173 while (tb < tb_end) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
174 const float* ch0_end = s->channel[0].coeffs +
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
175 FFMIN(*sfb_offsets,s->subframe_len);
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
176 if (*tb++ == 1) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
177 while (ch0 < ch0_end) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
178 const float v1 = *ch0;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
179 const float v2 = *ch1;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
180 *ch0++ = v1 - v2;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
181 *ch1++ = v1 + v2;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
182 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
183 } else {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
184 while (ch0 < ch0_end) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
185 *ch0++ *= 181.0 / 128;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
186 *ch1++ *= 181.0 / 128;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
187 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
188 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
189 ++sfb_offsets;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
190 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
191 } else if (s->chgroup[i].transform) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
192 float data[WMAPRO_MAX_CHANNELS];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
193 const int num_channels = s->chgroup[i].num_channels;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
194 float** ch_data = s->chgroup[i].channel_data;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
195 float** ch_end = ch_data + num_channels;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
196 const int8_t* tb = s->chgroup[i].transform_band;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
197 int16_t* sfb;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
198
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
199 /** multichannel decorrelation */
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
200 for (sfb = s->cur_sfb_offsets ;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
201 sfb < s->cur_sfb_offsets + s->num_bands;sfb++) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
202 if (*tb++ == 1) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
203 int y;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
204 /** multiply values with the decorrelation_matrix */
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
205 for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) {
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
206 const float* mat = s->chgroup[i].decorrelation_matrix;
10006
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
207 const float* data_end = data + num_channels;
4b91b74ff669 cosmetics: K&R coding style, prettyprinting
diego
parents: 10005
diff changeset
208 float* data_ptr = data;
10005
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
209 float** ch;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
210
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
211 for (ch = ch_data;ch < ch_end; ch++)
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
212 *data_ptr++ = (*ch)[y];
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
213
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
214 for (ch = ch_data; ch < ch_end; ch++) {
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
215 float sum = 0;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
216 data_ptr = data;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
217 while (data_ptr < data_end)
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
218 sum += *data_ptr++ * *mat++;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
219
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
220 (*ch)[y] = sum;
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
221 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
222 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
223 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
224 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
225 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
226 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
227 }
ca678269fa64 add approved hunks of the wmapro decoder
faust3
parents:
diff changeset
228