summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-05-09 07:31:27 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-05-09 07:31:27 +0000
commit91efc162564cd9c04677e2e38550cde21995b06e (patch)
treec927cefc7f12a49396541dbac246dc76ca444c71
parent67695617a13e9f37f17e3718b03046f6d748a9e1 (diff)
downloadrockbox-91efc162564cd9c04677e2e38550cde21995b06e.tar.gz
rockbox-91efc162564cd9c04677e2e38550cde21995b06e.zip
Split 8-bit-to-native conversion in bmp.c into a function, add support for plugging unscaled output in BMP and JPEG loaders, use output_row_8_native in JPEG decoder when possible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20884 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/bench_mem_jpeg.c5
-rw-r--r--apps/plugins/lib/grey_draw.c13
-rw-r--r--apps/plugins/lib/pluginlib_bmp.c7
-rw-r--r--apps/plugins/pictureflow/pictureflow.c35
-rw-r--r--apps/recorder/bmp.c218
-rw-r--r--apps/recorder/bmp.h4
-rw-r--r--apps/recorder/jpeg_load.c57
-rw-r--r--apps/recorder/resize.c23
-rw-r--r--apps/recorder/resize.h8
9 files changed, 242 insertions, 128 deletions
diff --git a/apps/plugins/bench_mem_jpeg.c b/apps/plugins/bench_mem_jpeg.c
index 958e5208e8..cd7dea356e 100644
--- a/apps/plugins/bench_mem_jpeg.c
+++ b/apps/plugins/bench_mem_jpeg.c
@@ -42,13 +42,14 @@ static void output_row_null(uint32_t row, void * row_in,
42} 42}
43 43
44const struct custom_format format_null = { 44const struct custom_format format_null = {
45 .output_row_8 = output_row_null,
45#ifdef HAVE_LCD_COLOR 46#ifdef HAVE_LCD_COLOR
46 .output_row = { 47 .output_row_32 = {
47 output_row_null, 48 output_row_null,
48 output_row_null 49 output_row_null
49 }, 50 },
50#else 51#else
51 .output_row = output_row_null, 52 .output_row_32 = output_row_null,
52#endif 53#endif
53 .get_size = get_size_null 54 .get_size = get_size_null
54}; 55};
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c
index 65f2211b7f..6315ad9b1a 100644
--- a/apps/plugins/lib/grey_draw.c
+++ b/apps/plugins/lib/grey_draw.c
@@ -719,7 +719,15 @@ void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width,
719 grey_ub_gray_bitmap_part(src, 0, 0, width, x, y, width, height); 719 grey_ub_gray_bitmap_part(src, 0, 0, width, x, y, width, height);
720} 720}
721 721
722static void output_row_grey(uint32_t row, void * row_in, struct scaler_context *ctx) 722static void output_row_grey_8(uint32_t row, void * row_in,
723 struct scaler_context *ctx)
724{
725 uint8_t *dest = (uint8_t*)ctx->bm->data + ctx->bm->width * row;
726 rb->memcpy(dest, row_in, ctx->bm->width);
727}
728
729static void output_row_grey_32(uint32_t row, void * row_in,
730 struct scaler_context *ctx)
723{ 731{
724 int col; 732 int col;
725 uint32_t *qp = (uint32_t*)row_in; 733 uint32_t *qp = (uint32_t*)row_in;
@@ -734,6 +742,7 @@ static unsigned int get_size_grey(struct bitmap *bm)
734} 742}
735 743
736const struct custom_format format_grey = { 744const struct custom_format format_grey = {
737 .output_row = output_row_grey, 745 .output_row_8 = output_row_grey_8,
746 .output_row_32 = output_row_grey_32,
738 .get_size = get_size_grey 747 .get_size = get_size_grey
739}; 748};
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c
index 110e534be0..6b1a54291c 100644
--- a/apps/plugins/lib/pluginlib_bmp.c
+++ b/apps/plugins/lib/pluginlib_bmp.c
@@ -124,14 +124,7 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst)
124 124
125#endif /* LCD_DEPTH > 1 */ 125#endif /* LCD_DEPTH > 1 */
126 126
127#ifndef HAVE_BMP_SCALING
128#include "wrappers.h" 127#include "wrappers.h"
129 128
130/* import the core bmp loader */ 129/* import the core bmp loader */
131#include "recorder/bmp.c" 130#include "recorder/bmp.c"
132#else
133/* the full 16x16 Bayer dither matrix may be calculated quickly with this table
134*/
135const unsigned char dither_table[16] =
136 { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 };
137#endif
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 82dc9748ec..6dd034c9a9 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -607,7 +607,29 @@ static inline uint32_t div255(uint32_t val)
607 607
608#define SCALE_VAL(val,out) div255((val) * (out) + 127) 608#define SCALE_VAL(val,out) div255((val) * (out) + 127)
609 609
610static void output_row_transposed(uint32_t row, void * row_in, 610static void output_row_8_transposed(uint32_t row, void * row_in,
611 struct scaler_context *ctx)
612{
613 pix_t *dest = (pix_t*)ctx->bm->data + row;
614 pix_t *end = dest + ctx->bm->height * ctx->bm->width;
615#ifdef USEGSLIB
616 uint8_t *qp = (uint8_t*)row_in;
617 for (; dest < end; dest += ctx->bm->height)
618 *dest = *qp++;
619#else
620 struct uint8_rgb *qp = (struct uint8_rgb*)row_in;
621 unsigned r, g, b;
622 for (; dest < end; dest += ctx->bm->height)
623 {
624 r = qp->red;
625 g = qp->green;
626 b = (qp++)->blue;
627 *dest = LCD_RGBPACK_LCD(r,g,b);
628 }
629#endif
630}
631
632static void output_row_32_transposed(uint32_t row, void * row_in,
611 struct scaler_context *ctx) 633 struct scaler_context *ctx)
612{ 634{
613 pix_t *dest = (pix_t*)ctx->bm->data + row; 635 pix_t *dest = (pix_t*)ctx->bm->data + row;
@@ -635,7 +657,7 @@ static void output_row_transposed(uint32_t row, void * row_in,
635} 657}
636 658
637#ifdef HAVE_LCD_COLOR 659#ifdef HAVE_LCD_COLOR
638static void output_row_transposed_fromyuv(uint32_t row, void * row_in, 660static void output_row_32_transposed_fromyuv(uint32_t row, void * row_in,
639 struct scaler_context *ctx) 661 struct scaler_context *ctx)
640{ 662{
641 pix_t *dest = (pix_t*)ctx->bm->data + row; 663 pix_t *dest = (pix_t*)ctx->bm->data + row;
@@ -663,13 +685,14 @@ static unsigned int get_size(struct bitmap *bm)
663} 685}
664 686
665const struct custom_format format_transposed = { 687const struct custom_format format_transposed = {
688 .output_row_8 = output_row_8_transposed,
666#ifdef HAVE_LCD_COLOR 689#ifdef HAVE_LCD_COLOR
667 .output_row = { 690 .output_row_32 = {
668 output_row_transposed, 691 output_row_32_transposed,
669 output_row_transposed_fromyuv 692 output_row_32_transposed_fromyuv
670 }, 693 },
671#else 694#else
672 .output_row = output_row_transposed, 695 .output_row_32 = output_row_32_transposed,
673#endif 696#endif
674 .get_size = get_size 697 .get_size = get_size
675}; 698};
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c
index f1fc1f83b4..4897b2db18 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -351,6 +351,93 @@ static inline int rgbcmp(struct uint8_rgb rgb1, struct uint8_rgb rgb2)
351 else 351 else
352 return 1; 352 return 1;
353} 353}
354#if LCD_DEPTH > 1
355void output_row_8_native(uint32_t row, void * row_in,
356 struct scaler_context *ctx)
357{
358 int col;
359 int fb_width = BM_WIDTH(ctx->bm->width,FORMAT_NATIVE,0);
360 uint8_t dy = DITHERY(row);
361#ifdef HAVE_LCD_COLOR
362 struct uint8_rgb *qp = (struct uint8_rgb*)row_in;
363#else
364 uint8_t *qp = (uint8_t*)row_in;
365#endif
366 BDEBUGF("output_row: y: %lu in: %p\n",row, row_in);
367#if LCD_DEPTH == 2
368#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
369 /* greyscale iPods */
370 fb_data *dest = (fb_data *)ctx->bm->data + fb_width * row;
371 int shift = 6;
372 int delta = 127;
373 unsigned bright;
374 unsigned data = 0;
375
376 for (col = 0; col < ctx->bm->width; col++) {
377 if (ctx->dither)
378 delta = DITHERXDY(col,dy);
379 bright = *qp++;
380 bright = (3 * bright + (bright >> 6) + delta) >> 8;
381 data |= (~bright & 3) << shift;
382 shift -= 2;
383 if (shift < 0) {
384 *dest++ = data;
385 data = 0;
386 shift = 6;
387 }
388 }
389 if (shift < 6)
390 *dest++ = data;
391#elif LCD_PIXELFORMAT == VERTICAL_PACKING
392 /* iriver H1x0 */
393 fb_data *dest = (fb_data *)ctx->bm->data + fb_width *
394 (row >> 2);
395 int shift = 2 * (row & 3);
396 int delta = 127;
397 unsigned bright;
398
399 for (col = 0; col < ctx->bm->width; col++) {
400 if (ctx->dither)
401 delta = DITHERXDY(col,dy);
402 bright = *qp++;
403 bright = (3 * bright + (bright >> 6) + delta) >> 8;
404 *dest++ |= (~bright & 3) << shift;
405 }
406#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
407 /* iAudio M3 */
408 fb_data *dest = (fb_data *)ctx->bm->data + fb_width *
409 (row >> 3);
410 int shift = row & 7;
411 int delta = 127;
412 unsigned bright;
413
414 for (col = 0; col < ctx->bm->width; col++) {
415 if (ctx->dither)
416 delta = DITHERXDY(col,dy);
417 bright = *qp++;
418 bright = (3 * bright + (bright >> 6) + delta) >> 8;
419 *dest++ |= vi_pattern[bright] << shift;
420 }
421#endif /* LCD_PIXELFORMAT */
422#elif LCD_DEPTH == 16
423 /* iriver h300, colour iPods, X5 */
424 fb_data *dest = (fb_data *)ctx->bm->data + fb_width * row;
425 int delta = 127;
426 unsigned r, g, b;
427 for (col = 0; col < ctx->bm->width; col++) {
428 if (ctx->dither)
429 delta = DITHERXDY(col,dy);
430 r = qp->red;
431 g = qp->green;
432 b = (qp++)->blue;
433 r = (31 * r + (r >> 3) + delta) >> 8;
434 g = (63 * g + (g >> 2) + delta) >> 8;
435 b = (31 * b + (b >> 3) + delta) >> 8;
436 *dest++ = LCD_RGBPACK_LCD(r, g, b);
437 }
438#endif /* LCD_DEPTH */
439}
440#endif
354 441
355/****************************************************************************** 442/******************************************************************************
356 * read_bmp_fd() 443 * read_bmp_fd()
@@ -598,7 +685,7 @@ int read_bmp_fd(int fd,
598#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \ 685#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
599 defined(HAVE_BMP_SCALING) || defined(PLUGIN) 686 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
600#if LCD_DEPTH > 1 && defined(HAVE_BMP_SCALING) 687#if LCD_DEPTH > 1 && defined(HAVE_BMP_SCALING)
601 if (resize || cformat) 688 if (resize)
602#endif 689#endif
603 { 690 {
604 if (resize_on_load(bm, dither, &src_dim, &rset, 691 if (resize_on_load(bm, dither, &src_dim, &rset,
@@ -610,31 +697,43 @@ int read_bmp_fd(int fd,
610 } 697 }
611#endif /* LCD_DEPTH */ 698#endif /* LCD_DEPTH */
612 699
613#ifndef PLUGIN 700#if LCD_DEPTH > 1 || defined(PLUGIN)
614#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) 701 struct scaler_context ctx = {
615 int fb_width = BM_WIDTH(bm->width,bm->format,remote); 702 .bm = bm,
703 .dither = dither,
704 };
705#endif
706#if LCD_DEPTH > 1
707 void (*output_row_8)(uint32_t, void*, struct scaler_context*) =
708 output_row_8_native;
709#elif defined(PLUGIN)
710 void (*output_row_8)(uint32_t, void*, struct scaler_context*) = NULL;
711#endif
712#if LCD_DEPTH > 1 || defined(PLUGIN)
713 if (cformat)
714 output_row_8 = cformat->output_row_8;
616#endif 715#endif
617 int col, row;
618 716
717 int row;
619 /* loop to read rows and put them to buffer */ 718 /* loop to read rows and put them to buffer */
620 for (row = rset.rowstart; row != rset.rowstop; row += rset.rowstep) { 719 for (row = rset.rowstart; row != rset.rowstop; row += rset.rowstep) {
720 if (!read_part_line(&ba))
721 return -9;
722#ifndef PLUGIN
621#if !defined(HAVE_LCD_COLOR) && \ 723#if !defined(HAVE_LCD_COLOR) && \
622 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) 724 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1))
623 uint8_t* qp = ba.buf; 725 uint8_t* qp = ba.buf;
624#else 726#else
625 struct uint8_rgb *qp = (struct uint8_rgb *)ba.buf; 727 struct uint8_rgb *qp = (struct uint8_rgb *)ba.buf;
626#endif 728#endif
627 unsigned mask; 729#endif
628 unsigned char *p;
629 if (!read_part_line(&ba))
630 return -9;
631
632 /* Convert to destination format */ 730 /* Convert to destination format */
633#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) 731#if ((LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) && \
634 unsigned char dy = DITHERY(row); 732 !defined(PLUGIN)
635 if (format == FORMAT_NATIVE) { 733 if (format == FORMAT_NATIVE) {
636#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 734#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
637 if (remote) { 735 if (remote) {
736 unsigned char dy = DITHERY(row);
638#if (LCD_REMOTE_DEPTH == 2) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) 737#if (LCD_REMOTE_DEPTH == 2) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)
639 /* iAudio X5/M5 remote */ 738 /* iAudio X5/M5 remote */
640 fb_remote_data *dest = (fb_remote_data *)bitmap 739 fb_remote_data *dest = (fb_remote_data *)bitmap
@@ -643,6 +742,7 @@ int read_bmp_fd(int fd,
643 int delta = 127; 742 int delta = 127;
644 unsigned bright; 743 unsigned bright;
645 744
745 int col;
646 for (col = 0; col < bm->width; col++) { 746 for (col = 0; col < bm->width; col++) {
647 if (dither) 747 if (dither)
648 delta = DITHERXDY(col,dy); 748 delta = DITHERXDY(col,dy);
@@ -658,85 +758,25 @@ int read_bmp_fd(int fd,
658#endif /* LCD_REMOTE_DEPTH / LCD_REMOTE_PIXELFORMAT */ 758#endif /* LCD_REMOTE_DEPTH / LCD_REMOTE_PIXELFORMAT */
659 } else 759 } else
660#endif /* defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 */ 760#endif /* defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 */
761#endif /* (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) &&
762 (LCD_REMOTE_DEPTH > 1) */
763#if LCD_DEPTH > 1 || defined(PLUGIN)
661 { 764 {
662#if LCD_DEPTH == 2 765 output_row_8(row, ba.buf, &ctx);
663#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
664 /* greyscale iPods */
665 fb_data *dest = (fb_data *)bitmap + fb_width * row;
666 int shift = 6;
667 int delta = 127;
668 unsigned bright;
669 unsigned data = 0;
670
671 for (col = 0; col < bm->width; col++) {
672 if (dither)
673 delta = DITHERXDY(col,dy);
674 bright = *qp++;
675 bright = (3 * bright + (bright >> 6) + delta) >> 8;
676 data |= (~bright & 3) << shift;
677 shift -= 2;
678 if (shift < 0) {
679 *dest++ = data;
680 data = 0;
681 shift = 6;
682 }
683 }
684 if (shift < 6)
685 *dest++ = data;
686#elif LCD_PIXELFORMAT == VERTICAL_PACKING
687 /* iriver H1x0 */
688 fb_data *dest = (fb_data *)bitmap + fb_width * (row >> 2);
689 int shift = 2 * (row & 3);
690 int delta = 127;
691 unsigned bright;
692
693 for (col = 0; col < bm->width; col++) {
694 if (dither)
695 delta = DITHERXDY(col,dy);
696 bright = *qp++;
697 bright = (3 * bright + (bright >> 6) + delta) >> 8;
698 *dest++ |= (~bright & 3) << shift;
699 }
700#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
701 /* iAudio M3 */
702 fb_data *dest = (fb_data *)bitmap + fb_width * (row >> 3);
703 int shift = row & 7;
704 int delta = 127;
705 unsigned bright;
706
707 for (col = 0; col < bm->width; col++) {
708 if (dither)
709 delta = DITHERXDY(col,dy);
710 bright = *qp++;
711 bright = (3 * bright + (bright >> 6) + delta) >> 8;
712 *dest++ |= vi_pattern[bright] << shift;
713 }
714#endif /* LCD_PIXELFORMAT */
715#elif LCD_DEPTH == 16
716 /* iriver h300, colour iPods, X5 */
717 fb_data *dest = (fb_data *)bitmap + fb_width * row;
718 int delta = 127;
719 unsigned r, g, b;
720 struct uint8_rgb q0;
721
722 for (col = 0; col < bm->width; col++) {
723 if (dither)
724 delta = DITHERXDY(col,dy);
725 q0 = *qp++;
726 r = (31 * q0.red + (q0.red >> 3) + delta) >> 8;
727 g = (63 * q0.green + (q0.green >> 2) + delta) >> 8;
728 b = (31 * q0.blue + (q0.blue >> 3) + delta) >> 8;
729 *dest++ = LCD_RGBPACK_LCD(r, g, b);
730 }
731#endif /* LCD_DEPTH */
732 } 766 }
733 } else 767#endif
734#endif /* (LCD_DEPTH > 1) || 768#if ((LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) && \
735 defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) */ 769 !defined(PLUGIN)
770 }
771#ifndef PLUGIN
772 else
773#endif
774#endif
775#ifndef PLUGIN
736 { 776 {
737 p = bitmap + bm->width * (row >> 3); 777 unsigned char *p = bitmap + bm->width * (row >> 3);
738 mask = 1 << (row & 7); 778 unsigned char mask = 1 << (row & 7);
739 779 int col;
740 for (col = 0; col < bm->width; col++, p++) 780 for (col = 0; col < bm->width; col++, p++)
741#if !defined(HAVE_LCD_COLOR) && \ 781#if !defined(HAVE_LCD_COLOR) && \
742 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) 782 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1))
@@ -747,7 +787,7 @@ int read_bmp_fd(int fd,
747 *p |= mask; 787 *p |= mask;
748#endif 788#endif
749 } 789 }
790#endif
750 } 791 }
751 return totalsize; /* return the used buffer size. */ 792 return totalsize; /* return the used buffer size. */
752#endif
753} 793}
diff --git a/apps/recorder/bmp.h b/apps/recorder/bmp.h
index c570a3d6bd..6437e42d26 100644
--- a/apps/recorder/bmp.h
+++ b/apps/recorder/bmp.h
@@ -212,4 +212,8 @@ int read_bmp_fd(int fd,
212 int format, 212 int format,
213 const struct custom_format *cformat); 213 const struct custom_format *cformat);
214 214
215#if LCD_DEPTH > 1
216void output_row_8_native(uint32_t row, void * row_in,
217 struct scaler_context *ctx);
218#endif
215#endif 219#endif
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c
index 555f60d6bd..9393e60de8 100644
--- a/apps/recorder/jpeg_load.c
+++ b/apps/recorder/jpeg_load.c
@@ -109,6 +109,7 @@ struct jpeg
109 int tab_membership[6]; 109 int tab_membership[6];
110 int subsample_x[3]; /* info per component */ 110 int subsample_x[3]; /* info per component */
111 int subsample_y[3]; 111 int subsample_y[3];
112 bool resize;
112 unsigned char buf[JPEG_READ_BUF_SIZE]; 113 unsigned char buf[JPEG_READ_BUF_SIZE];
113 struct img_part part; 114 struct img_part part;
114}; 115};
@@ -2025,14 +2026,15 @@ int read_jpeg_fd(int fd,
2025 recalc_dimension(&resize_dim, &src_dim); 2026 recalc_dimension(&resize_dim, &src_dim);
2026 bm->width = resize_dim.width; 2027 bm->width = resize_dim.width;
2027 bm->height = resize_dim.height; 2028 bm->height = resize_dim.height;
2028 if (bm->width == src_dim.width && bm->height == src_dim.height)
2029 resize = false;
2030 } else { 2029 } else {
2031 bm->width = p_jpeg->x_size; 2030 bm->width = p_jpeg->x_size;
2032 bm->height = p_jpeg->y_size; 2031 bm->height = p_jpeg->y_size;
2033 } 2032 }
2034 p_jpeg->h_scale[0] = calc_scale(p_jpeg->x_size, bm->width); 2033 p_jpeg->h_scale[0] = calc_scale(p_jpeg->x_size, bm->width);
2035 p_jpeg->v_scale[0] = calc_scale(p_jpeg->y_size, bm->height); 2034 p_jpeg->v_scale[0] = calc_scale(p_jpeg->y_size, bm->height);
2035 if ((p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3 &&
2036 (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3)
2037 resize = false;
2036#ifdef HAVE_LCD_COLOR 2038#ifdef HAVE_LCD_COLOR
2037 p_jpeg->h_scale[1] = p_jpeg->h_scale[0] + 2039 p_jpeg->h_scale[1] = p_jpeg->h_scale[0] +
2038 p_jpeg->frameheader[0].horizontal_sampling - 1; 2040 p_jpeg->frameheader[0].horizontal_sampling - 1;
@@ -2092,11 +2094,54 @@ int read_jpeg_fd(int fd,
2092 rset.rowstart = 0; 2094 rset.rowstart = 0;
2093 rset.rowstop = bm->height; 2095 rset.rowstop = bm->height;
2094 rset.rowstep = 1; 2096 rset.rowstep = 1;
2095 if (resize_on_load(bm, dither, &src_dim, &rset, buf_start, maxsize, cformat, 2097 p_jpeg->resize = resize;
2096 IF_PIX_FMT(p_jpeg->blocks == 1 ? 0 : 1,) store_row_jpeg, p_jpeg)) 2098 if (resize)
2099 {
2100 if (resize_on_load(bm, dither, &src_dim, &rset, buf_start, maxsize,
2101 cformat, IF_PIX_FMT(p_jpeg->blocks == 1 ? 0 : 1,) store_row_jpeg,
2102 p_jpeg))
2103 return bm_size;
2104 } else {
2105 int row;
2106 struct scaler_context ctx = {
2107 .bm = bm,
2108 .dither = dither,
2109 };
2110#if LCD_DEPTH > 1
2111 void (*output_row_8)(uint32_t, void*, struct scaler_context*) =
2112 output_row_8_native;
2113#elif defined(PLUGIN)
2114 void (*output_row_8)(uint32_t, void*, struct scaler_context*) = NULL;
2115#endif
2116#if LCD_DEPTH > 1 || defined(PLUGIN)
2117 if (cformat)
2118 output_row_8 = cformat->output_row_8;
2119#endif
2120 struct img_part *part;
2121 for (row = 0; row < bm->height; row++)
2122 {
2123 part = store_row_jpeg(p_jpeg);
2124#ifdef HAVE_LCD_COLOR
2125 struct uint8_rgb *qp = part->buf;
2126 struct uint8_rgb *end = qp + bm->width;
2127 uint8_t y, u, v;
2128 unsigned r, g, b;
2129 for (; qp < end; qp++)
2130 {
2131 y = qp->blue;
2132 u = qp->green;
2133 v = qp->red;
2134 yuv_to_rgb(y, u, v, &r, &g, &b);
2135 qp->red = r;
2136 qp->blue = b;
2137 qp->green = g;
2138 }
2139#endif
2140 output_row_8(row, part->buf, &ctx);
2141 }
2097 return bm_size; 2142 return bm_size;
2098 else 2143 }
2099 return 0; 2144 return 0;
2100} 2145}
2101 2146
2102/**************** end JPEG code ********************/ 2147/**************** end JPEG code ********************/
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c
index 5ecb5c24cf..1e9210e819 100644
--- a/apps/recorder/resize.c
+++ b/apps/recorder/resize.c
@@ -518,7 +518,7 @@ static inline bool scale_v_linear(struct rowset *rset,
518#endif /* HAVE_UPSCALER */ 518#endif /* HAVE_UPSCALER */
519 519
520#if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN)) 520#if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN))
521void output_row_native_fromyuv(uint32_t row, void * row_in, 521static void output_row_32_native_fromyuv(uint32_t row, void * row_in,
522 struct scaler_context *ctx) 522 struct scaler_context *ctx)
523{ 523{
524 int col; 524 int col;
@@ -547,7 +547,7 @@ void output_row_native_fromyuv(uint32_t row, void * row_in,
547#endif 547#endif
548 548
549#if !defined(PLUGIN) || LCD_DEPTH > 1 549#if !defined(PLUGIN) || LCD_DEPTH > 1
550void output_row_native(uint32_t row, void * row_in, 550static void output_row_32_native(uint32_t row, void * row_in,
551 struct scaler_context *ctx) 551 struct scaler_context *ctx)
552{ 552{
553 int col; 553 int col;
@@ -644,13 +644,14 @@ unsigned int get_size_native(struct bitmap *bm)
644} 644}
645 645
646const struct custom_format format_native = { 646const struct custom_format format_native = {
647 .output_row_8 = output_row_8_native,
647#if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN)) 648#if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN))
648 .output_row = { 649 .output_row_32 = {
649 output_row_native, 650 output_row_32_native,
650 output_row_native_fromyuv 651 output_row_32_native_fromyuv
651 }, 652 },
652#else 653#else
653 .output_row = output_row_native, 654 .output_row_32 = output_row_32_native,
654#endif 655#endif
655 .get_size = get_size_native 656 .get_size = get_size_native
656}; 657};
@@ -722,17 +723,17 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
722 ctx.dither = dither; 723 ctx.dither = dither;
723#if !defined(PLUGIN) 724#if !defined(PLUGIN)
724#if defined(HAVE_LCD_COLOR) && defined(HAVE_JPEG) 725#if defined(HAVE_LCD_COLOR) && defined(HAVE_JPEG)
725 ctx.output_row = format_index ? output_row_native_fromyuv 726 ctx.output_row = format_index ? output_row_32_native_fromyuv
726 : output_row_native; 727 : output_row_32_native;
727#else 728#else
728 ctx.output_row = output_row_native; 729 ctx.output_row = output_row_32_native;
729#endif 730#endif
730 if (format) 731 if (format)
731#endif 732#endif
732#if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN)) 733#if defined(HAVE_LCD_COLOR) && (defined(HAVE_JPEG) || defined(PLUGIN))
733 ctx.output_row = format->output_row[format_index]; 734 ctx.output_row = format->output_row_32[format_index];
734#else 735#else
735 ctx.output_row = format->output_row; 736 ctx.output_row = format->output_row_32;
736#endif 737#endif
737#ifdef HAVE_UPSCALER 738#ifdef HAVE_UPSCALER
738 if (sw > dw) 739 if (sw > dw)
diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h
index f7cda15254..2964fcd2a9 100644
--- a/apps/recorder/resize.h
+++ b/apps/recorder/resize.h
@@ -150,19 +150,17 @@ struct scaler_context {
150#endif 150#endif
151 151
152struct custom_format { 152struct custom_format {
153 void (*output_row_8)(uint32_t,void*, struct scaler_context*);
153#if defined(HAVE_LCD_COLOR) 154#if defined(HAVE_LCD_COLOR)
154 void (*output_row[2])(uint32_t,void*,struct scaler_context*); 155 void (*output_row_32[2])(uint32_t,void*, struct scaler_context*);
155#else 156#else
156 void (*output_row)(uint32_t,void*,struct scaler_context*); 157 void (*output_row_32)(uint32_t,void*, struct scaler_context*);
157#endif 158#endif
158 unsigned int (*get_size)(struct bitmap *bm); 159 unsigned int (*get_size)(struct bitmap *bm);
159}; 160};
160 161
161struct rowset; 162struct rowset;
162 163
163void output_row_native(uint32_t row, void * row_in,
164 struct scaler_context *ctx);
165
166extern const struct custom_format format_native; 164extern const struct custom_format format_native;
167 165
168int recalc_dimension(struct dim *dst, struct dim *src); 166int recalc_dimension(struct dim *dst, struct dim *src);