94 float c_re,
float c_im,
95 float mag_totall,
float mag_totalr,
96 float fl_phase,
float fr_phase,
97 float bl_phase,
float br_phase,
98 float sl_phase,
float sr_phase,
103 float c_re,
float c_im,
104 float lfe_re,
float lfe_im,
105 float mag_totall,
float mag_totalr,
106 float fl_phase,
float fr_phase,
107 float bl_phase,
float br_phase,
108 float sl_phase,
float sr_phase,
162 for (ch = 0; ch < inlink->
channels; ch++) {
204 for (ch = 0; ch < outlink->
channels; ch++) {
237 float *lfe_mag,
float *mag_total)
239 if (output_lfe && n < highcut) {
240 *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+
cosf(
M_PI*(lowcut-n)/(lowcut-highcut)));
241 *lfe_mag *= *mag_total;
242 *mag_total -= *lfe_mag;
261 mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
263 dst[2 *
n ] = mag *
cosf(c_phase);
264 dst[2 * n + 1] = mag *
sinf(c_phase);
276 float l_mag, r_mag, *dstl, *dstr;
281 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
282 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
284 dstl[2 *
n ] = l_mag *
cosf(l_phase);
285 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
287 dstr[2 *
n ] = r_mag *
cosf(r_phase);
288 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
300 float lfe_mag, l_mag, r_mag, *dstl, *dstr, *dstlfe;
308 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
309 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
311 dstl[2 *
n ] = l_mag *
cosf(l_phase);
312 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
314 dstr[2 *
n ] = r_mag *
cosf(r_phase);
315 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
317 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
318 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
330 float l_mag, r_mag, c_mag, *dstc, *dstl, *dstr;
336 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
337 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
338 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
340 dstl[2 *
n ] = l_mag *
cosf(l_phase);
341 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
343 dstr[2 *
n ] = r_mag *
cosf(r_phase);
344 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
346 dstc[2 *
n ] = c_mag *
cosf(c_phase);
347 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
359 float lfe_mag, l_mag, r_mag, c_mag, *dstc, *dstl, *dstr, *dstlfe;
368 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
369 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
370 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
372 dstl[2 *
n ] = l_mag *
cosf(l_phase);
373 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
375 dstr[2 *
n ] = r_mag *
cosf(r_phase);
376 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
378 dstc[2 *
n ] = c_mag *
cosf(c_phase);
379 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
381 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
382 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
395 float lfe_mag, l_mag, r_mag, *dstc, *dstl, *dstr, *dstlfe;
404 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
405 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
407 dstl[2 *
n ] = l_mag *
cosf(l_phase);
408 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
410 dstr[2 *
n ] = r_mag *
cosf(r_phase);
411 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
413 dstc[2 *
n ] = c_mag *
cosf(c_phase);
414 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
416 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
417 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
428 float b_mag, l_mag, r_mag, c_mag, *dstc, *dstl, *dstr, *dstb;
436 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
437 b_mag = sqrtf(1.f - fabsf(x)) * ((1.f - y) * .5f) * mag_total;
438 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
439 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
441 dstl[2 *
n ] = l_mag *
cosf(l_phase);
442 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
444 dstr[2 *
n ] = r_mag *
cosf(r_phase);
445 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
447 dstc[2 *
n ] = c_mag *
cosf(c_phase);
448 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
450 dstb[2 *
n ] = b_mag *
cosf(c_phase);
451 dstb[2 * n + 1] = b_mag *
sinf(c_phase);
462 float lfe_mag, b_mag, l_mag, r_mag, c_mag, *dstc, *dstl, *dstr, *dstb, *dstlfe;
473 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
474 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
476 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
477 b_mag = sqrtf(1.f - fabsf(x)) * ((1.f - y) * .5f) * mag_total;
478 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
479 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
481 dstl[2 *
n ] = l_mag *
cosf(l_phase);
482 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
484 dstr[2 *
n ] = r_mag *
cosf(r_phase);
485 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
487 dstc[2 *
n ] = c_mag *
cosf(c_phase);
488 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
490 dstb[2 *
n ] = b_mag *
cosf(c_phase);
491 dstb[2 * n + 1] = b_mag *
sinf(c_phase);
502 float l_mag, r_mag, ls_mag, rs_mag, c_mag, *dstc, *dstl, *dstr, *dstls, *dstrs;
511 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
512 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
513 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
514 ls_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
515 rs_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
517 dstl[2 *
n ] = l_mag *
cosf(l_phase);
518 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
520 dstr[2 *
n ] = r_mag *
cosf(r_phase);
521 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
523 dstc[2 *
n ] = c_mag *
cosf(c_phase);
524 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
526 dstls[2 *
n ] = ls_mag *
cosf(l_phase);
527 dstls[2 * n + 1] = ls_mag *
sinf(l_phase);
529 dstrs[2 *
n ] = rs_mag *
cosf(r_phase);
530 dstrs[2 * n + 1] = rs_mag *
sinf(r_phase);
541 float lfe_mag, l_mag, r_mag, ls_mag, rs_mag, c_mag, *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlfe;
553 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
554 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
555 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
556 ls_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
557 rs_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
559 dstl[2 *
n ] = l_mag *
cosf(l_phase);
560 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
562 dstr[2 *
n ] = r_mag *
cosf(r_phase);
563 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
565 dstc[2 *
n ] = c_mag *
cosf(c_phase);
566 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
568 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
569 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
571 dstls[2 *
n ] = ls_mag *
cosf(l_phase);
572 dstls[2 * n + 1] = ls_mag *
sinf(l_phase);
574 dstrs[2 *
n ] = rs_mag *
cosf(r_phase);
575 dstrs[2 * n + 1] = rs_mag *
sinf(r_phase);
588 float lfe_mag, l_mag, r_mag, *dstc, *dstl, *dstr, *dstlfe;
589 float ls_mag, rs_mag, *dstls, *dstrs;
600 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
601 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
602 ls_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
603 rs_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
605 dstl[2 *
n ] = l_mag *
cosf(l_phase);
606 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
608 dstr[2 *
n ] = r_mag *
cosf(r_phase);
609 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
611 dstc[2 *
n ] = c_mag *
cosf(c_phase);
612 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
614 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
615 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
617 dstls[2 *
n ] = ls_mag *
cosf(l_phase);
618 dstls[2 * n + 1] = ls_mag *
sinf(l_phase);
620 dstrs[2 *
n ] = rs_mag *
cosf(r_phase);
621 dstrs[2 * n + 1] = rs_mag *
sinf(r_phase);
635 float c_mag, l_mag, r_mag, *dstc, *dstl, *dstr, *dstlfe;
636 float ls_mag, rs_mag, *dstls, *dstrs;
645 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
646 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
647 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
648 ls_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
649 rs_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
651 dstl[2 *
n ] = l_mag *
cosf(l_phase);
652 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
654 dstr[2 *
n ] = r_mag *
cosf(r_phase);
655 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
657 dstc[2 *
n ] = c_mag *
cosf(c_phase);
658 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
660 dstlfe[2 *
n ] = lfe_re;
661 dstlfe[2 * n + 1] = lfe_im;
663 dstls[2 *
n ] = ls_mag *
cosf(l_phase);
664 dstls[2 * n + 1] = ls_mag *
sinf(l_phase);
666 dstrs[2 *
n ] = rs_mag *
cosf(r_phase);
667 dstrs[2 * n + 1] = rs_mag *
sinf(r_phase);
678 float l_mag, r_mag, ls_mag, rs_mag, c_mag, lb_mag, rb_mag;
679 float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb;
690 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
691 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
692 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
693 lb_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
694 rb_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
695 ls_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - fabsf(y)) * mag_total;
696 rs_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - fabsf(y)) * mag_total;
698 dstl[2 *
n ] = l_mag *
cosf(l_phase);
699 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
701 dstr[2 *
n ] = r_mag *
cosf(r_phase);
702 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
704 dstc[2 *
n ] = c_mag *
cosf(c_phase);
705 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
707 dstlb[2 *
n ] = lb_mag *
cosf(l_phase);
708 dstlb[2 * n + 1] = lb_mag *
sinf(l_phase);
710 dstrb[2 *
n ] = rb_mag *
cosf(r_phase);
711 dstrb[2 * n + 1] = rb_mag *
sinf(r_phase);
713 dstls[2 *
n ] = ls_mag *
cosf(l_phase);
714 dstls[2 * n + 1] = ls_mag *
sinf(l_phase);
716 dstrs[2 *
n ] = rs_mag *
cosf(r_phase);
717 dstrs[2 * n + 1] = rs_mag *
sinf(r_phase);
728 float lfe_mag, l_mag, r_mag, ls_mag, rs_mag, c_mag, lb_mag, rb_mag;
729 float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb, *dstlfe;
743 c_mag = sqrtf(1.f - fabsf(x)) * ((y + 1.f) * .5f) * mag_total;
744 l_mag = sqrtf(.5f * ( x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
745 r_mag = sqrtf(.5f * (-x + 1.f)) * ((y + 1.f) * .5f) * mag_total;
746 lb_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
747 rb_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - ((y + 1.f) * .5f)) * mag_total;
748 ls_mag = sqrtf(.5f * ( x + 1.f)) * (1.f - fabsf(y)) * mag_total;
749 rs_mag = sqrtf(.5f * (-x + 1.f)) * (1.f - fabsf(y)) * mag_total;
751 dstl[2 *
n ] = l_mag *
cosf(l_phase);
752 dstl[2 * n + 1] = l_mag *
sinf(l_phase);
754 dstr[2 *
n ] = r_mag *
cosf(r_phase);
755 dstr[2 * n + 1] = r_mag *
sinf(r_phase);
757 dstc[2 *
n ] = c_mag *
cosf(c_phase);
758 dstc[2 * n + 1] = c_mag *
sinf(c_phase);
760 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
761 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
763 dstlb[2 *
n ] = lb_mag *
cosf(l_phase);
764 dstlb[2 * n + 1] = lb_mag *
sinf(l_phase);
766 dstrb[2 *
n ] = rb_mag *
cosf(r_phase);
767 dstrb[2 * n + 1] = rb_mag *
sinf(r_phase);
769 dstls[2 *
n ] = ls_mag *
cosf(l_phase);
770 dstls[2 * n + 1] = ls_mag *
sinf(l_phase);
772 dstrs[2 *
n ] = rs_mag *
cosf(r_phase);
773 dstrs[2 * n + 1] = rs_mag *
sinf(r_phase);
777 float c_re,
float c_im,
778 float mag_totall,
float mag_totalr,
779 float fl_phase,
float fr_phase,
780 float bl_phase,
float br_phase,
781 float sl_phase,
float sr_phase,
786 float fl_mag, fr_mag, ls_mag, rs_mag, lb_mag, rb_mag;
787 float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb, *dstlfe;
788 float lfe_mag, c_phase, mag_total = (mag_totall + mag_totalr) * 0.5;
800 c_phase =
atan2f(c_im, c_re);
804 fl_mag = sqrtf(.5f * (xl + 1.f)) * ((yl + 1.f) * .5f) * mag_totall;
805 fr_mag = sqrtf(.5f * (xr + 1.f)) * ((yr + 1.f) * .5f) * mag_totalr;
806 lb_mag = sqrtf(.5f * (-xl + 1.f)) * ((yl + 1.f) * .5f) * mag_totall;
807 rb_mag = sqrtf(.5f * (-xr + 1.f)) * ((yr + 1.f) * .5f) * mag_totalr;
808 ls_mag = sqrtf(1.f - fabsf(xl)) * ((yl + 1.f) * .5f) * mag_totall;
809 rs_mag = sqrtf(1.f - fabsf(xr)) * ((yr + 1.f) * .5f) * mag_totalr;
811 dstl[2 *
n ] = fl_mag *
cosf(fl_phase);
812 dstl[2 * n + 1] = fl_mag *
sinf(fl_phase);
814 dstr[2 *
n ] = fr_mag *
cosf(fr_phase);
815 dstr[2 * n + 1] = fr_mag *
sinf(fr_phase);
818 dstc[2 * n + 1] = c_im;
820 dstlfe[2 *
n ] = lfe_mag *
cosf(c_phase);
821 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
823 dstlb[2 *
n ] = lb_mag *
cosf(bl_phase);
824 dstlb[2 * n + 1] = lb_mag *
sinf(bl_phase);
826 dstrb[2 *
n ] = rb_mag *
cosf(br_phase);
827 dstrb[2 * n + 1] = rb_mag *
sinf(br_phase);
829 dstls[2 *
n ] = ls_mag *
cosf(sl_phase);
830 dstls[2 * n + 1] = ls_mag *
sinf(sl_phase);
832 dstrs[2 *
n ] = rs_mag *
cosf(sr_phase);
833 dstrs[2 * n + 1] = rs_mag *
sinf(sr_phase);
837 float c_re,
float c_im,
838 float lfe_re,
float lfe_im,
839 float mag_totall,
float mag_totalr,
840 float fl_phase,
float fr_phase,
841 float bl_phase,
float br_phase,
842 float sl_phase,
float sr_phase,
847 float fl_mag, fr_mag, ls_mag, rs_mag, lb_mag, rb_mag;
848 float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb, *dstlfe;
860 fl_mag = sqrtf(.5f * (xl + 1.f)) * ((yl + 1.f) * .5f) * mag_totall;
861 fr_mag = sqrtf(.5f * (xr + 1.f)) * ((yr + 1.f) * .5f) * mag_totalr;
862 lb_mag = sqrtf(.5f * (-xl + 1.f)) * ((yl + 1.f) * .5f) * mag_totall;
863 rb_mag = sqrtf(.5f * (-xr + 1.f)) * ((yr + 1.f) * .5f) * mag_totalr;
864 ls_mag = sqrtf(1.f - fabsf(xl)) * ((yl + 1.f) * .5f) * mag_totall;
865 rs_mag = sqrtf(1.f - fabsf(xr)) * ((yr + 1.f) * .5f) * mag_totalr;
867 dstl[2 *
n ] = fl_mag *
cosf(fl_phase);
868 dstl[2 * n + 1] = fl_mag *
sinf(fl_phase);
870 dstr[2 *
n ] = fr_mag *
cosf(fr_phase);
871 dstr[2 * n + 1] = fr_mag *
sinf(fr_phase);
874 dstc[2 * n + 1] = c_im;
876 dstlfe[2 *
n ] = lfe_re;
877 dstlfe[2 * n + 1] = lfe_im;
879 dstlb[2 *
n ] = lb_mag *
cosf(bl_phase);
880 dstlb[2 * n + 1] = lb_mag *
sinf(bl_phase);
882 dstrb[2 *
n ] = rb_mag *
cosf(br_phase);
883 dstrb[2 * n + 1] = rb_mag *
sinf(br_phase);
885 dstls[2 *
n ] = ls_mag *
cosf(sl_phase);
886 dstls[2 * n + 1] = ls_mag *
sinf(sl_phase);
888 dstrs[2 *
n ] = rs_mag *
cosf(sr_phase);
889 dstrs[2 * n + 1] = rs_mag *
sinf(sr_phase);
902 float l_re = srcl[2 *
n], r_re = srcr[2 *
n];
903 float l_im = srcl[2 * n + 1], r_im = srcr[2 * n + 1];
904 float c_phase =
atan2f(l_im + r_im, l_re + r_re);
905 float l_mag = hypotf(l_re, l_im);
906 float r_mag = hypotf(r_re, r_im);
907 float l_phase =
atan2f(l_im, l_re);
908 float r_phase =
atan2f(r_im, r_re);
909 float phase_dif = fabsf(l_phase - r_phase);
910 float mag_dif = (l_mag - r_mag) / (l_mag + r_mag);
911 float mag_total = hypotf(l_mag, r_mag);
914 if (phase_dif >
M_PI)
915 phase_dif = 2 *
M_PI - phase_dif;
919 s->
upmix_stereo(ctx, l_phase, r_phase, c_phase, mag_total, x, y, n);
926 float *srcl, *srcr, *srcc;
934 float l_re = srcl[2 *
n], r_re = srcr[2 *
n];
935 float l_im = srcl[2 * n + 1], r_im = srcr[2 * n + 1];
936 float c_re = srcc[2 *
n], c_im = srcc[2 * n + 1];
937 float c_mag = hypotf(c_re, c_im);
938 float c_phase =
atan2f(c_im, c_re);
939 float l_mag = hypotf(l_re, l_im);
940 float r_mag = hypotf(r_re, r_im);
941 float l_phase =
atan2f(l_im, l_re);
942 float r_phase =
atan2f(r_im, r_re);
943 float phase_dif = fabsf(l_phase - r_phase);
944 float mag_dif = (l_mag - r_mag) / (l_mag + r_mag);
945 float mag_total = hypotf(l_mag, r_mag);
948 if (phase_dif >
M_PI)
949 phase_dif = 2 *
M_PI - phase_dif;
953 s->
upmix_3_0(ctx, l_phase, r_phase, c_phase, c_mag, mag_total, x, y, n);
960 float *srcl, *srcr, *srclfe;
968 float l_re = srcl[2 *
n], r_re = srcr[2 *
n];
969 float l_im = srcl[2 * n + 1], r_im = srcr[2 * n + 1];
970 float lfe_re = srclfe[2 *
n], lfe_im = srclfe[2 * n + 1];
971 float c_phase =
atan2f(l_im + r_im, l_re + r_re);
972 float l_mag = hypotf(l_re, l_im);
973 float r_mag = hypotf(r_re, r_im);
974 float l_phase =
atan2f(l_im, l_re);
975 float r_phase =
atan2f(r_im, r_re);
976 float phase_dif = fabsf(l_phase - r_phase);
977 float mag_dif = (l_mag - r_mag) / (l_mag + r_mag);
978 float mag_total = hypotf(l_mag, r_mag);
981 if (phase_dif >
M_PI)
982 phase_dif = 2 *
M_PI - phase_dif;
986 s->
upmix_2_1(ctx, l_phase, r_phase, c_phase, mag_total, lfe_re, lfe_im, x, y, n);
993 float *srcl, *srcr, *srcc, *srcsl, *srcsr;
1003 float fl_re = srcl[2 *
n], fr_re = srcr[2 *
n];
1004 float fl_im = srcl[2 * n + 1], fr_im = srcr[2 * n + 1];
1005 float c_re = srcc[2 *
n], c_im = srcc[2 * n + 1];
1006 float sl_re = srcsl[2 *
n], sl_im = srcsl[2 * n + 1];
1007 float sr_re = srcsr[2 *
n], sr_im = srcsr[2 * n + 1];
1008 float fl_mag = hypotf(fl_re, fl_im);
1009 float fr_mag = hypotf(fr_re, fr_im);
1010 float fl_phase =
atan2f(fl_im, fl_re);
1011 float fr_phase =
atan2f(fr_im, fr_re);
1012 float sl_mag = hypotf(sl_re, sl_im);
1013 float sr_mag = hypotf(sr_re, sr_im);
1014 float sl_phase =
atan2f(sl_im, sl_re);
1015 float sr_phase =
atan2f(sr_im, sr_re);
1016 float phase_difl = fabsf(fl_phase - sl_phase);
1017 float phase_difr = fabsf(fr_phase - sr_phase);
1018 float mag_difl = (fl_mag - sl_mag) / (fl_mag + sl_mag);
1019 float mag_difr = (fr_mag - sr_mag) / (fr_mag + sr_mag);
1020 float mag_totall = hypotf(fl_mag, sl_mag);
1021 float mag_totalr = hypotf(fr_mag, sr_mag);
1022 float bl_phase =
atan2f(fl_im + sl_im, fl_re + sl_re);
1023 float br_phase =
atan2f(fr_im + sr_im, fr_re + sr_re);
1027 if (phase_difl >
M_PI)
1028 phase_difl = 2 *
M_PI - phase_difl;
1030 if (phase_difr >
M_PI)
1031 phase_difr = 2 *
M_PI - phase_difr;
1037 mag_totall, mag_totalr,
1048 float *srcl, *srcr, *srcc, *srclfe, *srcsl, *srcsr;
1058 for (n = 0; n < s->
buf_size; n++) {
1059 float fl_re = srcl[2 *
n], fr_re = srcr[2 *
n];
1060 float fl_im = srcl[2 * n + 1], fr_im = srcr[2 * n + 1];
1061 float c_re = srcc[2 *
n], c_im = srcc[2 * n + 1];
1062 float lfe_re = srclfe[2 *
n], lfe_im = srclfe[2 * n + 1];
1063 float sl_re = srcsl[2 *
n], sl_im = srcsl[2 * n + 1];
1064 float sr_re = srcsr[2 *
n], sr_im = srcsr[2 * n + 1];
1065 float fl_mag = hypotf(fl_re, fl_im);
1066 float fr_mag = hypotf(fr_re, fr_im);
1067 float fl_phase =
atan2f(fl_im, fl_re);
1068 float fr_phase =
atan2f(fr_im, fr_re);
1069 float sl_mag = hypotf(sl_re, sl_im);
1070 float sr_mag = hypotf(sr_re, sr_im);
1071 float sl_phase =
atan2f(sl_im, sl_re);
1072 float sr_phase =
atan2f(sr_im, sr_re);
1073 float phase_difl = fabsf(fl_phase - sl_phase);
1074 float phase_difr = fabsf(fr_phase - sr_phase);
1075 float mag_difl = (fl_mag - sl_mag) / (fl_mag + sl_mag);
1076 float mag_difr = (fr_mag - sr_mag) / (fr_mag + sr_mag);
1077 float mag_totall = hypotf(fl_mag, sl_mag);
1078 float mag_totalr = hypotf(fr_mag, sr_mag);
1079 float bl_phase =
atan2f(fl_im + sl_im, fl_re + sl_re);
1080 float br_phase =
atan2f(fr_im + sr_im, fr_re + sr_re);
1084 if (phase_difl >
M_PI)
1085 phase_difl = 2 *
M_PI - phase_difl;
1087 if (phase_difr >
M_PI)
1088 phase_difr = 2 *
M_PI - phase_difr;
1093 s->
upmix_5_1(ctx, c_re, c_im, lfe_re, lfe_im,
1094 mag_totall, mag_totalr,
1105 float *srcl, *srcr, *srcc, *srclfe, *srcbl, *srcbr;
1115 for (n = 0; n < s->
buf_size; n++) {
1116 float fl_re = srcl[2 *
n], fr_re = srcr[2 *
n];
1117 float fl_im = srcl[2 * n + 1], fr_im = srcr[2 * n + 1];
1118 float c_re = srcc[2 *
n], c_im = srcc[2 * n + 1];
1119 float lfe_re = srclfe[2 *
n], lfe_im = srclfe[2 * n + 1];
1120 float bl_re = srcbl[2 *
n], bl_im = srcbl[2 * n + 1];
1121 float br_re = srcbr[2 *
n], br_im = srcbr[2 * n + 1];
1122 float fl_mag = hypotf(fl_re, fl_im);
1123 float fr_mag = hypotf(fr_re, fr_im);
1124 float fl_phase =
atan2f(fl_im, fl_re);
1125 float fr_phase =
atan2f(fr_im, fr_re);
1126 float bl_mag = hypotf(bl_re, bl_im);
1127 float br_mag = hypotf(br_re, br_im);
1128 float bl_phase =
atan2f(bl_im, bl_re);
1129 float br_phase =
atan2f(br_im, br_re);
1130 float phase_difl = fabsf(fl_phase - bl_phase);
1131 float phase_difr = fabsf(fr_phase - br_phase);
1132 float mag_difl = (fl_mag - bl_mag) / (fl_mag + bl_mag);
1133 float mag_difr = (fr_mag - br_mag) / (fr_mag + br_mag);
1134 float mag_totall = hypotf(fl_mag, bl_mag);
1135 float mag_totalr = hypotf(fr_mag, br_mag);
1136 float sl_phase =
atan2f(fl_im + bl_im, fl_re + bl_re);
1137 float sr_phase =
atan2f(fr_im + br_im, fr_re + br_re);
1141 if (phase_difl >
M_PI)
1142 phase_difl = 2 *
M_PI - phase_difl;
1144 if (phase_difr >
M_PI)
1145 phase_difr = 2 *
M_PI - phase_difr;
1150 s->
upmix_5_1(ctx, c_re, c_im, lfe_re, lfe_im,
1151 mag_totall, mag_totalr,
1178 av_log(ctx,
AV_LOG_ERROR,
"Low cut-off '%d' should be less than high cut-off '%d'.\n",
1337 for (n = 0; n < s->
buf_size; n++) {
1343 memcpy(dst, ptr, s->
hop_size *
sizeof(
float));
1437 #define OFFSET(x) offsetof(AudioSurroundContext, x) 1438 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 1482 .priv_class = &surround_class,
#define AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_4POINT1
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
static int config_input(AVFilterLink *inlink)
static void stereo_position(float a, float p, float *x, float *y)
This structure describes decoded (raw) audio or video data.
static int init(AVFilterContext *ctx)
static void upmix_4_0(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
#define AV_CH_LAYOUT_SURROUND
Main libavfilter public API header.
static int query_formats(AVFilterContext *ctx)
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
static int request_frame(AVFilterLink *outlink)
static av_cold void uninit(AVFilterContext *ctx)
#define AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_7POINT0
void(* upmix_5_0)(AVFilterContext *ctx, float c_re, float c_im, float mag_totall, float mag_totalr, float fl_phase, float fr_phase, float bl_phase, float br_phase, float sl_phase, float sr_phase, float xl, float yl, float xr, float yr, int n)
#define AV_CH_LAYOUT_STEREO
struct AVFilterChannelLayouts * in_channel_layouts
#define AV_CH_LAYOUT_5POINT0
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
const char * name
Pad name.
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
AVFilterLink ** inputs
array of pointers to input links
static void upmix_3_1_surround(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float c_mag, float mag_total, float x, float y, int n)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
void(* upmix_2_1)(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float lfe_im, float lfe_re, float x, float y, int n)
static void upmix_7_1_5_1(AVFilterContext *ctx, float c_re, float c_im, float lfe_re, float lfe_im, float mag_totall, float mag_totalr, float fl_phase, float fr_phase, float bl_phase, float br_phase, float sl_phase, float sr_phase, float xl, float yl, float xr, float yr, int n)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_CH_LOW_FREQUENCY
static void filter_stereo(AVFilterContext *ctx)
#define AVERROR_EOF
End of file.
static int ifft_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
A filter pad used for either input or output.
#define AV_CH_LAYOUT_5POINT1
static void upmix_7_1(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static void filter_5_1_back(AVFilterContext *ctx)
static const AVOption surround_options[]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static void upmix_5_1_back(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
void(* upmix_3_0)(AVFilterContext *ctx, float l_phase, float r_phase, float c_mag, float c_phase, float mag_total, float x, float y, int n)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
struct AVFilterChannelLayouts * out_channel_layouts
static void upmix_5_1_back_2_1(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float lfe_re, float lfe_im, float x, float y, int n)
static void get_lfe(int output_lfe, int n, float lowcut, float highcut, float *lfe_mag, float *mag_total)
void av_rdft_calc(RDFTContext *s, FFTSample *data)
Context for an Audio FIFO Buffer.
#define FFDIFFSIGN(x, y)
Comparator.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
void(* filter)(AVFilterContext *ctx)
audio channel layout utility functions
static void upmix_4_1(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
static int config_output(AVFilterLink *outlink)
#define AV_CH_LAYOUT_3POINT1
void(* upmix_stereo)(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
static int fft_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
static const AVFilterPad outputs[]
static void filter_5_0_side(AVFilterContext *ctx)
char * out_channel_layout_str
void av_rdft_end(RDFTContext *s)
static void upmix_7_1_5_0_side(AVFilterContext *ctx, float c_re, float c_im, float mag_totall, float mag_totalr, float fl_phase, float fr_phase, float bl_phase, float br_phase, float sl_phase, float sr_phase, float xl, float yl, float xr, float yr, int n)
AVFilterContext * src
source filter
RDFTContext * av_rdft_init(int nbits, enum RDFTransformType trans)
Set up a real FFT.
#define AV_CH_FRONT_CENTER
#define AV_CH_LAYOUT_5POINT1_BACK
int format
agreed upon media format
static void upmix_1_0(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
A list of supported channel layouts.
typedef void(RENAME(mix_any_func_type))
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
#define AV_CH_LAYOUT_5POINT0_BACK
const char * name
Filter name.
static void filter_5_1_side(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_layout.
static void upmix_7_0(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void upmix_5_1_back_surround(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float c_mag, float mag_total, float x, float y, int n)
static void filter_surround(AVFilterContext *ctx)
#define AV_CH_LAYOUT_2POINT1
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
avfilter_execute_func * execute
static void upmix_3_1(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
AVFilterContext * dst
dest filter
uint64_t in_channel_layout
char * in_channel_layout_str
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
Peek data from an AVAudioFifo.
uint64_t out_channel_layout
AVFILTER_DEFINE_CLASS(surround)
#define av_malloc_array(a, b)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
uint8_t ** extended_data
pointers to the data planes/channels.
#define AV_CH_LAYOUT_MONO
static void filter_2_1(AVFilterContext *ctx)
static const AVFilterPad inputs[]
static void upmix_5_0_back(AVFilterContext *ctx, float l_phase, float r_phase, float c_phase, float mag_total, float x, float y, int n)
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_NOPTS_VALUE
Undefined timestamp value.
void(* upmix_5_1)(AVFilterContext *ctx, float c_re, float c_im, float lfe_re, float lfe_im, float mag_totall, float mag_totalr, float fl_phase, float fr_phase, float bl_phase, float br_phase, float sl_phase, float sr_phase, float xl, float yl, float xr, float yr, int n)