Commit f9a2c5bc authored by Michael Niedermayer's avatar Michael Niedermayer

swr: simplify code by using av_get_bytes_per_sample()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 6e9c634c
...@@ -290,7 +290,7 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus ...@@ -290,7 +290,7 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus
for(out_i=0; out_i<out->ch_count; out_i++){ for(out_i=0; out_i<out->ch_count; out_i++){
switch(s->matrix_ch[out_i][0]){ switch(s->matrix_ch[out_i][0]){
case 0: case 0:
memset(out->ch[out_i], 0, len * (s->int_sample_fmt == AV_SAMPLE_FMT_FLT ? sizeof(float) : sizeof(int16_t))); memset(out->ch[out_i], 0, len * av_get_bytes_per_sample(s->int_sample_fmt));
break; break;
case 1: case 1:
in_i= s->matrix_ch[out_i][1]; in_i= s->matrix_ch[out_i][1];
......
...@@ -202,21 +202,17 @@ ResampleContext *swri_resample_init(ResampleContext *c, int out_rate, int in_rat ...@@ -202,21 +202,17 @@ ResampleContext *swri_resample_init(ResampleContext *c, int out_rate, int in_rat
c->format= format; c->format= format;
c->felem_size= av_get_bytes_per_sample(c->format);
switch(c->format){ switch(c->format){
case AV_SAMPLE_FMT_S16: case AV_SAMPLE_FMT_S16:
c->felem_size = 2;
c->filter_shift = 15; c->filter_shift = 15;
break; break;
case AV_SAMPLE_FMT_S32: case AV_SAMPLE_FMT_S32:
c->felem_size = 4;
c->filter_shift = 30; c->filter_shift = 30;
break; break;
case AV_SAMPLE_FMT_FLT: case AV_SAMPLE_FMT_FLT:
c->felem_size = 4;
c->filter_shift = 0;
break;
case AV_SAMPLE_FMT_DBL: case AV_SAMPLE_FMT_DBL:
c->felem_size = 8;
c->filter_shift = 0; c->filter_shift = 0;
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment