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
59 #define NUM_NAMED_CHANNELS 18
63 int nb_in, nb_out,
in,
out;
70 for (out = 0; out < nb_out; out++) {
71 for (in = 0; in < nb_in; in++)
72 s->
matrix[out][in] = matrix[in];
81 if(layout&(layout-1))
return 1;
117 int64_t unaccounted, in_ch_layout, out_ch_layout;
131 if( in_ch_layout == AV_CH_LAYOUT_STEREO_DOWNMIX
132 && (out_ch_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == 0
150 if(in_ch_layout & out_ch_layout & (1ULL<<i))
154 unaccounted= in_ch_layout & ~out_ch_layout;
162 if(in_ch_layout & AV_CH_LAYOUT_STEREO) {
173 if(out_ch_layout & AV_CH_FRONT_CENTER){
176 if(in_ch_layout & AV_CH_FRONT_CENTER)
192 if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) {
203 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
209 if(out_ch_layout & AV_CH_BACK_CENTER){
213 if(in_ch_layout & AV_CH_SIDE_LEFT){
235 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
243 if(out_ch_layout & AV_CH_BACK_LEFT){
246 if (in_ch_layout & AV_CH_BACK_LEFT) {
253 }
else if(out_ch_layout & AV_CH_BACK_CENTER){
271 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
282 }
else if(out_ch_layout & AV_CH_FRONT_CENTER){
290 if (out_ch_layout & AV_CH_FRONT_CENTER) {
299 for(out_i=i=0; i<64; i++){
302 if((out_ch_layout & (1ULL<<i)) == 0)
305 if((in_ch_layout & (1ULL<<j)) == 0)
308 s->
matrix[out_i][in_i]= matrix[i][j];
310 s->
matrix[out_i][in_i]= i == j && (in_ch_layout & out_ch_layout & (1ULL<<i));
311 sum += fabs(s->
matrix[out_i][in_i]);
314 maxcoef=
FFMAX(maxcoef, sum);
332 s->
matrix[i][j] /= maxcoef;
367 for (i = 0; i < nb_out; i++)
368 for (j = 0; j < nb_in; j++)
377 for (i = 0; i < nb_out; i++)
378 for (j = 0; j < nb_in; j++)
387 for (i = 0; i < nb_out; i++)
388 for (j = 0; j < nb_in; j++)
418 if(HAVE_YASM && HAVE_MMX)
432 int out_i, in_i, i, j;
443 off = len1 * out->
bps;
449 for(out_i=0; out_i<out->
ch_count; out_i++){
457 if(s->
matrix[out_i][in_i]!=1.0){
463 memcpy(out->
ch[out_i], in->
ch[in_i], len*out->
bps);
465 out->
ch[out_i]= in->
ch[in_i];
480 for(i=0; i<
len; i++){
484 v+= ((
float*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
486 ((
float*)out->
ch[out_i])[i]=
v;
489 for(i=0; i<
len; i++){
493 v+= ((
double*)in->
ch[in_i])[i] * s->
matrix[out_i][in_i];
495 ((
double*)out->
ch[out_i])[i]=
v;
498 for(i=0; i<
len; i++){
502 v+= ((int16_t*)in->
ch[in_i])[i] * s->
matrix32[out_i][in_i];
504 ((int16_t*)out->
ch[out_i])[i]= (v + 16384)>>15;