1 /*****************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 Andrew Mahone
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.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
25 #include "lib/jpeg_mem.h"
28 static unsigned char output
;
29 static int output_y
= 0;
31 static unsigned char *plugin_buf
;
35 /* a null output plugin to save memory and better isolate scale cost */
36 static unsigned int get_size_null(struct bitmap
*bm
)
42 static void output_row_null(uint32_t row
, void * row_in
,
43 struct scaler_context
*ctx
)
46 uint32_t *in
= (uint32_t *)row_in
;
48 uint32_t *lim
= in
+ ctx
->bm
->width
* 3;
50 uint32_t *lim
= in
+ ctx
->bm
->width
;
53 output
= SC_OUT(*in
++, ctx
);
57 struct img_part
*store_part_null(void *args
)
61 part
.buf
= (typeof(part
.buf
))plugin_buf
;
65 const struct custom_format format_null
= {
73 .output_row_32
= output_row_null
,
75 .get_size
= get_size_null
78 #define lcd_printf(...) \
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); \
86 /* this is the plugin entry point */
87 enum plugin_status
plugin_start(const void* parameter
)
89 size_t plugin_buf_len
;
90 plugin_buf
= (unsigned char *)rb
->plugin_get_buffer(&plugin_buf_len
);
93 struct rowset rset
= {
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
;
105 for (in
= 64; in
< 1025; in
<<= 2)
107 for (out
= 64; out
< 257; out
<<= 1)
111 lcd_printf("timing %dx%d->%dx>%d scale", in
, in
, out
, out
);
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 t_end
= t1
+ 10 * HZ
;
120 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
);
122 t2
= *(rb
->current_tick
);
123 } while (TIME_BEFORE(t2
, t_end
) || count
< 10);
130 lcd_printf("%01d.%03d secs/scale", (int)t1
, (int)t2
);
131 if (!(bm
.width
&& bm
.height
))
136 while (rb
->get_action(CONTEXT_STD
,1) != ACTION_STD_OK
) rb
->yield();