aboutsummaryrefslogtreecommitdiffstats
path: root/libswresample
diff options
context:
space:
mode:
authorMuhammad Faiz <mfcc64@gmail.com>2017-03-01 22:18:36 +0700
committerMuhammad Faiz <mfcc64@gmail.com>2017-03-08 16:09:38 +0700
commit61926b6c3e560283ef6c015d6d85c32716942833 (patch)
tree3e8d792b00cb2f55032103034fde319cda700968 /libswresample
parentdbc932e745fe4dc9ffbe48d0332a95cbbaa2b228 (diff)
downloadffmpeg-61926b6c3e560283ef6c015d6d85c32716942833.tar.gz
swresample/resample: use uniform normalization
this gives better frequency response update swresample fate and other fates that depend on resampling Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/resample.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libswresample/resample.c b/libswresample/resample.c
index 8e2f76901a..b0d14d1e95 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -149,6 +149,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
double *tab = av_malloc_array(tap_count+1, sizeof(*tab));
double *sin_lut = av_malloc_array(ph_nb, sizeof(*sin_lut));
const int center= (tap_count-1)/2;
+ double norm = 0;
int ret = AVERROR(ENOMEM);
if (!tab || !sin_lut)
@@ -160,10 +161,9 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
if (factor == 1.0) {
for (ph = 0; ph < ph_nb; ph++)
- sin_lut[ph] = sin(M_PI * ph / phase_count);
+ sin_lut[ph] = sin(M_PI * ph / phase_count) * (center & 1 ? 1 : -1);
}
for(ph = 0; ph < ph_nb; ph++) {
- double norm = 0;
s = sin_lut[ph];
for(i=0;i<=tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
@@ -194,7 +194,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
tab[i] = y;
s = -s;
- if (i < tap_count)
+ if (!ph && i < tap_count)
norm += y;
}
@@ -211,7 +211,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
else {
for (i = 1; i <= tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
- av_clip_int16(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
+ av_clip_int16(lrintf(tab[i] * scale / norm));
}
break;
case AV_SAMPLE_FMT_S32P:
@@ -225,7 +225,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
else {
for (i = 1; i <= tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
- av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
+ av_clipl_int32(llrint(tab[i] * scale / norm));
}
break;
case AV_SAMPLE_FMT_FLTP:
@@ -238,7 +238,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
}
else {
for (i = 1; i <= tap_count; i++)
- ((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
+ ((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / norm;
}
break;
case AV_SAMPLE_FMT_DBLP:
@@ -251,7 +251,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
}
else {
for (i = 1; i <= tap_count; i++)
- ((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
+ ((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / norm;
}
break;
}