diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-06 04:53:56 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-06 04:53:56 +0000 |
commit | eef7945a970e4da69b95c638a44a8ee1a9205430 (patch) | |
tree | ec015938370aaa6e84d3652f914c1766a963582d /apps/recorder/resize.c | |
parent | f779160de53686e45f57fad882a6d8f8db6360fd (diff) | |
download | rockbox-eef7945a970e4da69b95c638a44a8ee1a9205430.tar.gz rockbox-eef7945a970e4da69b95c638a44a8ee1a9205430.zip |
Move YUV->RGB in JPEG load from before scaler to after scaler. Required change to struct custom_format, so sorted the plugin API as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20856 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/resize.c')
-rw-r--r-- | apps/recorder/resize.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index 7000c448e6..1852519958 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c | |||
@@ -59,6 +59,7 @@ | |||
59 | #undef DEBUGF | 59 | #undef DEBUGF |
60 | #define DEBUGF(...) | 60 | #define DEBUGF(...) |
61 | #endif | 61 | #endif |
62 | #include <jpeg_load.h> | ||
62 | 63 | ||
63 | #if CONFIG_CPU == SH7034 | 64 | #if CONFIG_CPU == SH7034 |
64 | /* 16*16->32 bit multiplication is a single instrcution on the SH1 */ | 65 | /* 16*16->32 bit multiplication is a single instrcution on the SH1 */ |
@@ -516,6 +517,35 @@ static inline bool scale_v_linear(struct rowset *rset, | |||
516 | } | 517 | } |
517 | #endif /* HAVE_UPSCALER */ | 518 | #endif /* HAVE_UPSCALER */ |
518 | 519 | ||
520 | #if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN)) | ||
521 | void output_row_native_fromyuv(uint32_t row, void * row_in, | ||
522 | struct scaler_context *ctx) | ||
523 | { | ||
524 | int col; | ||
525 | int fb_width = BM_WIDTH(ctx->bm->width,FORMAT_NATIVE,0); | ||
526 | uint8_t dy = DITHERY(row); | ||
527 | struct uint32_rgb *qp = (struct uint32_rgb *)row_in; | ||
528 | SDEBUGF("output_row: y: %lu in: %p\n",row, row_in); | ||
529 | fb_data *dest = (fb_data *)ctx->bm->data + fb_width * row; | ||
530 | int delta = 127; | ||
531 | unsigned r, g, b, y, u, v; | ||
532 | |||
533 | for (col = 0; col < ctx->bm->width; col++) { | ||
534 | if (ctx->dither) | ||
535 | delta = DITHERXDY(col,dy); | ||
536 | y = SC_MUL(qp->b + ctx->round, ctx->divisor); | ||
537 | u = SC_MUL(qp->g + ctx->round, ctx->divisor); | ||
538 | v = SC_MUL(qp->r + ctx->round, ctx->divisor); | ||
539 | qp++; | ||
540 | yuv_to_rgb(y, u, v, &r, &g, &b); | ||
541 | r = (31 * r + (r >> 3) + delta) >> 8; | ||
542 | g = (63 * g + (g >> 2) + delta) >> 8; | ||
543 | b = (31 * b + (b >> 3) + delta) >> 8; | ||
544 | *dest++ = LCD_RGBPACK_LCD(r, g, b); | ||
545 | } | ||
546 | } | ||
547 | #endif | ||
548 | |||
519 | #if !defined(PLUGIN) || LCD_DEPTH > 1 | 549 | #if !defined(PLUGIN) || LCD_DEPTH > 1 |
520 | void output_row_native(uint32_t row, void * row_in, | 550 | void output_row_native(uint32_t row, void * row_in, |
521 | struct scaler_context *ctx) | 551 | struct scaler_context *ctx) |
@@ -614,7 +644,14 @@ unsigned int get_size_native(struct bitmap *bm) | |||
614 | } | 644 | } |
615 | 645 | ||
616 | const struct custom_format format_native = { | 646 | const struct custom_format format_native = { |
647 | #if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN)) | ||
648 | .output_row = { | ||
649 | output_row_native, | ||
650 | output_row_native_fromyuv | ||
651 | }, | ||
652 | #else | ||
617 | .output_row = output_row_native, | 653 | .output_row = output_row_native, |
654 | #endif | ||
618 | .get_size = get_size_native | 655 | .get_size = get_size_native |
619 | }; | 656 | }; |
620 | #endif | 657 | #endif |
@@ -622,6 +659,7 @@ const struct custom_format format_native = { | |||
622 | int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | 659 | int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, |
623 | struct rowset *rset, unsigned char *buf, unsigned int len, | 660 | struct rowset *rset, unsigned char *buf, unsigned int len, |
624 | const struct custom_format *format, | 661 | const struct custom_format *format, |
662 | IF_PIX_FMT(int format_index,) | ||
625 | struct img_part* (*store_part)(void *args), | 663 | struct img_part* (*store_part)(void *args), |
626 | void *args) | 664 | void *args) |
627 | { | 665 | { |
@@ -683,10 +721,19 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
683 | ctx.src = src; | 721 | ctx.src = src; |
684 | ctx.dither = dither; | 722 | ctx.dither = dither; |
685 | #if !defined(PLUGIN) | 723 | #if !defined(PLUGIN) |
724 | #if defined(HAVE_LCD_COLOR) && defined(HAVE_JPEG) | ||
725 | ctx.output_row = format_index ? output_row_native_fromyuv | ||
726 | : output_row_native; | ||
727 | #else | ||
686 | ctx.output_row = output_row_native; | 728 | ctx.output_row = output_row_native; |
729 | #endif | ||
687 | if (format) | 730 | if (format) |
688 | #endif | 731 | #endif |
732 | #if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN)) | ||
733 | ctx.output_row = format->output_row[format_index]; | ||
734 | #else | ||
689 | ctx.output_row = format->output_row; | 735 | ctx.output_row = format->output_row; |
736 | #endif | ||
690 | #ifdef HAVE_UPSCALER | 737 | #ifdef HAVE_UPSCALER |
691 | if (sw > dw) | 738 | if (sw > dw) |
692 | { | 739 | { |