rematrix: change type of integers from 16 to 32bit to allow increasing volume with it.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-10-26 00:41:26 +02:00
parent 1e40b2c22b
commit b1470d7a60
2 changed files with 6 additions and 6 deletions

View File

@ -197,7 +197,7 @@ int swr_rematrix_init(SwrContext *s){
int ch_in=0;
for(j=0; j<64; j++){
s->matrix[out_i][in_i]= matrix[i][j];
s->matrix16[out_i][in_i]= lrintf(matrix[i][j] * 32768);
s->matrix32[out_i][in_i]= lrintf(matrix[i][j] * 32768);
if(matrix[i][j]){
s->matrix_ch[out_i][++ch_in]= in_i;
sum += fabs(matrix[i][j]);
@ -215,7 +215,7 @@ int swr_rematrix_init(SwrContext *s){
for(i=0; i<SWR_CH_MAX; i++)
for(j=0; j<SWR_CH_MAX; j++){
s->matrix[i][j] /= maxcoef;
s->matrix16[i][j]= lrintf(s->matrix[i][j] * 32768);
s->matrix32[i][j]= lrintf(s->matrix[i][j] * 32768);
}
}
for(i=0; i<av_get_channel_layout_nb_channels(s->out_ch_layout); i++){
@ -241,7 +241,7 @@ int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int must
if(s->int_sample_fmt == AV_SAMPLE_FMT_FLT){
copy_float((float *)out->ch[out_i], (const float *)in->ch[in_i], s->matrix [out_i][in_i], len);
}else
copy_s16 ((int16_t*)out->ch[out_i], (const int16_t*)in->ch[in_i], s->matrix16[out_i][in_i], len);
copy_s16 ((int16_t*)out->ch[out_i], (const int16_t*)in->ch[in_i], s->matrix32[out_i][in_i], len);
}else{
out->ch[out_i]= in->ch[in_i];
}
@ -253,7 +253,7 @@ int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int must
len);
}else{
sum2_s16 ((int16_t*)out->ch[out_i], (const int16_t*)in->ch[ s->matrix_ch[out_i][1] ], (const int16_t*)in->ch[ s->matrix_ch[out_i][2] ],
s->matrix16[out_i][ s->matrix_ch[out_i][1] ], s->matrix16[out_i][ s->matrix_ch[out_i][2] ],
s->matrix32[out_i][ s->matrix_ch[out_i][1] ], s->matrix32[out_i][ s->matrix_ch[out_i][2] ],
len);
}
break;
@ -272,7 +272,7 @@ int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int must
int v=0;
for(j=0; j<s->matrix_ch[out_i][0]; j++){
in_i= s->matrix_ch[out_i][1+j];
v+= ((int16_t*)in->ch[in_i])[i] * s->matrix16[out_i][in_i];
v+= ((int16_t*)in->ch[in_i])[i] * s->matrix32[out_i][in_i];
}
((int16_t*)out->ch[out_i])[i]= (v + 16384)>>15;
}

View File

@ -62,7 +62,7 @@ typedef struct SwrContext { //FIXME find unused fields
struct AVResampleContext *resample;
float matrix[SWR_CH_MAX][SWR_CH_MAX];
int16_t matrix16[SWR_CH_MAX][SWR_CH_MAX];
int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX];
uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1];
//TODO callbacks for asm optims