diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/bmp.c | 34 | ||||
-rw-r--r-- | apps/recorder/bmp.h | 7 | ||||
-rw-r--r-- | apps/recorder/resize.c | 31 | ||||
-rw-r--r-- | apps/recorder/resize.h | 5 |
4 files changed, 19 insertions, 58 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 01b57d2116..d6d836a6c5 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -72,19 +72,6 @@ | |||
72 | #pragma pack (push, 2) | 72 | #pragma pack (push, 2) |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | #ifndef PLUGIN | ||
76 | #define API(x) x | ||
77 | #else | ||
78 | #define API(x) rb->x | ||
79 | |||
80 | static const struct plugin_api *rb; | ||
81 | |||
82 | void bmp_init(const struct plugin_api * api) | ||
83 | { | ||
84 | rb = api; | ||
85 | } | ||
86 | #endif | ||
87 | |||
88 | /* BMP header structure */ | 75 | /* BMP header structure */ |
89 | struct bmp_header { | 76 | struct bmp_header { |
90 | uint16_t type; /* signature - 'BM' */ | 77 | uint16_t type; /* signature - 'BM' */ |
@@ -137,15 +124,13 @@ static const struct uint8_rgb bitfields[3][3] = { | |||
137 | }, | 124 | }, |
138 | }; | 125 | }; |
139 | 126 | ||
140 | #if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) || \ | 127 | #if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) |
141 | defined(PLUGIN) | ||
142 | /* the full 16x16 Bayer dither matrix may be calculated quickly with this table | 128 | /* the full 16x16 Bayer dither matrix may be calculated quickly with this table |
143 | */ | 129 | */ |
144 | const unsigned char dither_table[16] = | 130 | const unsigned char dither_table[16] = |
145 | { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }; | 131 | { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }; |
146 | #endif | 132 | #endif |
147 | 133 | ||
148 | #ifndef PLUGIN | ||
149 | #if ((LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)) \ | 134 | #if ((LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)) \ |
150 | || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH == 2) \ | 135 | || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH == 2) \ |
151 | && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)) | 136 | && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)) |
@@ -153,7 +138,6 @@ const unsigned short vi_pattern[4] = { | |||
153 | 0x0101, 0x0100, 0x0001, 0x0000 | 138 | 0x0101, 0x0100, 0x0001, 0x0000 |
154 | }; | 139 | }; |
155 | #endif | 140 | #endif |
156 | #endif | ||
157 | 141 | ||
158 | /****************************************************************************** | 142 | /****************************************************************************** |
159 | * read_bmp_file() | 143 | * read_bmp_file() |
@@ -168,7 +152,7 @@ int read_bmp_file(const char* filename, | |||
168 | const struct custom_format *cformat) | 152 | const struct custom_format *cformat) |
169 | { | 153 | { |
170 | int fd, ret; | 154 | int fd, ret; |
171 | fd = API(open)(filename, O_RDONLY); | 155 | fd = open(filename, O_RDONLY); |
172 | 156 | ||
173 | /* Exit if file opening failed */ | 157 | /* Exit if file opening failed */ |
174 | if (fd < 0) { | 158 | if (fd < 0) { |
@@ -180,7 +164,7 @@ int read_bmp_file(const char* filename, | |||
180 | filename, !!(format & FORMAT_REMOTE), !!(format & FORMAT_RESIZE), | 164 | filename, !!(format & FORMAT_REMOTE), !!(format & FORMAT_RESIZE), |
181 | !!(format & FORMAT_KEEP_ASPECT)); | 165 | !!(format & FORMAT_KEEP_ASPECT)); |
182 | ret = read_bmp_fd(fd, bm, maxsize, format, cformat); | 166 | ret = read_bmp_fd(fd, bm, maxsize, format, cformat); |
183 | API(close)(fd); | 167 | close(fd); |
184 | return ret; | 168 | return ret; |
185 | } | 169 | } |
186 | 170 | ||
@@ -237,7 +221,7 @@ static unsigned int read_part_line(struct bmp_args *ba) | |||
237 | #endif | 221 | #endif |
238 | ibuf = ((unsigned char *)buf) + (BM_MAX_WIDTH << 2) - len; | 222 | ibuf = ((unsigned char *)buf) + (BM_MAX_WIDTH << 2) - len; |
239 | BDEBUGF("read_part_line: cols=%d len=%d\n",cols,len); | 223 | BDEBUGF("read_part_line: cols=%d len=%d\n",cols,len); |
240 | ret = API(read)(fd, ibuf, len); | 224 | ret = read(fd, ibuf, len); |
241 | if (ret != len) | 225 | if (ret != len) |
242 | { | 226 | { |
243 | DEBUGF("read_part_line: error reading image, read returned %d " | 227 | DEBUGF("read_part_line: error reading image, read returned %d " |
@@ -324,7 +308,7 @@ static unsigned int read_part_line(struct bmp_args *ba) | |||
324 | if (pad > 0) | 308 | if (pad > 0) |
325 | { | 309 | { |
326 | BDEBUGF("seeking %d bytes to next line\n",pad); | 310 | BDEBUGF("seeking %d bytes to next line\n",pad); |
327 | API(lseek)(fd, pad, SEEK_CUR); | 311 | lseek(fd, pad, SEEK_CUR); |
328 | } | 312 | } |
329 | #if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ | 313 | #if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ |
330 | defined(PLUGIN) | 314 | defined(PLUGIN) |
@@ -422,7 +406,7 @@ int read_bmp_fd(int fd, | |||
422 | #endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/ | 406 | #endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/ |
423 | 407 | ||
424 | /* read fileheader */ | 408 | /* read fileheader */ |
425 | ret = API(read)(fd, &bmph, sizeof(struct bmp_header)); | 409 | ret = read(fd, &bmph, sizeof(struct bmp_header)); |
426 | if (ret < 0) { | 410 | if (ret < 0) { |
427 | return ret * 10 - 2; | 411 | return ret * 10 - 2; |
428 | } | 412 | } |
@@ -531,7 +515,7 @@ int read_bmp_fd(int fd, | |||
531 | int i; | 515 | int i; |
532 | union rgb_union pal; | 516 | union rgb_union pal; |
533 | for (i = 0; i < numcolors; i++) { | 517 | for (i = 0; i < numcolors; i++) { |
534 | if (API(read)(fd, &pal, sizeof(pal)) != (int)sizeof(pal)) | 518 | if (read(fd, &pal, sizeof(pal)) != (int)sizeof(pal)) |
535 | { | 519 | { |
536 | DEBUGF("read_bmp_fd: Can't read color palette\n"); | 520 | DEBUGF("read_bmp_fd: Can't read color palette\n"); |
537 | return -7; | 521 | return -7; |
@@ -589,9 +573,9 @@ int read_bmp_fd(int fd, | |||
589 | } | 573 | } |
590 | 574 | ||
591 | /* Search to the beginning of the image data */ | 575 | /* Search to the beginning of the image data */ |
592 | API(lseek)(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET); | 576 | lseek(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET); |
593 | 577 | ||
594 | API(memset)(bitmap, 0, totalsize); | 578 | memset(bitmap, 0, totalsize); |
595 | 579 | ||
596 | struct bmp_args ba = { | 580 | struct bmp_args ba = { |
597 | .fd = fd, .padded_width = padded_width, .read_width = read_width, | 581 | .fd = fd, .padded_width = padded_width, .read_width = read_width, |
diff --git a/apps/recorder/bmp.h b/apps/recorder/bmp.h index 946bc6f8b8..c570a3d6bd 100644 --- a/apps/recorder/bmp.h +++ b/apps/recorder/bmp.h | |||
@@ -52,8 +52,7 @@ struct rowset { | |||
52 | short rowstop; | 52 | short rowstop; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | #if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) || \ | 55 | #if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) |
56 | defined(PLUGIN) | ||
57 | extern const unsigned char dither_table[16]; | 56 | extern const unsigned char dither_table[16]; |
58 | #define DITHERY(y) (dither_table[(y) & 15] & 0xAA) | 57 | #define DITHERY(y) (dither_table[(y) & 15] & 0xAA) |
59 | #define DITHERX(x) (dither_table[(x) & 15]) | 58 | #define DITHERX(x) (dither_table[(x) & 15]) |
@@ -212,9 +211,5 @@ int read_bmp_fd(int fd, | |||
212 | int maxsize, | 211 | int maxsize, |
213 | int format, | 212 | int format, |
214 | const struct custom_format *cformat); | 213 | const struct custom_format *cformat); |
215 | #ifdef PLUGIN | ||
216 | struct plugin_api; | ||
217 | void bmp_init(const struct plugin_api * api); | ||
218 | #endif | ||
219 | 214 | ||
220 | #endif | 215 | #endif |
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index 6e5e9c4efb..99ccc84d55 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c | |||
@@ -59,19 +59,6 @@ | |||
59 | #define DEBUGF(...) | 59 | #define DEBUGF(...) |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #ifndef PLUGIN | ||
63 | #define API(x) x | ||
64 | #else | ||
65 | #define API(x) rb->x | ||
66 | |||
67 | static const struct plugin_api *rb; | ||
68 | |||
69 | void resize_init(const struct plugin_api *api) | ||
70 | { | ||
71 | rb = api; | ||
72 | } | ||
73 | #endif | ||
74 | |||
75 | /* calculate the maximum dimensions which will preserve the aspect ration of | 62 | /* calculate the maximum dimensions which will preserve the aspect ration of |
76 | src while fitting in the constraints passed in dst, and store result in dst, | 63 | src while fitting in the constraints passed in dst, and store result in dst, |
77 | returning 0 if rounding and 1 if not rounding. | 64 | returning 0 if rounding and 1 if not rounding. |
@@ -154,7 +141,7 @@ static bool scale_h_area(void *out_line_ptr, | |||
154 | oxe = 0; | 141 | oxe = 0; |
155 | mul = 0; | 142 | mul = 0; |
156 | /* give other tasks a chance to run */ | 143 | /* give other tasks a chance to run */ |
157 | API(yield)(); | 144 | yield(); |
158 | for (ix = 0; ix < (unsigned int)ctx->src->width; ix++) | 145 | for (ix = 0; ix < (unsigned int)ctx->src->width; ix++) |
159 | { | 146 | { |
160 | oxe += ctx->bm->width; | 147 | oxe += ctx->bm->width; |
@@ -257,11 +244,11 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx) | |||
257 | #ifdef HAVE_LCD_COLOR | 244 | #ifdef HAVE_LCD_COLOR |
258 | uint32_t *rowacc = (uint32_t *) ctx->buf, | 245 | uint32_t *rowacc = (uint32_t *) ctx->buf, |
259 | *rowtmp = rowacc + 3 * ctx->bm->width; | 246 | *rowtmp = rowacc + 3 * ctx->bm->width; |
260 | API(memset)((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(struct uint32_rgb)); | 247 | memset((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(struct uint32_rgb)); |
261 | #else | 248 | #else |
262 | uint32_t *rowacc = (uint32_t *) ctx->buf, | 249 | uint32_t *rowacc = (uint32_t *) ctx->buf, |
263 | *rowtmp = rowacc + ctx->bm->width; | 250 | *rowtmp = rowacc + ctx->bm->width; |
264 | API(memset)((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(uint32_t)); | 251 | memset((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(uint32_t)); |
265 | #endif | 252 | #endif |
266 | SDEBUGF("scale_v_area\n"); | 253 | SDEBUGF("scale_v_area\n"); |
267 | /* zero the accumulator and temp rows */ | 254 | /* zero the accumulator and temp rows */ |
@@ -298,9 +285,9 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx) | |||
298 | ctx->output_row(oy, (void*)rowacc, ctx); | 285 | ctx->output_row(oy, (void*)rowacc, ctx); |
299 | /* clear accumulator row, store partial coverage for next row */ | 286 | /* clear accumulator row, store partial coverage for next row */ |
300 | #ifdef HAVE_LCD_COLOR | 287 | #ifdef HAVE_LCD_COLOR |
301 | API(memset)((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t) * 3); | 288 | memset((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t) * 3); |
302 | #else | 289 | #else |
303 | API(memset)((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t)); | 290 | memset((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t)); |
304 | #endif | 291 | #endif |
305 | mul = oye; | 292 | mul = oye; |
306 | oy += rset->rowstep; | 293 | oy += rset->rowstep; |
@@ -346,7 +333,7 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
346 | /* The error is set so that values are initialized on the first pass. */ | 333 | /* The error is set so that values are initialized on the first pass. */ |
347 | ixe = ctx->bm->width - 1; | 334 | ixe = ctx->bm->width - 1; |
348 | /* give other tasks a chance to run */ | 335 | /* give other tasks a chance to run */ |
349 | API(yield)(); | 336 | yield(); |
350 | for (ox = 0; ox < (uint32_t)ctx->bm->width; ox++) | 337 | for (ox = 0; ox < (uint32_t)ctx->bm->width; ox++) |
351 | { | 338 | { |
352 | #ifdef HAVE_LCD_COLOR | 339 | #ifdef HAVE_LCD_COLOR |
@@ -630,7 +617,7 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
630 | 0 : needed]; | 617 | 0 : needed]; |
631 | #endif | 618 | #endif |
632 | #if CONFIG_CODEC == SWCODEC | 619 | #if CONFIG_CODEC == SWCODEC |
633 | len = (unsigned int)API(align_buffer)(PUN_PTR(void**, &buf), len, | 620 | len = (unsigned int)align_buffer(PUN_PTR(void**, &buf), len, |
634 | sizeof(uint32_t)); | 621 | sizeof(uint32_t)); |
635 | #endif | 622 | #endif |
636 | if (needed > len) | 623 | if (needed > len) |
@@ -659,7 +646,7 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
659 | 646 | ||
660 | struct scaler_context ctx; | 647 | struct scaler_context ctx; |
661 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 648 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
662 | API(cpu_boost)(true); | 649 | cpu_boost(true); |
663 | #endif | 650 | #endif |
664 | ctx.store_part = store_part; | 651 | ctx.store_part = store_part; |
665 | ctx.args = args; | 652 | ctx.args = args; |
@@ -698,7 +685,7 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
698 | ret = scale_v_linear(rset, &ctx); | 685 | ret = scale_v_linear(rset, &ctx); |
699 | #endif | 686 | #endif |
700 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 687 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
701 | API(cpu_boost)(false); | 688 | cpu_boost(false); |
702 | #endif | 689 | #endif |
703 | if (!ret) | 690 | if (!ret) |
704 | return 0; | 691 | return 0; |
diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h index 9b52a7aa65..f8328e3f3d 100644 --- a/apps/recorder/resize.h +++ b/apps/recorder/resize.h | |||
@@ -95,9 +95,4 @@ int resize_on_load(struct bitmap *bm, bool dither, | |||
95 | struct img_part* (*store_part)(void *args), | 95 | struct img_part* (*store_part)(void *args), |
96 | void *args); | 96 | void *args); |
97 | 97 | ||
98 | #ifdef PLUGIN | ||
99 | struct plugin_api; | ||
100 | void resize_init(const struct plugin_api *api); | ||
101 | #endif | ||
102 | |||
103 | #endif /* _RESIZE_H_ */ | 98 | #endif /* _RESIZE_H_ */ |