[FFmpeg-cvslog] swr: simplify code by using av_get_bytes_per_sample()

Michael Niedermayer git at videolan.org
Wed Apr 11 10:18:24 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Apr 11 09:57:38 2012 +0200| [f9a2c5bc07fbcc6fa5bb6b53d3abe6ea3c0e3002] | committer: Michael Niedermayer

swr: simplify code by using av_get_bytes_per_sample()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f9a2c5bc07fbcc6fa5bb6b53d3abe6ea3c0e3002
---

 libswresample/rematrix.c |    2 +-
 libswresample/resample.c |    8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 845f854..4431979 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -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];
diff --git a/libswresample/resample.c b/libswresample/resample.c
index cdd00ba..806aba8 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -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:



More information about the ffmpeg-cvslog mailing list