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

Function encode_block

libavcodec/wmaenc.c:192–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
193 int total_gain)
194{
195 int channels = s->avctx->ch_layout.nb_channels;
196 int v, bsize, ch, coef_nb_bits, parse_exponents;
197 float mdct_norm;
198 int nb_coefs[MAX_CHANNELS];
199 static const int fixed_exp[25] = {
200 20, 20, 20, 20, 20,
201 20, 20, 20, 20, 20,
202 20, 20, 20, 20, 20,
203 20, 20, 20, 20, 20,
204 20, 20, 20, 20, 20
205 };
206
207 // FIXME remove duplication relative to decoder
208 if (s->use_variable_block_len) {
209 av_unreachable("use_variable_block_len unimplemented, set to 0 during init");
210 } else {
211 /* fixed block len */
212 s->next_block_len_bits = s->frame_len_bits;
213 s->prev_block_len_bits = s->frame_len_bits;
214 s->block_len_bits = s->frame_len_bits;
215 }
216
217 s->block_len = 1 << s->block_len_bits;
218// av_assert0((s->block_pos + s->block_len) <= s->frame_len);
219 bsize = s->frame_len_bits - s->block_len_bits;
220
221 // FIXME factor
222 v = s->coefs_end[bsize] - s->coefs_start;
223 for (ch = 0; ch < channels; ch++)
224 nb_coefs[ch] = v;
225 {
226 int n4 = s->block_len / 2;
227 mdct_norm = 1.0 / (float) n4;
228 if (s->version == 1)
229 mdct_norm *= sqrt(n4);
230 }
231
232 if (channels == 2)
233 put_bits(&s->pb, 1, !!s->ms_stereo);
234
235 for (ch = 0; ch < channels; ch++) {
236 // FIXME only set channel_coded when needed, instead of always
237 s->channel_coded[ch] = 1;
238 if (s->channel_coded[ch])
239 init_exp(s, ch, fixed_exp);
240 }
241
242 for (ch = 0; ch < channels; ch++) {
243 if (s->channel_coded[ch]) {
244 WMACoef *coefs1;
245 float *coefs, *exponents, mult;
246 int i, n;
247
248 coefs1 = s->coefs1[ch];
249 exponents = s->exponents[ch];

Callers 1

encode_frameFunction · 0.70

Calls 7

init_expFunction · 0.85
ff_exp10Function · 0.85
lrintFunction · 0.85
encode_exp_vlcFunction · 0.85
align_put_bitsFunction · 0.85
put_bitsFunction · 0.70

Tested by

no test coverage detected