diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-08-08 22:56:35 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-08-08 22:56:35 +0000 |
commit | b888fb25315ba1dd24b5bdb95246e0912bb76dca (patch) | |
tree | f54197df92f4efbe7318f82b418bc8a9ad215d80 /apps/plugins | |
parent | e559cdb916684a764fd14e4e17db15ccf5421bd2 (diff) | |
download | rockbox-b888fb25315ba1dd24b5bdb95246e0912bb76dca.tar.gz rockbox-b888fb25315ba1dd24b5bdb95246e0912bb76dca.zip |
Do the clipping with inline asm instead of a huge lookup table. Tiny speedup, and saves ~7.5KB of IRAM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10493 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/mpegplayer/idct.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/idct.c b/apps/plugins/mpegplayer/idct.c index 8a0b56ea22..5f37d7688c 100644 --- a/apps/plugins/mpegplayer/idct.c +++ b/apps/plugins/mpegplayer/idct.c | |||
@@ -47,8 +47,34 @@ void (* mpeg2_idct_add) (int last, int16_t * block, | |||
47 | * to +-3826 - this is the worst case for a column IDCT where the | 47 | * to +-3826 - this is the worst case for a column IDCT where the |
48 | * column inputs are 16-bit values. | 48 | * column inputs are 16-bit values. |
49 | */ | 49 | */ |
50 | #ifdef CPU_COLDFIRE | ||
51 | static inline unsigned CLIP(int value) | ||
52 | { | ||
53 | asm ( /* Note: Uses knowledge that only the low byte of the result is used */ | ||
54 | "cmp.l #255,%[v] \n" /* overflow? */ | ||
55 | "bls.b 1f \n" /* no: return value */ | ||
56 | "spl.b %[v] \n" /* yes: set low byte to appropriate boundary */ | ||
57 | "1: \n" | ||
58 | : /* outputs */ | ||
59 | [v]"+d"(value) | ||
60 | ); | ||
61 | return value; | ||
62 | } | ||
63 | #elif defined CPU_ARM | ||
64 | static inline unsigned CLIP(int value) | ||
65 | { | ||
66 | asm ( /* Note: Uses knowledge that only the low byte of the result is used */ | ||
67 | "cmp %[v], #255 \n" | ||
68 | "mvnhi %[v], %[v], asr #31 \n" | ||
69 | : /* outputs */ | ||
70 | [v]"+r"(value) | ||
71 | ); | ||
72 | return value; | ||
73 | } | ||
74 | #else | ||
50 | uint8_t mpeg2_clip[3840 * 2 + 256] IBSS_ATTR; | 75 | uint8_t mpeg2_clip[3840 * 2 + 256] IBSS_ATTR; |
51 | #define CLIP(i) ((mpeg2_clip + 3840)[i]) | 76 | #define CLIP(i) ((mpeg2_clip + 3840)[i]) |
77 | #endif | ||
52 | 78 | ||
53 | #if 0 | 79 | #if 0 |
54 | #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ | 80 | #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ |
@@ -275,8 +301,10 @@ void mpeg2_idct_init (uint32_t accel) | |||
275 | 301 | ||
276 | mpeg2_idct_copy = mpeg2_idct_copy_c; | 302 | mpeg2_idct_copy = mpeg2_idct_copy_c; |
277 | mpeg2_idct_add = mpeg2_idct_add_c; | 303 | mpeg2_idct_add = mpeg2_idct_add_c; |
304 | #if !defined(CPU_COLDFIRE) && !defined(CPU_ARM) | ||
278 | for (i = -3840; i < 3840 + 256; i++) | 305 | for (i = -3840; i < 3840 + 256; i++) |
279 | CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i); | 306 | CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i); |
307 | #endif | ||
280 | for (i = 0; i < 64; i++) { | 308 | for (i = 0; i < 64; i++) { |
281 | j = mpeg2_scan_norm[i]; | 309 | j = mpeg2_scan_norm[i]; |
282 | mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2); | 310 | mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2); |