summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/idct.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/idct.c')
-rw-r--r--apps/plugins/mpegplayer/idct.c67
1 files changed, 25 insertions, 42 deletions
diff --git a/apps/plugins/mpegplayer/idct.c b/apps/plugins/mpegplayer/idct.c
index bf7097401e..de192e3549 100644
--- a/apps/plugins/mpegplayer/idct.c
+++ b/apps/plugins/mpegplayer/idct.c
@@ -29,6 +29,27 @@
29#include "attributes.h" 29#include "attributes.h"
30#include "mpeg2_internal.h" 30#include "mpeg2_internal.h"
31 31
32/* idct main entry point */
33void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
34void (* mpeg2_idct_add) (int last, int16_t * block,
35 uint8_t * dest, int stride);
36
37#ifdef CPU_COLDFIRE
38/* assembler functions */
39extern void mpeg2_idct_copy_coldfire(int16_t * block, uint8_t * dest,
40 const int stride);
41extern void mpeg2_idct_add_coldfire(const int last, int16_t * block,
42 uint8_t * dest, const int stride);
43
44#elif defined CPU_ARM
45/* assembler functions */
46extern void mpeg2_idct_copy_arm(int16_t * block, uint8_t * dest,
47 const int stride);
48extern void mpeg2_idct_add_arm(const int last, int16_t * block,
49 uint8_t * dest, const int stride);
50
51#else /* !CPU_COLDFIE, !CPU_ARM */
52
32#define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */ 53#define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */
33#define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */ 54#define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */
34#define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */ 55#define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */
@@ -36,53 +57,14 @@
36#define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */ 57#define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */
37#define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */ 58#define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */
38 59
39/* idct main entry point */
40void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
41void (* mpeg2_idct_add) (int last, int16_t * block,
42 uint8_t * dest, int stride);
43
44/* 60/*
45 * In legal streams, the IDCT output should be between -384 and +384. 61 * In legal streams, the IDCT output should be between -384 and +384.
46 * In corrupted streams, it is possible to force the IDCT output to go 62 * In corrupted streams, it is possible to force the IDCT output to go
47 * to +-3826 - this is the worst case for a column IDCT where the 63 * to +-3826 - this is the worst case for a column IDCT where the
48 * column inputs are 16-bit values. 64 * column inputs are 16-bit values.
49 */ 65 */
50#ifdef CPU_COLDFIRE
51static 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
64static inline unsigned CLIP(int value)
65{
66 asm volatile ( /* 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
75uint8_t mpeg2_clip[3840 * 2 + 256] IBSS_ATTR; 66uint8_t mpeg2_clip[3840 * 2 + 256] IBSS_ATTR;
76#define CLIP(i) ((mpeg2_clip + 3840)[i]) 67#define CLIP(i) ((mpeg2_clip + 3840)[i])
77#endif
78
79#ifdef CPU_COLDFIRE
80/* assembler functions */
81extern void mpeg2_idct_copy_coldfire(int16_t * block, uint8_t * dest,
82 const int stride);
83extern void mpeg2_idct_add_coldfire(const int last, int16_t * block,
84 uint8_t * dest, const int stride);
85#else /* !CPU_COLDFIE */
86 68
87#if 0 69#if 0
88#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ 70#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
@@ -266,7 +248,7 @@ static void mpeg2_idct_add_c (const int last, int16_t * block,
266 } 248 }
267} 249}
268 250
269#endif /* !CPU_COLDFIRE */ 251#endif /* CPU selection */
270 252
271void mpeg2_idct_init (void) 253void mpeg2_idct_init (void)
272{ 254{
@@ -279,12 +261,13 @@ void mpeg2_idct_init (void)
279#ifdef CPU_COLDFIRE 261#ifdef CPU_COLDFIRE
280 mpeg2_idct_copy = mpeg2_idct_copy_coldfire; 262 mpeg2_idct_copy = mpeg2_idct_copy_coldfire;
281 mpeg2_idct_add = mpeg2_idct_add_coldfire; 263 mpeg2_idct_add = mpeg2_idct_add_coldfire;
264#elif defined CPU_ARM
265 mpeg2_idct_copy = mpeg2_idct_copy_arm;
266 mpeg2_idct_add = mpeg2_idct_add_arm;
282#else 267#else
283 mpeg2_idct_copy = mpeg2_idct_copy_c; 268 mpeg2_idct_copy = mpeg2_idct_copy_c;
284 mpeg2_idct_add = mpeg2_idct_add_c; 269 mpeg2_idct_add = mpeg2_idct_add_c;
285#endif
286 270
287#if !defined(CPU_COLDFIRE) && !defined(CPU_ARM)
288 for (i = -3840; i < 3840 + 256; i++) 271 for (i = -3840; i < 3840 + 256; i++)
289 CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i); 272 CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
290#endif 273#endif