diff options
Diffstat (limited to 'apps/recorder/resize.h')
-rw-r--r-- | apps/recorder/resize.h | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h index 2964fcd2a9..ef32066a0d 100644 --- a/apps/recorder/resize.h +++ b/apps/recorder/resize.h | |||
@@ -43,67 +43,61 @@ | |||
43 | #define MAX_SC_STACK_ALLOC 0 | 43 | #define MAX_SC_STACK_ALLOC 0 |
44 | #define HAVE_UPSCALER 1 | 44 | #define HAVE_UPSCALER 1 |
45 | 45 | ||
46 | #if defined(CPU_COLDFIRE) | 46 | #if defined(CPU_SH) |
47 | #define SC_MUL_INIT \ | 47 | /* perform 32x32->40 unsigned multiply, round off and return top 8 bits */ |
48 | unsigned long macsr_st = coldfire_get_macsr(); \ | 48 | static inline uint32_t sc_mul_u32_rnd(uint32_t m, uint32_t n) |
49 | coldfire_set_macsr(EMAC_UNSIGNED); | ||
50 | #define SC_MUL_END coldfire_set_macsr(macsr_st); | ||
51 | #define SC_MUL(x, y) \ | ||
52 | ({ \ | ||
53 | unsigned long t; \ | ||
54 | asm ("mac.l %[a], %[b], %%acc0\n\t" \ | ||
55 | "move.l %%accext01, %[t]\n\t" \ | ||
56 | "move.l #0, %%acc0\n\t" \ | ||
57 | : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \ | ||
58 | t; \ | ||
59 | }) | ||
60 | #elif (CONFIG_CPU == SH7034) | ||
61 | /* multiply two unsigned 32 bit values and return the top 32 bit | ||
62 | * of the 64 bit result */ | ||
63 | static inline unsigned sc_mul32(unsigned a, unsigned b) | ||
64 | { | 49 | { |
65 | unsigned r, t1, t2, t3; | 50 | unsigned r, t1, t2, t3; |
66 | 51 | unsigned h = 1 << 15; | |
52 | /* notation: | ||
53 | m = ab, n = cd | ||
54 | final result is (((a *c) << 32) + ((b * c + a * d) << 16) + b * d + | ||
55 | (1 << 31)) >> 32 | ||
56 | */ | ||
67 | asm ( | 57 | asm ( |
68 | "swap.w %[a], %[t1] \n" /* t1 = ba */ | 58 | "swap.w %[m], %[t1]\n\t" /* t1 = ba */ |
69 | "mulu %[t1], %[b] \n" /* a * d */ | 59 | "mulu %[m], %[n]\n\t" /* b * d */ |
70 | "swap.w %[b], %[t3] \n" /* t3 = dc */ | 60 | "swap.w %[n], %[t3]\n\t" /* t3 = dc */ |
71 | "sts macl, %[t2] \n" /* t2 = a * d */ | 61 | "sts macl, %[r]\n\t" /* r = b * d */ |
72 | "mulu %[t1], %[t3] \n" /* a * c */ | 62 | "mulu %[m], %[t3]\n\t" /* b * c */ |
73 | "sts macl, %[r] \n" /* hi = a * c */ | 63 | "shlr16 %[r]\n\t" |
74 | "mulu %[a], %[t3] \n" /* b * c */ | 64 | "sts macl, %[t2]\n\t" /* t2 = b * c */ |
75 | "clrt \n" | 65 | "mulu %[t1], %[t3]\n\t" /* a * c */ |
76 | "sts macl, %[t3] \n" /* t3 = b * c */ | 66 | "add %[t2], %[r]\n\t" |
77 | "addc %[t2], %[t3] \n" /* t3 += t2, carry -> t2 */ | 67 | "sts macl, %[t3]\n\t" /* t3 = a * c */ |
78 | "movt %[t2] \n" | 68 | "mulu %[t1], %[n]\n\t" /* a * d */ |
79 | "mulu %[a], %[b] \n" /* b * d */ | 69 | "shll16 %[t3]\n\t" |
80 | "mov %[t3], %[t1] \n" /* t1t3 = t2t3 << 16 */ | 70 | "sts macl, %[t2]\n\t" /* t2 = a * d */ |
81 | "xtrct %[t2], %[t1] \n" | 71 | "add %[t2], %[r]\n\t" |
82 | "shll16 %[t3] \n" | 72 | "add %[t3], %[r]\n\t" /* r = ((b * d) >> 16) + (b * c + a * d) + |
83 | "sts macl, %[t2] \n" /* lo = b * d */ | 73 | ((a * c) << 16) */ |
84 | "clrt \n" /* hi.lo += t1t3 */ | 74 | "add %[h], %[r]\n\t" /* round result */ |
85 | "addc %[t3], %[t2] \n" | 75 | "shlr16 %[r]\n\t" /* truncate result */ |
86 | "addc %[t1], %[r] \n" | ||
87 | : /* outputs */ | 76 | : /* outputs */ |
88 | [r] "=&r"(r), | 77 | [r] "=&r"(r), |
89 | [t1]"=&r"(t1), | 78 | [t1]"=&r"(t1), |
90 | [t2]"=&r"(t2), | 79 | [t2]"=&r"(t2), |
91 | [t3]"=&r"(t3) | 80 | [t3]"=&r"(t3) |
92 | : /* inputs */ | 81 | : /* inputs */ |
93 | [a] "r" (a), | 82 | [h] "r" (h), |
94 | [b] "r" (b) | 83 | [m] "r" (m), |
84 | [n] "r" (n) | ||
95 | ); | 85 | ); |
96 | return r; | 86 | return r; |
97 | } | 87 | } |
98 | #define SC_MUL(x, y) sc_mul32(x, y) | 88 | #elif defined(TEST_SH_MATH) |
99 | #define SC_MUL_INIT | 89 | static inline uint32_t sc_mul_u32_rnd(uint32_t op1, uint32_t op2) |
100 | #define SC_MUL_END | 90 | { |
91 | uint64_t tmp = (uint64_t)op1 * op2; | ||
92 | tmp += 1LU << 31; | ||
93 | tmp >>= 32; | ||
94 | return tmp; | ||
95 | } | ||
96 | #else | ||
97 | #define SC_OUT(n, c) (((n) + (1 << 23)) >> 24) | ||
101 | #endif | 98 | #endif |
102 | 99 | #ifndef SC_OUT | |
103 | #ifndef SC_MUL | 100 | #define SC_OUT(n, c) (sc_mul_u32_rnd(n, (c)->recip)) |
104 | #define SC_MUL(x, y) ((x) * (uint64_t)(y) >> 32) | ||
105 | #define SC_MUL_INIT | ||
106 | #define SC_MUL_END | ||
107 | #endif | 101 | #endif |
108 | 102 | ||
109 | struct img_part { | 103 | struct img_part { |
@@ -130,8 +124,14 @@ struct uint32_rgb { | |||
130 | horizontal scaler, and row output | 124 | horizontal scaler, and row output |
131 | */ | 125 | */ |
132 | struct scaler_context { | 126 | struct scaler_context { |
133 | uint32_t divisor; | 127 | #if defined(CPU_SH) || defined(TEST_SH_MATH) |
134 | uint32_t round; | 128 | uint32_t recip; |
129 | #else | ||
130 | uint32_t h_i_val; | ||
131 | uint32_t h_o_val; | ||
132 | uint32_t v_i_val; | ||
133 | uint32_t v_o_val; | ||
134 | #endif | ||
135 | struct bitmap *bm; | 135 | struct bitmap *bm; |
136 | struct dim *src; | 136 | struct dim *src; |
137 | unsigned char *buf; | 137 | unsigned char *buf; |