summaryrefslogtreecommitdiffstats
path: root/libswresample
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-04-11 09:57:38 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-04-11 10:02:00 +0200
commitf9a2c5bc07fbcc6fa5bb6b53d3abe6ea3c0e3002 (patch)
tree75fdd6379dfaef6a25331cc26fa3958a64329b2f /libswresample
parent6e9c634c36f00822cdd2d49f875be128112dd668 (diff)
downloadffmpeg-streaming-f9a2c5bc07fbcc6fa5bb6b53d3abe6ea3c0e3002.zip
ffmpeg-streaming-f9a2c5bc07fbcc6fa5bb6b53d3abe6ea3c0e3002.tar.gz
swr: simplify code by using av_get_bytes_per_sample()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/rematrix.c2
-rw-r--r--libswresample/resample.c8
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:
OpenPOWER on IntegriCloud