diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-10 02:03:43 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-10 02:44:21 +0100 |
commit | 65e33d8e23277bb96809842656482e0e3fe8746f (patch) | |
tree | 37ac29898e85f17fac69ea9fc44ed501abcfc9fd /libswresample | |
parent | 34db650784fbc6120631c2fc9bd25c083b4be02b (diff) | |
download | ffmpeg-65e33d8e23277bb96809842656482e0e3fe8746f.tar.gz |
swresample/resample_template: Add filter values in parallel
This is faster 2871 -> 2189 cycles for int16 matrixbench -> 23456hz
Fixes a integer overflow in a artificial corner case
Fixes part of 668007-media
Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswresample')
-rw-r--r-- | libswresample/resample_template.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c index 31cf3500ab..4c227b9940 100644 --- a/libswresample/resample_template.c +++ b/libswresample/resample_template.c @@ -104,12 +104,20 @@ static int RENAME(resample_common)(ResampleContext *c, for (dst_index = 0; dst_index < n; dst_index++) { FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; - FELEM2 val= FOFFSET; + FELEM2 val = FOFFSET; + FELEM2 val2= 0; int i; - for (i = 0; i < c->filter_length; i++) { - val += src[sample_index + i] * (FELEM2)filter[i]; + for (i = 0; i + 1 < c->filter_length; i+=2) { + val += src[sample_index + i ] * (FELEM2)filter[i ]; + val2 += src[sample_index + i + 1] * (FELEM2)filter[i + 1]; } - OUT(dst[dst_index], val); + if (i < c->filter_length) + val += src[sample_index + i ] * (FELEM2)filter[i ]; +#ifdef FELEML + OUT(dst[dst_index], val + (FELEML)val2); +#else + OUT(dst[dst_index], val + val2); +#endif frac += c->dst_incr_mod; index += c->dst_incr_div; |