summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-05-08 04:19:10 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-05-08 04:19:10 +0000
commit0af7494b372dc1b2b4612f811c625bb0edae6dae (patch)
tree4318899cc82ce2f720ae69e2680cc777b36fd2fb
parentcda907435b737359ec5c085c9b82fee4c9063ad0 (diff)
downloadrockbox-0af7494b372dc1b2b4612f811c625bb0edae6dae.zip
rockbox-0af7494b372dc1b2b4612f811c625bb0edae6dae.tar.gz
rockbox-0af7494b372dc1b2b4612f811c625bb0edae6dae.tar.bz2
rockbox-0af7494b372dc1b2b4612f811c625bb0edae6dae.tar.xz
Small size improvement for JPEG on ARM/Coldfire.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20873 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/recorder/jpeg_load.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c
index 5b16e6f..99ab611 100644
--- a/apps/recorder/jpeg_load.c
+++ b/apps/recorder/jpeg_load.c
@@ -1647,6 +1647,8 @@ static void search_restart(struct jpeg *p_jpeg)
}
/* Figure F.12: extend sign bit. */
+#if CONFIG_CPU == SH7034
+/* SH1 lacks a variable-shift instruction */
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
static const int extend_test[16] = /* entry n is 2**(n-1) */
@@ -1662,6 +1664,15 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1
};
+#else
+/* This saves some code and data size, benchmarks about the same on RAM */
+#define HUFF_EXTEND(x,s) \
+({ \
+ int x__ = x; \
+ int s__ = s; \
+ x__ & (1 << (s__- 1)) ? x__ : x__ + (-1 << s__) + 1; \
+})
+#endif
/* Decode a single value */
INLINE int huff_decode_dc(struct jpeg *p_jpeg, struct derived_tbl* tbl)