diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c index a13235154c..f0e1dc0ec7 100644 --- a/libswresample/resample_template.c +++ b/libswresample/resample_template.c @@ -123,42 +123,42 @@ int RENAME(swri_resample_common)(ResampleContext *c, DELEM *dst, const DELEM *src, int n, int update_ctx) { - int dst_index; - int index= c->index; - int frac= c->frac; - int dst_incr_frac= c->dst_incr % c->src_incr; - int dst_incr= c->dst_incr / c->src_incr; - int sample_index = index >> c->phase_shift; + int dst_index; + int index= c->index; + int frac= c->frac; + int dst_incr_frac= c->dst_incr % c->src_incr; + int dst_incr= c->dst_incr / c->src_incr; + int sample_index = index >> c->phase_shift; - index &= c->phase_mask; - for (dst_index = 0; dst_index < n; dst_index++) { - FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; + index &= c->phase_mask; + for (dst_index = 0; dst_index < n; dst_index++) { + FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; #ifdef COMMON_CORE - COMMON_CORE + COMMON_CORE #else - FELEM2 val=0; - int i; - for (i = 0; i < c->filter_length; i++) { - val += src[sample_index + i] * (FELEM2)filter[i]; - } - OUT(dst[dst_index], val); + FELEM2 val=0; + int i; + for (i = 0; i < c->filter_length; i++) { + val += src[sample_index + i] * (FELEM2)filter[i]; + } + OUT(dst[dst_index], val); #endif - frac += dst_incr_frac; - index += dst_incr; - if (frac >= c->src_incr) { - frac -= c->src_incr; - index++; - } - sample_index += index >> c->phase_shift; - index &= c->phase_mask; - } - - if(update_ctx){ - c->frac= frac; - c->index= index; - } + frac += dst_incr_frac; + index += dst_incr; + if (frac >= c->src_incr) { + frac -= c->src_incr; + index++; + } + sample_index += index >> c->phase_shift; + index &= c->phase_mask; + } + + if(update_ctx){ + c->frac= frac; + c->index= index; + } return sample_index; } @@ -167,44 +167,44 @@ int RENAME(swri_resample_linear)(ResampleContext *c, DELEM *dst, const DELEM *src, int n, int update_ctx) { - int dst_index; - int index= c->index; - int frac= c->frac; - int dst_incr_frac= c->dst_incr % c->src_incr; - int dst_incr= c->dst_incr / c->src_incr; - int sample_index = index >> c->phase_shift; - - index &= c->phase_mask; - for (dst_index = 0; dst_index < n; dst_index++) { - FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; - FELEM2 val=0, v2 = 0; + int dst_index; + int index= c->index; + int frac= c->frac; + int dst_incr_frac= c->dst_incr % c->src_incr; + int dst_incr= c->dst_incr / c->src_incr; + int sample_index = index >> c->phase_shift; + + index &= c->phase_mask; + for (dst_index = 0; dst_index < n; dst_index++) { + FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; + FELEM2 val=0, v2 = 0; #ifdef LINEAR_CORE - LINEAR_CORE + LINEAR_CORE #else - int i; - for (i = 0; i < c->filter_length; i++) { - val += src[sample_index + i] * (FELEM2)filter[i]; - v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc]; - } + int i; + for (i = 0; i < c->filter_length; i++) { + val += src[sample_index + i] * (FELEM2)filter[i]; + v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc]; + } #endif - val += (v2 - val) * (FELEML) frac / c->src_incr; - OUT(dst[dst_index], val); - - frac += dst_incr_frac; - index += dst_incr; - if (frac >= c->src_incr) { - frac -= c->src_incr; - index++; - } - sample_index += index >> c->phase_shift; - index &= c->phase_mask; - } - - if(update_ctx){ - c->frac= frac; - c->index= index; - } + val += (v2 - val) * (FELEML) frac / c->src_incr; + OUT(dst[dst_index], val); + + frac += dst_incr_frac; + index += dst_incr; + if (frac >= c->src_incr) { + frac -= c->src_incr; + index++; + } + sample_index += index >> c->phase_shift; + index &= c->phase_mask; + } + + if(update_ctx){ + c->frac= frac; + c->index= index; + } return sample_index; }