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;
118 double matrix[64][64]={{0}};
119 int64_t unaccounted, in_ch_layout, out_ch_layout;
140 if(in_ch_layout & out_ch_layout & (1ULL<<i))
144 unaccounted= in_ch_layout & ~out_ch_layout;
152 if(in_ch_layout & AV_CH_LAYOUT_STEREO) {
163 if(out_ch_layout & AV_CH_FRONT_CENTER){
166 if(in_ch_layout & AV_CH_FRONT_CENTER)
182 if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) {
193 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
199 if(out_ch_layout & AV_CH_BACK_CENTER){
203 if(in_ch_layout & AV_CH_SIDE_LEFT){
225 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
233 if(out_ch_layout & AV_CH_BACK_LEFT){
236 if (in_ch_layout & AV_CH_BACK_LEFT) {
243 }
else if(out_ch_layout & AV_CH_BACK_CENTER){
261 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
272 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
280 if (out_ch_layout & AV_CH_FRONT_CENTER) {
289 for(out_i=i=0; i<64; i++){
293 s->
matrix[out_i][in_i]= matrix[i][j];
295 sum += fabs(matrix[i][j]);
297 if(in_ch_layout & (1ULL<<j))
300 maxcoef=
FFMAX(maxcoef, sum);
301 if(out_ch_layout & (1ULL<<i))
311 s->
matrix[i][j] /= maxcoef;
346 for (i = 0; i < nb_out; i++)
347 for (j = 0; j < nb_in; j++)
356 for (i = 0; i < nb_out; i++)
357 for (j = 0; j < nb_in; j++)
366 for (i = 0; i < nb_out; i++)
367 for (j = 0; j < nb_in; j++)
410 int out_i, in_i, i, j;
421 off = len1 * out->
bps;
427 for(out_i=0; out_i<out->
ch_count; out_i++){
435 if(s->
matrix[out_i][in_i]!=1.0){
441 memcpy(out->
ch[out_i], in->
ch[in_i], len*out->
bps);
443 out->
ch[out_i]= in->
ch[in_i];
458 for(i=0; i<
len; i++){
462 v+= ((
float*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
464 ((
float*)out->
ch[out_i])[i]=
v;
467 for(i=0; i<
len; i++){
471 v+= ((
double*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
473 ((
double*)out->
ch[out_i])[i]=
v;
476 for(i=0; i<
len; i++){
480 v+= ((int16_t*)in->
ch[in_i])[i] * s->
matrix32[out_i][in_i];
482 ((int16_t*)out->
ch[out_i])[i]= (v + 16384)>>15;