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;
144 if(in_ch_layout & out_ch_layout & (1ULL<<i))
148 unaccounted= in_ch_layout & ~out_ch_layout;
156 if(in_ch_layout & AV_CH_LAYOUT_STEREO) {
167 if(out_ch_layout & AV_CH_FRONT_CENTER){
170 if(in_ch_layout & AV_CH_FRONT_CENTER)
186 if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) {
197 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
203 if(out_ch_layout & AV_CH_BACK_CENTER){
207 if(in_ch_layout & AV_CH_SIDE_LEFT){
229 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
237 if(out_ch_layout & AV_CH_BACK_LEFT){
240 if (in_ch_layout & AV_CH_BACK_LEFT) {
247 }
else if(out_ch_layout & AV_CH_BACK_CENTER){
265 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
276 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
284 if (out_ch_layout & AV_CH_FRONT_CENTER) {
293 for(out_i=i=0; i<64; i++){
297 s->
matrix[out_i][in_i]= matrix[i][j];
299 sum += fabs(matrix[i][j]);
301 if(in_ch_layout & (1ULL<<j))
304 maxcoef=
FFMAX(maxcoef, sum);
305 if(out_ch_layout & (1ULL<<i))
323 s->
matrix[i][j] /= maxcoef;
358 for (i = 0; i < nb_out; i++)
359 for (j = 0; j < nb_in; j++)
368 for (i = 0; i < nb_out; i++)
369 for (j = 0; j < nb_in; j++)
378 for (i = 0; i < nb_out; i++)
379 for (j = 0; j < nb_in; j++)
422 int out_i, in_i, i, j;
433 off = len1 * out->
bps;
439 for(out_i=0; out_i<out->
ch_count; out_i++){
447 if(s->
matrix[out_i][in_i]!=1.0){
453 memcpy(out->
ch[out_i], in->
ch[in_i], len*out->
bps);
455 out->
ch[out_i]= in->
ch[in_i];
470 for(i=0; i<
len; i++){
474 v+= ((
float*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
476 ((
float*)out->
ch[out_i])[i]=
v;
479 for(i=0; i<
len; i++){
483 v+= ((
double*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
485 ((
double*)out->
ch[out_i])[i]=
v;
488 for(i=0; i<
len; i++){
492 v+= ((int16_t*)in->
ch[in_i])[i] * s->
matrix32[out_i][in_i];
494 ((int16_t*)out->
ch[out_i])[i]= (v + 16384)>>15;