25 #define TEMPLATE_REMATRIX_FLT
27 #undef TEMPLATE_REMATRIX_FLT
29 #define TEMPLATE_REMATRIX_DBL
31 #undef TEMPLATE_REMATRIX_DBL
33 #define TEMPLATE_REMATRIX_S16
35 #undef TEMPLATE_REMATRIX_S16
37 #define TEMPLATE_REMATRIX_S32
39 #undef TEMPLATE_REMATRIX_S32
43 #define FRONT_CENTER 2
44 #define LOW_FREQUENCY 3
47 #define FRONT_LEFT_OF_CENTER 6
48 #define FRONT_RIGHT_OF_CENTER 7
53 #define TOP_FRONT_LEFT 12
54 #define TOP_FRONT_CENTER 13
55 #define TOP_FRONT_RIGHT 14
56 #define TOP_BACK_LEFT 15
57 #define TOP_BACK_CENTER 16
58 #define TOP_BACK_RIGHT 17
62 int nb_in, nb_out,
in,
out;
69 for (out = 0; out < nb_out; out++) {
70 for (in = 0; in < nb_in; in++)
71 s->
matrix[out][in] = matrix[in];
80 if(layout&(layout-1))
return 1;
115 double matrix[64][64]={{0}};
116 int64_t unaccounted, in_ch_layout, out_ch_layout;
130 if( in_ch_layout == AV_CH_LAYOUT_STEREO_DOWNMIX
131 && (out_ch_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == 0
149 if(in_ch_layout & out_ch_layout & (1ULL<<i))
153 unaccounted= in_ch_layout & ~out_ch_layout;
161 if(in_ch_layout & AV_CH_LAYOUT_STEREO) {
172 if(out_ch_layout & AV_CH_FRONT_CENTER){
175 if(in_ch_layout & AV_CH_FRONT_CENTER)
191 if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) {
202 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
208 if(out_ch_layout & AV_CH_BACK_CENTER){
212 if(in_ch_layout & AV_CH_SIDE_LEFT){
234 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
242 if(out_ch_layout & AV_CH_BACK_LEFT){
245 if (in_ch_layout & AV_CH_BACK_LEFT) {
252 }
else if(out_ch_layout & AV_CH_BACK_CENTER){
270 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
281 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
289 if (out_ch_layout & AV_CH_FRONT_CENTER) {
298 for(out_i=i=0; i<64; i++){
302 s->
matrix[out_i][in_i]= matrix[i][j];
304 sum += fabs(matrix[i][j]);
306 if(in_ch_layout & (1ULL<<j))
309 maxcoef=
FFMAX(maxcoef, sum);
310 if(out_ch_layout & (1ULL<<i))
328 s->
matrix[i][j] /= maxcoef;
363 for (i = 0; i < nb_out; i++)
364 for (j = 0; j < nb_in; j++)
373 for (i = 0; i < nb_out; i++)
374 for (j = 0; j < nb_in; j++)
383 for (i = 0; i < nb_out; i++)
384 for (j = 0; j < nb_in; j++)
427 int out_i, in_i, i, j;
438 off = len1 * out->
bps;
444 for(out_i=0; out_i<out->
ch_count; out_i++){
452 if(s->
matrix[out_i][in_i]!=1.0){
458 memcpy(out->
ch[out_i], in->
ch[in_i], len*out->
bps);
460 out->
ch[out_i]= in->
ch[in_i];
475 for(i=0; i<
len; i++){
479 v+= ((
float*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
481 ((
float*)out->
ch[out_i])[i]=
v;
484 for(i=0; i<
len; i++){
488 v+= ((
double*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
490 ((
double*)out->
ch[out_i])[i]=
v;
493 for(i=0; i<
len; i++){
497 v+= ((int16_t*)in->
ch[in_i])[i] * s->
matrix32[out_i][in_i];
499 ((int16_t*)out->
ch[out_i])[i]= (v + 16384)>>15;