swr: simplify code by using av_get_bytes_per_sample()
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 11 Apr 2012 07:57:38 +0000 (09:57 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 11 Apr 2012 08:02:00 +0000 (10:02 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/rematrix.c
libswresample/resample.c

index 845f854..4431979 100644 (file)
@@ -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++){
         switch(s->matrix_ch[out_i][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;
         case 1:
             in_i= s->matrix_ch[out_i][1];
index cdd00ba..806aba8 100644 (file)
@@ -202,21 +202,17 @@ ResampleContext *swri_resample_init(ResampleContext *c, int out_rate, int in_rat
 
         c->format= format;
 
+        c->felem_size= av_get_bytes_per_sample(c->format);
+
         switch(c->format){
         case AV_SAMPLE_FMT_S16:
-            c->felem_size   = 2;
             c->filter_shift = 15;
             break;
         case AV_SAMPLE_FMT_S32:
-            c->felem_size   = 4;
             c->filter_shift = 30;
             break;
         case AV_SAMPLE_FMT_FLT:
-            c->felem_size   = 4;
-            c->filter_shift = 0;
-            break;
         case AV_SAMPLE_FMT_DBL:
-            c->felem_size   = 8;
             c->filter_shift = 0;
             break;
         default: