diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-12-31 12:58:46 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-12-31 12:58:46 +0000 |
commit | 6cb5dcb3920f04772b9a323776f6f64653a1e147 (patch) | |
tree | a30d31aed573d9643d7236f2d3bc1e9ec7525a1f /libavcodec/resample2.c | |
parent | 579448a0836d7fbd597ff5c6cab3610c753705e5 (diff) | |
download | ffmpeg-6cb5dcb3920f04772b9a323776f6f64653a1e147.tar.gz |
special case for filter_length==1
Originally committed as revision 3787 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/resample2.c')
-rw-r--r-- | libavcodec/resample2.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c index baa6a50864..c713030c8a 100644 --- a/libavcodec/resample2.c +++ b/libavcodec/resample2.c @@ -141,7 +141,7 @@ AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, c->phase_mask= phase_count-1; c->linear= linear; - c->filter_length= ceil(filter_size/factor); + c->filter_length= FFMAX(ceil(filter_size/factor), 1); c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); av_build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, 1); memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); @@ -194,6 +194,22 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int 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); + 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++; + } + } + }else{ for(dst_index=0; dst_index < dst_size; dst_index++){ FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); int sample_index= index >> c->phase_shift; @@ -234,6 +250,7 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int dst_incr= c->ideal_dst_incr / c->src_incr; } } + } *consumed= FFMAX(index, 0) >> c->phase_shift; if(index>=0) index &= c->phase_mask; |