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>
This commit is contained in:
Michael Niedermayer 2016-12-10 02:03:43 +01:00
parent 34db650784
commit 65e33d8e23
1 changed files with 12 additions and 4 deletions

View File

@ -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;