diff options
author | Loren Merritt <lorenm@u.washington.edu> | 2007-09-29 23:21:57 +0000 |
---|---|---|
committer | Loren Merritt <lorenm@u.washington.edu> | 2007-09-29 23:21:57 +0000 |
commit | a309dce75fb08f9c7b4a248afab97d5ac105b9b3 (patch) | |
tree | 023c9e0b37f175ecdbc85acd772e0c906b07cf08 /libavcodec/flacenc.c | |
parent | 0b04ebb3265400a1e6208ed9200d42a526a00732 (diff) | |
download | ffmpeg-streaming-a309dce75fb08f9c7b4a248afab97d5ac105b9b3.zip ffmpeg-streaming-a309dce75fb08f9c7b4a248afab97d5ac105b9b3.tar.gz |
encode_residual_fixed(): replace FIR with finite differences.
4x faster order 2, 3.5x order 3, 3x order 4.
overall flac encoding: 35% faster at compression_levels 0-2, no effect at higher levels.
Originally committed as revision 10624 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flacenc.c')
-rw-r--r-- | libavcodec/flacenc.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 5f9d78e..e2627a8 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -840,14 +840,35 @@ static void encode_residual_fixed(int32_t *res, const int32_t *smp, int n, for(i=order; i<n; i++) res[i]= smp[i] - smp[i-1]; }else if(order==2){ - for(i=order; i<n; i++) - res[i]= smp[i] - 2*smp[i-1] + smp[i-2]; + int a = smp[order-1] - smp[order-2]; + for(i=order; i<n; i++) { + int b = smp[i] - smp[i-1]; + res[i]= b - a; + a = b; + } }else if(order==3){ - for(i=order; i<n; i++) - res[i]= smp[i] - 3*smp[i-1] + 3*smp[i-2] - smp[i-3]; + int a = smp[order-1] - smp[order-2]; + int c = smp[order-1] - 2*smp[order-2] + smp[order-3]; + for(i=order; i<n; i++) { + int b = smp[i] - smp[i-1]; + int d = b - a; + res[i]= d - c; + a = b; + c = d; + } }else{ - for(i=order; i<n; i++) - res[i]= smp[i] - 4*smp[i-1] + 6*smp[i-2] - 4*smp[i-3] + smp[i-4]; + int a = smp[order-1] - smp[order-2]; + int c = smp[order-1] - 2*smp[order-2] + smp[order-3]; + int e = smp[order-1] - 3*smp[order-2] + 3*smp[order-3] - smp[order-4]; + for(i=order; i<n; i++) { + int b = smp[i] - smp[i-1]; + int d = b - a; + int f = d - c; + res[i]= f - e; + a = b; + c = d; + e = f; + } } } |