Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
- index a695478..ad88bde 100644
- --- a/apps/plugins/SOURCES
- +++ b/apps/plugins/SOURCES
- @@ -47,6 +47,7 @@ disktidy.c
- flipit.c
- #ifdef HAVE_LCD_BITMAP /* Not for the Player */
- +bench_scaler.c
- rockblox1d.c
- brickmania.c
- maze.c
- diff --git a/apps/plugins/bench_scaler.c b/apps/plugins/bench_scaler.c
- index c24807d..7bdd4b9 100644
- --- a/apps/plugins/bench_scaler.c
- +++ b/apps/plugins/bench_scaler.c
- @@ -49,8 +49,8 @@ static void output_row_null(uint32_t row, void * row_in,
- #else
- uint32_t *lim = in + ctx->bm->width;
- #endif
- - for (; in < lim; in++)
- - output = SC_MUL(*in + ctx->round, ctx->divisor);
- + while (in < lim)
- + output = SC_OUT(*in++);
- return;
- }
- @@ -86,6 +86,9 @@ do { \
- /* this is the plugin entry point */
- enum plugin_status plugin_start(const void* parameter)
- {
- + int fd;
- + char logfilename[MAX_PATH];
- + char *ext;
- size_t plugin_buf_len;
- plugin_buf = (unsigned char *)rb->plugin_get_buffer(&plugin_buf_len);
- struct bitmap bm;
- @@ -96,13 +99,24 @@ enum plugin_status plugin_start(const void* parameter)
- };
- (void)parameter;
- + rb->strcpy(logfilename, rb->plugin_get_current_filename());
- + ext = logfilename + rb->strlen(logfilename) - 5;
- + if (rb->strcasecmp(ext, ".rock"))
- + ext += 5;
- + DEBUGF("ext: %s\n", ext);
- + rb->strncpy(ext, ".log", MAX_PATH - (ext - logfilename));
- + logfilename[MAX_PATH - 1] = 0;
- + DEBUGF("logfilename: %s\n", logfilename);
- + fd = rb->open(logfilename, O_APPEND|O_WRONLY|O_CREAT);
- + if (fd < 0)
- + return PLUGIN_ERROR;
- rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
- rb->lcd_fillrect(0, 0, LCD_WIDTH, LCD_HEIGHT);
- rb->lcd_set_drawmode(DRMODE_SOLID);
- rb->lcd_getstringsize("A", NULL, &font_h);
- bm.data = plugin_buf;
- int in, out;
- - for (in = 64; in < 1025; in <<= 2)
- + for (in = 64; in < 257; in <<= 2)
- {
- for (out = 64; out < 257; out <<= 1)
- {
- @@ -128,11 +142,12 @@ enum plugin_status plugin_start(const void* parameter)
- t1 = t2 / 1000;
- t2 -= t1 * 1000;
- lcd_printf("%01d.%03d secs/scale", (int)t1, (int)t2);
- + rb->fdprintf(fd,"%dx%d->%dx%d took %d.%03d secs/scale\n", in, in, out, out, (int)t1, (int)t2);
- if (!(bm.width && bm.height))
- break;
- }
- }
- -
- + rb->close(fd);
- while (rb->get_action(CONTEXT_STD,1) != ACTION_STD_OK) rb->yield();
- return PLUGIN_OK;
- }
- diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c
- index 6315ad9..521643c 100644
- --- a/apps/plugins/lib/grey_draw.c
- +++ b/apps/plugins/lib/grey_draw.c
- @@ -733,7 +733,7 @@ static void output_row_grey_32(uint32_t row, void * row_in,
- uint32_t *qp = (uint32_t*)row_in;
- uint8_t *dest = (uint8_t*)ctx->bm->data + ctx->bm->width * row;
- for (col = 0; col < ctx->bm->width; col++)
- - *dest++ = SC_MUL((*qp++) + ctx->round,ctx->divisor);
- + *dest++ = SC_OUT(*qp++);
- }
- static unsigned int get_size_grey(struct bitmap *bm)
- diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
- index c678254..2ad74df 100644
- --- a/apps/plugins/pictureflow/pictureflow.c
- +++ b/apps/plugins/pictureflow/pictureflow.c
- @@ -634,20 +634,19 @@ static void output_row_32_transposed(uint32_t row, void * row_in,
- #ifdef USEGSLIB
- uint32_t *qp = (uint32_t*)row_in;
- for (; dest < end; dest += ctx->bm->height)
- - *dest = SC_MUL((*qp++) + ctx->round, ctx->divisor);
- + *dest = SC_OUT(*qp++);
- #else
- struct uint32_rgb *qp = (struct uint32_rgb*)row_in;
- - uint32_t rb_mul = SCALE_VAL(ctx->divisor, 31),
- - rb_rnd = SCALE_VAL(ctx->round, 31),
- - g_mul = SCALE_VAL(ctx->divisor, 63),
- - g_rnd = SCALE_VAL(ctx->round, 63);
- int r, g, b;
- for (; dest < end; dest += ctx->bm->height)
- {
- - r = SC_MUL(qp->r + rb_rnd, rb_mul);
- - g = SC_MUL(qp->g + g_rnd, g_mul);
- - b = SC_MUL(qp->b + rb_rnd, rb_mul);
- + r = SC_OUT(qp->r);
- + g = SC_OUT(qp->g);
- + b = SC_OUT(qp->b);
- qp++;
- + r = SCALE_VAL(r, 31);
- + g = SCALE_VAL(g, 63);
- + b = SCALE_VAL(b, 31);
- *dest = LCD_RGBPACK_LCD(r,g,b);
- }
- #endif
- @@ -663,9 +662,9 @@ static void output_row_32_transposed_fromyuv(uint32_t row, void * row_in,
- for (; dest < end; dest += ctx->bm->height)
- {
- unsigned r, g, b, y, u, v;
- - y = SC_MUL(qp->b + ctx->round, ctx->divisor);
- - u = SC_MUL(qp->g + ctx->round, ctx->divisor);
- - v = SC_MUL(qp->r + ctx->round, ctx->divisor);
- + y = SC_OUT(qp->b);
- + u = SC_OUT(qp->g);
- + v = SC_OUT(qp->r);
- qp++;
- yuv_to_rgb(y, u, v, &r, &g, &b);
- r = (31 * r + (r >> 3) + 127) >> 8;
- diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c
- index 1e9210e..e6abbe9 100644
- --- a/apps/recorder/resize.c
- +++ b/apps/recorder/resize.c
- @@ -131,14 +131,6 @@ int recalc_dimension(struct dim *dst, struct dim *src)
- return false; \
- }
- -/* Set up rounding and scale factors for horizontal area scaler */
- -static inline void scale_h_area_setup(struct scaler_context *ctx)
- -{
- -/* sum is output value * src->width */
- - SDEBUGF("scale_h_area_setup\n");
- - ctx->divisor = ctx->src->width;
- -}
- -
- /* horizontal area average scaler */
- static bool scale_h_area(void *out_line_ptr,
- struct scaler_context *ctx, bool accum)
- @@ -159,33 +151,86 @@ static bool scale_h_area(void *out_line_ptr,
- mul = 0;
- /* give other tasks a chance to run */
- yield();
- +#ifdef CPU_COLDFIRE
- + asm volatile (
- + "move.l #0, %acc0\n\t"
- +#ifdef HAVE_LCD_COLOR
- + "move.l #0, %acc1\n\t"
- + "move.l #0, %acc2\n\t"
- +#endif
- + );
- +#endif
- for (ix = 0; ix < (unsigned int)ctx->src->width; ix++)
- {
- - oxe += ctx->bm->width;
- + oxe += ctx->h_o_val;
- /* end of current area has been reached */
- /* fill buffer if needed */
- FILL_BUF(part,ctx->store_part,ctx->args);
- #ifdef HAVE_LCD_COLOR
- - if (oxe >= (unsigned int)ctx->src->width)
- + if (oxe >= ctx->h_i_val)
- {
- /* "reset" error, which now represents partial coverage of next
- pixel by the next area
- */
- - oxe -= ctx->src->width;
- + oxe -= ctx->h_i_val;
- +#ifdef CPU_COLDFIRE
- /* add saved partial pixel from start of area */
- - rgbvalacc.r = rgbvalacc.r * ctx->bm->width + rgbvaltmp.r * mul;
- - rgbvalacc.g = rgbvalacc.g * ctx->bm->width + rgbvaltmp.g * mul;
- - rgbvalacc.b = rgbvalacc.b * ctx->bm->width + rgbvaltmp.b * mul;
- + asm volatile (
- + "mac.l %[racc], %[h_o], %%acc0\n\t"
- + "mac.l %[gacc], %[h_o], %%acc1\n\t"
- + "mac.l %[bacc], %[h_o], %%acc2\n\t"
- + "mac.l %[rtmp], %[mul], %%acc0\n\t"
- + "mac.l %[gtmp], %[mul], %%acc1\n\t"
- + "mac.l %[btmp], %[mul], %%acc2\n\t"
- + :
- + : [racc] "r" (rgbvalacc.r),
- + [gacc] "r" (rgbvalacc.g),
- + [bacc] "r" (rgbvalacc.b),
- + [rtmp] "r" (rgbvaltmp.r),
- + [gtmp] "r" (rgbvaltmp.g),
- + [btmp] "r" (rgbvaltmp.b),
- + [h_o] "r" (ctx->h_o_val),
- + [mul] "r" (mul)
- + );
- + /* get new pixel , then add its partial coverage to this area */
- + rgbvaltmp.r = part->buf->red;
- + rgbvaltmp.g = part->buf->green;
- + rgbvaltmp.b = part->buf->blue;
- + mul = ctx->h_o_val - oxe;
- + asm volatile (
- + "mac.l %[rtmp], %[mul], %%acc0\n\t"
- + "mac.l %[gtmp], %[mul], %%acc1\n\t"
- + "mac.l %[btmp], %[mul], %%acc2\n\t"
- + "movclr.l %%acc0, %[racc]\n\t"
- + "movclr.l %%acc1, %[gacc]\n\t"
- + "movclr.l %%acc2, %[bacc]\n\t"
- + : [racc] "=r" (rgbvalacc.r),
- + [gacc] "=r" (rgbvalacc.g),
- + [bacc] "=r" (rgbvalacc.b)
- + : [rtmp] "r" (rgbvaltmp.r),
- + [gtmp] "r" (rgbvaltmp.g),
- + [btmp] "r" (rgbvaltmp.b),
- + [mul] "r" (mul)
- + );
- +#else
- + /* add saved partial pixel from start of area */
- + rgbvalacc.r = rgbvalacc.r * ctx->h_o_val + rgbvaltmp.r * mul;
- + rgbvalacc.g = rgbvalacc.g * ctx->h_o_val + rgbvaltmp.g * mul;
- + rgbvalacc.b = rgbvalacc.b * ctx->h_o_val + rgbvaltmp.b * mul;
- /* get new pixel , then add its partial coverage to this area */
- rgbvaltmp.r = part->buf->red;
- rgbvaltmp.g = part->buf->green;
- rgbvaltmp.b = part->buf->blue;
- - mul = ctx->bm->width - oxe;
- + mul = ctx->h_o_val - oxe;
- rgbvalacc.r += rgbvaltmp.r * mul;
- rgbvalacc.g += rgbvaltmp.g * mul;
- rgbvalacc.b += rgbvaltmp.b * mul;
- +#endif
- + rgbvalacc.r = (rgbvalacc.r + (1 << 21)) >> 22;
- + rgbvalacc.g = (rgbvalacc.g + (1 << 21)) >> 22;
- + rgbvalacc.b = (rgbvalacc.b + (1 << 21)) >> 22;
- /* store or accumulate to output row */
- if (accum)
- {
- @@ -200,7 +245,7 @@ static bool scale_h_area(void *out_line_ptr,
- rgbvalacc.r = 0;
- rgbvalacc.g = 0;
- rgbvalacc.b = 0;
- - mul = ctx->bm->width - mul;
- + mul = ctx->h_o_val - mul;
- ox += 1;
- /* inside an area */
- } else {
- @@ -210,21 +255,45 @@ static bool scale_h_area(void *out_line_ptr,
- rgbvalacc.b += part->buf->blue;
- }
- #else
- - if (oxe >= (unsigned int)ctx->src->width)
- + if (oxe >= ctx->h_i_val)
- {
- /* "reset" error, which now represents partial coverage of next
- pixel by the next area
- */
- - oxe -= ctx->src->width;
- + oxe -= ctx->h_i_val;
- +#ifdef CPU_COLDFIRE
- + /* add saved partial pixel from start of area */
- + asm volatile (
- + "mac.l %[acc], %[h_o], %%acc0\n\t"
- + "mac.l %[tmp], %[mul], %%acc0\n\t"
- + :
- + : [acc] "r" (acc),
- + [tmp] "r" (tmp),
- + [h_o] "r" (ctx->h_o_val),
- + [mul] "r" (mul)
- + );
- + /* get new pixel , then add its partial coverage to this area */
- + tmp = *(part->buf);
- + mul = ctx->h_o_val - oxe;
- + asm volatile (
- + "mac.l %[tmp], %[mul], %%acc0\n\t"
- + "movclr.l %%acc0, %[acc]\n\t"
- + : [acc] "=r" (acc)
- + : [tmp] "r" (tmp),
- + [mul] "r" (mul)
- + );
- +#else
- /* add saved partial pixel from start of area */
- - acc = MULUQ(acc, ctx->bm->width) + MULUQ(tmp, mul);
- + acc = (acc * ctx->h_o_val) + (tmp * mul);
- /* get new pixel , then add its partial coverage to this area */
- tmp = *(part->buf);
- - mul = ctx->bm->width - oxe;
- - acc += MULUQ(tmp, mul);
- + mul = ctx->h_o_val - oxe;
- + acc += tmp * mul;
- +#endif
- /* round, divide, and either store or accumulate to output row */
- + acc = (acc + (1 << 21)) >> 22;
- if (accum)
- {
- acc += out_line[ox];
- @@ -232,7 +301,7 @@ static bool scale_h_area(void *out_line_ptr,
- out_line[ox] = acc;
- /* reset accumulator */
- acc = 0;
- - mul = ctx->bm->width - mul;
- + mul = ctx->h_o_val - mul;
- ox += 1;
- /* inside an area */
- } else {
- @@ -252,9 +321,6 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx)
- uint32_t mul, x, oy, iy, oye;
- /* Set up rounding and scale factors */
- - ctx->divisor *= ctx->src->height;
- - ctx->round = ctx->divisor >> 1;
- - ctx->divisor = 1 + (-((ctx->divisor + 1) >> 1)) / ctx->divisor;
- mul = 0;
- oy = rset->rowstart;
- oye = 0;
- @@ -271,28 +337,28 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx)
- /* zero the accumulator and temp rows */
- for (iy = 0; iy < (unsigned int)ctx->src->height; iy++)
- {
- - oye += ctx->bm->height;
- + oye += ctx->v_o_val;
- /* end of current area has been reached */
- - if (oye >= (unsigned int)ctx->src->height)
- + if (oye >= (unsigned int)ctx->v_i_val)
- {
- /* "reset" error, which now represents partial coverage of the next
- row by the next area
- */
- - oye -= ctx->src->height;
- + oye -= ctx->v_i_val;
- /* add stored partial row to accumulator */
- #ifdef HAVE_LCD_COLOR
- for (x = 0; x < 3 * (unsigned int)ctx->bm->width; x++)
- #else
- for (x = 0; x < (unsigned int)ctx->bm->width; x++)
- #endif
- - rowacc[x] = rowacc[x] * ctx->bm->height + mul * rowtmp[x];
- + rowacc[x] = rowacc[x] * ctx->v_o_val + mul * rowtmp[x];
- /* store new scaled row in temp row */
- if(!ctx->h_scaler(rowtmp, ctx, false))
- return false;
- /* add partial coverage by new row to this area, then round and
- scale to final value
- */
- - mul = ctx->bm->height - oye;
- + mul = ctx->v_o_val - oye;
- #ifdef HAVE_LCD_COLOR
- for (x = 0; x < 3 * (unsigned int)ctx->bm->width; x++)
- #else
- @@ -319,15 +385,6 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx)
- }
- #ifdef HAVE_UPSCALER
- -/* Set up rounding and scale factors for the horizontal scaler. The divisor
- - is bm->width - 1, so that the first and last pixels in the row align
- - exactly between input and output
- -*/
- -static inline void scale_h_linear_setup(struct scaler_context *ctx)
- -{
- - ctx->divisor = ctx->bm->width - 1;
- -}
- -
- /* horizontal linear scaler */
- static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx,
- bool accum)
- @@ -348,24 +405,24 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx,
- FILL_BUF_INIT(part,ctx->store_part,ctx->args);
- ix = 0;
- /* The error is set so that values are initialized on the first pass. */
- - ixe = ctx->bm->width - 1;
- + ixe = ctx->h_o_val;
- /* give other tasks a chance to run */
- yield();
- for (ox = 0; ox < (uint32_t)ctx->bm->width; ox++)
- {
- #ifdef HAVE_LCD_COLOR
- - if (ixe >= ((uint32_t)ctx->bm->width - 1))
- + if (ixe >= ctx->h_o_val)
- {
- /* Store the new "current" pixel value in rgbval, and the color
- step value in rgbinc.
- */
- - ixe -= (ctx->bm->width - 1);
- + ixe -= ctx->h_o_val;
- rgbinc.r = -(part->buf->red);
- rgbinc.g = -(part->buf->green);
- rgbinc.b = -(part->buf->blue);
- - rgbval.r = (part->buf->red) * (ctx->bm->width - 1);
- - rgbval.g = (part->buf->green) * (ctx->bm->width - 1);
- - rgbval.b = (part->buf->blue) * (ctx->bm->width - 1);
- + rgbval.r = (part->buf->red) * ctx->h_o_val;
- + rgbval.g = (part->buf->green) * ctx->h_o_val;
- + rgbval.b = (part->buf->blue) * ctx->h_o_val;
- ix += 1;
- /* If this wasn't the last pixel, add the next one to rgbinc. */
- if (ix < (uint32_t)ctx->src->width) {
- @@ -383,10 +440,10 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx,
- rgbval.g += rgbinc.g * ixe;
- rgbval.b += rgbinc.b * ixe;
- }
- - /* Now multiple the color increment to its proper value */
- - rgbinc.r *= ctx->src->width - 1;
- - rgbinc.g *= ctx->src->width - 1;
- - rgbinc.b *= ctx->src->width - 1;
- + /* Now multiply the color increment to its proper value */
- + rgbinc.r *= ctx->h_i_val;
- + rgbinc.g *= ctx->h_i_val;
- + rgbinc.b *= ctx->h_i_val;
- } else {
- rgbval.r += rgbinc.r;
- rgbval.g += rgbinc.g;
- @@ -395,24 +452,24 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx,
- /* round and scale values, and accumulate or store to output */
- if (accum)
- {
- - out_line[ox].r += rgbval.r;
- - out_line[ox].g += rgbval.g;
- - out_line[ox].b += rgbval.b;
- + out_line[ox].r += (rgbval.r + (1 << 21)) >> 22;
- + out_line[ox].g += (rgbval.g + (1 << 21)) >> 22;
- + out_line[ox].b += (rgbval.b + (1 << 21)) >> 22;
- } else {
- - out_line[ox].r = rgbval.r;
- - out_line[ox].g = rgbval.g;
- - out_line[ox].b = rgbval.b;
- + out_line[ox].r = (rgbval.r + (1 << 21)) >> 22;
- + out_line[ox].g = (rgbval.g + (1 << 21)) >> 22;
- + out_line[ox].b = (rgbval.b + (1 << 21)) >> 22;
- }
- #else
- - if (ixe >= ((uint32_t)ctx->bm->width - 1))
- + if (ixe >= ctx->h_o_val)
- {
- /* Store the new "current" pixel value in rgbval, and the color
- step value in rgbinc.
- */
- - ixe -= (ctx->bm->width - 1);
- + ixe -= ctx->h_o_val;
- val = *(part->buf);
- inc = -val;
- - val = MULUQ(val, ctx->bm->width - 1);
- + val = val * ctx->h_o_val;
- ix += 1;
- /* If this wasn't the last pixel, add the next one to rgbinc. */
- if (ix < (uint32_t)ctx->src->width) {
- @@ -424,21 +481,21 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx,
- /* Add a partial step to rgbval, in this pixel isn't precisely
- aligned with the new source pixel
- */
- - val += MULQ(inc, ixe);
- + val += inc * ixe;
- }
- /* Now multiply the color increment to its proper value */
- - inc = MULQ(inc, ctx->src->width - 1);
- + inc = inc * ctx->h_i_val;
- } else
- val += inc;
- /* round and scale values, and accumulate or store to output */
- if (accum)
- {
- - out_line[ox] += val;
- + out_line[ox] += (val + (1 << 21)) >> 22;
- } else {
- - out_line[ox] = val;
- + out_line[ox] = (val + (1 << 21)) >> 22;
- }
- #endif
- - ixe += ctx->src->width - 1;
- + ixe += ctx->h_i_val;
- }
- return true;
- }
- @@ -449,12 +506,8 @@ static inline bool scale_v_linear(struct rowset *rset,
- {
- uint32_t mul, x, iy, iye;
- int32_t oy;
- - /* Set up scale and rounding factors, the divisor is bm->height - 1 */
- - ctx->divisor *= (ctx->bm->height - 1);
- - ctx->round = ctx->divisor >> 1;
- - ctx->divisor = 1 + (-((ctx->divisor + 1) >> 1)) / ctx->divisor;
- - /* Set up our two temp buffers. The names are generic because they'll be
- - swapped each time a new input row is read
- + /* Set up our buffers, to store the increment and current value for each
- + column, and one temp buffer used to read in new rows.
- */
- #ifdef HAVE_LCD_COLOR
- uint32_t *rowinc = (uint32_t *)(ctx->buf),
- @@ -469,15 +522,15 @@ static inline bool scale_v_linear(struct rowset *rset,
- SDEBUGF("scale_v_linear\n");
- mul = 0;
- iy = 0;
- - iye = ctx->bm->height - 1;
- + iye = ctx->v_o_val;
- /* get first scaled row in rowtmp */
- if(!ctx->h_scaler((void*)rowtmp, ctx, false))
- return false;
- for (oy = rset->rowstart; oy != rset->rowstop; oy += rset->rowstep)
- {
- - if (iye >= (uint32_t)ctx->bm->height - 1)
- + if (iye >= ctx->v_o_val)
- {
- - iye -= ctx->bm->height - 1;
- + iye -= ctx->v_o_val;
- iy += 1;
- #ifdef HAVE_LCD_COLOR
- for (x = 0; x < 3 * (uint32_t)ctx->bm->width; x++)
- @@ -486,7 +539,7 @@ static inline bool scale_v_linear(struct rowset *rset,
- #endif
- {
- rowinc[x] = -rowtmp[x];
- - rowval[x] = rowtmp[x] * (ctx->bm->height - 1);
- + rowval[x] = rowtmp[x] * ctx->v_o_val;
- }
- if (iy < (uint32_t)ctx->src->height)
- {
- @@ -500,7 +553,7 @@ static inline bool scale_v_linear(struct rowset *rset,
- {
- rowinc[x] += rowtmp[x];
- rowval[x] += rowinc[x] * iye;
- - rowinc[x] *= ctx->src->height - 1;
- + rowinc[x] *= ctx->v_i_val;
- }
- }
- } else
- @@ -511,7 +564,7 @@ static inline bool scale_v_linear(struct rowset *rset,
- #endif
- rowval[x] += rowinc[x];
- ctx->output_row(oy, (void*)rowval, ctx);
- - iye += ctx->src->height - 1;
- + iye += ctx->v_i_val;
- }
- return true;
- }
- @@ -533,9 +586,9 @@ static void output_row_32_native_fromyuv(uint32_t row, void * row_in,
- for (col = 0; col < ctx->bm->width; col++) {
- if (ctx->dither)
- delta = DITHERXDY(col,dy);
- - y = SC_MUL(qp->b + ctx->round, ctx->divisor);
- - u = SC_MUL(qp->g + ctx->round, ctx->divisor);
- - v = SC_MUL(qp->r + ctx->round, ctx->divisor);
- + y = SC_OUT(qp->b);
- + u = SC_OUT(qp->g);
- + v = SC_OUT(qp->r);
- qp++;
- yuv_to_rgb(y, u, v, &r, &g, &b);
- r = (31 * r + (r >> 3) + delta) >> 8;
- @@ -571,7 +624,7 @@ static void output_row_32_native(uint32_t row, void * row_in,
- for (col = 0; col < ctx->bm->width; col++) {
- if (ctx->dither)
- delta = DITHERXDY(col,dy);
- - bright = SC_MUL((*qp++) + ctx->round,ctx->divisor);
- + bright = SC_OUT(*qp++);
- bright = (3 * bright + (bright >> 6) + delta) >> 8;
- data |= (~bright & 3) << shift;
- shift -= 2;
- @@ -594,7 +647,7 @@ static void output_row_32_native(uint32_t row, void * row_in,
- for (col = 0; col < ctx->bm->width; col++) {
- if (ctx->dither)
- delta = DITHERXDY(col,dy);
- - bright = SC_MUL((*qp++) + ctx->round, ctx->divisor);
- + bright = SC_OUT(*qp++);
- bright = (3 * bright + (bright >> 6) + delta) >> 8;
- *dest++ |= (~bright & 3) << shift;
- }
- @@ -609,7 +662,7 @@ static void output_row_32_native(uint32_t row, void * row_in,
- for (col = 0; col < ctx->bm->width; col++) {
- if (ctx->dither)
- delta = DITHERXDY(col,dy);
- - bright = SC_MUL((*qp++) + ctx->round, ctx->divisor);
- + bright = SC_OUT(*qp++);
- bright = (3 * bright + (bright >> 6) + delta) >> 8;
- *dest++ |= vi_pattern[bright] << shift;
- }
- @@ -625,9 +678,9 @@ static void output_row_32_native(uint32_t row, void * row_in,
- if (ctx->dither)
- delta = DITHERXDY(col,dy);
- q0 = *qp++;
- - r = SC_MUL(q0.r + ctx->round, ctx->divisor);
- - g = SC_MUL(q0.g + ctx->round, ctx->divisor);
- - b = SC_MUL(q0.b + ctx->round, ctx->divisor);
- + r = SC_OUT(q0.r);
- + g = SC_OUT(q0.g);
- + b = SC_OUT(q0.b);
- r = (31 * r + (r >> 3) + delta) >> 8;
- g = (63 * g + (g >> 2) + delta) >> 8;
- b = (31 * b + (b >> 3) + delta) >> 8;
- @@ -664,13 +717,10 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
- struct img_part* (*store_part)(void *args),
- void *args)
- {
- -
- -#ifdef HAVE_UPSCALER
- const int sw = src->width;
- const int sh = src->height;
- const int dw = bm->width;
- const int dh = bm->height;
- -#endif
- int ret;
- #ifdef HAVE_LCD_COLOR
- unsigned int needed = sizeof(struct uint32_rgb) * 3 * bm->width;
- @@ -740,23 +790,35 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
- {
- #endif
- ctx.h_scaler = scale_h_area;
- - scale_h_area_setup(&ctx);
- + uint32_t h_div = (1U << 24) / sw;
- + ctx.h_i_val = sw * h_div;
- + ctx.h_o_val = dw * h_div;
- #ifdef HAVE_UPSCALER
- } else {
- ctx.h_scaler = scale_h_linear;
- - scale_h_linear_setup(&ctx);
- + uint32_t h_div = (1U << 24) / (dw - 1);
- + ctx.h_i_val = (sw - 1) * h_div;
- + ctx.h_o_val = (dw - 1) * h_div;
- }
- #endif
- - SC_MUL_INIT;
- #ifdef HAVE_UPSCALER
- if (sh > dh)
- #endif
- + {
- + uint32_t v_div = (1U << 22) / sh;
- + ctx.v_i_val = sh * v_div;
- + ctx.v_o_val = dh * v_div;
- ret = scale_v_area(rset, &ctx);
- + }
- #ifdef HAVE_UPSCALER
- else
- + {
- + uint32_t v_div = (1U << 22) / dh;
- + ctx.v_i_val = (sh - 1) * v_div;
- + ctx.v_o_val = (dh - 1) * v_div;
- ret = scale_v_linear(rset, &ctx);
- + }
- #endif
- - SC_MUL_END;
- #ifdef HAVE_ADJUSTABLE_CPU_FREQ
- cpu_boost(false);
- #endif
- diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h
- index 2964fcd..b861e43 100644
- --- a/apps/recorder/resize.h
- +++ b/apps/recorder/resize.h
- @@ -43,68 +43,7 @@
- #define MAX_SC_STACK_ALLOC 0
- #define HAVE_UPSCALER 1
- -#if defined(CPU_COLDFIRE)
- -#define SC_MUL_INIT \
- - unsigned long macsr_st = coldfire_get_macsr(); \
- - coldfire_set_macsr(EMAC_UNSIGNED);
- -#define SC_MUL_END coldfire_set_macsr(macsr_st);
- -#define SC_MUL(x, y) \
- -({ \
- - unsigned long t; \
- - asm ("mac.l %[a], %[b], %%acc0\n\t" \
- - "move.l %%accext01, %[t]\n\t" \
- - "move.l #0, %%acc0\n\t" \
- - : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
- - t; \
- -})
- -#elif (CONFIG_CPU == SH7034)
- -/* multiply two unsigned 32 bit values and return the top 32 bit
- - * of the 64 bit result */
- -static inline unsigned sc_mul32(unsigned a, unsigned b)
- -{
- - unsigned r, t1, t2, t3;
- -
- - asm (
- - "swap.w %[a], %[t1] \n" /* t1 = ba */
- - "mulu %[t1], %[b] \n" /* a * d */
- - "swap.w %[b], %[t3] \n" /* t3 = dc */
- - "sts macl, %[t2] \n" /* t2 = a * d */
- - "mulu %[t1], %[t3] \n" /* a * c */
- - "sts macl, %[r] \n" /* hi = a * c */
- - "mulu %[a], %[t3] \n" /* b * c */
- - "clrt \n"
- - "sts macl, %[t3] \n" /* t3 = b * c */
- - "addc %[t2], %[t3] \n" /* t3 += t2, carry -> t2 */
- - "movt %[t2] \n"
- - "mulu %[a], %[b] \n" /* b * d */
- - "mov %[t3], %[t1] \n" /* t1t3 = t2t3 << 16 */
- - "xtrct %[t2], %[t1] \n"
- - "shll16 %[t3] \n"
- - "sts macl, %[t2] \n" /* lo = b * d */
- - "clrt \n" /* hi.lo += t1t3 */
- - "addc %[t3], %[t2] \n"
- - "addc %[t1], %[r] \n"
- - : /* outputs */
- - [r] "=&r"(r),
- - [t1]"=&r"(t1),
- - [t2]"=&r"(t2),
- - [t3]"=&r"(t3)
- - : /* inputs */
- - [a] "r" (a),
- - [b] "r" (b)
- - );
- - return r;
- -}
- -#define SC_MUL(x, y) sc_mul32(x, y)
- -#define SC_MUL_INIT
- -#define SC_MUL_END
- -#endif
- -
- -#ifndef SC_MUL
- -#define SC_MUL(x, y) ((x) * (uint64_t)(y) >> 32)
- -#define SC_MUL_INIT
- -#define SC_MUL_END
- -#endif
- +#define SC_OUT(n) (((n) + (1 << 23)) >> 24);
- struct img_part {
- int len;
- @@ -130,8 +69,12 @@ struct uint32_rgb {
- horizontal scaler, and row output
- */
- struct scaler_context {
- - uint32_t divisor;
- - uint32_t round;
- + uint32_t h_div;
- + uint32_t h_i_val;
- + uint32_t h_o_val;
- + uint32_t v_div;
- + uint32_t v_i_val;
- + uint32_t v_o_val;
- struct bitmap *bm;
- struct dim *src;
- unsigned char *buf;
Add Comment
Please, Sign In to add comment