summaryrefslogtreecommitdiff
path: root/libavcodec/resample2.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2007-03-22 11:10:30 +0000
committerMichael Niedermayer <michaelni@gmx.at>2007-03-22 11:10:30 +0000
commit303bd95cd2a8c2df5f0726dd2e435bb31d44aced (patch)
tree91afe704940e46ff180d2cf0fa398e2d70eb8427 /libavcodec/resample2.c
parentd971a5fa8175ec6618583df5e76bde9421c8dfa8 (diff)
downloadffmpeg-303bd95cd2a8c2df5f0726dd2e435bb31d44aced.tar.gz
optimize linear filter coeff interpolation code, this also makes the code less prone to overflows
Originally committed as revision 8480 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/resample2.c')
-rw-r--r--libavcodec/resample2.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c
index e88e709e78..0cbe9b7a66 100644
--- a/libavcodec/resample2.c
+++ b/libavcodec/resample2.c
@@ -268,13 +268,12 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
}else if(sample_index + c->filter_length > src_size){
break;
}else if(c->linear){
- int64_t v=0;
- int sub_phase= (frac<<8) / c->src_incr;
+ FELEM2 v2=0;
for(i=0; i<c->filter_length; i++){
- FELEML coeff= filter[i]*(256 - sub_phase) + filter[i + c->filter_length]*sub_phase;
- v += src[sample_index + i] * coeff;
+ val += src[sample_index + i] * (FELEM2)filter[i];
+ v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
}
- val= v>>8;
+ val+=(v2-val)*(FELEML)frac / c->src_incr;
}else{
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];