131 float c_re,
float c_im,
132 float mag_totall,
float mag_totalr,
133 float fl_phase,
float fr_phase,
134 float bl_phase,
float br_phase,
135 float sl_phase,
float sr_phase,
140 float c_re,
float c_im,
141 float lfe_re,
float lfe_im,
142 float mag_totall,
float mag_totalr,
143 float fl_phase,
float fr_phase,
144 float bl_phase,
float br_phase,
145 float sl_phase,
float sr_phase,
190 for (
int ch = 0; ch <
s->nb_in_channels &&
s->level_in >= 0.f; ch++)
191 s->input_levels[ch] =
s->level_in;
197 s->input_levels[ch] =
s->f_i[n];
205 for (
int ch = 0; ch <
s->nb_out_channels &&
s->level_out >= 0.f; ch++)
206 s->output_levels[ch] =
s->level_out;
212 s->output_levels[ch] =
s->f_o[n];
225 s->nb_in_channels =
inlink->ch_layout.nb_channels;
227 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
231 0,
s->win_size, &
scale, 0);
237 if (!
s->input_levels)
254 s->lowcut = 1.f *
s->lowcutf / (
inlink->sample_rate * 0.5) * (
s->win_size / 2);
255 s->highcut = 1.f *
s->highcutf / (
inlink->sample_rate * 0.5) * (
s->win_size / 2);
275 1,
s->win_size, &iscale, 0);
281 if (!
s->output_levels)
293 if (!
s->overlap_buffer || !
s->output || !
s->output_out || !
s->output_mag ||
294 !
s->output_ph || !
s->factors || !
s->sfactors)
297 s->rdft_size =
s->win_size / 2 + 1;
301 s->l_phase =
av_calloc(
s->rdft_size,
sizeof(*
s->l_phase));
302 s->r_phase =
av_calloc(
s->rdft_size,
sizeof(*
s->r_phase));
304 s->c_phase =
av_calloc(
s->rdft_size,
sizeof(*
s->c_phase));
305 s->mag_total =
av_calloc(
s->rdft_size,
sizeof(*
s->mag_total));
306 s->lfe_mag =
av_calloc(
s->rdft_size,
sizeof(*
s->lfe_mag));
307 s->lfe_phase =
av_calloc(
s->rdft_size,
sizeof(*
s->lfe_phase));
308 if (!
s->x_pos || !
s->y_pos || !
s->l_phase || !
s->r_phase || !
s->lfe_phase ||
309 !
s->c_phase || !
s->mag_total || !
s->lfe_mag || !
s->c_mag)
325 #define MIN_MAG_SUM 0.00000001f
329 float reference,
r,
a;
334 reference = angle *
M_PIf / 180.f;
361 r = focus > 0.f ? 1.f -
powf(1.
f -
r, 1.
f + focus * 20.
f) :
powf(
r, 1.
f - focus * 20.
f);
375 static inline void get_lfe(
int output_lfe,
int n,
float lowcut,
float highcut,
376 float *lfe_mag,
float c_mag,
float *mag_total,
int lfe_mode)
378 if (output_lfe && n < highcut) {
379 *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+
cosf(
M_PIf*(lowcut-n)/(lowcut-highcut)));
382 *mag_total -= *lfe_mag;
389 dst[2 * n ] = mag * cosf(ph); \
390 dst[2 * n + 1] = mag * sinf(ph);
395 float *
factor = (
float *)
s->factors->extended_data[ch];
396 const float f_x =
s->f_x[
sc_map[chan >= 0 ? chan : 0]];
397 const float f_y =
s->f_y[
sc_map[chan >= 0 ? chan : 0]];
398 const int rdft_size =
s->rdft_size;
399 const float *x =
s->x_pos;
400 const float *y =
s->y_pos;
404 for (
int n = 0; n < rdft_size; n++)
408 for (
int n = 0; n < rdft_size; n++)
412 for (
int n = 0; n < rdft_size; n++)
416 for (
int n = 0; n < rdft_size; n++)
420 for (
int n = 0; n < rdft_size; n++)
424 for (
int n = 0; n < rdft_size; n++)
428 for (
int n = 0; n < rdft_size; n++)
432 for (
int n = 0; n < rdft_size; n++)
436 for (
int n = 0; n < rdft_size; n++)
440 for (
int n = 0; n < rdft_size; n++)
449 float *sfactor = (
float *)
s->sfactors->extended_data[ch];
450 float *
factor = (
float *)
s->factors->extended_data[ch];
451 float *omag = (
float *)
s->output_mag->extended_data[ch];
452 float *oph = (
float *)
s->output_ph->extended_data[ch];
453 float *dst = (
float *)
s->output->extended_data[ch];
454 const int rdft_size =
s->rdft_size;
455 const float smooth =
s->smooth;
458 for (
int n = 0; n < rdft_size; n++)
464 for (
int n = 0; n < rdft_size; n++)
467 for (
int n = 0; n < rdft_size; n++) {
468 const float mag = omag[n];
469 const float ph = oph[n];
478 float *omag = (
float *)
s->output_mag->extended_data[ch];
479 float *oph = (
float *)
s->output_ph->extended_data[ch];
480 const float *mag_total =
s->mag_total;
481 const int rdft_size =
s->rdft_size;
482 const float *c_phase =
s->c_phase;
483 const float *l_phase =
s->l_phase;
484 const float *r_phase =
s->r_phase;
485 const float *lfe_mag =
s->lfe_mag;
486 const float *c_mag =
s->c_mag;
490 memcpy(omag, c_mag, rdft_size *
sizeof(*omag));
493 memcpy(omag, lfe_mag, rdft_size *
sizeof(*omag));
502 memcpy(omag, mag_total, rdft_size *
sizeof(*omag));
512 memcpy(oph, c_phase, rdft_size *
sizeof(*oph));
517 memcpy(oph, l_phase, rdft_size *
sizeof(*oph));
522 memcpy(oph, r_phase, rdft_size *
sizeof(*oph));
545 float *omag = (
float *)
s->output_mag->extended_data[ch];
546 float *oph = (
float *)
s->output_ph->extended_data[ch];
547 const float *mag_total =
s->mag_total;
548 const float *lfe_phase =
s->lfe_phase;
549 const int rdft_size =
s->rdft_size;
550 const float *c_phase =
s->c_phase;
551 const float *l_phase =
s->l_phase;
552 const float *r_phase =
s->r_phase;
553 const float *lfe_mag =
s->lfe_mag;
554 const float *c_mag =
s->c_mag;
567 memcpy(omag, c_mag, rdft_size *
sizeof(*omag));
570 memcpy(omag, lfe_mag, rdft_size *
sizeof(*omag));
579 memcpy(omag, mag_total, rdft_size *
sizeof(*omag));
587 memcpy(oph, lfe_phase, rdft_size *
sizeof(*oph));
591 memcpy(oph, c_phase, rdft_size *
sizeof(*oph));
596 memcpy(oph, l_phase, rdft_size *
sizeof(*oph));
601 memcpy(oph, r_phase, rdft_size *
sizeof(*oph));
630 float c_re,
float c_im,
631 float mag_totall,
float mag_totalr,
632 float fl_phase,
float fr_phase,
633 float bl_phase,
float br_phase,
634 float sl_phase,
float sr_phase,
639 float fl_mag, fr_mag, ls_mag, rs_mag, lb_mag, rb_mag;
640 float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb, *dstlfe;
641 float lfe_mag, c_phase, mag_total = (mag_totall + mag_totalr) * 0.5
f;
644 dstl = (
float *)
s->output->extended_data[0];
645 dstr = (
float *)
s->output->extended_data[1];
646 dstc = (
float *)
s->output->extended_data[2];
647 dstlfe = (
float *)
s->output->extended_data[3];
648 dstlb = (
float *)
s->output->extended_data[4];
649 dstrb = (
float *)
s->output->extended_data[5];
650 dstls = (
float *)
s->output->extended_data[6];
651 dstrs = (
float *)
s->output->extended_data[7];
653 c_phase =
atan2f(c_im, c_re);
655 get_lfe(
s->output_lfe, n,
s->lowcut,
s->highcut, &lfe_mag, hypotf(c_re, c_im), &mag_total,
s->lfe_mode);
664 dstl[2 * n ] = fl_mag *
cosf(fl_phase);
665 dstl[2 * n + 1] = fl_mag *
sinf(fl_phase);
667 dstr[2 * n ] = fr_mag *
cosf(fr_phase);
668 dstr[2 * n + 1] = fr_mag *
sinf(fr_phase);
671 dstc[2 * n + 1] = c_im;
673 dstlfe[2 * n ] = lfe_mag *
cosf(c_phase);
674 dstlfe[2 * n + 1] = lfe_mag *
sinf(c_phase);
676 dstlb[2 * n ] = lb_mag *
cosf(bl_phase);
677 dstlb[2 * n + 1] = lb_mag *
sinf(bl_phase);
679 dstrb[2 * n ] = rb_mag *
cosf(br_phase);
680 dstrb[2 * n + 1] = rb_mag *
sinf(br_phase);
682 dstls[2 * n ] = ls_mag *
cosf(sl_phase);
683 dstls[2 * n + 1] = ls_mag *
sinf(sl_phase);
685 dstrs[2 * n ] = rs_mag *
cosf(sr_phase);
686 dstrs[2 * n + 1] = rs_mag *
sinf(sr_phase);
690 float c_re,
float c_im,
691 float lfe_re,
float lfe_im,
692 float mag_totall,
float mag_totalr,
693 float fl_phase,
float fr_phase,
694 float bl_phase,
float br_phase,
695 float sl_phase,
float sr_phase,
700 float fl_mag, fr_mag, ls_mag, rs_mag, lb_mag, rb_mag;
701 float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb, *dstlfe;
704 dstl = (
float *)
s->output->extended_data[0];
705 dstr = (
float *)
s->output->extended_data[1];
706 dstc = (
float *)
s->output->extended_data[2];
707 dstlfe = (
float *)
s->output->extended_data[3];
708 dstlb = (
float *)
s->output->extended_data[4];
709 dstrb = (
float *)
s->output->extended_data[5];
710 dstls = (
float *)
s->output->extended_data[6];
711 dstrs = (
float *)
s->output->extended_data[7];
720 dstl[2 * n ] = fl_mag *
cosf(fl_phase);
721 dstl[2 * n + 1] = fl_mag *
sinf(fl_phase);
723 dstr[2 * n ] = fr_mag *
cosf(fr_phase);
724 dstr[2 * n + 1] = fr_mag *
sinf(fr_phase);
727 dstc[2 * n + 1] = c_im;
729 dstlfe[2 * n ] = lfe_re;
730 dstlfe[2 * n + 1] = lfe_im;
732 dstlb[2 * n ] = lb_mag *
cosf(bl_phase);
733 dstlb[2 * n + 1] = lb_mag *
sinf(bl_phase);
735 dstrb[2 * n ] = rb_mag *
cosf(br_phase);
736 dstrb[2 * n + 1] = rb_mag *
sinf(br_phase);
738 dstls[2 * n ] = ls_mag *
cosf(sl_phase);
739 dstls[2 * n + 1] = ls_mag *
sinf(sl_phase);
741 dstrs[2 * n ] = rs_mag *
cosf(sr_phase);
742 dstrs[2 * n + 1] = rs_mag *
sinf(sr_phase);
748 const float *srcl = (
const float *)
s->input->extended_data[0];
749 const float *srcr = (
const float *)
s->input->extended_data[1];
750 const int output_lfe =
s->output_lfe &&
s->create_lfe;
751 const int rdft_size =
s->rdft_size;
752 const int lfe_mode =
s->lfe_mode;
753 const float highcut =
s->highcut;
754 const float lowcut =
s->lowcut;
755 const float angle =
s->angle;
756 const float focus =
s->focus;
757 float *magtotal =
s->mag_total;
758 float *lfemag =
s->lfe_mag;
759 float *lphase =
s->l_phase;
760 float *rphase =
s->r_phase;
761 float *cphase =
s->c_phase;
762 float *cmag =
s->c_mag;
763 float *xpos =
s->x_pos;
764 float *ypos =
s->y_pos;
766 for (
int n = 0; n < rdft_size; n++) {
767 float l_re = srcl[2 * n], r_re = srcr[2 * n];
768 float l_im = srcl[2 * n + 1], r_im = srcr[2 * n + 1];
769 float c_phase =
atan2f(l_im + r_im, l_re + r_re);
770 float l_mag = hypotf(l_re, l_im);
771 float r_mag = hypotf(r_re, r_im);
772 float mag_total = hypotf(l_mag, r_mag);
773 float l_phase =
atan2f(l_im, l_re);
774 float r_phase =
atan2f(r_im, r_re);
775 float phase_dif =
fabsf(l_phase - r_phase);
776 float mag_sum = l_mag + r_mag;
777 float c_mag = mag_sum * 0.5f;
781 mag_dif = (l_mag - r_mag) / mag_sum;
782 if (phase_dif >
M_PIf)
783 phase_dif = 2.f *
M_PIf - phase_dif;
788 get_lfe(output_lfe, n, lowcut, highcut, &lfemag[n], c_mag, &mag_total, lfe_mode);
796 magtotal[n] = mag_total;
803 const float *srcl = (
const float *)
s->input->extended_data[0];
804 const float *srcr = (
const float *)
s->input->extended_data[1];
805 const float *srclfe = (
const float *)
s->input->extended_data[2];
806 const int rdft_size =
s->rdft_size;
807 const float angle =
s->angle;
808 const float focus =
s->focus;
809 float *magtotal =
s->mag_total;
810 float *lfephase =
s->lfe_phase;
811 float *lfemag =
s->lfe_mag;
812 float *lphase =
s->l_phase;
813 float *rphase =
s->r_phase;
814 float *cphase =
s->c_phase;
815 float *cmag =
s->c_mag;
816 float *xpos =
s->x_pos;
817 float *ypos =
s->y_pos;
819 for (
int n = 0; n < rdft_size; n++) {
820 float l_re = srcl[2 * n], r_re = srcr[2 * n];
821 float l_im = srcl[2 * n + 1], r_im = srcr[2 * n + 1];
822 float lfe_re = srclfe[2 * n], lfe_im = srclfe[2 * n + 1];
823 float c_phase =
atan2f(l_im + r_im, l_re + r_re);
824 float l_mag = hypotf(l_re, l_im);
825 float r_mag = hypotf(r_re, r_im);
826 float lfe_mag = hypotf(lfe_re, lfe_im);
827 float lfe_phase =
atan2f(lfe_im, lfe_re);
828 float mag_total = hypotf(l_mag, r_mag);
829 float l_phase =
atan2f(l_im, l_re);
830 float r_phase =
atan2f(r_im, r_re);
831 float phase_dif =
fabsf(l_phase - r_phase);
832 float mag_sum = l_mag + r_mag;
833 float c_mag = mag_sum * 0.5f;
837 mag_dif = (l_mag - r_mag) / mag_sum;
838 if (phase_dif >
M_PIf)
839 phase_dif = 2.f *
M_PIf - phase_dif;
852 lfephase[n] = lfe_phase;
853 magtotal[n] = mag_total;
860 const float *srcl = (
const float *)
s->input->extended_data[0];
861 const float *srcr = (
const float *)
s->input->extended_data[1];
862 const float *srcc = (
const float *)
s->input->extended_data[2];
863 const int output_lfe =
s->output_lfe &&
s->create_lfe;
864 const int rdft_size =
s->rdft_size;
865 const int lfe_mode =
s->lfe_mode;
866 const float highcut =
s->highcut;
867 const float lowcut =
s->lowcut;
868 const float angle =
s->angle;
869 const float focus =
s->focus;
870 float *magtotal =
s->mag_total;
871 float *lfemag =
s->lfe_mag;
872 float *lphase =
s->l_phase;
873 float *rphase =
s->r_phase;
874 float *cphase =
s->c_phase;
875 float *cmag =
s->c_mag;
876 float *xpos =
s->x_pos;
877 float *ypos =
s->y_pos;
879 for (
int n = 0; n < rdft_size; n++) {
880 float l_re = srcl[2 * n], r_re = srcr[2 * n];
881 float l_im = srcl[2 * n + 1], r_im = srcr[2 * n + 1];
882 float c_re = srcc[2 * n], c_im = srcc[2 * n + 1];
883 float c_phase =
atan2f(c_im, c_re);
884 float c_mag = hypotf(c_re, c_im);
885 float l_mag = hypotf(l_re, l_im);
886 float r_mag = hypotf(r_re, r_im);
887 float mag_total = hypotf(l_mag, r_mag);
888 float l_phase =
atan2f(l_im, l_re);
889 float r_phase =
atan2f(r_im, r_re);
890 float phase_dif =
fabsf(l_phase - r_phase);
891 float mag_sum = l_mag + r_mag;
895 mag_dif = (l_mag - r_mag) / mag_sum;
896 if (phase_dif >
M_PIf)
897 phase_dif = 2.f *
M_PIf - phase_dif;
902 get_lfe(output_lfe, n, lowcut, highcut, &lfemag[n], c_mag, &mag_total, lfe_mode);
910 magtotal[n] = mag_total;
917 const int rdft_size =
s->rdft_size;
918 float *srcl, *srcr, *srcc, *srcsl, *srcsr;
921 srcl = (
float *)
s->input->extended_data[0];
922 srcr = (
float *)
s->input->extended_data[1];
923 srcc = (
float *)
s->input->extended_data[2];
924 srcsl = (
float *)
s->input->extended_data[3];
925 srcsr = (
float *)
s->input->extended_data[4];
927 for (n = 0; n < rdft_size; n++) {
928 float fl_re = srcl[2 * n], fr_re = srcr[2 * n];
929 float fl_im = srcl[2 * n + 1], fr_im = srcr[2 * n + 1];
930 float c_re = srcc[2 * n], c_im = srcc[2 * n + 1];
931 float sl_re = srcsl[2 * n], sl_im = srcsl[2 * n + 1];
932 float sr_re = srcsr[2 * n], sr_im = srcsr[2 * n + 1];
933 float fl_mag = hypotf(fl_re, fl_im);
934 float fr_mag = hypotf(fr_re, fr_im);
935 float fl_phase =
atan2f(fl_im, fl_re);
936 float fr_phase =
atan2f(fr_im, fr_re);
937 float sl_mag = hypotf(sl_re, sl_im);
938 float sr_mag = hypotf(sr_re, sr_im);
939 float sl_phase =
atan2f(sl_im, sl_re);
940 float sr_phase =
atan2f(sr_im, sr_re);
941 float phase_difl =
fabsf(fl_phase - sl_phase);
942 float phase_difr =
fabsf(fr_phase - sr_phase);
943 float magl_sum = fl_mag + sl_mag;
944 float magr_sum = fr_mag + sr_mag;
947 float mag_totall = hypotf(fl_mag, sl_mag);
948 float mag_totalr = hypotf(fr_mag, sr_mag);
949 float bl_phase =
atan2f(fl_im + sl_im, fl_re + sl_re);
950 float br_phase =
atan2f(fr_im + sr_im, fr_re + sr_re);
954 if (phase_difl >
M_PIf)
955 phase_difl = 2.f *
M_PIf - phase_difl;
957 if (phase_difr >
M_PIf)
958 phase_difr = 2.f *
M_PIf - phase_difr;
963 s->upmix_5_0(
ctx, c_re, c_im,
964 mag_totall, mag_totalr,
975 const int rdft_size =
s->rdft_size;
976 float *srcl, *srcr, *srcc, *srclfe, *srcsl, *srcsr;
979 srcl = (
float *)
s->input->extended_data[0];
980 srcr = (
float *)
s->input->extended_data[1];
981 srcc = (
float *)
s->input->extended_data[2];
982 srclfe = (
float *)
s->input->extended_data[3];
983 srcsl = (
float *)
s->input->extended_data[4];
984 srcsr = (
float *)
s->input->extended_data[5];
986 for (n = 0; n < rdft_size; n++) {
987 float fl_re = srcl[2 * n], fr_re = srcr[2 * n];
988 float fl_im = srcl[2 * n + 1], fr_im = srcr[2 * n + 1];
989 float c_re = srcc[2 * n], c_im = srcc[2 * n + 1];
990 float lfe_re = srclfe[2 * n], lfe_im = srclfe[2 * n + 1];
991 float sl_re = srcsl[2 * n], sl_im = srcsl[2 * n + 1];
992 float sr_re = srcsr[2 * n], sr_im = srcsr[2 * n + 1];
993 float fl_mag = hypotf(fl_re, fl_im);
994 float fr_mag = hypotf(fr_re, fr_im);
995 float fl_phase =
atan2f(fl_im, fl_re);
996 float fr_phase =
atan2f(fr_im, fr_re);
997 float sl_mag = hypotf(sl_re, sl_im);
998 float sr_mag = hypotf(sr_re, sr_im);
999 float sl_phase =
atan2f(sl_im, sl_re);
1000 float sr_phase =
atan2f(sr_im, sr_re);
1001 float phase_difl =
fabsf(fl_phase - sl_phase);
1002 float phase_difr =
fabsf(fr_phase - sr_phase);
1003 float magl_sum = fl_mag + sl_mag;
1004 float magr_sum = fr_mag + sr_mag;
1005 float mag_difl = magl_sum <
MIN_MAG_SUM ?
FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
1006 float mag_difr = magr_sum <
MIN_MAG_SUM ?
FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
1007 float mag_totall = hypotf(fl_mag, sl_mag);
1008 float mag_totalr = hypotf(fr_mag, sr_mag);
1009 float bl_phase =
atan2f(fl_im + sl_im, fl_re + sl_re);
1010 float br_phase =
atan2f(fr_im + sr_im, fr_re + sr_re);
1014 if (phase_difl >
M_PIf)
1015 phase_difl = 2.f *
M_PIf - phase_difl;
1017 if (phase_difr >
M_PIf)
1018 phase_difr = 2.f *
M_PIf - phase_difr;
1023 s->upmix_5_1(
ctx, c_re, c_im, lfe_re, lfe_im,
1024 mag_totall, mag_totalr,
1035 const int rdft_size =
s->rdft_size;
1036 float *srcl, *srcr, *srcc, *srclfe, *srcbl, *srcbr;
1039 srcl = (
float *)
s->input->extended_data[0];
1040 srcr = (
float *)
s->input->extended_data[1];
1041 srcc = (
float *)
s->input->extended_data[2];
1042 srclfe = (
float *)
s->input->extended_data[3];
1043 srcbl = (
float *)
s->input->extended_data[4];
1044 srcbr = (
float *)
s->input->extended_data[5];
1046 for (n = 0; n < rdft_size; n++) {
1047 float fl_re = srcl[2 * n], fr_re = srcr[2 * n];
1048 float fl_im = srcl[2 * n + 1], fr_im = srcr[2 * n + 1];
1049 float c_re = srcc[2 * n], c_im = srcc[2 * n + 1];
1050 float lfe_re = srclfe[2 * n], lfe_im = srclfe[2 * n + 1];
1051 float bl_re = srcbl[2 * n], bl_im = srcbl[2 * n + 1];
1052 float br_re = srcbr[2 * n], br_im = srcbr[2 * n + 1];
1053 float fl_mag = hypotf(fl_re, fl_im);
1054 float fr_mag = hypotf(fr_re, fr_im);
1055 float fl_phase =
atan2f(fl_im, fl_re);
1056 float fr_phase =
atan2f(fr_im, fr_re);
1057 float bl_mag = hypotf(bl_re, bl_im);
1058 float br_mag = hypotf(br_re, br_im);
1059 float bl_phase =
atan2f(bl_im, bl_re);
1060 float br_phase =
atan2f(br_im, br_re);
1061 float phase_difl =
fabsf(fl_phase - bl_phase);
1062 float phase_difr =
fabsf(fr_phase - br_phase);
1063 float magl_sum = fl_mag + bl_mag;
1064 float magr_sum = fr_mag + br_mag;
1065 float mag_difl = magl_sum <
MIN_MAG_SUM ?
FFDIFFSIGN(fl_mag, bl_mag) : (fl_mag - bl_mag) / magl_sum;
1066 float mag_difr = magr_sum <
MIN_MAG_SUM ?
FFDIFFSIGN(fr_mag, br_mag) : (fr_mag - br_mag) / magr_sum;
1067 float mag_totall = hypotf(fl_mag, bl_mag);
1068 float mag_totalr = hypotf(fr_mag, br_mag);
1069 float sl_phase =
atan2f(fl_im + bl_im, fl_re + bl_re);
1070 float sr_phase =
atan2f(fr_im + br_im, fr_re + br_re);
1074 if (phase_difl >
M_PIf)
1075 phase_difl = 2.f *
M_PIf - phase_difl;
1077 if (phase_difr >
M_PIf)
1078 phase_difr = 2.f *
M_PIf - phase_difr;
1083 s->upmix_5_1(
ctx, c_re, c_im, lfe_re, lfe_im,
1084 mag_totall, mag_totalr,
1096 if (
s->all_x >= 0.f)
1097 for (
int n = 0; n <
SC_NB; n++)
1098 s->f_x[n] =
s->all_x;
1100 if (
s->all_y >= 0.f)
1101 for (
int n = 0; n <
SC_NB; n++)
1102 s->f_y[n] =
s->all_y;
1109 int64_t in_channel_layout, out_channel_layout;
1115 s->out_channel_layout_str);
1121 s->in_channel_layout_str);
1125 if (
s->lowcutf >=
s->highcutf) {
1127 s->lowcutf,
s->highcutf);
1132 s->in_ch_layout.u.mask : 0;
1134 s->out_ch_layout.u.mask : 0;
1139 switch (in_channel_layout) {
1154 switch (out_channel_layout) {
1164 switch (out_channel_layout) {
1174 switch (out_channel_layout) {
1185 s->in_channel_layout_str,
s->out_channel_layout_str);
1189 s->window_func_lut =
av_calloc(
s->win_size,
sizeof(*
s->window_func_lut));
1190 if (!
s->window_func_lut)
1194 if (
s->overlap == 1)
1195 s->overlap = overlap;
1197 for (
int i = 0;
i <
s->win_size;
i++)
1198 s->window_func_lut[
i] =
sqrtf(
s->window_func_lut[
i] /
s->win_size);
1199 s->hop_size =
FFMAX(1,
s->win_size * (1. -
s->overlap));
1202 float max = 0.f, *temp_lut =
av_calloc(
s->win_size,
sizeof(*temp_lut));
1206 for (
int j = 0; j <
s->win_size; j +=
s->hop_size) {
1207 for (
int i = 0;
i <
s->win_size;
i++)
1208 temp_lut[(
i + j) %
s->win_size] +=
s->window_func_lut[
i];
1211 for (
int i = 0;
i <
s->win_size;
i++)
1215 s->win_gain = 1.f / (
max *
sqrtf(
s->win_size));
1226 float *
src = (
float *)
s->input_in->extended_data[ch];
1227 float *
win = (
float *)
s->window->extended_data[ch];
1228 const int offset =
s->win_size -
s->hop_size;
1229 const float level_in =
s->input_levels[ch];
1235 for (
int n = 0; n <
s->win_size; n++)
1236 win[n] =
src[n] *
s->window_func_lut[n] * level_in;
1238 s->tx_fn(
s->rdft[ch], (
float *)
s->input->extended_data[ch],
win,
sizeof(
float));
1249 for (
int ch = start; ch < end; ch++)
1258 const float level_out =
s->output_levels[ch] *
s->win_gain;
1261 dst = (
float *)
s->output_out->extended_data[ch];
1262 ptr = (
float *)
s->overlap_buffer->extended_data[ch];
1263 s->itx_fn(
s->irdft[ch], dst, (
float *)
s->output->extended_data[ch],
sizeof(
AVComplexFloat));
1265 memmove(
s->overlap_buffer->extended_data[ch],
1266 s->overlap_buffer->extended_data[ch] +
s->hop_size *
sizeof(
float),
1267 s->win_size *
sizeof(
float));
1268 memset(
s->overlap_buffer->extended_data[ch] +
s->win_size *
sizeof(
float),
1269 0,
s->hop_size *
sizeof(
float));
1271 for (
int n = 0; n <
s->win_size; n++)
1272 ptr[n] += dst[n] *
s->window_func_lut[n] * level_out;
1274 ptr = (
float *)
s->overlap_buffer->extended_data[ch];
1275 dst = (
float *)
out->extended_data[ch];
1276 memcpy(dst, ptr,
s->hop_size *
sizeof(
float));
1285 const int start = (
out->ch_layout.nb_channels * jobnr) / nb_jobs;
1286 const int end = (
out->ch_layout.nb_channels * (jobnr+1)) / nb_jobs;
1288 for (
int ch = start; ch < end; ch++) {
1375 for (
int ch = 0; ch <
s->nb_in_channels; ch++)
1377 for (
int ch = 0; ch <
s->nb_out_channels; ch++)
1397 char *res,
int res_len,
int flags)
1406 s->hop_size =
FFMAX(1,
s->win_size * (1. -
s->overlap));
1415 #define OFFSET(x) offsetof(AudioSurroundContext, x)
1416 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
1417 #define TFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
1497 .priv_class = &surround_class,