[FFmpeg-cvslog] avcodec/apedec: Factor constant sign out of loop in long_filter_high_3800()
Michael Niedermayer
git at videolan.org
Mon May 1 02:04:41 EEST 2023
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Apr 23 23:54:50 2023 +0200| [b2a3279dbe1f1c6a2b9c36a6137281c828b5d0e4] | committer: Michael Niedermayer
avcodec/apedec: Factor constant sign out of loop in long_filter_high_3800()
930 -> 850 cycles
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b2a3279dbe1f1c6a2b9c36a6137281c828b5d0e4
---
libavcodec/apedec.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 40cd78a991..772636afde 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -955,9 +955,20 @@ static void long_filter_high_3800(int32_t *buffer, int order, int shift, int len
for (i = order; i < length; i++) {
dotprod = 0;
sign = APESIGN(buffer[i]);
- for (j = 0; j < order; j++) {
- dotprod += delayp[j] * (unsigned)coeffs[j];
- coeffs[j] += ((delayp[j] >> 31) | 1) * sign;
+ if (sign == 1) {
+ for (j = 0; j < order; j++) {
+ dotprod += delayp[j] * (unsigned)coeffs[j];
+ coeffs[j] += (delayp[j] >> 31) | 1;
+ }
+ } else if (sign == -1) {
+ for (j = 0; j < order; j++) {
+ dotprod += delayp[j] * (unsigned)coeffs[j];
+ coeffs[j] -= (delayp[j] >> 31) | 1;
+ }
+ } else {
+ for (j = 0; j < order; j++) {
+ dotprod += delayp[j] * (unsigned)coeffs[j];
+ }
}
buffer[i] -= (unsigned)(dotprod >> shift);
delayp ++;
More information about the ffmpeg-cvslog
mailing list