summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-04-26 15:21:43 -0400
committerMichael Sevakis <jethead71@rockbox.org>2012-04-26 16:04:43 -0400
commite5c3327cefb4e6f3a9089ad30fd12bb8f40a0658 (patch)
tree973027f2688c478bf0d30ce1ead0bfc24dae766b /lib
parent2866063c3cff10814f0e2e6c5263c7ee6d4c7fa1 (diff)
downloadrockbox-e5c3327cefb4e6f3a9089ad30fd12bb8f40a0658.zip
rockbox-e5c3327cefb4e6f3a9089ad30fd12bb8f40a0658.tar.gz
rockbox-e5c3327cefb4e6f3a9089ad30fd12bb8f40a0658.tar.bz2
rockbox-e5c3327cefb4e6f3a9089ad30fd12bb8f40a0658.tar.xz
Add a more correct absolute difference function to dsp-util.
Differences between signed samples cover the entire unsigned 32-bit range. "abs" will think any difference exceeding INT32_MAX is negative which is not corrent. Test which argument is greater and subtract the lesser from it, outputting unsigned difference. Change-Id: I73a8e5e418d49ff73d1a7c98eeb4731946dcfe84
Diffstat (limited to 'lib')
-rw-r--r--lib/rbcodec/dsp/tdspeed.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/rbcodec/dsp/tdspeed.c b/lib/rbcodec/dsp/tdspeed.c
index 731be12..c2f4a3f 100644
--- a/lib/rbcodec/dsp/tdspeed.c
+++ b/lib/rbcodec/dsp/tdspeed.c
@@ -29,6 +29,7 @@
#include "system.h"
#include "tdspeed.h"
#include "settings.h"
+#include "dsp-util.h"
#define assert(cond)
@@ -308,8 +309,7 @@ static int tdspeed_apply(int32_t *buf_out[2], int32_t *buf_in[2],
for (int j = 0; j < st->dst_step; j += INC2, curr += INC2, prev += INC2)
{
- int32_t diff = *curr - *prev;
- delta += abs(diff);
+ delta += ad_s32(*curr, *prev);
if (delta >= min_delta)
goto skip;
@@ -322,8 +322,7 @@ static int tdspeed_apply(int32_t *buf_out[2], int32_t *buf_in[2],
for (int j = 0; j < st->dst_step; j += INC2, curr += INC2, prev += INC2)
{
- int32_t diff = *curr - *prev;
- delta += abs(diff);
+ delta += ad_s32(*curr, *prev);
if (delta >= min_delta)
goto skip;