diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2008-12-26 07:05:13 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2008-12-26 07:05:13 +0000 |
commit | 9058620849c080a404fb156915856f9d0b06e71c (patch) | |
tree | 004590b20a5ea0fa6b099f5332af162896e44098 | |
parent | f7fa7e5ad537415f1f75b3a9c1a58eb925e10d04 (diff) | |
download | rockbox-9058620849c080a404fb156915856f9d0b06e71c.tar.gz rockbox-9058620849c080a404fb156915856f9d0b06e71c.zip |
Make scaler output truly pluggable, add an 8-bit greyscale output to
pluginlib for use with greylib, and add source for a test scaled bmp
viewer using greylib.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19593 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/buffering.c | 2 | ||||
-rw-r--r-- | apps/gui/backdrop.c | 4 | ||||
-rw-r--r-- | apps/gui/icon.c | 2 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 2 | ||||
-rw-r--r-- | apps/plugin.h | 6 | ||||
-rw-r--r-- | apps/plugins/CATEGORIES | 1 | ||||
-rw-r--r-- | apps/plugins/lib/grey.h | 1 | ||||
-rw-r--r-- | apps/plugins/lib/grey_draw.c | 19 | ||||
-rw-r--r-- | apps/plugins/pictureflow.c | 2 | ||||
-rw-r--r-- | apps/plugins/rockpaint.c | 2 | ||||
-rw-r--r-- | apps/plugins/sliding_puzzle.c | 3 | ||||
-rw-r--r-- | apps/plugins/test_resize.c | 2 | ||||
-rw-r--r-- | apps/plugins/viewers.config | 1 | ||||
-rw-r--r-- | apps/recorder/bmp.c | 26 | ||||
-rw-r--r-- | apps/recorder/bmp.h | 7 | ||||
-rw-r--r-- | apps/recorder/resize.c | 25 | ||||
-rw-r--r-- | apps/recorder/resize.h | 25 |
17 files changed, 88 insertions, 42 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index 6160869498..1e643c5771 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -861,7 +861,7 @@ static int load_bitmap(int fd) | |||
861 | get_albumart_size(bmp); | 861 | get_albumart_size(bmp); |
862 | 862 | ||
863 | rc = read_bmp_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| | 863 | rc = read_bmp_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| |
864 | FORMAT_RESIZE|FORMAT_KEEP_ASPECT); | 864 | FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL); |
865 | return rc + (rc > 0 ? sizeof(struct bitmap) : 0); | 865 | return rc + (rc > 0 ? sizeof(struct bitmap) : 0); |
866 | } | 866 | } |
867 | #endif | 867 | #endif |
diff --git a/apps/gui/backdrop.c b/apps/gui/backdrop.c index 6178894c42..c95fda9022 100644 --- a/apps/gui/backdrop.c +++ b/apps/gui/backdrop.c | |||
@@ -52,7 +52,7 @@ static bool load_backdrop(const char* filename, fb_data* backdrop_buffer) | |||
52 | /* load the image */ | 52 | /* load the image */ |
53 | bm.data=(char*)backdrop_buffer; | 53 | bm.data=(char*)backdrop_buffer; |
54 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), | 54 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), |
55 | FORMAT_NATIVE | FORMAT_DITHER); | 55 | FORMAT_NATIVE | FORMAT_DITHER, NULL); |
56 | 56 | ||
57 | if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)) | 57 | if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)) |
58 | { | 58 | { |
@@ -114,7 +114,7 @@ static bool load_remote_backdrop(const char* filename, fb_remote_data* backdrop_ | |||
114 | /* load the image */ | 114 | /* load the image */ |
115 | bm.data=(char*)backdrop_buffer; | 115 | bm.data=(char*)backdrop_buffer; |
116 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), | 116 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), |
117 | FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE); | 117 | FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL); |
118 | 118 | ||
119 | if ((ret > 0) && (bm.width == LCD_REMOTE_WIDTH) && (bm.height == LCD_REMOTE_HEIGHT)) | 119 | if ((ret > 0) && (bm.width == LCD_REMOTE_WIDTH) && (bm.height == LCD_REMOTE_HEIGHT)) |
120 | { | 120 | { |
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index e11c21cbea..3e1e793194 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -222,7 +222,7 @@ static void load_icons(const char* filename, enum Iconset iconset, | |||
222 | char path[MAX_PATH]; | 222 | char path[MAX_PATH]; |
223 | 223 | ||
224 | snprintf(path, sizeof(path), "%s/%s.bmp", ICON_DIR, filename); | 224 | snprintf(path, sizeof(path), "%s/%s.bmp", ICON_DIR, filename); |
225 | size_read = read_bmp_file(path, bmp, IMG_BUFSIZE, bmpformat); | 225 | size_read = read_bmp_file(path, bmp, IMG_BUFSIZE, bmpformat, NULL); |
226 | if (size_read > 0) | 226 | if (size_read > 0) |
227 | { | 227 | { |
228 | *loaded_ok = true; | 228 | *loaded_ok = true; |
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 307d0bb784..acf161b6bb 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -416,7 +416,7 @@ static bool load_bitmap(struct wps_data *wps_data, | |||
416 | 416 | ||
417 | int ret = read_bmp_file(filename, bm, | 417 | int ret = read_bmp_file(filename, bm, |
418 | wps_data->img_buf_free, | 418 | wps_data->img_buf_free, |
419 | format); | 419 | format,NULL); |
420 | 420 | ||
421 | if (ret > 0) | 421 | if (ret > 0) |
422 | { | 422 | { |
diff --git a/apps/plugin.h b/apps/plugin.h index 20e3a71595..81c069666a 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -132,12 +132,12 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
132 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 132 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
133 | 133 | ||
134 | /* increase this every time the api struct changes */ | 134 | /* increase this every time the api struct changes */ |
135 | #define PLUGIN_API_VERSION 130 | 135 | #define PLUGIN_API_VERSION 131 |
136 | 136 | ||
137 | /* update this to latest version if a change to the api struct breaks | 137 | /* update this to latest version if a change to the api struct breaks |
138 | backwards compatibility (and please take the opportunity to sort in any | 138 | backwards compatibility (and please take the opportunity to sort in any |
139 | new function which are "waiting" at the end of the function table) */ | 139 | new function which are "waiting" at the end of the function table) */ |
140 | #define PLUGIN_MIN_API_VERSION 130 | 140 | #define PLUGIN_MIN_API_VERSION 131 |
141 | 141 | ||
142 | /* plugin return codes */ | 142 | /* plugin return codes */ |
143 | enum plugin_status { | 143 | enum plugin_status { |
@@ -714,7 +714,7 @@ struct plugin_api { | |||
714 | #endif | 714 | #endif |
715 | #ifdef HAVE_LCD_BITMAP | 715 | #ifdef HAVE_LCD_BITMAP |
716 | int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize, | 716 | int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize, |
717 | int format); | 717 | int format, const struct custom_format *cformat); |
718 | void (*screen_dump_set_hook)(void (*hook)(int fh)); | 718 | void (*screen_dump_set_hook)(void (*hook)(int fh)); |
719 | #endif | 719 | #endif |
720 | int (*show_logo)(void); | 720 | int (*show_logo)(void); |
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES index 750d149aeb..09a4476db0 100644 --- a/apps/plugins/CATEGORIES +++ b/apps/plugins/CATEGORIES | |||
@@ -92,6 +92,7 @@ test_sampr,apps | |||
92 | test_scanrate,apps | 92 | test_scanrate,apps |
93 | test_touchscreen,apps | 93 | test_touchscreen,apps |
94 | test_viewports,apps | 94 | test_viewports,apps |
95 | test_greylib_bitmap_scale,viewers | ||
95 | text_editor,apps | 96 | text_editor,apps |
96 | vbrfix,viewers | 97 | vbrfix,viewers |
97 | video,viewers | 98 | video,viewers |
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h index 8f8de9db99..8c9d40ab8d 100644 --- a/apps/plugins/lib/grey.h +++ b/apps/plugins/lib/grey.h | |||
@@ -106,6 +106,7 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
106 | int stride, int x, int y, int width, int height); | 106 | int stride, int x, int y, int width, int height); |
107 | void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, | 107 | void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, |
108 | int height); | 108 | int height); |
109 | extern const struct custom_format format_grey; | ||
109 | 110 | ||
110 | /* Text */ | 111 | /* Text */ |
111 | void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str); | 112 | void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str); |
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c index e9812b6784..51d340dd7f 100644 --- a/apps/plugins/lib/grey_draw.c +++ b/apps/plugins/lib/grey_draw.c | |||
@@ -669,3 +669,22 @@ void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, | |||
669 | { | 669 | { |
670 | grey_ub_gray_bitmap_part(src, 0, 0, width, x, y, width, height); | 670 | grey_ub_gray_bitmap_part(src, 0, 0, width, x, y, width, height); |
671 | } | 671 | } |
672 | |||
673 | static void output_row_grey(uint32_t row, void * row_in, struct scaler_context *ctx) | ||
674 | { | ||
675 | int col; | ||
676 | uint32_t *qp = (uint32_t*)row_in; | ||
677 | uint8_t *dest = (uint8_t*)ctx->bm->data + ctx->bm->width * row; | ||
678 | for (col = 0; col < ctx->bm->width; col++) | ||
679 | *dest++ = ((*qp++) + ctx->round) * (uint64_t)ctx->divisor >> 32; | ||
680 | } | ||
681 | |||
682 | static unsigned int get_size_grey(struct bitmap *bm) | ||
683 | { | ||
684 | return bm->width * bm->height; | ||
685 | } | ||
686 | |||
687 | const struct custom_format format_grey = { | ||
688 | .output_row = output_row_grey, | ||
689 | .get_size = get_size_grey | ||
690 | }; | ||
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index 150d88212f..0dd9f924d7 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c | |||
@@ -636,7 +636,7 @@ bool create_albumart_cache(bool force) | |||
636 | input_bmp.data = (char *)input_bmp_buffer; | 636 | input_bmp.data = (char *)input_bmp_buffer; |
637 | ret = rb->read_bmp_file(arlbumart_file, &input_bmp, | 637 | ret = rb->read_bmp_file(arlbumart_file, &input_bmp, |
638 | sizeof(fb_data)*MAX_IMG_WIDTH*MAX_IMG_HEIGHT, | 638 | sizeof(fb_data)*MAX_IMG_WIDTH*MAX_IMG_HEIGHT, |
639 | FORMAT_NATIVE); | 639 | FORMAT_NATIVE, NULL); |
640 | if (ret <= 0) { | 640 | if (ret <= 0) { |
641 | rb->splash(HZ, "Could not read bmp"); | 641 | rb->splash(HZ, "Could not read bmp"); |
642 | continue; /* skip missing/broken files */ | 642 | continue; /* skip missing/broken files */ |
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index 300821b3a4..40d19101fc 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c | |||
@@ -2967,7 +2967,7 @@ static int load_bitmap( const char *file ) | |||
2967 | 2967 | ||
2968 | bm.data = (char*)save_buffer; | 2968 | bm.data = (char*)save_buffer; |
2969 | ret = rb->read_bmp_file( file, &bm, ROWS*COLS*sizeof( fb_data ), | 2969 | ret = rb->read_bmp_file( file, &bm, ROWS*COLS*sizeof( fb_data ), |
2970 | FORMAT_NATIVE ); | 2970 | FORMAT_NATIVE, NULL ); |
2971 | 2971 | ||
2972 | if((bm.width > COLS ) || ( bm.height > ROWS )) | 2972 | if((bm.width > COLS ) || ( bm.height > ROWS )) |
2973 | return -1; | 2973 | return -1; |
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c index fa9e093c3c..8a607c9272 100644 --- a/apps/plugins/sliding_puzzle.c +++ b/apps/plugins/sliding_puzzle.c | |||
@@ -340,7 +340,8 @@ static bool load_resize_bitmap(void) | |||
340 | 340 | ||
341 | rc = rb->read_bmp_file( filename, &main_bitmap, | 341 | rc = rb->read_bmp_file( filename, &main_bitmap, |
342 | sizeof(img_buf), | 342 | sizeof(img_buf), |
343 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_DITHER); | 343 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_DITHER, |
344 | NULL); | ||
344 | if( rc > 0 ) | 345 | if( rc > 0 ) |
345 | { | 346 | { |
346 | puzzle_bmp_ptr = (const fb_data *)img_buf; | 347 | puzzle_bmp_ptr = (const fb_data *)img_buf; |
diff --git a/apps/plugins/test_resize.c b/apps/plugins/test_resize.c index b0ef787d36..a608005c10 100644 --- a/apps/plugins/test_resize.c +++ b/apps/plugins/test_resize.c | |||
@@ -78,7 +78,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
78 | output_bmp.data = (char*)output_bmp_data; | 78 | output_bmp.data = (char*)output_bmp_data; |
79 | 79 | ||
80 | int ret = rb->read_bmp_file("/test.bmp", &input_bmp, sizeof(input_bmp_data), | 80 | int ret = rb->read_bmp_file("/test.bmp", &input_bmp, sizeof(input_bmp_data), |
81 | FORMAT_NATIVE); | 81 | FORMAT_NATIVE, NULL); |
82 | 82 | ||
83 | if (ret < 0) { | 83 | if (ret < 0) { |
84 | rb->splash(HZ, "Could not load /test.bmp"); | 84 | rb->splash(HZ, "Could not load /test.bmp"); |
diff --git a/apps/plugins/viewers.config b/apps/plugins/viewers.config index e2babf6134..2ec8fe9299 100644 --- a/apps/plugins/viewers.config +++ b/apps/plugins/viewers.config | |||
@@ -25,6 +25,7 @@ wav,viewers/mp3_encoder,- | |||
25 | wav,viewers/wavplay,9 | 25 | wav,viewers/wavplay,9 |
26 | wav,viewers/wavview,10 | 26 | wav,viewers/wavview,10 |
27 | wav,viewers/test_codec,- | 27 | wav,viewers/test_codec,- |
28 | bmp,viewers/test_greylib_bitmap_scale,- | ||
28 | bmp,apps/rockpaint,11 | 29 | bmp,apps/rockpaint,11 |
29 | bmp,games/sliding_puzzle,11 | 30 | bmp,games/sliding_puzzle,11 |
30 | mpg,viewers/mpegplayer,4 | 31 | mpg,viewers/mpegplayer,4 |
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index cc574649d8..86c057a907 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -147,7 +147,8 @@ const unsigned short vi_pattern[4] = { | |||
147 | int read_bmp_file(const char* filename, | 147 | int read_bmp_file(const char* filename, |
148 | struct bitmap *bm, | 148 | struct bitmap *bm, |
149 | int maxsize, | 149 | int maxsize, |
150 | int format) | 150 | int format, |
151 | const struct custom_format *cformat) | ||
151 | { | 152 | { |
152 | int fd, ret; | 153 | int fd, ret; |
153 | fd = open(filename, O_RDONLY); | 154 | fd = open(filename, O_RDONLY); |
@@ -161,7 +162,7 @@ int read_bmp_file(const char* filename, | |||
161 | BDEBUGF("read_bmp_file: '%s' remote: %d resize: %d keep_aspect: %d\n", | 162 | BDEBUGF("read_bmp_file: '%s' remote: %d resize: %d keep_aspect: %d\n", |
162 | filename, !!(format & FORMAT_REMOTE), !!(format & FORMAT_RESIZE), | 163 | filename, !!(format & FORMAT_REMOTE), !!(format & FORMAT_RESIZE), |
163 | !!(format & FORMAT_KEEP_ASPECT)); | 164 | !!(format & FORMAT_KEEP_ASPECT)); |
164 | ret = read_bmp_fd(fd, bm, maxsize, format); | 165 | ret = read_bmp_fd(fd, bm, maxsize, format, cformat); |
165 | close(fd); | 166 | close(fd); |
166 | return ret; | 167 | return ret; |
167 | } | 168 | } |
@@ -349,7 +350,8 @@ static inline int rgbcmp(struct uint8_rgb rgb1, struct uint8_rgb rgb2) | |||
349 | int read_bmp_fd(int fd, | 350 | int read_bmp_fd(int fd, |
350 | struct bitmap *bm, | 351 | struct bitmap *bm, |
351 | int maxsize, | 352 | int maxsize, |
352 | int format) | 353 | int format, |
354 | const struct custom_format *cformat) | ||
353 | { | 355 | { |
354 | struct bmp_header bmph; | 356 | struct bmp_header bmph; |
355 | int padded_width; | 357 | int padded_width; |
@@ -473,7 +475,10 @@ int read_bmp_fd(int fd, | |||
473 | rset.rowstop = -1; | 475 | rset.rowstop = -1; |
474 | } | 476 | } |
475 | 477 | ||
476 | totalsize = BM_SIZE(bm->width,bm->height,format,remote); | 478 | if (cformat) |
479 | totalsize = cformat->get_size(bm); | ||
480 | else | ||
481 | totalsize = BM_SIZE(bm->width,bm->height,format,remote); | ||
477 | 482 | ||
478 | /* Check if this fits the buffer */ | 483 | /* Check if this fits the buffer */ |
479 | if (totalsize > maxsize) { | 484 | if (totalsize > maxsize) { |
@@ -565,10 +570,15 @@ int read_bmp_fd(int fd, | |||
565 | }; | 570 | }; |
566 | 571 | ||
567 | #if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | 572 | #if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) |
568 | if (resize) | 573 | if (resize || cformat) |
569 | return resize_on_load(bm, dither, &src_dim, &rset, | 574 | { |
570 | bitmap + totalsize, maxsize - totalsize, | 575 | if (resize_on_load(bm, dither, &src_dim, &rset, |
571 | store_part_bmp, &ba); | 576 | bitmap + totalsize, maxsize - totalsize, |
577 | cformat, store_part_bmp, &ba)) | ||
578 | return totalsize; | ||
579 | else | ||
580 | return 0; | ||
581 | } | ||
572 | 582 | ||
573 | int fb_width = BM_WIDTH(bm->width,bm->format,remote); | 583 | int fb_width = BM_WIDTH(bm->width,bm->format,remote); |
574 | #endif /* LCD_DEPTH */ | 584 | #endif /* LCD_DEPTH */ |
diff --git a/apps/recorder/bmp.h b/apps/recorder/bmp.h index 273e178bc9..c53f295dfb 100644 --- a/apps/recorder/bmp.h +++ b/apps/recorder/bmp.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "config.h" | 24 | #include "config.h" |
25 | #include "lcd.h" | 25 | #include "lcd.h" |
26 | #include "inttypes.h" | 26 | #include "inttypes.h" |
27 | #include "resize.h" | ||
27 | #ifdef HAVE_REMOTE_LCD | 28 | #ifdef HAVE_REMOTE_LCD |
28 | #include "lcd-remote.h" | 29 | #include "lcd-remote.h" |
29 | #endif | 30 | #endif |
@@ -202,10 +203,12 @@ extern const unsigned short vi_pattern[4]; | |||
202 | int read_bmp_file(const char* filename, | 203 | int read_bmp_file(const char* filename, |
203 | struct bitmap *bm, | 204 | struct bitmap *bm, |
204 | int maxsize, | 205 | int maxsize, |
205 | int format); | 206 | int format, |
207 | const struct custom_format *cformat); | ||
206 | 208 | ||
207 | int read_bmp_fd(int fd, | 209 | int read_bmp_fd(int fd, |
208 | struct bitmap *bm, | 210 | struct bitmap *bm, |
209 | int maxsize, | 211 | int maxsize, |
210 | int format); | 212 | int format, |
213 | const struct custom_format *cformat); | ||
211 | #endif | 214 | #endif |
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index 3c1d34f046..658cdd85ae 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c | |||
@@ -114,23 +114,6 @@ int recalc_dimension(struct dim *dst, struct dim *src) | |||
114 | return false; \ | 114 | return false; \ |
115 | } | 115 | } |
116 | 116 | ||
117 | /* struct which containers various parameters shared between vertical scaler, | ||
118 | horizontal scaler, and row output | ||
119 | */ | ||
120 | struct scaler_context { | ||
121 | uint32_t divisor; | ||
122 | uint32_t round; | ||
123 | struct bitmap *bm; | ||
124 | struct dim *src; | ||
125 | unsigned char *buf; | ||
126 | bool dither; | ||
127 | int len; | ||
128 | void *args; | ||
129 | struct img_part* (*store_part)(void *); | ||
130 | void (*output_row)(uint32_t,void*,struct scaler_context*); | ||
131 | bool (*h_scaler)(void*,struct scaler_context*, bool); | ||
132 | }; | ||
133 | |||
134 | /* Set up rounding and scale factors for horizontal area scaler */ | 117 | /* Set up rounding and scale factors for horizontal area scaler */ |
135 | static inline void scale_h_area_setup(struct scaler_context *ctx) | 118 | static inline void scale_h_area_setup(struct scaler_context *ctx) |
136 | { | 119 | { |
@@ -610,6 +593,7 @@ void output_row_native(uint32_t row, void * row_in, struct scaler_context *ctx) | |||
610 | 593 | ||
611 | int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | 594 | int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, |
612 | struct rowset *rset, unsigned char *buf, unsigned int len, | 595 | struct rowset *rset, unsigned char *buf, unsigned int len, |
596 | const struct custom_format *format, | ||
613 | struct img_part* (*store_part)(void *args), | 597 | struct img_part* (*store_part)(void *args), |
614 | void *args) | 598 | void *args) |
615 | { | 599 | { |
@@ -669,7 +653,10 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
669 | ctx.bm = bm; | 653 | ctx.bm = bm; |
670 | ctx.src = src; | 654 | ctx.src = src; |
671 | ctx.dither = dither; | 655 | ctx.dither = dither; |
672 | ctx.output_row = output_row_native; | 656 | if (format) |
657 | ctx.output_row = format->output_row; | ||
658 | else | ||
659 | ctx.output_row = output_row_native; | ||
673 | #ifdef HAVE_UPSCALER | 660 | #ifdef HAVE_UPSCALER |
674 | if (sw > dw) | 661 | if (sw > dw) |
675 | { | 662 | { |
@@ -693,5 +680,5 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
693 | cpu_boost(false); | 680 | cpu_boost(false); |
694 | if (!ret) | 681 | if (!ret) |
695 | return 0; | 682 | return 0; |
696 | return BM_SIZE(bm->width,bm->height,bm->format,0); | 683 | return 1; |
697 | } | 684 | } |
diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h index 451830742e..ca7e6326d0 100644 --- a/apps/recorder/resize.h +++ b/apps/recorder/resize.h | |||
@@ -20,7 +20,6 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #ifndef _RESIZE_H_ | 21 | #ifndef _RESIZE_H_ |
22 | #define _RESIZE_H_ | 22 | #define _RESIZE_H_ |
23 | |||
24 | #include "config.h" | 23 | #include "config.h" |
25 | #include "lcd.h" | 24 | #include "lcd.h" |
26 | #include "inttypes.h" | 25 | #include "inttypes.h" |
@@ -65,11 +64,35 @@ struct uint32_rgb { | |||
65 | }; | 64 | }; |
66 | #endif | 65 | #endif |
67 | 66 | ||
67 | /* struct which contains various parameters shared between vertical scaler, | ||
68 | horizontal scaler, and row output | ||
69 | */ | ||
70 | struct scaler_context { | ||
71 | uint32_t divisor; | ||
72 | uint32_t round; | ||
73 | struct bitmap *bm; | ||
74 | struct dim *src; | ||
75 | unsigned char *buf; | ||
76 | bool dither; | ||
77 | int len; | ||
78 | void *args; | ||
79 | struct img_part* (*store_part)(void *); | ||
80 | void (*output_row)(uint32_t,void*,struct scaler_context*); | ||
81 | bool (*h_scaler)(void*,struct scaler_context*, bool); | ||
82 | }; | ||
83 | |||
84 | struct custom_format { | ||
85 | void (*output_row)(uint32_t,void*,struct scaler_context*); | ||
86 | unsigned int (*get_size)(struct bitmap *bm); | ||
87 | }; | ||
88 | |||
89 | struct rowset; | ||
68 | int recalc_dimension(struct dim *dst, struct dim *src); | 90 | int recalc_dimension(struct dim *dst, struct dim *src); |
69 | 91 | ||
70 | int resize_on_load(struct bitmap *bm, bool dither, | 92 | int resize_on_load(struct bitmap *bm, bool dither, |
71 | struct dim *src, struct rowset *tmp_row, | 93 | struct dim *src, struct rowset *tmp_row, |
72 | unsigned char *buf, unsigned int len, | 94 | unsigned char *buf, unsigned int len, |
95 | const struct custom_format *cformat, | ||
73 | struct img_part* (*store_part)(void *args), | 96 | struct img_part* (*store_part)(void *args), |
74 | void *args); | 97 | void *args); |
75 | #endif /* _RESIZE_H_ */ | 98 | #endif /* _RESIZE_H_ */ |