00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if defined(TEMPLATE_REMATRIX_FLT)
00022 # define R(x) x
00023 # define SAMPLE float
00024 # define COEFF float
00025 # define INTER float
00026 # define RENAME(x) x ## _float
00027 #elif defined(TEMPLATE_REMATRIX_DBL)
00028 # define R(x) x
00029 # define SAMPLE double
00030 # define COEFF double
00031 # define INTER double
00032 # define RENAME(x) x ## _double
00033 #elif defined(TEMPLATE_REMATRIX_S16)
00034 # define R(x) (((x) + 16384)>>15)
00035 # define SAMPLE int16_t
00036 # define COEFF int
00037 # define INTER int
00038 # define RENAME(x) x ## _s16
00039 #endif
00040
00041 typedef void (RENAME(mix_any_func_type))(SAMPLE **out, const SAMPLE **in1, COEFF *coeffp, integer len);
00042
00043 static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, COEFF *coeffp, integer index1, integer index2, integer len){
00044 int i;
00045 COEFF coeff1 = coeffp[index1];
00046 COEFF coeff2 = coeffp[index2];
00047
00048 for(i=0; i<len; i++)
00049 out[i] = R(coeff1*in1[i] + coeff2*in2[i]);
00050 }
00051
00052 static void RENAME(copy)(SAMPLE *out, const SAMPLE *in, COEFF *coeffp, integer index, integer len){
00053 int i;
00054 COEFF coeff = coeffp[index];
00055 for(i=0; i<len; i++)
00056 out[i] = R(coeff*in[i]);
00057 }
00058
00059 static void RENAME(mix6to2)(SAMPLE **out, const SAMPLE **in, COEFF *coeffp, integer len){
00060 int i;
00061
00062 for(i=0; i<len; i++) {
00063 INTER t = in[2][i]*coeffp[0*6+2] + in[3][i]*coeffp[0*6+3];
00064 out[0][i] = R(t + in[0][i]*coeffp[0*6+0] + in[4][i]*coeffp[0*6+4]);
00065 out[1][i] = R(t + in[1][i]*coeffp[1*6+1] + in[5][i]*coeffp[1*6+5]);
00066 }
00067 }
00068
00069 static void RENAME(mix8to2)(SAMPLE **out, const SAMPLE **in, COEFF *coeffp, integer len){
00070 int i;
00071
00072 for(i=0; i<len; i++) {
00073 INTER t = in[2][i]*coeffp[0*8+2] + in[3][i]*coeffp[0*8+3];
00074 out[0][i] = R(t + in[0][i]*coeffp[0*8+0] + in[4][i]*coeffp[0*8+4] + in[6][i]*coeffp[0*8+6]);
00075 out[1][i] = R(t + in[1][i]*coeffp[1*8+1] + in[5][i]*coeffp[1*8+5] + in[7][i]*coeffp[1*8+7]);
00076 }
00077 }
00078
00079 static RENAME(mix_any_func_type) *RENAME(get_mix_any_func)(SwrContext *s){
00080 if( s->out_ch_layout == AV_CH_LAYOUT_STEREO && (s->in_ch_layout == AV_CH_LAYOUT_5POINT1 || s->in_ch_layout == AV_CH_LAYOUT_5POINT1_BACK)
00081 && s->matrix[0][2] == s->matrix[1][2] && s->matrix[0][3] == s->matrix[1][3]
00082 && !s->matrix[0][1] && !s->matrix[0][5] && !s->matrix[1][0] && !s->matrix[1][4]
00083 )
00084 return RENAME(mix6to2);
00085
00086 if( s->out_ch_layout == AV_CH_LAYOUT_STEREO && s->in_ch_layout == AV_CH_LAYOUT_7POINT1
00087 && s->matrix[0][2] == s->matrix[1][2] && s->matrix[0][3] == s->matrix[1][3]
00088 && !s->matrix[0][1] && !s->matrix[0][5] && !s->matrix[1][0] && !s->matrix[1][4]
00089 && !s->matrix[0][7] && !s->matrix[1][6]
00090 )
00091 return RENAME(mix8to2);
00092
00093 return NULL;
00094 }
00095
00096 #undef R
00097 #undef SAMPLE
00098 #undef COEFF
00099 #undef INTER
00100 #undef RENAME