diff options
-rw-r--r-- | apps/recorder/resize.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index 55b8f77ca9..e75638140b 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c | |||
@@ -60,6 +60,15 @@ | |||
60 | #define DEBUGF(...) | 60 | #define DEBUGF(...) |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | #if CONFIG_CPU == SH7034 | ||
64 | /* 16*16->32 bit multiplication is a single instrcution on the SH1 */ | ||
65 | #define MULUQ(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b)))) | ||
66 | #define MULQ(a, b) ((int32_t) (((int16_t) (a)) * ((int16_t) (b)))) | ||
67 | #else | ||
68 | #define MULUQ(a, b) ((a) * (b)) | ||
69 | #define MULQ(a, b) ((a) * (b)) | ||
70 | #endif | ||
71 | |||
63 | /* calculate the maximum dimensions which will preserve the aspect ration of | 72 | /* calculate the maximum dimensions which will preserve the aspect ration of |
64 | src while fitting in the constraints passed in dst, and store result in dst, | 73 | src while fitting in the constraints passed in dst, and store result in dst, |
65 | returning 0 if rounding and 1 if not rounding. | 74 | returning 0 if rounding and 1 if not rounding. |
@@ -208,12 +217,12 @@ static bool scale_h_area(void *out_line_ptr, | |||
208 | oxe -= ctx->src->width; | 217 | oxe -= ctx->src->width; |
209 | 218 | ||
210 | /* add saved partial pixel from start of area */ | 219 | /* add saved partial pixel from start of area */ |
211 | acc = acc * ctx->bm->width + tmp * mul; | 220 | acc = MULUQ(acc, ctx->bm->width) + MULUQ(tmp, mul); |
212 | 221 | ||
213 | /* get new pixel , then add its partial coverage to this area */ | 222 | /* get new pixel , then add its partial coverage to this area */ |
214 | tmp = *(part->buf); | 223 | tmp = *(part->buf); |
215 | mul = ctx->bm->width - oxe; | 224 | mul = ctx->bm->width - oxe; |
216 | acc += tmp * mul; | 225 | acc += MULUQ(tmp, mul); |
217 | /* round, divide, and either store or accumulate to output row */ | 226 | /* round, divide, and either store or accumulate to output row */ |
218 | if (accum) | 227 | if (accum) |
219 | { | 228 | { |
@@ -402,7 +411,7 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
402 | ixe -= (ctx->bm->width - 1); | 411 | ixe -= (ctx->bm->width - 1); |
403 | val = *(part->buf); | 412 | val = *(part->buf); |
404 | inc = -val; | 413 | inc = -val; |
405 | val *= (ctx->bm->width - 1); | 414 | val = MULUQ(val, ctx->bm->width - 1); |
406 | ix += 1; | 415 | ix += 1; |
407 | /* If this wasn't the last pixel, add the next one to rgbinc. */ | 416 | /* If this wasn't the last pixel, add the next one to rgbinc. */ |
408 | if (ix < (uint32_t)ctx->src->width) { | 417 | if (ix < (uint32_t)ctx->src->width) { |
@@ -414,10 +423,10 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
414 | /* Add a partial step to rgbval, in this pixel isn't precisely | 423 | /* Add a partial step to rgbval, in this pixel isn't precisely |
415 | aligned with the new source pixel | 424 | aligned with the new source pixel |
416 | */ | 425 | */ |
417 | val += inc * ixe; | 426 | val += MULQ(inc, ixe); |
418 | } | 427 | } |
419 | /* Now multiply the color increment to its proper value */ | 428 | /* Now multiply the color increment to its proper value */ |
420 | inc *= ctx->src->width - 1; | 429 | inc = MULQ(inc, ctx->src->width - 1); |
421 | } else | 430 | } else |
422 | val += inc; | 431 | val += inc; |
423 | /* round and scale values, and accumulate or store to output */ | 432 | /* round and scale values, and accumulate or store to output */ |