[FFmpeg-cvslog] avcodec/apedec: Move pointer instead of copying each element in delay in long_filter_high_3800()
Michael Niedermayer
git at videolan.org
Mon May 1 02:04:39 EEST 2023
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Apr 23 23:51:38 2023 +0200| [eb768a75f8a0b347ab0f84c2c68959f5dbde6d4b] | committer: Michael Niedermayer
avcodec/apedec: Move pointer instead of copying each element in delay in long_filter_high_3800()
~1000 -> 930 cycles
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb768a75f8a0b347ab0f84c2c68959f5dbde6d4b
---
libavcodec/apedec.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index c08d13d6c2..40cd78a991 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -944,7 +944,7 @@ static void long_filter_high_3800(int32_t *buffer, int order, int shift, int len
{
int i, j;
int32_t dotprod, sign;
- int32_t coeffs[256], delay[256];
+ int32_t coeffs[256], delay[256+256], *delayp = delay;
if (order >= length)
return;
@@ -956,13 +956,16 @@ static void long_filter_high_3800(int32_t *buffer, int order, int shift, int len
dotprod = 0;
sign = APESIGN(buffer[i]);
for (j = 0; j < order; j++) {
- dotprod += delay[j] * (unsigned)coeffs[j];
- coeffs[j] += ((delay[j] >> 31) | 1) * sign;
+ dotprod += delayp[j] * (unsigned)coeffs[j];
+ coeffs[j] += ((delayp[j] >> 31) | 1) * sign;
}
buffer[i] -= (unsigned)(dotprod >> shift);
- for (j = 0; j < order - 1; j++)
- delay[j] = delay[j + 1];
- delay[order - 1] = buffer[i];
+ delayp ++;
+ delayp[order - 1] = buffer[i];
+ if (delayp - delay == 256) {
+ memcpy(delay, delayp, sizeof(*delay)*256);
+ delayp = delay;
+ }
}
}
More information about the ffmpeg-cvslog
mailing list