summaryrefslogtreecommitdiff
path: root/apps/recorder/resize.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/resize.c')
-rw-r--r--apps/recorder/resize.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c
index 5c9f7a6dd6..6e5e9c4efb 100644
--- a/apps/recorder/resize.c
+++ b/apps/recorder/resize.c
@@ -36,7 +36,9 @@
36#include <string.h> 36#include <string.h>
37#include <general.h> 37#include <general.h>
38#include "inttypes.h" 38#include "inttypes.h"
39#ifndef PLUGIN
39#include "debug.h" 40#include "debug.h"
41#endif
40#include "lcd.h" 42#include "lcd.h"
41#include "file.h" 43#include "file.h"
42#ifdef HAVE_REMOTE_LCD 44#ifdef HAVE_REMOTE_LCD
@@ -50,15 +52,26 @@
50#ifndef __PCTOOL__ 52#ifndef __PCTOOL__
51#include "config.h" 53#include "config.h"
52#include "system.h" 54#include "system.h"
53#include "bmp.h" 55#include <bmp.h>
54#include "resize.h"
55#include "resize.h" 56#include "resize.h"
56#include "debug.h"
57#else 57#else
58#undef DEBUGF 58#undef DEBUGF
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
67static const struct plugin_api *rb;
68
69void resize_init(const struct plugin_api *api)
70{
71 rb = api;
72}
73#endif
74
62/* calculate the maximum dimensions which will preserve the aspect ration of 75/* calculate the maximum dimensions which will preserve the aspect ration of
63 src while fitting in the constraints passed in dst, and store result in dst, 76 src while fitting in the constraints passed in dst, and store result in dst,
64 returning 0 if rounding and 1 if not rounding. 77 returning 0 if rounding and 1 if not rounding.
@@ -141,7 +154,7 @@ static bool scale_h_area(void *out_line_ptr,
141 oxe = 0; 154 oxe = 0;
142 mul = 0; 155 mul = 0;
143 /* give other tasks a chance to run */ 156 /* give other tasks a chance to run */
144 yield(); 157 API(yield)();
145 for (ix = 0; ix < (unsigned int)ctx->src->width; ix++) 158 for (ix = 0; ix < (unsigned int)ctx->src->width; ix++)
146 { 159 {
147 oxe += ctx->bm->width; 160 oxe += ctx->bm->width;
@@ -244,11 +257,11 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx)
244#ifdef HAVE_LCD_COLOR 257#ifdef HAVE_LCD_COLOR
245 uint32_t *rowacc = (uint32_t *) ctx->buf, 258 uint32_t *rowacc = (uint32_t *) ctx->buf,
246 *rowtmp = rowacc + 3 * ctx->bm->width; 259 *rowtmp = rowacc + 3 * ctx->bm->width;
247 memset((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(struct uint32_rgb)); 260 API(memset)((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(struct uint32_rgb));
248#else 261#else
249 uint32_t *rowacc = (uint32_t *) ctx->buf, 262 uint32_t *rowacc = (uint32_t *) ctx->buf,
250 *rowtmp = rowacc + ctx->bm->width; 263 *rowtmp = rowacc + ctx->bm->width;
251 memset((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(uint32_t)); 264 API(memset)((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(uint32_t));
252#endif 265#endif
253 SDEBUGF("scale_v_area\n"); 266 SDEBUGF("scale_v_area\n");
254 /* zero the accumulator and temp rows */ 267 /* zero the accumulator and temp rows */
@@ -285,9 +298,9 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx)
285 ctx->output_row(oy, (void*)rowacc, ctx); 298 ctx->output_row(oy, (void*)rowacc, ctx);
286 /* clear accumulator row, store partial coverage for next row */ 299 /* clear accumulator row, store partial coverage for next row */
287#ifdef HAVE_LCD_COLOR 300#ifdef HAVE_LCD_COLOR
288 memset((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t) * 3); 301 API(memset)((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t) * 3);
289#else 302#else
290 memset((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t)); 303 API(memset)((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t));
291#endif 304#endif
292 mul = oye; 305 mul = oye;
293 oy += rset->rowstep; 306 oy += rset->rowstep;
@@ -333,7 +346,7 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx,
333 /* The error is set so that values are initialized on the first pass. */ 346 /* The error is set so that values are initialized on the first pass. */
334 ixe = ctx->bm->width - 1; 347 ixe = ctx->bm->width - 1;
335 /* give other tasks a chance to run */ 348 /* give other tasks a chance to run */
336 yield(); 349 API(yield)();
337 for (ox = 0; ox < (uint32_t)ctx->bm->width; ox++) 350 for (ox = 0; ox < (uint32_t)ctx->bm->width; ox++)
338 { 351 {
339#ifdef HAVE_LCD_COLOR 352#ifdef HAVE_LCD_COLOR
@@ -500,8 +513,8 @@ static inline bool scale_v_linear(struct rowset *rset,
500} 513}
501#endif /* HAVE_UPSCALER */ 514#endif /* HAVE_UPSCALER */
502 515
503static void output_row_native(uint32_t row, void * row_in, 516#ifndef PLUGIN
504 struct scaler_context *ctx) 517void output_row_native(uint32_t row, void * row_in, struct scaler_context *ctx)
505{ 518{
506 int col; 519 int col;
507 int fb_width = BM_WIDTH(ctx->bm->width,FORMAT_NATIVE,0); 520 int fb_width = BM_WIDTH(ctx->bm->width,FORMAT_NATIVE,0);
@@ -511,7 +524,7 @@ static void output_row_native(uint32_t row, void * row_in,
511#else 524#else
512 uint32_t *qp = (uint32_t*)row_in; 525 uint32_t *qp = (uint32_t*)row_in;
513#endif 526#endif
514 SDEBUGF("output_row: y: %d in: %p\n",row, row_in); 527 SDEBUGF("output_row: y: %lu in: %p\n",row, row_in);
515#if LCD_DEPTH == 2 528#if LCD_DEPTH == 2
516#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 529#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
517 /* greyscale iPods */ 530 /* greyscale iPods */
@@ -591,6 +604,7 @@ static void output_row_native(uint32_t row, void * row_in,
591 } 604 }
592#endif /* LCD_DEPTH */ 605#endif /* LCD_DEPTH */
593} 606}
607#endif
594 608
595int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, 609int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
596 struct rowset *rset, unsigned char *buf, unsigned int len, 610 struct rowset *rset, unsigned char *buf, unsigned int len,
@@ -615,8 +629,10 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
615 uint8_t sc_buf[(needed <= len || needed > MAX_SC_STACK_ALLOC) ? 629 uint8_t sc_buf[(needed <= len || needed > MAX_SC_STACK_ALLOC) ?
616 0 : needed]; 630 0 : needed];
617#endif 631#endif
618 len = (unsigned int)align_buffer(PUN_PTR(void**, &buf), len, 632#if CONFIG_CODEC == SWCODEC
633 len = (unsigned int)API(align_buffer)(PUN_PTR(void**, &buf), len,
619 sizeof(uint32_t)); 634 sizeof(uint32_t));
635#endif
620 if (needed > len) 636 if (needed > len)
621 { 637 {
622#if MAX_SC_STACK_ALLOC 638#if MAX_SC_STACK_ALLOC
@@ -642,7 +658,9 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
642 } 658 }
643 659
644 struct scaler_context ctx; 660 struct scaler_context ctx;
645 cpu_boost(true); 661#ifdef HAVE_ADJUSTABLE_CPU_FREQ
662 API(cpu_boost)(true);
663#endif
646 ctx.store_part = store_part; 664 ctx.store_part = store_part;
647 ctx.args = args; 665 ctx.args = args;
648#if MAX_SC_STACK_ALLOC 666#if MAX_SC_STACK_ALLOC
@@ -654,10 +672,11 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
654 ctx.bm = bm; 672 ctx.bm = bm;
655 ctx.src = src; 673 ctx.src = src;
656 ctx.dither = dither; 674 ctx.dither = dither;
675#ifndef PLUGIN
676 ctx.output_row = output_row_native;
657 if (format) 677 if (format)
678#endif
658 ctx.output_row = format->output_row; 679 ctx.output_row = format->output_row;
659 else
660 ctx.output_row = output_row_native;
661#ifdef HAVE_UPSCALER 680#ifdef HAVE_UPSCALER
662 if (sw > dw) 681 if (sw > dw)
663 { 682 {
@@ -678,7 +697,9 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
678 else 697 else
679 ret = scale_v_linear(rset, &ctx); 698 ret = scale_v_linear(rset, &ctx);
680#endif 699#endif
681 cpu_boost(false); 700#ifdef HAVE_ADJUSTABLE_CPU_FREQ
701 API(cpu_boost)(false);
702#endif
682 if (!ret) 703 if (!ret)
683 return 0; 704 return 0;
684 return 1; 705 return 1;