[FFmpeg-cvslog] swr/resample: optimize C code for the most common case
Michael Niedermayer
git at videolan.org
Tue Jun 19 03:20:25 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Jun 18 23:02:44 2012 +0200| [80e857c967ff063def0ffc2499d1c78b8d6d130b] | committer: Michael Niedermayer
swr/resample: optimize C code for the most common case
15% speedup
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=80e857c967ff063def0ffc2499d1c78b8d6d130b
---
libswresample/resample_template.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c
index 0523add..4060c66 100644
--- a/libswresample/resample_template.c
+++ b/libswresample/resample_template.c
@@ -48,6 +48,28 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int
index += dst_index * dst_incr;
index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
+ }else if(compensation_distance == 0 && !c->linear && index >= 0){
+ for(dst_index=0; dst_index < dst_size; dst_index++){
+ FELEM *filter= ((FELEM*)c->filter_bank) + c->filter_length*(index & c->phase_mask);
+ int sample_index= index >> c->phase_shift;
+
+ if(sample_index + c->filter_length > src_size){
+ break;
+ }else{
+ FELEM2 val=0;
+ for(i=0; i<c->filter_length; i++){
+ val += src[sample_index + i] * (FELEM2)filter[i];
+ }
+ OUT(dst[dst_index], val);
+ }
+
+ 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= ((FELEM*)c->filter_bank) + c->filter_length*(index & c->phase_mask);
More information about the ffmpeg-cvslog
mailing list