aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/resample2.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-12-31 17:37:23 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-12-31 17:37:23 +0000
commit53f0090dcc779da3537736d7e0bab26a1ea2120a (patch)
tree78008e61dfc7fe640b149106a0c1f97a7cb395b1 /libavcodec/resample2.c
parent17bfbd70ab458717faaa06874fbe08a884b5524a (diff)
downloadffmpeg-53f0090dcc779da3537736d7e0bab26a1ea2120a.tar.gz
faster and slightly less accurate nearest neighbor resampler
Originally committed as revision 3789 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/resample2.c')
-rw-r--r--libavcodec/resample2.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c
index c713030c8a..0a9e44ef02 100644
--- a/libavcodec/resample2.c
+++ b/libavcodec/resample2.c
@@ -193,22 +193,20 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
int dst_incr_frac= c->dst_incr % c->src_incr;
int dst_incr= c->dst_incr / c->src_incr;
int compensation_distance= c->compensation_distance;
-
+
if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){
- assert(index >= 0);
+ int64_t index2= ((int64_t)index)<<32;
+ int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
+ dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr);
+
for(dst_index=0; dst_index < dst_size; dst_index++){
- if(index < src_size)
- dst[dst_index] = src[index];
- else
- break;
-
- frac += dst_incr_frac;
- index += dst_incr;
- if(frac >= c->src_incr){
- frac -= c->src_incr;
- index++;
- }
+ dst[dst_index] = src[index2>>32];
+ index2 += incr;
}
+ frac += dst_index * dst_incr_frac;
+ index += dst_index * dst_incr;
+ index += frac / c->src_incr;
+ frac %= c->src_incr;
}else{
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);