summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-05-16 20:12:39 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-05-16 20:12:39 +0000
commite20548f93ea75656d4b7a2525319ea256ea03294 (patch)
tree4fb18506ba61338de9811606eff4de486a7b5652
parentb68707d4651876435161729beab68a329e6d9b6d (diff)
downloadrockbox-e20548f93ea75656d4b7a2525319ea256ea03294.tar.gz
rockbox-e20548f93ea75656d4b7a2525319ea256ea03294.zip
Add a simple benchmark plugin for the scaler, using the pluginlib import of resize_on_load.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20969 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/bench_scaler.c137
1 files changed, 137 insertions, 0 deletions
diff --git a/apps/plugins/bench_scaler.c b/apps/plugins/bench_scaler.c
new file mode 100644
index 0000000000..723e427aa7
--- /dev/null
+++ b/apps/plugins/bench_scaler.c
@@ -0,0 +1,137 @@
1/*****************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 Andrew Mahone
11 *
12 * scaler benchmark
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#include "plugin.h"
25#include "lib/jpeg_mem.h"
26PLUGIN_HEADER
27
28static unsigned char output;
29static int output_y = 0;
30static int font_h;
31static unsigned char *plugin_buf;
32char output_buf[256];
33struct img_part part;
34
35/* a null output plugin to save memory and better isolate scale cost */
36static unsigned int get_size_null(struct bitmap *bm)
37{
38 (void) bm;
39 return 1;
40}
41
42static void output_row_null(uint32_t row, void * row_in,
43 struct scaler_context *ctx)
44{
45 (void) row;
46 uint32_t *in = (uint32_t *)row_in;
47#ifdef HAVE_LCD_COLOR
48 uint32_t *lim = in + ctx->bm->width * 3;
49#else
50 uint32_t *lim = in + ctx->bm->width;
51#endif
52 for (; in < lim; in++)
53 output = SC_MUL(*in + ctx->round, ctx->divisor);
54 return;
55}
56
57struct img_part *store_part_null(void *args)
58{
59 (void) args;
60 part.len = 256;
61 part.buf = (typeof(part.buf))plugin_buf;
62 return &part;
63}
64
65const struct custom_format format_null = {
66 .output_row_8 = NULL,
67#ifdef HAVE_LCD_COLOR
68 .output_row_32 = {
69 output_row_null,
70 output_row_null
71 },
72#else
73 .output_row_32 = output_row_null,
74#endif
75 .get_size = get_size_null
76};
77
78#define lcd_printf(...) \
79do { \
80 rb->snprintf(output_buf, sizeof(output_buf), __VA_ARGS__); \
81 rb->lcd_putsxy(0, output_y, output_buf); \
82 rb->lcd_update_rect(0, output_y, LCD_WIDTH, font_h); \
83 output_y += font_h; \
84} while (0)
85
86/* this is the plugin entry point */
87enum plugin_status plugin_start(const void* parameter)
88{
89 size_t plugin_buf_len;
90 plugin_buf = (unsigned char *)rb->plugin_get_buffer(&plugin_buf_len);
91 struct bitmap bm;
92 struct dim in_dim;
93 struct rowset rset = {
94 .rowstep = 1,
95 .rowstart = 0,
96 };
97 (void)parameter;
98
99 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
100 rb->lcd_fillrect(0, 0, LCD_WIDTH, LCD_HEIGHT);
101 rb->lcd_set_drawmode(DRMODE_SOLID);
102 rb->lcd_getstringsize("A", NULL, &font_h);
103 bm.data = plugin_buf;
104 int in, out;
105 for (in = 64; in < 1025; in <<= 2)
106 {
107 for (out = 64; out < 257; out <<= 1)
108 {
109 if (in == out)
110 continue;
111 lcd_printf("timing %dx%d->%dx>%d scale", in, in, out, out);
112 long t1, t2;
113 int count = 0;
114 t2 = *(rb->current_tick);
115 in_dim.width = in_dim.height = in;
116 bm.width = bm.height = rset.rowstop = out;
117 while (t2 != (t1 = *(rb->current_tick)));
118 do {
119 resize_on_load(&bm, false, &in_dim, &rset, (unsigned char *)plugin_buf, plugin_buf_len, &format_null, IF_PIX_FMT(0,) store_part_null, NULL);
120 count++;
121 t2 = *(rb->current_tick);
122 } while (t2 - t1 < HZ || count < 10);
123 t2 -= t1;
124 t2 *= 10;
125 t2 += count >> 1;
126 t2 /= count;
127 t1 = t2 / 1000;
128 t2 -= t1 * 1000;
129 lcd_printf("%01d.%03d secs/scale", (int)t1, (int)t2);
130 if (!(bm.width && bm.height))
131 break;
132 }
133 }
134
135 while (rb->get_action(CONTEXT_STD,1) != ACTION_STD_OK) rb->yield();
136 return PLUGIN_OK;
137}