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) {
122 if (run > num_bands - band - run_len) {
127 }
while (run == esc_val);
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);
227 int dst_size,
int type,
float band_scale)
229 int i,
val, val1, val2, sign;
231 for (i = 0; i < dst_size; i += 2) {
237 if (val1 <= -16 || val1 >= 16) {
238 sign = 1 - (val1 < 0) * 2;
241 if (val2 <= -16 || val2 >= 16) {
242 sign = 1 - (val2 < 0) * 2;
265 coeff_ptr = c->
coeffs[ch];
274 coeff_ptr += band_size;
283 coeff_ptr += band_size;
295 float *ch0 = c->
coeffs[0];
296 float *ch1 = c->
coeffs[1];
300 if (c->
ms_info[band_off + b]) {
302 float l = *ch0,
r = *ch1;
318 memset(src, 0,
sizeof(*src) * order0);
319 memset(src + len - order1, 0,
sizeof(*src) * order1);
323 int step,
int order0,
int order1,
const double *
const *
tabs)
331 for (i = 0; i < tab_step; i++) {
333 for (j = 0; j < order0; j++)
334 sum += src[j] * tab[j * tab_step + i];
338 out = dst + dst_len - tab_step;
340 src2 = src + (dst_len - tab_step) / step + 1 + order0;
341 for (i = 0; i < tab_step; i++) {
343 for (j = 0; j < order1; j++)
344 sum += src2[j] * tab[j * tab_step + i];
349 static void twiddle(
float *src1,
float *src2,
int src2_len,
350 const double *
tab,
int tab_len,
int step,
351 int order0,
int order1,
const double *
const *
tabs)
357 steps = (src2_len - tab_len) / step + 1;
358 pretwiddle(src1, src2, src2_len, tab_len, step, order0, order1, tabs);
361 for (i = 0; i < steps; i++) {
362 float in0 = src1[order0 + i];
363 int pos = (src2_len - 1) & mask;
366 const double *t =
tab;
367 for (j = pos; j >= 0; j--)
368 src2[j] += in0 * *t++;
369 for (j = 0; j < tab_len - pos - 1; j++)
370 src2[src2_len - j - 1] += in0 * tab[pos + 1 + j];
372 for (j = 0; j < tab_len; j++)
373 src2[pos - j] += in0 * tab[j];
379 #define CMUL1_R(s, t, is, it) \
380 s[is + 0] * t[it + 0] - s[is + 1] * t[it + 1]
381 #define CMUL1_I(s, t, is, it) \
382 s[is + 0] * t[it + 1] + s[is + 1] * t[it + 0]
383 #define CMUL2_R(s, t, is, it) \
384 s[is + 0] * t[it + 0] + s[is + 1] * t[it + 1]
385 #define CMUL2_I(s, t, is, it) \
386 s[is + 0] * t[it + 1] - s[is + 1] * t[it + 0]
388 #define CMUL0(dst, id, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
389 dst[id] = s0[is] * t0[it] + s1[is] * t1[it] \
390 + s2[is] * t2[it] + s3[is] * t3[it]; \
391 dst[id + 1] = s0[is] * t0[it + 1] + s1[is] * t1[it + 1] \
392 + s2[is] * t2[it + 1] + s3[is] * t3[it + 1];
394 #define CMUL1(dst, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
395 *dst++ = CMUL1_R(s0, t0, is, it) \
396 + CMUL1_R(s1, t1, is, it) \
397 + CMUL1_R(s2, t2, is, it) \
398 + CMUL1_R(s3, t3, is, it); \
399 *dst++ = CMUL1_I(s0, t0, is, it) \
400 + CMUL1_I(s1, t1, is, it) \
401 + CMUL1_I(s2, t2, is, it) \
402 + CMUL1_I(s3, t3, is, it);
404 #define CMUL2(dst, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
405 *dst++ = CMUL2_R(s0, t0, is, it) \
406 + CMUL2_R(s1, t1, is, it) \
407 + CMUL2_R(s2, t2, is, it) \
408 + CMUL2_R(s3, t3, is, it); \
409 *dst++ = CMUL2_I(s0, t0, is, it) \
410 + CMUL2_I(s1, t1, is, it) \
411 + CMUL2_I(s2, t2, is, it) \
412 + CMUL2_I(s3, t3, is, it);
415 const float *
t0,
const float *
t1,
416 const float *
t2,
const float *
t3,
int len,
int step)
418 const float *h0, *h1, *h2, *h3;
421 int len2 = len >> 1, len4 = len >> 2;
426 for (half = len2; tmp > 1; half <<= 1, tmp >>= 1);
433 CMUL0(dst, 0, s0, s1, s2, s3, t0, t1, t2, t3, 0, 0);
435 hoff = 2 * step * (len4 >> 1);
440 d2 = dst + 2 + (len >> 1);
441 for (i = 0; i < (len4 - 1) >> 1; i++) {
442 CMUL1(d1, s0, s1, s2, s3, t0, t1, t2, t3, j, k);
443 CMUL1(d2, s0, s1, s2, s3, h0, h1, h2, h3, j, k);
447 CMUL0(dst, len4, s0, s1, s2, s3, t0, t1, t2, t3, 1, hoff);
448 CMUL0(dst, len4 + len2, s0, s1, s2, s3, h0, h1, h2, h3, 1, hoff);
451 k = hoff + 2 * step * len4;
453 d2 = dst + len4 + 2 + len2;
454 for (i = 0; i < (len4 - 2) >> 1; i++) {
455 CMUL2(d1, s0, s1, s2, s3, t0, t1, t2, t3, j, k);
456 CMUL2(d2, s0, s1, s2, s3, h0, h1, h2, h3, j, k);
460 CMUL0(dst, len2 + 4, s0, s1, s2, s3, t0, t1, t2, t3, 0, k);
464 float *tmp0,
float *tmp1)
466 memcpy(src, tmp0, 384 *
sizeof(*tmp0));
467 memcpy(tmp0 + 384, src + 384, 128 *
sizeof(*tmp0));
482 combine_fft(src, src + 128, src + 256, src + 384, tmp1,
493 memcpy(src, tmp1, 512 *
sizeof(
float));
497 float *tmp0,
float *tmp1)
499 memcpy(src, tmp0, 768 *
sizeof(*tmp0));
500 memcpy(tmp0 + 768, src + 768, 256 *
sizeof(*tmp0));
515 combine_fft(src, src + 256, src + 512, src + 768, tmp1,
526 memcpy(src, tmp1, 1024 *
sizeof(
float));
531 float *tmp0 = c->
temp, *tmp1 = c->
temp + 1024;
533 memset(tmp0, 0,
sizeof(*tmp0) * 1024);
534 memset(tmp1, 0,
sizeof(*tmp1) * 1024);
558 memset(tmp0, 0, 64 *
sizeof(*tmp0));
596 memset(tmp0, 0, 128 *
sizeof(*tmp0));
617 float *tmp0 = c->
temp, *tmp1 = c->
temp + 1024;
619 memset(tmp0, 0,
sizeof(*tmp0) * 1024);
620 memset(tmp1, 0,
sizeof(*tmp1) * 1024);
640 memset(tmp0, 0, 64 *
sizeof(*tmp0));
672 memset(tmp0, 0, 128 *
sizeof(*tmp0));
693 for (ch = 0; ch < 2; ch++) {
696 float *saved = c->
delay[ch];
698 float *wout = out + 448;
710 for (i = 0; i < 256; i++) {
716 for (i = 0; i < 256; i++) {
719 c->
wtf(c,
buf + 512,
in + 512, 512);
723 memcpy(out, saved, 448 *
sizeof(
float));
725 memcpy(wout + 128,
buf + 64, 448 *
sizeof(
float));
726 memcpy(saved,
buf + 512, 448 *
sizeof(
float));
727 memcpy(saved + 448,
buf + 7*128 + 64, 64 *
sizeof(
float));
740 float *saved = c->
delay[channel];
762 float *wout = out + 448;
763 memcpy(out, saved, 448 *
sizeof(
float));
771 memcpy(wout + 4*128,
temp, 64 *
sizeof(
float));
774 memcpy(wout + 128,
buf + 64, 448 *
sizeof(
float));
781 memcpy(saved,
temp + 64, 64 *
sizeof(
float));
785 memcpy(saved + 448,
buf + 7*128 + 64, 64 *
sizeof(
float));
788 memcpy(saved,
buf + 512, 448 *
sizeof(
float));
789 memcpy(saved + 448,
buf + 7*128 + 64, 64 *
sizeof(
float));
793 memcpy(saved,
buf + 512, 512 *
sizeof(
float));
845 int *got_frame_ptr,
AVPacket *avpkt)
849 int buf_size = avpkt->
size;
890 frame, audio_off)) < 0)
907 for (i = 1; i < 16; i++)
934 "Stereo mode support is not good, patch is welcome\n");
936 for (i = 0; i < 20; i++)
937 c->
scale_tab[i] = ceil(pow(10.0, i * 0.1) * 16) / 32;
939 c->
scale_tab[i] = ceil(pow(10.0, i * 0.1) * 0.5);
970 for (i = 1; i < 9; i++) {
979 for (i = 9; i < 16; i++) {