35 #define ON2AVC_SUBFRAME_SIZE 1024
91 int w,
b, band_off = 0;
112 int bits_per_sect = c->
is_long ? 5 : 3;
113 int esc_val = (1 << bits_per_sect) - 1;
117 while (band < num_bands) {
123 }
while (run == esc_val);
124 if (band + run_len > num_bands) {
128 for (i = band; i < band +
run_len; i++) {
142 int w, w2,
b, scale, first = 1;
175 if (scale < 0 || scale > 127) {
189 return v * sqrtf(fabsf(v)) * scale;
194 int dst_size,
int type,
float band_scale)
198 for (i = 0; i < dst_size; i += 4) {
201 for (j = 0; j < 4; j++) {
202 val1 =
sign_extend((val >> (12 - j * 4)) & 0xF, 4);
220 int dst_size,
int type,
float band_scale)
222 int i,
val, val1, val2, sign;
224 for (i = 0; i < dst_size; i += 2) {
230 if (val1 <= -16 || val1 >= 16) {
231 sign = 1 - (val1 < 0) * 2;
234 if (val2 <= -16 || val2 >= 16) {
235 sign = 1 - (val2 < 0) * 2;
258 coeff_ptr = c->
coeffs[ch];
267 coeff_ptr += band_size;
276 coeff_ptr += band_size;
288 float *ch0 = c->
coeffs[0];
289 float *ch1 = c->
coeffs[1];
293 if (c->
ms_info[band_off + b]) {
295 float l = *ch0,
r = *ch1;
311 memset(src, 0,
sizeof(*src) * order0);
312 memset(src + len - order1, 0,
sizeof(*src) * order1);
316 int step,
int order0,
int order1,
const double *
const *
tabs)
324 for (i = 0; i < tab_step; i++) {
326 for (j = 0; j < order0; j++)
327 sum += src[j] * tab[j * tab_step + i];
331 out = dst + dst_len - tab_step;
333 src2 = src + (dst_len - tab_step) / step + 1 + order0;
334 for (i = 0; i < tab_step; i++) {
336 for (j = 0; j < order1; j++)
337 sum += src2[j] * tab[j * tab_step + i];
342 static void twiddle(
float *src1,
float *src2,
int src2_len,
343 const double *
tab,
int tab_len,
int step,
344 int order0,
int order1,
const double *
const *
tabs)
350 steps = (src2_len - tab_len) / step + 1;
351 pretwiddle(src1, src2, src2_len, tab_len, step, order0, order1, tabs);
354 for (i = 0; i < steps; i++) {
355 float in0 = src1[order0 + i];
356 int pos = (src2_len - 1) & mask;
359 const double *t =
tab;
360 for (j = pos; j >= 0; j--)
361 src2[j] += in0 * *t++;
362 for (j = 0; j < tab_len - pos - 1; j++)
363 src2[src2_len - j - 1] += in0 * tab[pos + 1 + j];
365 for (j = 0; j < tab_len; j++)
366 src2[pos - j] += in0 * tab[j];
372 #define CMUL1_R(s, t, is, it) \
373 s[is + 0] * t[it + 0] - s[is + 1] * t[it + 1]
374 #define CMUL1_I(s, t, is, it) \
375 s[is + 0] * t[it + 1] + s[is + 1] * t[it + 0]
376 #define CMUL2_R(s, t, is, it) \
377 s[is + 0] * t[it + 0] + s[is + 1] * t[it + 1]
378 #define CMUL2_I(s, t, is, it) \
379 s[is + 0] * t[it + 1] - s[is + 1] * t[it + 0]
381 #define CMUL0(dst, id, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
382 dst[id] = s0[is] * t0[it] + s1[is] * t1[it] \
383 + s2[is] * t2[it] + s3[is] * t3[it]; \
384 dst[id + 1] = s0[is] * t0[it + 1] + s1[is] * t1[it + 1] \
385 + s2[is] * t2[it + 1] + s3[is] * t3[it + 1];
387 #define CMUL1(dst, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
388 *dst++ = CMUL1_R(s0, t0, is, it) \
389 + CMUL1_R(s1, t1, is, it) \
390 + CMUL1_R(s2, t2, is, it) \
391 + CMUL1_R(s3, t3, is, it); \
392 *dst++ = CMUL1_I(s0, t0, is, it) \
393 + CMUL1_I(s1, t1, is, it) \
394 + CMUL1_I(s2, t2, is, it) \
395 + CMUL1_I(s3, t3, is, it);
397 #define CMUL2(dst, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
398 *dst++ = CMUL2_R(s0, t0, is, it) \
399 + CMUL2_R(s1, t1, is, it) \
400 + CMUL2_R(s2, t2, is, it) \
401 + CMUL2_R(s3, t3, is, it); \
402 *dst++ = CMUL2_I(s0, t0, is, it) \
403 + CMUL2_I(s1, t1, is, it) \
404 + CMUL2_I(s2, t2, is, it) \
405 + CMUL2_I(s3, t3, is, it);
408 const float *
t0,
const float *
t1,
409 const float *
t2,
const float *
t3,
int len,
int step)
411 const float *h0, *h1, *h2, *h3;
414 int len2 = len >> 1, len4 = len >> 2;
419 for (half = len2; tmp > 1; half <<= 1, tmp >>= 1);
426 CMUL0(dst, 0, s0, s1, s2, s3, t0, t1, t2, t3, 0, 0);
428 hoff = 2 * step * (len4 >> 1);
433 d2 = dst + 2 + (len >> 1);
434 for (i = 0; i < (len4 - 1) >> 1; i++) {
435 CMUL1(d1, s0, s1, s2, s3, t0, t1, t2, t3, j, k);
436 CMUL1(d2, s0, s1, s2, s3, h0, h1, h2, h3, j, k);
440 CMUL0(dst, len4, s0, s1, s2, s3, t0, t1, t2, t3, 1, hoff);
441 CMUL0(dst, len4 + len2, s0, s1, s2, s3, h0, h1, h2, h3, 1, hoff);
444 k = hoff + 2 * step * len4;
446 d2 = dst + len4 + 2 + len2;
447 for (i = 0; i < (len4 - 2) >> 1; i++) {
448 CMUL2(d1, s0, s1, s2, s3, t0, t1, t2, t3, j, k);
449 CMUL2(d2, s0, s1, s2, s3, h0, h1, h2, h3, j, k);
453 CMUL0(dst, len2 + 4, s0, s1, s2, s3, t0, t1, t2, t3, 0, k);
457 float *tmp0,
float *tmp1)
459 memcpy(src, tmp0, 384 *
sizeof(*tmp0));
460 memcpy(tmp0 + 384, src + 384, 128 *
sizeof(*tmp0));
475 combine_fft(src, src + 128, src + 256, src + 384, tmp1,
486 memcpy(src, tmp1, 512 *
sizeof(
float));
490 float *tmp0,
float *tmp1)
492 memcpy(src, tmp0, 768 *
sizeof(*tmp0));
493 memcpy(tmp0 + 768, src + 768, 256 *
sizeof(*tmp0));
508 combine_fft(src, src + 256, src + 512, src + 768, tmp1,
519 memcpy(src, tmp1, 1024 *
sizeof(
float));
524 float *tmp0 = c->
temp, *tmp1 = c->
temp + 1024;
526 memset(tmp0, 0,
sizeof(*tmp0) * 1024);
527 memset(tmp1, 0,
sizeof(*tmp1) * 1024);
551 memset(tmp0, 0, 64 *
sizeof(*tmp0));
589 memset(tmp0, 0, 128 *
sizeof(*tmp0));
610 float *tmp0 = c->
temp, *tmp1 = c->
temp + 1024;
612 memset(tmp0, 0,
sizeof(*tmp0) * 1024);
613 memset(tmp1, 0,
sizeof(*tmp1) * 1024);
633 memset(tmp0, 0, 64 *
sizeof(*tmp0));
665 memset(tmp0, 0, 128 *
sizeof(*tmp0));
686 for (ch = 0; ch < 2; ch++) {
689 float *saved = c->
delay[ch];
691 float *wout = out + 448;
703 for (i = 0; i < 256; i++) {
709 for (i = 0; i < 256; i++) {
712 c->
wtf(c,
buf + 512,
in + 512, 512);
716 memcpy(out, saved, 448 *
sizeof(
float));
718 memcpy(wout + 128,
buf + 64, 448 *
sizeof(
float));
719 memcpy(saved,
buf + 512, 448 *
sizeof(
float));
720 memcpy(saved + 448,
buf + 7*128 + 64, 64 *
sizeof(
float));
733 float *saved = c->
delay[channel];
755 float *wout = out + 448;
756 memcpy(out, saved, 448 *
sizeof(
float));
764 memcpy(wout + 4*128,
temp, 64 *
sizeof(
float));
767 memcpy(wout + 128,
buf + 64, 448 *
sizeof(
float));
774 memcpy(saved,
temp + 64, 64 *
sizeof(
float));
778 memcpy(saved + 448,
buf + 7*128 + 64, 64 *
sizeof(
float));
781 memcpy(saved,
buf + 512, 448 *
sizeof(
float));
782 memcpy(saved + 448,
buf + 7*128 + 64, 64 *
sizeof(
float));
786 memcpy(saved,
buf + 512, 512 *
sizeof(
float));
836 int *got_frame_ptr,
AVPacket *avpkt)
840 int buf_size = avpkt->
size;
885 frame, audio_off)) < 0)
902 for (i = 1; i < 16; i++)
923 "Stereo mode support is not good, patch is welcome\n");
925 for (i = 0; i < 20; i++)
926 c->
scale_tab[i] = ceil(pow(10.0, i * 0.1) * 16) / 32;
928 c->
scale_tab[i] = ceil(pow(10.0, i * 0.1) * 0.5);
958 for (i = 1; i < 9; i++) {
969 for (i = 9; i < 16; i++) {