MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decode_block

Function decode_block

libavcodec/binkaudio.c:154–244  ·  view source on GitHub ↗

* Decode Bink Audio block * @param[out] out Output buffer (must contain s->block_size elements) */

Source from the content-addressed store, hash-verified

152 * @param[out] out Output buffer (must contain s->block_size elements)
153 */
154static void decode_block(BinkAudioContext *s, short *out, int use_dct)
155{
156 int ch, i, j, k;
157 float q, quant[25];
158 int width, coeff;
159 GetBitContext *gb = &s->gb;
160
161 if (use_dct)
162 skip_bits(gb, 2);
163
164 for (ch = 0; ch < s->channels; ch++) {
165 FFTSample *coeffs = s->coeffs_ptr[ch];
166 q = 0.0f;
167 coeffs[0] = get_float(gb) * s->root;
168 coeffs[1] = get_float(gb) * s->root;
169
170 for (i = 0; i < s->num_bands; i++) {
171 /* constant is result of 0.066399999/log10(M_E) */
172 int value = get_bits(gb, 8);
173 quant[i] = expf(FFMIN(value, 95) * 0.15289164787221953823f) * s->root;
174 }
175
176 // find band (k)
177 for (k = 0; s->bands[k] < 1; k++) {
178 q = quant[k];
179 }
180
181 // parse coefficients
182 i = 2;
183 while (i < s->frame_len) {
184 if (get_bits1(gb)) {
185 j = i + rle_length_tab[get_bits(gb, 4)] * 8;
186 } else {
187 j = i + 8;
188 }
189
190 j = FFMIN(j, s->frame_len);
191
192 width = get_bits(gb, 4);
193 if (width == 0) {
194 memset(coeffs + i, 0, (j - i) * sizeof(*coeffs));
195 i = j;
196 while (s->bands[k] * 2 < i)
197 q = quant[k++];
198 } else {
199 while (i < j) {
200 if (s->bands[k] * 2 == i)
201 q = quant[k++];
202 coeff = get_bits(gb, width);
203 if (coeff) {
204 if (get_bits1(gb))
205 coeffs[i] = -q * coeff;
206 else
207 coeffs[i] = q * coeff;
208 } else {
209 coeffs[i] = 0.0f;
210 }
211 i++;

Callers 1

decode_frameFunction · 0.70

Calls 6

skip_bitsFunction · 0.85
get_floatFunction · 0.85
get_bitsFunction · 0.85
get_bits1Function · 0.85
ff_dct_calcFunction · 0.85
ff_rdft_calcFunction · 0.85

Tested by

no test coverage detected