From bafc3e84dfcd846d4adecf14dbec0d535ece57cd Mon Sep 17 00:00:00 2001 From: unhelpful Date: Fri, 8 May 2009 04:19:10 +0000 Subject: [PATCH] Small size improvement for JPEG on ARM/Coldfire. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20873 a1c6a512-1295-4272-9138-f99709370657 --- apps/recorder/jpeg_load.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c index 5b16e6f96..99ab61154 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) -- 2.11.4.GIT