diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-09 07:31:27 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-09 07:31:27 +0000 |
commit | 91efc162564cd9c04677e2e38550cde21995b06e (patch) | |
tree | c927cefc7f12a49396541dbac246dc76ca444c71 /apps/recorder/jpeg_load.c | |
parent | 67695617a13e9f37f17e3718b03046f6d748a9e1 (diff) | |
download | rockbox-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
Diffstat (limited to 'apps/recorder/jpeg_load.c')
-rw-r--r-- | apps/recorder/jpeg_load.c | 57 |
1 files changed, 51 insertions, 6 deletions
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 ********************/ |